forked from 0ad/0ad
Added a script for i18n maintenance tasks
The script updates the local repository, regenerates the POT files, downloads the latest PO files, reverts any change that Pology determines as not meaningful, and adds the modified files to the local VCS. The script does not actually perform the final commit, that is left for the user. Ref #2492 This was SVN commit r16222.
This commit is contained in:
parent
ac8124b332
commit
c976366590
69
source/tools/i18n/maintenanceTasks.sh
Normal file
69
source/tools/i18n/maintenanceTasks.sh
Normal file
@ -0,0 +1,69 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Regenerates the POT files and uploads them to Transifex, downloads the latest
|
||||
# translations from Transifex, and commits the updated POT and PO files.
|
||||
|
||||
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 ##############################################################
|
||||
|
||||
echo ":: Regenerating the translation templates…"
|
||||
python2 "${SCRIPT_PATH}/updateTemplates.py"
|
||||
|
||||
|
||||
# PO Download #################################################################
|
||||
|
||||
echo ":: Downloading translations from Transifex…"
|
||||
python2 "${SCRIPT_PATH}/pullTranslations.py"
|
||||
|
||||
|
||||
# Pre-Commit Cleanup #########################################################
|
||||
|
||||
# Note: I (Gallaecio) tried using GNU parallel for this, the problem is that
|
||||
# poediff accesses Subversion, and when you use Subversion more than once
|
||||
# simultaneously you end up with commands not running properly due to the
|
||||
# Subversion database being locked. So just take a beverage, put some music on
|
||||
# and wait for the task to eventually finish.
|
||||
|
||||
echo ":: Reverting unnecessary changes…"
|
||||
for FILE_PATH in $(find "${SCRIPT_PATH}/../../.." -name "*.pot") \
|
||||
$(find "${SCRIPT_PATH}/../../.." -name "*.po")
|
||||
do
|
||||
if [[ ! -n "$(poediff -c ${VCS} -rHEAD -qs "${FILE_PATH}")" ]]; then
|
||||
$(printf "${VCS_REVERT}" "${FILE_PATH}")
|
||||
else
|
||||
$(printf "${VCS_ADD}" ${FILE_PATH}) &> /dev/null
|
||||
fi
|
||||
done
|
||||
|
||||
|
||||
# Commit ######################################################################
|
||||
|
||||
echo ":: Done"
|
||||
echo " Now you can commit your changes to the server."
|
Loading…
Reference in New Issue
Block a user