Files
@ 3be168914a12
Branch filter:
Location: DistRen/htdocs/sql/lang/sync_lang.sh - annotation
3be168914a12
7.7 KiB
application/x-sh
Added web interface fileshg commit -h
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 | 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 | #!/bin/sh
# $Id: sync_lang.sh 11213 2008-04-23 17:13:43Z lem9 $
##
# Shell script that synchronises all translations in phpMyAdmin
##
# Any parameters (except --iconv/--recode) will be passed to grep to filter
# processed translation, for example: './sync_lang.sh czech' will process only
# czech translation, './sync_lang.sh -e czech -e english' will process czech
# and english translations.
##
# Written by Michal Cihar <nijel at users.sourceforge.net>
##
# Changes:
# 2005-12-08
# * less verbose output to allow quick overview
# 2005-11-29
# * hack for multibyte chars, so that \'; at the end will not fool PHP
# 2004-09-22
# * default to iconv, as it doesn't break things as recode does
# 2004-09-03
# * hack for hebrew
# 2003-11-18
# * switch php3 -> php
# 2003-04-14
# * convert only files that are needed to convert (checks mtime), --force to
# avoid this checking
# * get charset from filename when reading from file failed
# * report failed translations at the end
# 2002-09-18
# * now accepts parameters --iconv/--recode for specifying which convertor
# to use
# 2002-08-13
# * support for synchronisation only for selected language(s)
# 2002-07-18
# * can exclude some languages from conversion
# 2002-07-17
# * support for multiple convertors (recode added)
##
##
# convertor setup
##
# CONVERTOR_PARAMS is used for printf and it also receives two params: source
# and target charset
#
case "$1" in
--iconv)
echo Using iconv on user request
CONVERTOR=iconv
# the space on following is REQUIRED
CONVERTOR_PARAMS=" -f %s -t %s"
shift
;;
--recode)
echo Using recode on user request
echo '(please use iconv for arabic)'
CONVERTOR=recode
CONVERTOR_PARAMS=" -f %s..%s"
shift
;;
*)
echo Using iconv as default, force with --iconv/--recode
CONVERTOR=iconv
# the space on following is REQUIRED
CONVERTOR_PARAMS=" -f %s -t %s"
;;
esac
if [ "$1" = "--force" ] ; then
FORCE=1
shift
else
FORCE=0
fi
##
# names of translations to process
##
# Here should be listed all translations for which conversion should be done.
# The name is filename without inc.php.
#
BASE_TRANSLATIONS="afrikaans-iso-8859-1
albanian-iso-8859-1
arabic-windows-1256
azerbaijani-iso-8859-9
basque-iso-8859-1
belarusian_cyrillic-windows-1251
belarusian_latin-utf-8
bosnian-windows-1250
brazilian_portuguese-iso-8859-1
bulgarian-utf-8
catalan-iso-8859-1
chinese_traditional-utf-8
chinese_simplified-gb2312
croatian-utf-8
czech-utf-8
danish-iso-8859-1
dutch-iso-8859-1
english-iso-8859-1
estonian-iso-8859-1
finnish-iso-8859-1
french-iso-8859-1
galician-iso-8859-1
german-utf-8
greek-iso-8859-7
hebrew-iso-8859-8-i
hungarian-iso-8859-2
indonesian-iso-8859-1
italian-utf-8
japanese-utf-8
korean-utf-8
latvian-windows-1257
lithuanian-windows-1257
malay-iso-8859-1
macedonian_cyrillic-windows-1251
norwegian-iso-8859-1
persian-windows-1256
polish-iso-8859-2
portuguese-iso-8859-1
romanian-utf-8
russian-windows-1251
serbian_cyrillic-utf-8
serbian_latin-utf-8
slovenian-iso-8859-2
slovak-utf-8
spanish-utf-8
swedish-iso-8859-1
tatarish-iso-8859-9
thai-utf-8
turkish-utf-8
ukrainian-windows-1251"
##
# which translations should not be translated to utf-8
##
# List here any translation that should not be converted to utf-8. The name is
# same as above.
#
IGNORE_UTF=""
##
# which translations should not be automatically generated
##
# List here any translation should not be automatically generated from base
# translation for that language (usually for those which are not correctly
# supported by convertor).
#
IGNORE_TRANSLATIONS="
russian-cp-866"
##
# end of configuration, you hopefully won't need to edit anything bellow
##
TEMPFILE=`mktemp /tmp/pma-sync-lang.XXXXXX`
cleanup() {
rm -f $TEMPFILE
}
trap cleanup INT ABRT TERM
FAILED=""
echo "-------------------------------------------------------------------"
# go through all file we should process
for base in $BASE_TRANSLATIONS ; do
if [ "$#" -gt 0 ] ; then
if ( echo $base | grep -q "$@" ) ; then
true
else
continue
fi
fi
# grep language from basename
lang=$(echo $base|sed 's%-.*%%')
# which files will we create from current?
create_files=$(ls --color=none -1 $lang*.inc.php|grep -v $base.inc.php)
for ignore in $IGNORE_TRANSLATIONS ; do
create_files=$(echo "$create_files" | grep -v $ignore)
done
# charset of source file
src_charset=$(grep '\$charset' $base.inc.php | sed "s%^[^'\"]*['\"]\\([^'\"]*\\)['\"][^'\"]*$%\\1%")
replace_charset=$src_charset
# special case for hebrew
if [ $src_charset = 'iso-8859-8-i' ] ; then
src_charset=iso-8859-8
fi
echo -n "$base [charset $src_charset]"
# do we already have utf-8 translation?
if [ $src_charset = 'utf-8' ] ; then
is_utf=yes
else
is_utf=no
fi
# at first update existing translations
for file in $create_files ; do
# charset of destination file
# grepping from file causes problems when it is empty...
charset=$(grep '\$charset' $file | sed "s%^[^'\"]*['\"]\\([^'\"]*\\)['\"][^'\"]*$%\\1%")
if [ -z "$charset" ] ; then
charset=$(echo $file | sed -e 's/^[^-]*-//' -e 's/\.inc\.php\?$//')
fi
if [ $charset = 'utf-8' ] ; then
is_utf=yes
fi
# check whether we need to update translation
if [ ! "$base.inc.php" -nt "$file" -a "$FORCE" -eq 0 -a -s "$file" ] ; then
echo -n " ($file:ok)"
continue
fi
echo -n " ($file:to $charset:"
if [ $charset = 'utf-8' ] ; then
# if we convert to utf-8, we should add allow_recoding
is_utf=yes
$CONVERTOR $(printf "$CONVERTOR_PARAMS" $src_charset $charset) < $base.inc.php| sed -e "s/$replace_charset/$charset/" -e '/\$charset/a\
$allow_recoding = TRUE;' > $TEMPFILE
elif [ $src_charset = 'utf-8' ] ; then
is_utf=yes
# if we convert from utf-8, we should remove allow_recoding
$CONVERTOR $(printf "$CONVERTOR_PARAMS" $src_charset $charset) < $base.inc.php| grep -v allow_recoding | sed "s/$replace_charset/$charset/" > $TEMPFILE
else
# just convert
$CONVERTOR $(printf "$CONVERTOR_PARAMS" $src_charset $charset) < $base.inc.php| sed "s/$replace_charset/$charset/" > $TEMPFILE
fi
if [ -s $TEMPFILE ] ; then
sed "s/\\\\';[[:space:]]\+$/\\\\\\\\';/" $TEMPFILE > $file
echo -n 'done)'
else
FAILED="$FAILED $file"
echo -n 'FAILED)'
fi
done
# now check whether we found utf-8 translation
if [ $is_utf = no ] ; then
if ( echo $IGNORE_UTF | grep -q $base ) ; then
# utf-8 should not be created
true
else
# we should create utf-8 translation
charset=utf-8
file=$lang-$charset.inc.php
echo -n " [$file:$charset:"
$CONVERTOR $(printf "$CONVERTOR_PARAMS" $src_charset $charset) < $base.inc.php| sed -e "s/$replace_charset/$charset/" -e '/\$charset/a\
$allow_recoding = TRUE;' > $TEMPFILE
if [ -s $TEMPFILE ] ; then
cat $TEMPFILE > $file
echo -n 'done)'
else
FAILED="$FAILED $file"
echo -n 'FAILED)'
fi
fi
fi
echo
done
echo "-------------------------------------------------------------------"
if [ -z "$FAILED" ] ; then
echo "Everything seems to went okay"
else
echo "!!!SOME CONVERSION FAILED!!!"
echo "Following file were NOT updated:"
echo
echo "$FAILED"
echo
echo "!!!SOME CONVERSION FAILED!!!"
fi
cleanup
|