Do not include incomplete translations in release.
[phpmyadmin-regexreplace.git] / scripts / remove-incomplete-mo
blob79ca24ae4d5ddfdf61fc64f1dc83ed5cb642351b
1 #!/bin/sh
3 # Removes mo files for incomplete translations
7 # How many percent needs to be translated
9 THRESHOLD=50
11 check() {
12 lang=`echo $1 | sed 's@po/\(.*\)\.po@\1@'`
13 STATS=`LANG=C msgfmt --statistics -o /dev/null $1 2>&1`
14 if echo $STATS | grep -q ' translated ' ; then
15 TRANSLATED=`echo $STATS | sed 's/\(^\|.* \)\([0-9]*\) translated.*/\2/'`
16 else
17 TRANSLATED=0
19 if echo $STATS | grep -q ' fuzzy ' ; then
20 FUZZY=`echo $STATS | sed 's/\(^\|.* \)\([0-9]*\) fuzzy.*/\2/'`
21 else
22 FUZZY=0
24 if echo $STATS | grep -q ' untranslated ' ; then
25 UNTRANSLATED=`echo $STATS | sed 's/\(^\|.* \)\([0-9]*\) untranslated.*/\2/'`
26 else
27 UNTRANSLATED=0
29 PERCENT=`expr 100 \* $TRANSLATED / \( $TRANSLATED + $FUZZY + $UNTRANSLATED \)`
31 if [ $PERCENT -lt $THRESHOLD ] ; then
32 echo "Removing $lang, only $PERCENT%"
33 rm -f locale/$lang/LC_MESSAGES/phpmyadmin.mo
37 if [ ! -z "$1" ] ; then
38 check po/$1.po
39 exit 0
42 for x in po/*.po ; do
43 check $x
44 done