Simplify the translations maintenance script.

- Removed bashisms
- Removed the call to SVN update which is usually done beforehand in CI
- Removed the git alternative which is never used
- Fixed the call to poediff which seems to fail with latest poediff

Tested on Jenkins since the revamp.
Reviewed By: Gallaecio
Differential Revision: https://code.wildfiregames.com/D2078
This was SVN commit r22690.
This commit is contained in:
Nicolas Auvray 2019-08-18 18:13:04 +00:00
parent 9985fcf5bd
commit 5cfef19a06

View File

@ -1,36 +1,11 @@
#!/bin/bash #!/bin/sh
# Regenerates the POT files and uploads them to Transifex, downloads the latest # Regenerates the POT files, downloads the latest translations from Transifex,
# translations from Transifex, and commits the updated POT and PO files. # and prepares the commit of the updated POT and PO files.
SCRIPT_PATH="`dirname \"$0\"`" SCRIPT_PATH="`dirname \"$0\"`"
# VCS Config ##################################################################
VCS="svn"
VCS_UPDATE="svn update"
VCS_REVERT="svn revert %s@"
VCS_ADD="svn add %s"
VCS_COMMIT_AND_PUSH="svn commit -m '[i18n] Updated POT and PO files.'"
git rev-parse &> /dev/null
if [[ "$?" = "0" ]]; then
VCS="git"
VCS_UPDATE="git pull --rebase origin master"
VCS_REVERT="git checkout -- %s"
VCS_ADD="git add %s"
VCS_COMMIT_AND_PUSH="git commit -am '[i18n] Updated POT and PO files.' &&
git pull --rebase origin master &&
git push origin master"
fi
# Source Update ###############################################################
echo ":: Updating sources…"
${VCS_UPDATE}
# POT Generation ############################################################## # POT Generation ##############################################################
echo ":: Regenerating the translation templates…" echo ":: Regenerating the translation templates…"
@ -54,10 +29,10 @@ python2 "${SCRIPT_PATH}/pullTranslations.py"
echo ":: Reverting unnecessary changes…" echo ":: Reverting unnecessary changes…"
for FILE_PATH in $(find "${SCRIPT_PATH}/../../../binaries/data" -name "*.pot" -o -name "*.po") for FILE_PATH in $(find "${SCRIPT_PATH}/../../../binaries/data" -name "*.pot" -o -name "*.po")
do do
if [[ ! -n "$(poediff -c ${VCS} -rHEAD -qs "${FILE_PATH}")" ]]; then if [ -z "$(poediff -c svn -qs "${FILE_PATH}")" ]; then
$(printf "${VCS_REVERT}" "${FILE_PATH}") svn revert "${FILE_PATH}"
else else
$(printf "${VCS_ADD}" ${FILE_PATH}) &> /dev/null svn add "${FILE_PATH}" 2> /dev/null
fi fi
done done