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