2016-11-16 20:59:04 +00:00
|
|
|
#!/bin/bash
|
2009-11-12 20:58:03 +00:00
|
|
|
|
2016-11-16 20:59:04 +00:00
|
|
|
set -e # abort if a command exits non-zero
|
2009-11-12 22:19:36 +00:00
|
|
|
|
2018-06-24 13:34:25 +00:00
|
|
|
# update localization files from transifex and compile .po to .mo
|
|
|
|
# .po files are updated according to minimum_perc in .tx/config, outdated files are not removed!
|
|
|
|
# Then commit and push changes manually.
|
2016-11-16 20:59:04 +00:00
|
|
|
|
|
|
|
# find source root upward from CWD
|
|
|
|
while ! test -r .tx/config; do
|
|
|
|
cd ..
|
|
|
|
test "`pwd`" = "/" && echo "no source directory found" >&2 && exit
|
2010-02-18 20:57:13 +00:00
|
|
|
done
|
2009-11-12 21:48:04 +00:00
|
|
|
|
2016-11-16 20:59:04 +00:00
|
|
|
command -v pocompile >/dev/null 2>&1 || { echo >&2 "pocompile (translate-toolkit) is needed but not installed. Aborting."; exit 1; }
|
|
|
|
command -v tx >/dev/null 2>&1 || { echo >&2 "tx (transifex-client) is needed but not installed. Aborting."; exit 1; }
|
2010-02-18 20:57:13 +00:00
|
|
|
|
2016-11-16 20:59:04 +00:00
|
|
|
# check if working directory is clean to ensure we only commit localization changes
|
|
|
|
if test 0 -ne `git status -s -uno |wc -l`; then
|
2018-06-24 13:34:25 +00:00
|
|
|
echo "Warning: You have pending changes! Please make sure to only commit localization changes!"
|
2016-11-16 20:59:04 +00:00
|
|
|
fi
|
2015-03-24 19:14:31 +00:00
|
|
|
|
2016-11-16 20:59:04 +00:00
|
|
|
echo "pulling translations from transifex"
|
2018-06-24 13:34:25 +00:00
|
|
|
# this updates existing languages and adds new languages
|
|
|
|
tx pull -a
|
2010-07-13 20:02:33 +00:00
|
|
|
|
2016-11-16 20:59:04 +00:00
|
|
|
echo "compiling localization files for Manager and Client"
|
|
|
|
srcdir=`pwd`
|
|
|
|
cd ${srcdir}/locale
|
2015-03-24 19:25:10 +00:00
|
|
|
|
2016-11-16 20:59:04 +00:00
|
|
|
templates=("BOINC-Manager" "BOINC-Client" "BOINC-Setup" "BOINC-Web")
|
2015-03-24 19:25:10 +00:00
|
|
|
|
2016-11-16 20:59:04 +00:00
|
|
|
for template_name in "${templates[@]}"; do
|
|
|
|
for file in `find -name "${template_name}.po"`; do
|
|
|
|
dir=`dirname $file`
|
|
|
|
locale=`basename $dir`
|
2011-12-16 00:55:04 +00:00
|
|
|
|
2016-11-16 20:59:04 +00:00
|
|
|
cd ${srcdir}/locale/${locale}
|
2018-06-24 13:34:25 +00:00
|
|
|
# Compile the PO file into an MO file.
|
|
|
|
pocompile ${template_name}.po ${template_name}.mo
|
|
|
|
# Touch each file to adjust timestamps
|
|
|
|
touch ${template_name}.po
|
2011-12-16 00:55:04 +00:00
|
|
|
|
2016-11-16 20:59:04 +00:00
|
|
|
done
|
|
|
|
cd ${srcdir}/locale
|
2011-12-16 00:55:04 +00:00
|
|
|
done
|
|
|
|
|
2018-06-24 13:34:25 +00:00
|
|
|
echo "running pofilter for BOINC-Manager.po"
|
|
|
|
echo "Please check output in BOINC-Manager-pofilter.txt!"
|
|
|
|
echo "" > BOINC-Manager-pofilter.txt
|
|
|
|
for file in `find -name "BOINC-Manager.po"`; do
|
|
|
|
dir=`dirname $file`
|
|
|
|
locale=`basename $dir`
|
|
|
|
echo $file >> BOINC-Manager-pofilter.txt
|
|
|
|
pofilter --language ${locale} -t printf -t escapes -t numbers -t tabs --nofuzzy ${srcdir}/locale/${locale}/BOINC-Manager.po >> BOINC-Manager-pofilter.txt
|
|
|
|
done
|
|
|
|
|
2016-11-16 20:59:04 +00:00
|
|
|
cd ${srcdir}
|
2011-12-16 00:55:04 +00:00
|
|
|
|
2018-06-24 13:34:25 +00:00
|
|
|
echo "Translations compiled successfully. Now some manual steps:"
|
|
|
|
echo " 1. less BOINC-Manager-pofilter.txt # check output from pofilter and adjust translations then start this script again"
|
|
|
|
echo " 2. git add -u # only update already tracked files (add new files when needed too)"
|
|
|
|
echo " 3. git commit -m \"Locale: Update localization files [skip ci]\""
|
|
|
|
echo " 4. git push"
|
2013-06-05 20:49:02 +00:00
|
|
|
|
2009-11-12 20:58:03 +00:00
|
|
|
exit 0
|