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