GancioF2F/tools/updtrans.bash
2024-11-07 20:22:25 +01:00

34 lines
1.2 KiB
Bash
Executable file

#!/bin/bash
if [ -z $1 ]; then
echo "You must specify a command («updpo» to update the pot and po files, «updmo» to update the mo files)."
exit 1
fi
if [ $1 != "updpo" ] && [ $1 != "updmo" ]; then
echo "«$1» is not a known command; please use «updpo» to update the pot and po files, «updmo» to update the mo files."
exit 1
fi
langs=("en" "it")
basedir=$(dirname "$0")
cd "$basedir"
cd ..
if [ $1 == "updpo" ]; then
echo "Updating pot file with xgettext"
xgettext ganciof2f -L PHP --no-wrap --from-code utf-8 --add-comments --copyright-holder jones@insicuri.net --package-name GancioF2F --package-version 1.1 --msgid-bugs-address jones@insicuri.net -o - | sed -e 's/^"Content-Type: text\/plain; charset=CHARSET\\n"$/"Content-Type: text\/plain; charset=utf-8\\n"/' > locale/ganciof2f.pot
for lang in ${langs[@]}; do
echo "Updating po file for «$lang» with msgmerge"
msgmerge --lang "${lang}" --update --no-wrap locale/$lang/LC_MESSAGES/ganciof2f.po locale/ganciof2f.pot
done
echo "Done!"
elif [ $1 == "updmo" ]; then
for lang in ${langs[@]}; do
echo "Updating mo file for «$lang»"
msgfmt locale/$lang/LC_MESSAGES/ganciof2f.po -o locale/$lang/LC_MESSAGES/ganciof2f.mo
done
echo "Done!"
fi
exit 0