#!/bin/sh # $Id$ ## # 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 ## # Changes: # 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 CONVERTOR=recode CONVERTOR_PARAMS=" -f %s..%s" shift ;; *) echo Using recode as default, force with --iconv/--recode CONVERTOR=recode CONVERTOR_PARAMS=" -f %s..%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.php3. # BASE_TRANSLATIONS=`cat < $TEMPFILE if [ -s $TEMPFILE ] ; then cat $TEMPFILE > $file echo done else FAILED="$FAILED $file" echo FAILED fi elif [ $src_charset = 'utf-8' ] ; then # if we convert from utf-8, we should remove allow_recoding $CONVERTOR $(printf "$CONVERTOR_PARAMS" $src_charset $charset) < $base.inc.php3| grep -v allow_recoding > $TEMPFILE if [ -s $TEMPFILE ] ; then cat $TEMPFILE > $file echo done else FAILED="$FAILED $file" echo FAILED fi else # just convert $CONVERTOR $(printf "$CONVERTOR_PARAMS" $src_charset $charset) < $base.inc.php3| sed "s/$src_charset/$charset/" > $TEMPFILE if [ -s $TEMPFILE ] ; then cat $TEMPFILE > $file echo done else FAILED="$FAILED $file" echo FAILED fi 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 echo -n " creating utf-8 translation ... " charset=utf-8 file=$lang-$charset.inc.php3 $CONVERTOR $(printf "$CONVERTOR_PARAMS" $src_charset $charset) < $base.inc.php3| sed -e "s/$src_charset/$charset/" -e '/\$charset/a\ $allow_recoding = TRUE;' > $TEMPFILE if [ -s $TEMPFILE ] ; then cat $TEMPFILE > $file echo done else FAILED="$FAILED $file" echo FAILED fi fi fi echo "$lang processing finished." echo "-------------------------------------------------------------------" done 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