slitaz-base-files diff rootfs/lib/libtaz.sh @ rev 177

libtaz.sh, Makefile: fix design of i18n
author Aleksej Bobylev <al.bobylev@gmail.com>
date Mon May 21 10:06:27 2012 +0300 (2012-05-21)
parents c09b461ada93
children d8adb319ac56
line diff
     1.1 --- a/rootfs/lib/libtaz.sh	Sat May 19 03:57:26 2012 -0500
     1.2 +++ b/rootfs/lib/libtaz.sh	Mon May 21 10:06:27 2012 +0300
     1.3 @@ -12,12 +12,21 @@
     1.4  
     1.5  # Internationalization.
     1.6  . /usr/bin/gettext.sh
     1.7 -TEXTDOMAIN='slitaz-base'
     1.8 -export TEXTDOMAIN
     1.9 +# We can't export TEXTDOMAIN because this script includes to other scripts
    1.10 +#  with other TEXTDOMAIN exported
    1.11 +## TEXTDOMAIN='slitaz-base'
    1.12 +## export TEXTDOMAIN
    1.13 +
    1.14 +# xgettext (from Makefile) can't extract strings from above example:
    1.15 +#  gettext -d 'slitaz-base' 'Done'
    1.16 +# so, I define own function (and add it as option to xgettext to Makefile)
    1.17 +lgettext() {
    1.18 +	gettext -d 'slitaz-base' $1
    1.19 +}
    1.20  
    1.21  # Internal variables.
    1.22 -okmsg="$(gettext "Done")"
    1.23 -ermsg="$(gettext "Failed")"
    1.24 +okmsg="$(lgettext 'Done')"
    1.25 +ermsg="$(lgettext 'Failed')"
    1.26  : ${okcolor=32}
    1.27  : ${ercolor=31}
    1.28  : ${decolor=36}
    1.29 @@ -109,7 +118,7 @@
    1.30  # Check if user is logged as root.
    1.31  check_root() {
    1.32  	if [ $(id -u) != 0 ]; then
    1.33 -		gettext "You must be root to execute:" && echo " $(basename $0) $@"
    1.34 +		lgettext "You must be root to execute:" && echo " $(basename $0) $@"
    1.35  		exit 1
    1.36  	fi
    1.37  }
    1.38 @@ -122,10 +131,10 @@
    1.39  # Gettextize yes/no.
    1.40  translate_query() {
    1.41  	case $1 in
    1.42 -		y) gettext "y" ;;
    1.43 -		Y) gettext "Y" ;;
    1.44 -		n) gettext "n" ;;
    1.45 -		N) gettext "N" ;;
    1.46 +		y) lgettext "y" ;;
    1.47 +		Y) lgettext "Y" ;;
    1.48 +		n) lgettext "n" ;;
    1.49 +		N) lgettext "N" ;;
    1.50  		# Support other cases but keep them untranslated.
    1.51  		*) echo "$1" ;;
    1.52  	esac