Merge remote-tracking branch 'origin/zykure/playerstats_ladders' into samual/combined...
[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                 msgmerge -F -U "$tcurfile" common.pot
27                 msgmerge -F -U "$goldfile" common.pot
28                 msgmerge -F -U "$gnewfile" common.pot
29                 if diff -u "$goldfile" "$gnewfile" >/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" "$gnewfile" | patch "$tcurfile"; then
35                                 while :; do
36                                         vim -o "$tcurfile.rej" "$tcurfile"
37                                         echo "OK?"
38                                         read -r OK || exit 1
39                                         [ x"$OK" != x"y" ] || break
40                                 done
41                                 rm -f "$tcurfile.rej"
42                         fi
43                         msgmerge -F -U "$tcurfile" common.pot
44                         cp "$tcurfile" "$gnewfile"
45                 fi
46                 rm "$goldfile"
47         else
48                 msgmerge -F -U "$gnewfile" common.pot
49                 cp "$gnewfile" "$tcurfile"
50         fi
51 done
52 for f in translations/xonotic.commonpot/*..po; do
53         lang=${f%..po}
54         lang=${lang#translations/xonotic.commonpot/}
55         [ x"$lang" != x"en" ] || continue
56         tcurfile=translations/xonotic.commonpot/$lang..po
57         gnewfile=common.$lang.po
58         if ! [ -f "$gnewfile" ]; then
59                 touch "$gnewfile"
60                 git add "$gnewfile"
61                 cp "$tcurfile" "$gnewfile"
62         fi
63 done
64 tx push -t --skip
65 date > .tx/merge-base