Re: Gettext solution (Was: Re: gettext packages)
> elif [ -n "$BASH" ]; then
> echo $"$*"
>
> I've tried it. I can't get the $"..." syntax to do anything though, YMMV :}
> It works fine if I run it with ash too.
Bash first performs the locale translation $"<string>" and replaces it
by "<translated string>". Only then does it perform variable
expansion etc. The following works, however:
eval "echo \$\"$*\""
Nicer might be the following, but this is untested:
TEXTDOMAIN=foo
export TEXTDOMAIN
if command -v gettext >/dev/null 2>&1; then echo="gettext -s"
elif [ -n "$BASH" ]; then xecho(){ eval "echo \$\"$*\""; } ; echo=xecho
else echo=echo
fi
and then use $echo instead of echo throughout the script.
But of course, if the script is #!/bin/bash, $"..." can be used in the
first place. And if it's /bin/sh, then I don't know whether it's
necessarily so useful to test for sh=bash.
When I have finished a couple of other projects (primarily a more
secure version of the mktex* scripts), I intend to help the upstream
author split out the gettext program from the rest of the suite.
Julian
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
Julian Gilbey, Dept of Maths, QMW, Univ. of London. J.D.Gilbey@qmw.ac.uk
Debian GNU/Linux Developer, see http://www.debian.org/~jdg
Reply to: