2023-01-31 13:23:39 +00:00
|
|
|
#!/usr/bin/env bash
|
2023-02-11 02:31:58 +00:00
|
|
|
#SPDX-FileCopyrightText: 2023 HackerNCoder
|
|
|
|
#SPDX-License-Identifier: MIT-0
|
2023-01-31 13:23:39 +00:00
|
|
|
|
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
|
|
|
|
2023-08-17 17:31:11 +00:00
|
|
|
declare -a filesToDo
|
2023-01-31 13:23:39 +00:00
|
|
|
|
2023-08-17 17:31:11 +00:00
|
|
|
for file in ./translations-*.po; do
|
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-04-19 19:45:09 +00:00
|
|
|
if [[ $numdone -le 5400 ]]; then
|
2023-08-17 17:31:11 +00:00
|
|
|
echo -e "\x1B[36mSKIPPING ${file#\.\/} since it has less than 5400 strings translated\x1B[0m"
|
2023-01-31 13:23:39 +00:00
|
|
|
continue
|
|
|
|
fi
|
|
|
|
|
2023-02-11 20:50:05 +00:00
|
|
|
if (( $(date -d $(awk '/PO-Revision-Date/{ sub(/\+.*/,""); print $2"T"$3}' ${file}) +%s) < $CI_PREV_BUILD_STARTED )); then
|
2023-08-17 17:31:11 +00:00
|
|
|
echo -e "\x1B[36mSKIPPING ${file#\.\/} since it hasn't been changed since last CI\x1B[0m"
|
2023-02-11 01:56:03 +00:00
|
|
|
continue
|
|
|
|
fi
|
|
|
|
|
2023-08-17 17:31:11 +00:00
|
|
|
echo -e "\x1B[36mAdding ${file#\.\/} to list of files to build\x1B[0m"
|
|
|
|
filesToDo+=(file)
|
2023-01-31 13:23:39 +00:00
|
|
|
done
|
2023-08-17 17:31:11 +00:00
|
|
|
|
2023-08-17 17:34:26 +00:00
|
|
|
if (( ${#filesToDo[@]} > 0 )); then
|
2023-09-12 15:03:26 +00:00
|
|
|
echo
|
2023-12-18 02:44:25 +00:00
|
|
|
echo -e "\x1B[36m---------------------"
|
2023-09-12 15:03:26 +00:00
|
|
|
echo "| INSTALLING |"
|
2023-12-18 02:44:25 +00:00
|
|
|
echo -e "---------------------\x1B[0m"
|
2023-09-12 15:03:26 +00:00
|
|
|
echo
|
|
|
|
apt-get install --no-install-recommends -y git ca-certificates python3 libgl1 zip
|
2023-08-17 17:31:11 +00:00
|
|
|
echo
|
2023-12-18 02:44:25 +00:00
|
|
|
echo -e "\x1B[36m---------------------"
|
2023-08-17 17:31:11 +00:00
|
|
|
echo "| CLONING |"
|
2023-12-18 02:44:25 +00:00
|
|
|
echo -e "---------------------\x1B[0m"
|
2023-08-17 17:31:11 +00:00
|
|
|
echo
|
|
|
|
git clone https://lab.encryptionin.space/Queerscriptors/rttk-queerscriptors.git
|
|
|
|
git clone https://lab.encryptionin.space/Queerscriptors/renpy.git
|
|
|
|
git clone -b game ${CI_REPO_REMOTE} ./game-source
|
|
|
|
echo
|
2023-12-18 02:44:25 +00:00
|
|
|
echo -e "\x1B[36m--------------------"
|
2023-08-17 17:31:11 +00:00
|
|
|
echo "| BUILDING |"
|
2023-12-18 02:44:25 +00:00
|
|
|
echo -e "--------------------\x1B[0m"
|
2023-08-17 17:31:11 +00:00
|
|
|
echo
|
|
|
|
for file in filesToDo; do
|
|
|
|
file2=${file%.po}
|
|
|
|
langcc=${file2#\.\/translations\-}
|
|
|
|
if [[ -n ${langnames[$langcc]} ]]; then
|
|
|
|
lang=${langnames[$langcc]}
|
|
|
|
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
|
|
|
|
fi
|
|
|
|
|
|
|
|
echo -e "\x1B[36mBUILDING ${file#\.\/} \x1B[0m"
|
|
|
|
msgfmt "$file" -o game.mo
|
|
|
|
PATH=$(pwd)/renpy:${PATH} RENPY_DIR=$(pwd)/renpy python3 rttk-queerscriptors/mo2tl.py $(pwd)/game-source game.mo ${lang}
|
|
|
|
(cd game-source/game/tl/${lang} && zip -r "${lang}.zip" . && mv "${lang}.zip" "/var/www/queer/build/${CI_REPO_NAME}/${lang}.zip" )
|
|
|
|
echo -e "\e[32mFINISHED $file\e[0m"
|
|
|
|
echo
|
|
|
|
done
|
|
|
|
echo
|
2023-12-18 02:44:25 +00:00
|
|
|
echo -e "\x1B[36m--------------------"
|
2023-08-17 17:31:11 +00:00
|
|
|
echo "| DONE |"
|
2023-12-18 02:44:25 +00:00
|
|
|
echo -e "--------------------\x1B[0m"
|
2023-08-17 17:31:11 +00:00
|
|
|
echo
|
|
|
|
else
|
|
|
|
echo -e "\x1B[36mNothing to do\x1B[0m"
|
|
|
|
fi
|