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