Translation update done using Pootle.
[phpmyadmin/sankalp_k.git] / scripts / remove-incomplete-mo
blob83d14ea7aeebefef1a5534070c6764fbb69eaad7
1 #!/bin/sh
3 # Removes mo files for incomplete translations
6 set -e
9 # How many percent needs to be translated
11 THRESHOLD=50
14 # Generated output file
16 OUTPUTFILE=libraries/language_stats.inc.php
18 if [ ! -z "$1" ] ; then
19 THRESHOLD=$1
22 echo '<?php' > $OUTPUTFILE
23 echo '/* Automatically generated file, do not edit! */' >> $OUTPUTFILE
24 echo '/* Generated by scripts/remove-incomplete-mo */' >> $OUTPUTFILE
25 echo '' >> $OUTPUTFILE
26 echo '$GLOBALS["language_stats"] = array (' >> $OUTPUTFILE
28 check() {
29 OUTPUTFILE=$2
30 lang=`echo $1 | sed 's@po/\(.*\)\.po@\1@'`
31 STATS=`LC_ALL=C msgfmt --statistics -o /dev/null $1 2>&1`
32 if echo $STATS | grep -q ' translated ' ; then
33 TRANSLATED=`echo $STATS | sed 's/\(^\|.* \)\([0-9]*\) translated.*/\2/'`
34 else
35 TRANSLATED=0
37 if echo $STATS | grep -q ' fuzzy ' ; then
38 FUZZY=`echo $STATS | sed 's/\(^\|.* \)\([0-9]*\) fuzzy.*/\2/'`
39 else
40 FUZZY=0
42 if echo $STATS | grep -q ' untranslated ' ; then
43 UNTRANSLATED=`echo $STATS | sed 's/\(^\|.* \)\([0-9]*\) untranslated.*/\2/'`
44 else
45 UNTRANSLATED=0
47 PERCENT=`expr 100 \* $TRANSLATED / \( $TRANSLATED + $FUZZY + $UNTRANSLATED \) || true`
48 echo " '$lang' => $PERCENT," >> $OUTPUTFILE
50 if [ $PERCENT -lt $THRESHOLD ] ; then
51 echo "Removing $lang, only $PERCENT%"
52 rm -f locale/$lang/LC_MESSAGES/phpmyadmin.mo
56 for x in po/*.po ; do
57 check $x $OUTPUTFILE
58 done
60 echo ');' >> $OUTPUTFILE
61 echo '?>' >> $OUTPUTFILE