i18n: document txpull, de-bash

This commit is contained in:
Adriaan de Groot 2017-08-09 07:14:42 +09:00
parent ca3b10002b
commit e1ba93a0c2

View File

@ -1,38 +1,69 @@
#!/bin/bash #!/bin/sh
#
# Fetch the Transifex translations for Calamares and incorporate them
# into the source tree, adding commits of the different files.
# Make sure we can make Transifex and git operations from the Calamares Docker+Jenkins environment. ### INITIAL SETUP
cp ~/jenkins-master/.transifexrc ~ #
cp ~/jenkins-master/.gitconfig ~ # This stuff needs to be done once; in a real CI environment where it
cp -R ~/jenkins-master/.ssh ~ # runs regularly in a container, the setup needs to be done when
# creating the container.
#
#
# cp ~/jenkins-master/.transifexrc ~ # Transifex user settings
# cp ~/jenkins-master/.gitconfig ~ # Git config, user settings
# cp -R ~/jenkins-master/.ssh ~ # SSH, presumably for github
#
# cd "$WORKSPACE"
# git config --global http.sslVerify false
cd "$WORKSPACE" test -f "CMakeLists.txt" || { echo "! Not at Calamares top-level" ; exit 1 ; }
git config --global http.sslVerify false test -f ".tx/config" || { echo "! Not at Calamares top-level" ; exit 1 ; }
test -f "calamares.desktop" || { echo "! Not at Calamares top-level" ; exit 1 ; }
### FETCH TRANSLATIONS
#
# Use Transifex client to get translations; this depends on the
# .tx/config file to locate files, and overwrites them in the
# filesystem with new (merged) translations.
export QT_SELECT=5 export QT_SELECT=5
tx pull --force --source --all tx pull --force --source --all
### COMMIT TRANSLATIONS
#
# Produce multiple commits (for the various parts of the i18n
# infrastructure used by Calamares) of the updated translations.
# Try to be a little smart about not committing trivial changes.
# Who is credited with these CI commits
AUTHOR="--author='Calamares CI <groot@kde.org>'"
# Message to put after the module name
BOILERPLATE="Automatic merge of Transifex translations"
git add --verbose lang/calamares*.ts git add --verbose lang/calamares*.ts
git commit --author='Calamares CI <groot@kde.org>' --message='[core] Automatic merge of Transifex translations' | true git commit "$AUTHOR" --message="[core] $BOILERPLATE" | true
git add --verbose lang/desktop*.desktop calamares.desktop git add --verbose lang/desktop*.desktop calamares.desktop
git commit --author='Calamares CI <groot@kde.rg>' --message='[desktop] Automatic merge of Transifex translations' | true git commit "$AUTHOR" --message="[desktop] $BOILERPLATE" | true
# Transifex updates the PO-Created timestamp also when nothing interesting # Transifex updates the PO-Created timestamp also when nothing interesting
# has happened, so drop the files which have just 1 line changed (the # has happened, so drop the files which have just 1 line changed (the
# PO-Created line). This applies only to modules which use po-files. # PO-Created line). This applies only to modules which use po-files.
git diff --numstat src/modules | awk '($1==1 && $2==1){print $3}' | xargs git checkout -- git diff --numstat src/modules | awk '($1==1 && $2==1){print $3}' | xargs git checkout --
for MODULE_DIR in `find src/modules -maxdepth 1 -mindepth 1 -type d`; do # Go through the Python modules; those with a lang/ subdir have their
FILES=(${MODULE_DIR}/*.py) # own complete gettext-based setup.
if [ ${#FILES[@]} -gt 0 ]; then for MODULE_DIR in $(find src/modules -maxdepth 1 -mindepth 1 -type d) ; do
FILES=$(find "$MODULE_DIR" -name "*.py" -a -type f)
if test -n "$FILES" ; then
MODULE_NAME=$(basename ${MODULE_DIR}) MODULE_NAME=$(basename ${MODULE_DIR})
if [ -d ${MODULE_DIR}/lang ]; then if [ -d ${MODULE_DIR}/lang ]; then
# Convert PO files to MO files # Convert PO files to MO files
for POFILE in `find ${MODULE_DIR} -name "*.po"` ; do for POFILE in $(find ${MODULE_DIR} -name "*.po") ; do
msgfmt -o ${POFILE/.po/.mo} $POFILE msgfmt -o ${POFILE%.po}.mo $POFILE
done done
git add --verbose ${MODULE_DIR}/lang/* git add --verbose ${MODULE_DIR}/lang/*
git commit --author='Calamares CI <groot@kde.org>' --message="[${MODULE_NAME}] Automatic merge of Transifex translations" | true git commit "$AUTHOR" --message="[${MODULE_NAME}] $BOILERPLATE" | true
fi fi
fi fi
done done