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