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