[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Using gettext for runtime translations
From: |
Bruno Haible |
Subject: |
Re: Using gettext for runtime translations |
Date: |
Tue, 12 Apr 2005 13:55:19 +0200 |
User-agent: |
KMail/1.5 |
Hello,
Torsten Bronger wrote:
> For Texinfo (actually makeinfo), we need to translate things like
> "see section" or "node" to various languages. The language is *not*
> determined by the locale but by a parameter in the input file. The
> best way would be (for German as an example)
>
> translation = super_gettext("see ", "de");
>
> However, this doesn't exist (yet?).
You are already aware of
http://lists.gnu.org/archive/html/bug-texinfo/2003-12/msg00023.html
and
http://lists.gnu.org/archive/html/bug-gnu-utils/2004-09/msg00057.html
Something like this will be supported in gettext 0.15:
gl_locale_t locale = gl_newlocale ("de_DE", NULL);
translation = gl_dgettext ("texinfo", "see ", locale);
But meanwhile:
> So I have to set the locale manually. Using "setenv",
Yes.
> Is this also true if one uses setlocale()? Is setenv better than
> setlocale for some reason?
If you use setlocale() without using setenv(), code that uses gettext()
will not work on non-glibc platforms.
> And most importantly: What is a reliable way to know the language's
> name? For example, German is "de", but this doesn't work. Instead,
> it has to be "de_DE". Does "ll_CC" work everywhere and always,
> given that the translations are properly installed?
When you use gettext(), "ll_CC" works on all non-glibc systems, and on all
glibc systems on which the "ll_CC" locale is actually installed.
With the gettext 0.15 API gl_dgettext(), "ll_CC" will work on all systems,
regardless whether a "ll_CC" locale is installed.
"de" alone doesn't work as a locale name. The only place where it works
is in the LANGUAGE environment variable.
> Is there a decent fallback mechanism or do I have to mimic one?
I don't understand. What do you mean exactly?
Bruno