slitaz-base-files 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 8e5e47cb6581
files Makefile rootfs/lib/libtaz.sh
line diff
     1.1 --- a/Makefile	Sat May 19 03:57:26 2012 -0500
     1.2 +++ b/Makefile	Mon May 21 10:06:27 2012 +0300
     1.3 @@ -14,7 +14,14 @@
     1.4  
     1.5  pot:
     1.6  	xgettext -o po/$(PACKAGE).pot -L Shell --package-name="SliTaz Base" \
     1.7 -		./rootfs/lib/libtaz.sh ./rootfs/usr/lib/slitaz/libpkg.sh
     1.8 +		--copyright-holder="SliTaz Association" -k -klgettext \
     1.9 +		./rootfs/lib/libtaz.sh
    1.10 +	xgettext -j -o po/$(PACKAGE).pot -L Shell --package-name="SliTaz Base" \
    1.11 +		--copyright-holder="SliTaz Association" \
    1.12 +		./rootfs/usr/lib/slitaz/libpkg.sh \
    1.13 +		./rootfs/var/www/cgi-bin/cgi-env.sh \
    1.14 +		./rootfs/var/www/cgi-bin/index.cgi \
    1.15 +		./rootfs/usr/bin/man
    1.16  
    1.17  msgmerge:
    1.18  	@for l in $(LINGUAS); do \
     2.1 --- a/rootfs/lib/libtaz.sh	Sat May 19 03:57:26 2012 -0500
     2.2 +++ b/rootfs/lib/libtaz.sh	Mon May 21 10:06:27 2012 +0300
     2.3 @@ -12,12 +12,21 @@
     2.4  
     2.5  # Internationalization.
     2.6  . /usr/bin/gettext.sh
     2.7 -TEXTDOMAIN='slitaz-base'
     2.8 -export TEXTDOMAIN
     2.9 +# We can't export TEXTDOMAIN because this script includes to other scripts
    2.10 +#  with other TEXTDOMAIN exported
    2.11 +## TEXTDOMAIN='slitaz-base'
    2.12 +## export TEXTDOMAIN
    2.13 +
    2.14 +# xgettext (from Makefile) can't extract strings from above example:
    2.15 +#  gettext -d 'slitaz-base' 'Done'
    2.16 +# so, I define own function (and add it as option to xgettext to Makefile)
    2.17 +lgettext() {
    2.18 +	gettext -d 'slitaz-base' $1
    2.19 +}
    2.20  
    2.21  # Internal variables.
    2.22 -okmsg="$(gettext "Done")"
    2.23 -ermsg="$(gettext "Failed")"
    2.24 +okmsg="$(lgettext 'Done')"
    2.25 +ermsg="$(lgettext 'Failed')"
    2.26  : ${okcolor=32}
    2.27  : ${ercolor=31}
    2.28  : ${decolor=36}
    2.29 @@ -109,7 +118,7 @@
    2.30  # Check if user is logged as root.
    2.31  check_root() {
    2.32  	if [ $(id -u) != 0 ]; then
    2.33 -		gettext "You must be root to execute:" && echo " $(basename $0) $@"
    2.34 +		lgettext "You must be root to execute:" && echo " $(basename $0) $@"
    2.35  		exit 1
    2.36  	fi
    2.37  }
    2.38 @@ -122,10 +131,10 @@
    2.39  # Gettextize yes/no.
    2.40  translate_query() {
    2.41  	case $1 in
    2.42 -		y) gettext "y" ;;
    2.43 -		Y) gettext "Y" ;;
    2.44 -		n) gettext "n" ;;
    2.45 -		N) gettext "N" ;;
    2.46 +		y) lgettext "y" ;;
    2.47 +		Y) lgettext "Y" ;;
    2.48 +		n) lgettext "n" ;;
    2.49 +		N) lgettext "N" ;;
    2.50  		# Support other cases but keep them untranslated.
    2.51  		*) echo "$1" ;;
    2.52  	esac