]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - tx.sh
Integrate with Transifex.
[xonotic/xonotic-data.pk3dir.git] / tx.sh
1 #!/bin/sh
2
3 # We store:
4 #   .tx/merge-base - changed whenever translations get merged
5
6 mergebase=`git log --pretty=oneline -1 .tx/merge-base | cut -d ' ' -f 1`
7
8 set -e
9
10 # First upload our current .pot.
11 mkdir -p translations/xonotic.commonpot/
12 cp common.pot translations/xonotic.commonpot/en..po
13 tx push -s
14
15 # Then pull the rest.
16 tx pull -f -a
17
18 for f in common.*.po; do
19         lang=${f%.po}
20         lang=${lang#common.}
21         tcurfile=translations/xonotic.commonpot/$lang..po
22         goldfile=translations/xonotic.commonpot/$lang..po.orig
23         gnewfile=common.$lang.po
24         if [ -f "$tcurfile" ]; then
25                 git show "$mergebase":"$gnewfile" > "$goldfile"
26                 msgcat -s --no-location --strict "$tcurfile" | grep -v "^#" > "$tcurfile.sorted"
27                 msgcat -s --no-location --strict "$goldfile" | grep -v "^#" > "$goldfile.sorted"
28                 msgcat -s --no-location --strict "$gnewfile" | grep -v "^#" > "$gnewfile.sorted"
29                 if diff -u "$goldfile.sorted" "$gnewfile.sorted" >/dev/null; then
30                         # no change on git, changed on tx only
31                         msgmerge -F -U "$tcurfile" common.pot
32                         cp "$tcurfile" "$gnewfile"
33                 else
34                         if ! diff -u "$goldfile.sorted" "$gnewfile.sorted" | patch "$tcurfile.sorted"; then
35                                 while :; do
36                                         vim -o "$tcurfile.sorted.rej" "$tcurfile.sorted"
37                                         echo "OK?"
38                                         read -r OK || exit 1
39                                         [ x"$OK" != x"y" ] || break
40                                 done
41                                 rm -f "$tcurfile.sorted.rej"
42                         fi
43                         mv "$tcurfile.sorted" "$tcurfile"
44                         msgmerge -F -U "$tcurfile" common.pot
45                         cp "$tcurfile" "$gnewfile"
46                         rm "$goldfile.sorted"
47                         rm "$gnewfile.sorted"
48                         rm "$goldfile"
49                 fi
50         else
51                 msgmerge -F -U "$gnewfile" common.pot
52                 cp "$gnewfile" "$tcurfile"
53         fi
54 done
55 for f in translations/xonotic.commonpot/*..po; do
56         lang=${f%..po}
57         lang=${lang#translations/xonotic.commonpot/}
58         [ x"$lang" != x"en" ] || continue
59         tcurfile=translations/xonotic.commonpot/$lang..po
60         gnewfile=common.$lang.po
61         if ! [ -f "$gnewfile" ]; then
62                 touch "$gnewfile"
63                 git add "$gnewfile"
64                 cp "$tcurfile" "$gnewfile"
65         fi
66 done
67 tx push -t
68 date > .tx/merge-base