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