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