Remove useless comparison
[pidgin-git.git] / po / import-from-transifex
blob678bce6a4a1b317b3b5d230e09edddc5f956beae
1 #!/bin/bash -eu
2 # This uses bash for the <() syntax.
4 # TODO: Is there a way we can ignore files with only fuzzy-string changes?
6 # These are the languages which are maintained in Transifex.
7 transifex_languages="sq ar ar_SA hy hy_AM ast be brx br my_MM ca cs nl en_AU en_GB et fi gl ka de el he hi hu id ga it ja ks kk km ku_IQ lv lt mai ms_MY mr ne nqo nb nn oc pa fa pl pt pt_BR ro ru szl sd sl es es_AR sv tt te tr uk uz cy
10 if ! which tx > /dev/null
11 then
12 cat >&2 << EOF
13 You must install the Transifex command-line client:
14 http://docs.transifex.com/client/setup/
15 EOF
16 exit 1
19 cat << EOF
20 This script assumes your working tree is clean, at least in the po directory.
21 It pulls the translations from Transifex, works out what has changed, and
22 COMMITS intltool-update changes without prompting. It then leaves the
23 remaining changes for manual review and committing.
25 Ctrl-C now to abort...
26 EOF
27 sleep 10
29 if [ -d po ]
30 then
31 cd po
34 changed_files=
35 commitable_files=
36 for i in $transifex_languages
38 if [ -e $i.po ]
39 then
40 cp $i.po $i.po.original
41 XGETTEXT_ARGS=--no-location intltool-update $i
42 cp $i.po $i.po.cleaned
45 tx pull -f -l $i
46 XGETTEXT_ARGS=--no-location intltool-update $i
48 if [ -e $i.po.cleaned ]
49 then
50 if cmp -s <(grep ^msg $i.po.cleaned) <(grep ^msg $i.po)
51 then
52 # There were no actual changes.
53 mv $i.po.original $i.po
54 else
55 # There were changes.
56 mv $i.po $i.po.transifex
57 changed_files="$changed_files $i.po"
59 if cmp -s <(grep ^msg $i.po.original) <(grep ^msg $i.po.cleaned)
60 then
61 # The cleaning produced no actual changes; undo the cleaning.
62 mv $i.po.original $i.po
63 else
64 # The cleaning produced changes; leave it for committing.
65 mv $i.po.cleaned $i.po
66 commitable_files="$commitable_files $i.po"
71 rm -f $i.po.original $i.po.cleaned
72 done
74 # Commit cleaned versions of the changed files.
75 if [ -n "$commitable_files" ]
76 then
77 hg commit -u "Pidgin Translators <translators@pidgin.im>" \
78 -m "Clean changed translations" $commitable_files
81 # Leave the cleaned Transifex versions in place, ready for committing.
82 for i in $changed_files
84 mv $i.transifex $i
85 done