4 # vim: expandtab sw=4 ts=4 sts=4:
6 # Script for removing language selection from phpMyAdmin
9 echo "Usage: lang-cleanup.sh type ..."
10 echo "Type can be one of:"
11 echo " all-languages - nothing will be done"
12 echo " all-languages-utf-8-only - non utf-8 languages will be deleted"
13 echo " language - keeps utf-8 version of language"
14 echo " language-charset - keeps this exact language"
16 echo "Types can be entered multiple times, all matched languages will be kept"
20 # Construct expressions for find
25 match
="$match -and -false"
27 all-languages-utf-8-only
)
28 match
="$match -and -not -name *-utf-8.inc.php"
31 if [ -f lang
/$type-utf-8.inc.php
] ; then
32 match
="$match -and -not -name $type-utf-8.inc.php"
33 elif [ -f lang
/$type.inc.php
] ; then
34 match
="$match -and -not -name $type.inc.php"
36 echo "ERROR: $type seems to be wrong!"
43 # Delete unvanted languages
44 find lang
-name \
*.inc.php
$match -print0 |
xargs -0r rm
46 # Cleanup libraries/select_lang.lib.php
48 # Find languages we have
49 langmatch
="$(awk -F, \
53 /^\$available_languages/ { pr = 0 };' \
54 libraries/select_lang.lib.php \
56 | while read lng ; do if [ -f lang/$lng.inc.php ] ; then echo $lng ; fi ; done \
61 # Prepare working copy
62 tmp
=`mktemp libraries/select_lang.lib.php.XXXX`
63 cat libraries
/select_lang.lib.php
> $tmp
65 # Remove languages we don't have
70 /'$langmatch'/ {if (!pr) print $0;};
71 /^\$available_languages/ { pr = 0 };' \
72 $tmp > libraries
/select_lang.lib.php