]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - tx.sh
Merge branch 'martin-t/insta' into 'master'
[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 mode=$1
11 case "$mode" in
12         all)
13                 push_pot=true
14                 sync_po=true
15                 ;;
16         pot)
17                 push_pot=true
18                 sync_po=false
19                 ;;
20         po)
21                 push_pot=false
22                 sync_po=true
23                 ;;
24         *)
25                 echo "Usage: $0 [all|pot|po]"
26                 exit 1
27                 ;;
28 esac
29
30 if $push_pot; then
31         # Update the .pot.
32         sh check-translations.sh pot
33
34         # First upload our current .pot.
35         mkdir -p translations/xonotic.commonpot/
36         cp common.pot translations/xonotic.commonpot/en..po
37         tx push -s
38 fi
39
40 if $sync_po; then
41         # Then pull the rest.
42         tx pull -f -a
43
44         for f in common.*.po; do
45                 lang=${f%.po}
46                 lang=${lang#common.}
47                 case "$lang" in
48                         de_CH)
49                                 continue
50                                 ;;
51                 esac
52                 tcurfile=translations/xonotic.commonpot/$lang..po
53                 goldfile=translations/xonotic.commonpot/$lang..po.orig
54                 gnewfile=common.$lang.po
55                 if [ -f "$tcurfile" ]; then
56                         git show "$mergebase":"$gnewfile" > "$goldfile"
57                         msgmerge -N -F -U "$tcurfile" common.pot
58                         msgmerge -N -F -U "$goldfile" common.pot
59                         msgmerge -N -F -U "$gnewfile" common.pot
60                         if diff -u "$goldfile" "$gnewfile" >/dev/null; then
61                                 # no change on git, changed on tx only
62                                 msgmerge -N -F -U "$tcurfile" common.pot
63                                 cp "$tcurfile" "$gnewfile"
64                         else
65                                 if ! diff -u "$goldfile" "$gnewfile" | patch "$tcurfile"; then
66                                         while :; do
67                                                 vim -o "$tcurfile.rej" "$tcurfile"
68                                                 echo "OK?"
69                                                 read -r OK || exit 1
70                                                 [ x"$OK" != x"y" ] || break
71                                         done
72                                         rm -f "$tcurfile.rej"
73                                 fi
74                                 msgmerge -N -F -U "$tcurfile" common.pot
75                                 cp "$tcurfile" "$gnewfile"
76                         fi
77                         rm "$goldfile"
78                 else
79                         msgmerge -N -F -U "$gnewfile" common.pot
80                         cp "$gnewfile" "$tcurfile"
81                 fi
82         done
83         for f in translations/xonotic.commonpot/*..po; do
84                 lang=${f%..po}
85                 lang=${lang#translations/xonotic.commonpot/}
86                 [ x"$lang" != x"en" ] || continue
87                 tcurfile=translations/xonotic.commonpot/$lang..po
88                 gnewfile=common.$lang.po
89                 if ! [ -f "$gnewfile" ]; then
90                         touch "$gnewfile"
91                         git add "$gnewfile"
92                         cp "$tcurfile" "$gnewfile"
93                 fi
94         done
95         tx push -t --skip
96         date > .tx/merge-base
97
98         # Generate Swiss Standard German from German.
99         msgfilter -i common.de.po -o common.de_CH.po perl -pe '
100                 # Character filters go here.
101                 s/ß/ss/g;
102                 # Word filters go here. By default we match even inside words, as there
103                 # are constructs like ^BGflag where "flag" is the actual word. Make
104                 # sure to not commit the clbuttical mistake.
105                 s/eventuell/allfällig/g;
106         '
107
108         # Build new languages list.
109         sh check-translations.sh txt > languages.txt.new
110         mv languages.txt.new languages.txt
111
112         # Report stats.
113         git diff --stat
114         git diff --color-words languages.txt
115 fi