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
12 MERGE_DIR
=_tmp_merge_dir
13 MESSAGES_POT
=messages.pot
15 if [ "`which tx`" == "" ]; then
16 echo "The Transifex client 'tx' was not found."
17 echo "If you are on Debian: apt-get install transifex-client"
21 if [ "`which git`" == "" ]; then
22 echo "Please install 'git'. We need it to revert changes by 'tx' ;)"
28 if git status
--porcelain |
grep -q '^ M po'; then
29 echo "Uncommitted changes in po/ - cannot continue."
30 echo "Please revert or commit current changes before continuing."
34 if [ -d "$MERGE_DIR" ]; then
35 echo "The directory $MERGE_DIR still exists. Please remove it."
39 # First, pull translations from Transifex, overwriting existing .po files
40 echo "Downloading UPDATED translations from Transifex..."
43 FILES
=`git status --porcelain |
44 grep '^ M po/.*.po$' |
48 echo "`echo $FILES | wc -w` files changed by 'tx'."
50 if [ "$FILES" != "" ]; then
51 echo "Moving files to merge directory..."
53 mv -v $FILES "$MERGE_DIR"
56 echo "Restoring original .po files from Git..."
59 echo "Merging translations..."
61 for POFILE
in $FILES; do
62 echo -n "Merging $POFILE"
63 msgmerge
--compendium="$MERGE_DIR/$POFILE" \
64 "$POFILE" "$MESSAGES_POT" --output-file="$POFILE"
67 echo "Removing merge directory..."
70 # To finish things off, fetch new translations from the server
71 echo "Downloading NEW translations from Transifex..."
72 tx pull
--all --disable-overwrite
74 echo "Running validation script to check for errors..."
77 echo "All done. Please review changes and stage them for commmit."