forked from phpmyadmin/phpmyadmin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathremove-incomplete-mo
executable file
·66 lines (56 loc) · 1.67 KB
/
remove-incomplete-mo
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#!/bin/sh
#
# Removes mo files for incomplete translations
#
set -e
#
# How many percent needs to be translated
#
THRESHOLD=40
#
# Generated output file
#
TMPOUTPUTFILE=libraries/language_stats.inc.php.tmp
OUTPUTFILE=libraries/language_stats.inc.php
if [ ! -z "$1" ] ; then
THRESHOLD=$1
fi
echo '<?php' > $TMPOUTPUTFILE
echo '/* Automatically generated file, do not edit! */' >> $TMPOUTPUTFILE
echo '/* Generated by scripts/remove-incomplete-mo */' >> $TMPOUTPUTFILE
echo '' >> $TMPOUTPUTFILE
echo '$GLOBALS["language_stats"] = array (' >> $TMPOUTPUTFILE
check() {
TMPOUTPUTFILE=$2
lang=`echo $1 | sed 's@po/\(.*\)\.po@\1@'`
STATS=`LC_ALL=C msgfmt --statistics -o /dev/null $1 2>&1`
if echo $STATS | grep -q ' translated ' ; then
TRANSLATED=`echo $STATS | sed 's/\(^\|.* \)\([0-9]*\) translated.*/\2/'`
else
TRANSLATED=0
fi
if echo $STATS | grep -q ' fuzzy ' ; then
FUZZY=`echo $STATS | sed 's/\(^\|.* \)\([0-9]*\) fuzzy.*/\2/'`
else
FUZZY=0
fi
if echo $STATS | grep -q ' untranslated ' ; then
UNTRANSLATED=`echo $STATS | sed 's/\(^\|.* \)\([0-9]*\) untranslated.*/\2/'`
else
UNTRANSLATED=0
fi
PERCENT=`expr 100 \* $TRANSLATED / \( $TRANSLATED + $FUZZY + $UNTRANSLATED \) || true`
echo " '$lang' => $PERCENT," >> $TMPOUTPUTFILE
if [ $PERCENT -lt $THRESHOLD ] ; then
echo "Removing $lang, only $PERCENT%"
rm -f locale/$lang/LC_MESSAGES/phpmyadmin.mo
rmdir locale/$lang/LC_MESSAGES
rmdir locale/$lang
fi
}
for x in po/*.po ; do
check $x $TMPOUTPUTFILE
done
echo ');' >> $TMPOUTPUTFILE
echo '?>' >> $TMPOUTPUTFILE
mv $TMPOUTPUTFILE $OUTPUTFILE