3 # Removes mo files for incomplete translations
9 # How many percent needs to be translated
14 # Generated output file
16 TMPOUTPUTFILE
=libraries
/language_stats.inc.php.tmp
17 OUTPUTFILE
=libraries
/language_stats.inc.php
19 if [ ! -z "$1" ] ; then
23 echo '<?php' > $TMPOUTPUTFILE
24 echo '/* Automatically generated file, do not edit! */' >> $TMPOUTPUTFILE
25 echo '/* Generated by scripts/remove-incomplete-mo */' >> $TMPOUTPUTFILE
26 echo '' >> $TMPOUTPUTFILE
27 echo '$GLOBALS["language_stats"] = array (' >> $TMPOUTPUTFILE
31 lang
=`echo $1 | sed 's@po/\(.*\)\.po@\1@'`
32 STATS
=`LC_ALL=C msgfmt --statistics -o /dev/null $1 2>&1`
33 if echo $STATS |
grep -q ' translated ' ; then
34 TRANSLATED
=`echo $STATS | sed 's/\(^\|.* \)\([0-9]*\) translated.*/\2/'`
38 if echo $STATS |
grep -q ' fuzzy ' ; then
39 FUZZY
=`echo $STATS | sed 's/\(^\|.* \)\([0-9]*\) fuzzy.*/\2/'`
43 if echo $STATS |
grep -q ' untranslated ' ; then
44 UNTRANSLATED
=`echo $STATS | sed 's/\(^\|.* \)\([0-9]*\) untranslated.*/\2/'`
48 PERCENT
=`expr 100 \* $TRANSLATED / \( $TRANSLATED + $FUZZY + $UNTRANSLATED \) || true`
49 echo " '$lang' => $PERCENT," >> $TMPOUTPUTFILE
51 if [ $PERCENT -lt $THRESHOLD ] ; then
52 echo "Removing $lang, only $PERCENT%"
53 rm -f locale
/$lang/LC_MESSAGES
/phpmyadmin.mo
54 rmdir locale
/$lang/LC_MESSAGES
60 check
$x $TMPOUTPUTFILE
63 echo ');' >> $TMPOUTPUTFILE
64 echo '?>' >> $TMPOUTPUTFILE
66 mv $TMPOUTPUTFILE $OUTPUTFILE