Adjus languages cleanup for gettext.

This commit is contained in:
Michal Čihař
2010-03-12 14:00:11 +01:00
parent ba106a107a
commit 486280626a

View File

@@ -6,71 +6,37 @@
# Script for removing language selection from phpMyAdmin # Script for removing language selection from phpMyAdmin
if [ $# -lt 1 ] ; then if [ $# -lt 1 ] ; then
echo "Usage: lang-cleanup.sh type ..." echo "Usage: lang-cleanup.sh type"
echo "Type can be one of:" echo "Type can be one of:"
echo " all-languages - nothing will be done" echo " all-languages - nothing will be done"
echo " all-languages-utf-8-only - non utf-8 languages will be deleted" echo " english - no translations will be kept"
echo " language - keeps utf-8 version of language" echo " langcode - keeps language"
echo " language-charset - keeps this exact language"
echo echo
echo "Types can be entered multiple times, all matched languages will be kept" echo "Languages can be scpecified multiple times"
exit 1 exit 1
fi fi
# Construct expressions for find # Expression for find
match="" match=""
for type in "$@" ; do for type in "$@" ; do
case $type in case $type in
all-languages) all-languages)
match="$match -and -false" exit 0
;; ;;
all-languages-utf-8-only) english)
match="$match -and -not -name *-utf-8.inc.php" rm -rf po
rm -rf locale
exit 0
;; ;;
*) *)
if [ -f lang/$type-utf-8.inc.php ] ; then match="$match -and -not -name $type.po -and -not -path locale/$type/LC_MESSAGES/phpmyadmin.mo"
match="$match -and -not -name $type-utf-8.inc.php"
elif [ -f lang/$type.inc.php ] ; then
match="$match -and -not -name $type.inc.php"
else
echo "ERROR: $type seems to be wrong!"
exit 2
fi
;; ;;
esac esac
done done
# Delete unvanted languages # Delete unvanted languages
find lang -name \*.inc.php $match -print0 | xargs -0r rm find po locale -type f $match -print0 | xargs -0r rm
# Cleanup libraries/select_lang.lib.php
# Find languages we have
langmatch="$(awk -F, \
'BEGIN { pr = 1 } ;
/^\);/ { pr = 1 } ;
{if(!pr) print $2;};
/^\$available_languages/ { pr = 0 };' \
libraries/select_lang.lib.php \
| tr -d \' \
| while read lng ; do if [ -f lang/$lng.inc.php ] ; then echo $lng ; fi ; done \
| tr '\n' '|' \
| sed 's/|$//' \
)"
# Prepare working copy
tmp=`mktemp libraries/select_lang.lib.php.XXXX`
cat libraries/select_lang.lib.php > $tmp
# Remove languages we don't have
awk -F, \
'BEGIN { pr = 1 } ;
/^\);/ { pr = 1 } ;
{if(pr) print $0;};
/'$langmatch'/ {if (!pr) print $0;};
/^\$available_languages/ { pr = 0 };' \
$tmp > libraries/select_lang.lib.php
# Final cleanup
rm -f $tmp
# Delete empty directories
rmdir --ignore-fail-on-non-empty locale/*/*
rmdir --ignore-fail-on-non-empty locale/*