4 # Shell script that synchronises all translations in phpMyAdmin
6 # Any parameters (except --iconv/--recode) will be passed to grep to filter
7 # processed translation, for example: './sync_lang.sh czech' will process only
8 # czech translation, './sync_lang.sh -e czech -e english' will process czech
9 # and english translations.
11 # Written by Michal Cihar <nijel at users.sourceforge.net>
15 # * now accepts parameters --iconv/--recode for specifying which convertor
18 # * support for synchronisation only for selected language(s)
20 # * can exclude some languages from conversion
22 # * support for multiple convertors (recode added)
28 # CONVERTOR_PARAMS is used for printf and it also receives two params: source
34 echo Using
iconv on user request
36 # the space on following is REQUIRED
37 CONVERTOR_PARAMS
=" -f %s -t %s"
41 echo Using
recode on user request
43 CONVERTOR_PARAMS
="%s..%s"
47 echo Using
recode as default
, force with
--iconv/--recode
49 CONVERTOR_PARAMS
="%s..%s"
55 # names of translations to process
57 # Here should be listed all translations for which conversion should be done.
58 # The name is filename without inc.php3.
60 BASE_TRANSLATIONS
=`cat <<EOT
64 brazilian_portuguese-iso-8859-1
88 lithuanian-windows-1257
102 ukrainian-windows-1251
106 # which translations should not be translated to utf-8
108 # List here any translation that should not be converted to utf-8. The name is
111 IGNORE_UTF
=`cat <<EOT
113 korean-ks_c_5601-1987
117 # which translations should not be automatically generated
119 # List here any translation should not be automatically generated from base
120 # translation for that language (usually for those which are not correctly
121 # supported by convertor).
123 IGNORE_TRANSLATIONS
=`cat <<EOT
129 # end of configuration, you hopefully won't need to edit anything bellow
132 echo "-------------------------------------------------------------------"
133 # go through all file we should process
134 for base
in $BASE_TRANSLATIONS ; do
135 if [ "$#" -gt 0 ] ; then
136 if ( echo $base |
grep -q "$@" ) ; then
142 # grep language from basename
143 lang
=$
(echo $base|
sed 's%-.*%%')
144 # which files will we create from current?
145 create_files
=$
(ls --color=none
-1 $lang*.inc.php3|
grep -v $base.inc.php3
)
147 for ignore
in $IGNORE_TRANSLATIONS ; do
148 create_files
=$
(echo "$create_files" |
grep -v $ignore)
151 # charset of source file
152 src_charset
=$
(grep '\$charset' $base.inc.php3 |
sed "s%^[^'\"]*['\"]\\([^'\"]*\\)['\"][^'\"]*$%\\1%")
153 echo "$base [charset $src_charset]"
157 # at first update existing translations
158 for file in $create_files ; do
159 # charset of destination file
160 charset
=$
(grep '\$charset' $file |
sed "s%^[^'\"]*['\"]\\([^'\"]*\\)['\"][^'\"]*$%\\1%")
161 echo -n " to $charset..."
162 if [ $charset = 'utf-8' ] ; then
163 # if we convert to utf-8, we should add allow_recoding
165 $CONVERTOR $
(printf "$CONVERTOR_PARAMS" $src_charset $charset) < $base.inc.php3|
sed -e "s/$src_charset/$charset/" -e '/\$charset/a\
166 $allow_recoding = TRUE;' > $file
168 elif [ $src_charset = 'utf-8' ] ; then
169 # if we convert from utf-8, we should remove allow_recoding
170 $CONVERTOR $
(printf "$CONVERTOR_PARAMS" $src_charset $charset) < $base.inc.php3|
grep -v allow_recoding
> $file
174 $CONVERTOR $
(printf "$CONVERTOR_PARAMS" $src_charset $charset) < $base.inc.php3|
sed "s/$src_charset/$charset/" > $file
179 # now check whether we found utf-8 translation
180 if [ $is_utf = no
] ; then
181 if ( echo $IGNORE_UTF |
grep -q $base ) ; then
182 # utf-8 should not be created
185 # we should create utf-8 translation
186 echo " creating utf-8 translation"
188 iconv -f $src_charset -t $charset $base.inc.php3|
sed -e "s/$src_charset/$charset/" -e '/\$charset/a\
189 $allow_recoding = TRUE;' > $lang-$charset.inc.php3
192 echo "$lang processing finished."
193 echo "-------------------------------------------------------------------"