MastodonHelp/web/clitools/updtrans.bash

41 lines
1.7 KiB
Bash
Raw Normal View History

2020-10-15 19:24:45 +02:00
#!/bin/bash
2020-10-27 16:32:23 +01:00
if [ -z $1 ]; then
echo "Devi specificare un comando («updpo» per aggiornare il pot e i po, «updmo» per poi aggiornare gli mo)."
exit 1
fi
if [ $1 != "updpo" ] && [ $1 != "updmo" ]; then
echo "«$1» non è un comando noto; usa «updpo» per aggiornare il pot e i po, «updmo» per poi aggiornare gli mo."
exit 1
fi
langs=("ar_AE" "be_BY" "ca_ES" "cs_CZ" "de_DE" "en_EN" "es_ES" "fa_IR" "fr_FR" "gl_ES" "id_ID" "it_IT" "nl_NL" "pl_PL" "pt_BR" "pt_PT" "ru_RU" "tr_TR" "uk_UA")
2020-10-15 19:24:45 +02:00
2020-10-27 16:32:23 +01:00
basedir=$(dirname "$0")
cd "$basedir"
cd ../../
2020-10-15 19:24:45 +02:00
2020-10-27 16:32:23 +01:00
if [ $1 == "updpo" ]; then
echo "Aggiorno masthelp.pot con xgettext"
xgettext --no-wrap --from-code utf-8 --add-comments --copyright-holder masthelp@insicuri.net --package-name mastodon.help --package-version 1.1 --msgid-bugs-address masthelp@insicuri.net web/site/*.php web/lib/*.php -o - | sed -e 's/^"Language: \\n"$/"Language: en\\n"/' > web/site/locale/masthelp.pot
2020-10-27 16:32:23 +01:00
echo "Aggiorno masthelp.po per «en» con msgen"
msgen --no-wrap web/site/locale/masthelp.pot -o - | sed -e 's/msgstr "Not available{singular}"/msgstr "Not available"/' -e 's/msgstr "Not available{plural}"/msgstr "Not available"/' > web/site/locale/en_EN/LC_MESSAGES/masthelp.po
2020-10-27 16:32:23 +01:00
for lang in ${langs[@]}; do
if [ $lang != "en_EN" ]; then
2020-10-27 16:32:23 +01:00
echo "Aggiorno masthelp.po per «$lang» con msgmerge"
msgmerge --update --no-wrap web/site/locale/$lang/LC_MESSAGES/masthelp.po web/site/locale/masthelp.pot
2020-10-27 16:32:23 +01:00
fi
done
echo "Fatto! Ora puoi editare i vari masthelp.po."
2020-10-27 16:32:23 +01:00
elif [ $1 == "updmo" ]; then
for lang in ${langs[@]}; do
2020-10-30 19:33:09 +01:00
echo "Aggiorno masthelp.mo per «$lang»"
msgfmt web/site/locale/$lang/LC_MESSAGES/masthelp.po -o web/site/locale/$lang/LC_MESSAGES/masthelp.mo
2020-10-27 16:32:23 +01:00
done
echo "Fatto! :-)"
else
echo "IMPOSSIBILE!"
fi
2020-10-23 19:00:43 +02:00
2020-10-27 16:32:23 +01:00
exit 0