3 # merge-from-transifex.sh
4 # Fix problems with the "tx" command line client by forcing a download of
5 # all translations and then using the downloaded translations as a compendium
6 # in msgmerge to update the .po file without destroying existing content.
7 # ..which I think is what the "tx" client should do all along?! :/
9 # Thomas Perl <thp.io/about>; 2012-01-21
14 MERGE_DIR
=..
/_tmp_merge_dir
15 MESSAGES_POT
=en
/LC_MESSAGES
/django.po
17 if [ "`which tx`" = "" ]; then
18 echo "The Transifex client 'tx' was not found."
19 echo "If you are on Debian: apt-get install transifex-client"
23 if [ "`which git`" = "" ]; then
24 echo "Please install 'git'. We need it to revert changes by 'tx' ;)"
28 cd `dirname $0`/..
/..
/mygpo
/locale
30 if git status
--porcelain |
grep -q '^ M po'; then
31 echo "Uncommitted changes in po/ - cannot continue."
32 echo "Please revert or commit current changes before continuing."
36 rm */LC_MESSAGES
/django.po
38 # restore english source language
41 if [ -d "$MERGE_DIR" ]; then
42 echo "The directory $MERGE_DIR still exists. Please remove it."
46 # First, pull translations from Transifex, overwriting existing .po files
47 echo "Downloading UPDATED translations from Transifex..."
50 echo "Moving files to merge directory..."
53 find -mindepth 1 -maxdepth 1 -not -name "en" -exec mv -v '{}' "$MERGE_DIR" \
;
55 echo "Restoring original .po files from Git..."
58 echo "Merging translations..."
60 for POFILE
in `find . -path ./en -prune -o -name django.po -print`; do
61 echo -n "Merging $POFILE"
62 msgmerge
--compendium="$MERGE_DIR/$POFILE" \
63 "$POFILE" "$MESSAGES_POT" --output-file="$POFILE"
66 echo "Removing merge directory..."
69 echo "Running validation script to check for errors..."
70 sh ..
/..
/tools
/i18n
/validate.sh
72 echo "All done. Please review changes and stage them for commmit."