weblate-butterflysoup2/.po2tl.sh

32 lines
1,011 B
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-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
continue
fi
2023-01-31 13:23:39 +00:00
msgfmt "$file" -o game.mo
PATH=$(pwd)/renpy:${PATH} RENPY_DIR=$(pwd)/renpy python3 rttk-queerscriptors/mo2tl.py $(pwd)/game-source game.mo ${lang}
zip "${lang}.zip" game-source/game/tl/${lang}/*
mv "${lang}.zip" "/var/www/queer/build/${CI_REPO_NAME}/${lang}.zip"
done