Support displaying in UTC (RFE #1440386).
[phpmyadmin/last10db.git] / scripts / lang-cleanup.sh
blobd8688e9cd533da907f25fdae7f1decf64ff98837
1 #!/bin/sh
3 # $Id$
4 # vim: expandtab sw=4 ts=4 sts=4:
6 # Script for removing language selection from phpMyAdmin
8 if [ $# -lt 1 ] ; then
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"
15 echo
16 echo "Types can be entered multiple times, all matched languages will be kept"
17 exit 1
20 # Construct expressions for find
21 match=""
22 for type in "$@" ; do
23 case $type in
24 all-languages)
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"
35 else
36 echo "ERROR: $type seems to be wrong!"
37 exit 2
40 esac
41 done
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, \
50 'BEGIN { pr = 1 } ;
51 /^\);/ { pr = 1 } ;
52 {if(!pr) print $2;};
53 /^\$available_languages/ { pr = 0 };' \
54 libraries/select_lang.lib.php \
55 | tr -d \' \
56 | while read lng ; do if [ -f lang/$lng.inc.php ] ; then echo $lng ; fi ; done \
57 | tr '\n' '|' \
58 | sed 's/|$//' \
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
66 awk -F, \
67 'BEGIN { pr = 1 } ;
68 /^\);/ { pr = 1 } ;
69 {if(pr) print $0;};
70 /'$langmatch'/ {if (!pr) print $0;};
71 /^\$available_languages/ { pr = 0 };' \
72 $tmp > libraries/select_lang.lib.php
74 # Final cleanup
75 rm -f $tmp