]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - check-translations.sh
Fix merge conflict
[xonotic/xonotic-data.pk3dir.git] / check-translations.sh
1 #!/bin/sh
2
3 case "$1" in
4         pot)
5                 mode=pot
6                 mail=true
7                 ;;
8         po)
9                 mode=po
10                 mail=true
11                 language=
12                 ;;
13         '')
14                 echo "Sorry, you are not supposed to use this script."
15                 echo "This script is solely for use by the Xonotic Core Team."
16                 echo "Unauthorized use of it can cause HIGHLY annoying merge"
17                 echo "conflicts."
18                 exit 1
19                 ;;
20         *)
21                 mode=po
22                 mail=false
23                 language=$1
24                 ;;
25 esac
26
27 for VM in menu csprogs; do
28         case "$VM" in
29                 csprogs)
30                         VMD=client
31                         ;;
32                 *)
33                         VMD=$VM
34                         ;;
35         esac
36
37         if [ x"$mode" = x"pot" ]; then
38                 {
39                         find qcsrc/"$VMD" -type f -not -name \*.po -not -name \*.txt
40                         find qcsrc/common -type f -not -name \*.po -not -name \*.txt
41                         find qcsrc/server -type f -name w_\*.qc
42                 } | xgettext -LC -k_ -f- --from-code utf-8 -o "$VM".dat.pot >&2
43         fi
44
45         if [ x"$mode" = x"po" ]; then
46                 for X in "$VM".dat.*.po; do
47                         [ -f "$X" ] || continue
48                         if [ -n "$language" ]; then
49                                 if [ x"${X#*.dat.}" != x"$language.po" ]; then
50                                         continue
51                                 fi
52                         fi
53                         for Y in ~/check-translations/"$X".*; do
54                                 [ -f "$Y" ] || continue
55                                 msgcat -F --use-first "$Y" "$X" > "$X".new
56                                 mv "$X".new "$X"
57                         done
58                         msgmerge -F -U "$X" "$VM".dat.pot >&2
59                         msgattrib --untranslated "$X" | grep . > "$X".untranslated || rm -f "$X".untranslated
60                         msgattrib --fuzzy "$X"        | grep . > "$X".fuzzy        || rm -f "$X".fuzzy
61                         nu=$((`grep -c ^#: "$X".untranslated` + 0))
62                         nf=$((`grep -c ^#: "$X".fuzzy`        + 0))
63                         n=$(($nu + $nf))
64                         if [ $n -gt 0 ]; then
65                                 echo "TODO for translation $X:"
66                                 echo "Untranslated: $nu"
67                                 echo "Fuzzy:        $nf"
68                                 ltr=`grep '^"Last-Translator: ' "$X" | cut -d ' ' -f 2- | cut -d '\\' -f 1 | egrep -v '<LL@li.org>|<EMAIL@ADDRESS>'`
69                                 ltm=`grep '^"Language-Team: ' "$X" | cut -d ' ' -f 2- | cut -d '\\' -f 1 | egrep -v '<LL@li.org>|<EMAIL@ADDRESS>'`
70                                 echo "Translators:  $ltr, $ltm"
71                                 case "$ltr" in
72                                         '')
73                                                 to=$ltm
74                                                 cc=
75                                                 ;;
76                                         *)
77                                                 to=$ltr
78                                                 if [ x"$ltr" = x"$ltm" ]; then
79                                                         cc=
80                                                 else
81                                                         cc=$ltm
82                                                 fi
83                                                 ;;
84                                 esac
85                                 if [ -n "$to" ]; then
86                                         echo "To:           $to"
87                                 fi
88                                 if [ -n "$cc" ]; then
89                                         echo "Cc:           $cc"
90                                 fi
91                                 if [ -n "$to" ]; then
92                                         while $mail; do
93                                                 echo "Send mail? [y/n]"
94                                                 read -r yesno
95                                                 case "$yesno" in
96                                                         y)
97                                                                 attach=
98                                                                 if [ $nu -gt 0 ]; then
99                                                                         attach="$attach $X.untranslated"
100                                                                 fi
101                                                                 if [ $nf -gt 0 ]; then
102                                                                         attach="$attach $X.fuzzy"
103                                                                 fi
104                                                                 {
105                                                                         cat <<EOF
106 Hi,
107
108 as you provided us with translations in the past, we kindly ask you
109 to update the translation to match changes in the Xonotic source. Can
110 you please work on them and provide updates to us?
111
112 If you do not wish to be contacted for translation updates any more,
113 please tell us in a reply to this message.
114
115 EOF
116                                                                         if [ $nu -gt 0 ]; then
117                                                                                 cat <<EOF
118 Attached to this message is a file
119 $X.untranslated
120 with $nu yet to be translated messages. Please translate them and reply
121 with the file containing the translations in the "msgstr" fields.
122
123 EOF
124                                                                         fi
125                                                                         if [ $nf -gt 0 ]; then
126                                                                                 cat <<EOF
127 Attached to this message is a file
128 $X.fuzzy
129 with $nf automatically generated translations. Please verify and/or fix
130 them and reply with the file having been verified by you.
131
132 EOF
133                                                                         fi
134                                                                         cat <<EOF
135 Thanks in advance,
136
137 Team Xonotic
138 EOF
139                                                                 } | mutt \
140                                                                         -e "set from=\"divVerent@xonotic.org\"" \
141                                                                         -e "set use_from=yes" \
142                                                                         -e "set use_envelope_from=yes" \
143                                                                         -s "Need update for translations: $X" \
144                                                                         -c "$cc" \
145                                                                         -b "divVerent@xonotic.org" \
146                                                                         -a $attach -- \
147                                                                         "$to"
148                                                                 break
149                                                                 ;;
150                                                         n)
151                                                                 break
152                                                                 ;;
153                                                 esac
154                                         done
155                                 fi
156                         fi
157                 done
158
159                 for X in "$VM".dat.*.po.disabled; do
160                         [ -f "$X" ] || continue
161                         if [ -n "$language" ]; then
162                                 if [ x"${X#*.dat.}" != x"$language.po" ]; then
163                                         continue
164                                 fi
165                         fi
166                         msgmerge -F -U "$X" "$VM".dat.pot >/dev/null 2>&1
167                 done
168         fi
169 done