po/make_pot: Fix sorting and make POSIX compliant

Replaces non POSIX `echo -e` with an equivalent printf call and
fixes sorting of lua files.

This still leaves a problem with the order of old commented strings
being being reversed and there #, c-format comments being stripped.
See: https://savannah.gnu.org/bugs/?58778
This commit is contained in:
Oneric 2020-07-17 18:29:16 +02:00
parent e2ea84541f
commit 4aee271d03

View file

@ -1,5 +1,8 @@
#!/bin/sh
#Abort on error
set -e
maybe_append() {
while read -r msg; do
msgfile=$(echo $msg | cut -d'|' -f1)
@ -7,13 +10,16 @@ maybe_append() {
msgid=$(echo $msg | cut -d'|' -f3-)
if ! grep -Fq "msgid $msgid" aegisub.pot; then
echo -e "\n#: $msgfile:$msgline\nmsgid $msgid\nmsgstr \"\"\n" >> aegisub.pot
printf "\n#: %s:%s\nmsgid %s\nmsgstr \"\"\n\n" \
"$msgfile" "$msgline" "$msgid" >> aegisub.pot
fi
done
}
find ../src -name \*.cpp -o -name \*.h | LC_ALL=C sort \
| xgettext --files-from=- -o - --c++ -k_ -kSTR_MENU -kSTR_DISP -kSTR_HELP -kfmt_tl -kfmt_plural:2,3 -kwxT -kwxPLURAL:1,2 \
find ../src -name \*.cpp -o -name \*.h \
| LC_ALL=C sort \
| xgettext --files-from=- -o - --c++ \
-k_ -kSTR_MENU -kSTR_DISP -kSTR_HELP -kfmt_tl -kfmt_plural:2,3 -kwxT -kwxPLURAL:1,2 \
| sed 's/SOME DESCRIPTIVE TITLE./Aegisub 3.3+/' \
| sed 's/YEAR/2005-2020/' \
| sed "s/THE PACKAGE'S COPYRIGHT HOLDER/Rodrigo Braz Monteiro, Niels Martin Hansen, Thomas Goyne et. al./" \
@ -34,6 +40,7 @@ grep '"[A-Za-z ]\+" : {' -n ../src/libresrc/default_hotkey.json \
| maybe_append
find ../automation -name '*.lua' \
| LC_ALL=C sort \
| xargs grep 'tr"[^"]*"' -o -n \
| sed 's/\(.*\):\([0-9]\+\):tr\(".*"\)/\1|\2|\3/' \
| sed 's/\\/\\\\\\\\/g' \