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
33 echo Using
iconv on user request
35 CONVERTOR_PARAMS
="-f %s -t %s"
39 echo Using
recode on user request
41 CONVERTOR_PARAMS
="%s..%s"
45 echo Using
recode as default
, force with
--iconv/--recode
47 CONVERTOR_PARAMS
="%s..%s"
53 # names of translations to process
55 # Here should be listed all translations for which conversion should be done.
56 # The name is filename without inc.php3.
58 BASE_TRANSLATIONS
=`cat <<EOT
62 brazilian_portuguese-iso-8859-1
85 lithuanian-windows-1257
99 ukrainian-windows-1251
103 # which translations should not be translated to utf-8
105 # List here any translation that should not be converted to utf-8. The name is
108 IGNORE_UTF
=`cat <<EOT
110 korean-ks_c_5601-1987
114 # which translations should not be automatically generated
116 # List here any translation should not be automatically generated from base
117 # translation for that language (usually for those which are not correctly
118 # supported by convertor).
120 IGNORE_TRANSLATIONS
=`cat <<EOT
126 # end of configuration, you hopefully won't need to edit anything bellow
129 echo "-------------------------------------------------------------------"
130 # go through all file we should process
131 for base
in $BASE_TRANSLATIONS ; do
132 if [ "$#" -gt 0 ] ; then
133 if ( echo $base |
grep -q "$@" ) ; then
139 # grep language from basename
140 lang
=$
(echo $base|
sed 's%-.*%%')
141 # which files will we create from current?
142 create_files
=$
(ls --color=none
-1 $lang*.inc.php3|
grep -v $base.inc.php3
)
144 for ignore
in $IGNORE_TRANSLATIONS ; do
145 create_files
=$
(echo "$create_files" |
grep -v $ignore)
148 # charset of source file
149 src_charset
=$
(grep '\$charset' $base.inc.php3 |
sed "s%^[^'\"]*['\"]\\([^'\"]*\\)['\"][^'\"]*$%\\1%")
150 echo "$base [charset $src_charset]"
154 # at first update existing translations
155 for file in $create_files ; do
156 # charset of destination file
157 charset
=$
(grep '\$charset' $file |
sed "s%^[^'\"]*['\"]\\([^'\"]*\\)['\"][^'\"]*$%\\1%")
158 echo -n " to $charset..."
159 if [ $charset = 'utf-8' ] ; then
160 # if we convert to utf-8, we should add allow_recoding
162 $CONVERTOR $
(printf -- "$CONVERTOR_PARAMS" $src_charset $charset) < $base.inc.php3|
sed -e "s/$src_charset/$charset/" -e '/\$charset/a\
163 $allow_recoding = TRUE;' > $file
165 elif [ $src_charset = 'utf-8' ] ; then
166 # if we convert from utf-8, we should remove allow_recoding
167 $CONVERTOR $
(printf -- "$CONVERTOR_PARAMS" $src_charset $charset) < $base.inc.php3|
grep -v allow_recoding
> $file
171 $CONVERTOR $
(printf -- "$CONVERTOR_PARAMS" $src_charset $charset) < $base.inc.php3|
sed "s/$src_charset/$charset/" > $file
176 # now check whether we found utf-8 translation
177 if [ $is_utf = no
] ; then
178 if ( echo $IGNORE_UTF |
grep -q $base ) ; then
179 # utf-8 should not be created
182 # we should create utf-8 translation
183 echo " creating utf-8 translation"
185 iconv -f $src_charset -t $charset $base.inc.php3|
sed -e "s/$src_charset/$charset/" -e '/\$charset/a\
186 $allow_recoding = TRUE;' > $lang-$charset.inc.php3
189 echo "$lang processing finished."
190 echo "-------------------------------------------------------------------"