[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Gettext solution (Was: Re: gettext packages)



On Thu, Jun 03, 1999 at 12:45:18AM +0100, Julian Gilbey wrote:
> > I've tried it. I can't get the $"..." syntax to do anything though, YMMV :}
> 
> 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:

What I meant was I've never got it to transform an english string into
something else, even when gettext works on the same string, e.g.:

bash$ LANG=de TEXTDOMAIN=gnome-libs gettext -s Exit
Beenden
bash$ LANG=de TEXTDOMAIN=gnome-libs echo $"Exit"
Exit

In fact, I wrote a script to try this and ltrace shows a correct call
to textdomain() but no call to gettext()...

> 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.

I don't think there's much in it, and script maintainers can of course
use whichever method they wish, provided it works.

> 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.

IMHO, #!/bin/bash is evil and should be avoided. Arguably, since bash
is an essential package in Debian, it's not fatal, but I'm just not
happy about it.

It's possible that the script is /bin/sh and /bin/sh is a symlink to
bash, and that the gettext program is uninstalled. In fact, won't this
be the default state of a non-developer Debian installation? In this
case, the $"..." method should still be usable, allowing i18n of shell
scripts without requiring us to split packages or change default
setups.

> secure version of the mktex* scripts), I intend to help the upstream
> author split out the gettext program from the rest of the suite.

Which I think would be handy, since bash's locale translation doesn't
seem to work for me...

SRH
-- 
Steve Haslam               Debian GNU/Linux               araqnid@debian.org
orbit, gnome-libs, gnome-core, gnome-control-center, gdm, p3nfs,
theme-convertors, device3dfx. what, me worry?

Attachment: pgptG7n1TQOqz.pgp
Description: PGP signature


Reply to: