weblate-butterflysoup2/.po2tl.sh

36 lines
1.3 KiB
Bash
Raw Normal View History

2023-01-31 13:23:39 +00:00
#!/usr/bin/env bash
2023-01-31 13:59:28 +00:00
declare -A langnames=( ["es_419"]="spanish" ["pt_BR"]="brazilian_portuguese" ["ru"]="russian" ["pl"]="polish" )
2023-01-31 13:23:39 +00:00
for file in ./translations-*.po; do
file2=${file%.po}
langcc=${file2#\.\/translations\-}
2023-02-11 01:55:43 +00:00
if [[ -n ${langnames[$langcc]} ]]; then
2023-01-31 13:50:44 +00:00
lang=${langnames[$langcc]}
2023-02-11 01:55:43 +00:00
if [[ -f "/var/www/queer/build/${CI_REPO_NAME}/${langcc}.zip" ]]; then
rm "/var/www/queer/build/${CI_REPO_NAME}/${langcc}.zip"
fi
else
lang=$langcc
2023-01-31 13:23:39 +00:00
fi
2023-01-31 13:50:44 +00:00
stats=$(msgfmt --statistics ${file} 2>&1)
2023-01-31 13:23:39 +00:00
numdone=$(echo ${stats%* translated*})
2023-01-31 13:50:44 +00:00
if [[ $numdone -le 5680 ]]; then
2023-02-11 02:22:41 +00:00
echo -e "\x1B[36mSKIPPING $file since it has less than 5680 strings translated\x1B[0m"
2023-01-31 13:23:39 +00:00
continue
fi
if (( $(date -d $(awk '/PO-Revision-Date/{print $2}' ${file}) +%s) < $CI_PREV_BUILD_STARTED )); then
2023-02-11 02:22:41 +00:00
echo -e "\x1B[36mSKIPPING $file since it hasn't been changed since last CI\x1B[0m"
continue
fi
2023-02-11 02:22:41 +00:00
echo -e "\x1B[36mBUILDING $file \x1B[0m"
2023-01-31 13:23:39 +00:00
msgfmt "$file" -o game.mo
2023-02-11 02:22:41 +00:00
echo "\t$(PATH=$(pwd)/renpy:${PATH} RENPY_DIR=$(pwd)/renpy python3 rttk-queerscriptors/mo2tl.py $(pwd)/game-source game.mo ${lang})"
echo "\t$(zip "${lang}.zip" game-source/game/tl/${lang}/*)"
2023-01-31 13:23:39 +00:00
mv "${lang}.zip" "/var/www/queer/build/${CI_REPO_NAME}/${lang}.zip"
2023-02-11 02:22:41 +00:00
echo -e "\e[32mFINISHED $file\e[0m"
2023-01-31 13:23:39 +00:00
done