]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - check-translations.sh
update the check-translations script
[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                                                         zip -9r "$X"-todo.zip "$X".untranslated "$X".fuzzy
59                                                         {
60                                                                 cat <<EOF
61 Hi,
62
63 we need updates to the translations you made for Xonotic.
64
65 EOF
66                                                                 if [ $nu -gt 0 ]; then
67                                                                         cat <<EOF
68 The attached zip file contains a file
69 $X.untranslated
70 with $nu yet to be translated messages. Please translate them and reply with
71 the file containing the translations in the "msgstr" fields.
72
73 EOF
74                                                                 fi
75                                                                 if [ $nf -gt 0 ]; then
76                                                                         cat <<EOF
77 The attached zip file contains a file
78 $X.fuzzy
79 with $nf automatically generated translations. Please verify and/or fix them
80 and reply with the file having been verified by you.
81
82 EOF
83                                                                 fi
84                                                                 cat <<EOF
85 Thanks in advance,
86
87 Team Xonotic
88 EOF
89                                                         } | mail \
90                                                                 -s "Need update for translations: $X" \
91                                                                 -a "$X"-todo.zip \
92                                                                 -c "$cc" \
93                                                                 -b "divVerent@xonotic.org" \
94                                                                 -S from="divVerent@xonotic.org" \
95                                                                 "$to"
96 EOF
97                                                 n)
98                                                         break
99                                                         ;;
100                                         esac
101                                 done
102                         fi
103                 fi
104         done
105         for X in "$VM".dat.*.po.disabled; do
106                 [ -f "$X" ] || continue
107                 msgmerge -F -U "$X" "$VM".dat.pot >/dev/null 2>&1
108         done
109 done