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