Translation update done using Pootle.
[phpmyadmin.git] / scripts / remove-incomplete-mo
blobec7d3b3dd39e366e36123d6aba726e89b6535fe3
1 #!/bin/sh
3 # Removes mo files for incomplete translations
6 set -e
9 # How many percent needs to be translated
11 THRESHOLD=40
14 # Generated output file
16 TMPOUTPUTFILE=libraries/language_stats.inc.php.tmp
17 OUTPUTFILE=libraries/language_stats.inc.php
19 if [ ! -z "$1" ] ; then
20 THRESHOLD=$1
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
29 check() {
30 TMPOUTPUTFILE=$2
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/'`
35 else
36 TRANSLATED=0
38 if echo $STATS | grep -q ' fuzzy ' ; then
39 FUZZY=`echo $STATS | sed 's/\(^\|.* \)\([0-9]*\) fuzzy.*/\2/'`
40 else
41 FUZZY=0
43 if echo $STATS | grep -q ' untranslated ' ; then
44 UNTRANSLATED=`echo $STATS | sed 's/\(^\|.* \)\([0-9]*\) untranslated.*/\2/'`
45 else
46 UNTRANSLATED=0
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
55 rmdir locale/$lang
59 for x in po/*.po ; do
60 check $x $TMPOUTPUTFILE
61 done
63 echo ');' >> $TMPOUTPUTFILE
64 echo '?>' >> $TMPOUTPUTFILE
66 mv $TMPOUTPUTFILE $OUTPUTFILE