Re: How to use the LANGUAGE environment variable
On Sat, May 28, 2005 at 10:15:35PM +0200, Mirko Parthey wrote:
> [I had first posted this on debian-user, but did not receive any
> helpful replies.]
>
> According to the glibc reference manual, LANGUAGE can contain a
> colon-separated list of locales to indicate their order of preference.
>
> However, the behaviour I observed is different from what I expected.
> (see the table; tested with "cat -h", which produces a short error message)
> LANGUAGE seems to have no effect when I leave LANG unset,
LANGUAGE is ignored if the locale is C, which is the default if none of
the environment variables are set. I couldn't find that in the
documentation, unfortunately.
> so I did the experiment with LANG=de_DE and LANG=en_GB.
>
> +---------+---------+
> LANGUAGE LANG> | de_DE | en_GB |
> V | | |
> +-----------------+---------+---------+
> | en_GB | english | english |
> | de_DE | german | german |
> | en_GB:de_DE | german | german | <- this seems strange to me
> | de_DE:en_GB | german | german |
> +-----------------+---------+---------+
>
> With LANGUAGE=en_GB:de_DE, I would have expected English output
> rather than German.
>
> Is this a misunderstanding on my part about how LANGUAGE works,
> or should I report this as a bug in glibc/locales/gettext?
I don't know much about i18n, so please don't take my words too
seriously, but I will try to explain what is happening. Try using this
command to see what happens:
LANGUAGE=en_GB:de_DE LANG=en_GB strace -e file cat -h
(I used en_US, since I don't generate en_GB.)
open("/usr/share/locale/en_US/LC_MESSAGES/libc.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/share/locale/en/LC_MESSAGES/libc.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/share/locale/de_DE/LC_MESSAGES/libc.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/share/locale/de/LC_MESSAGES/libc.mo", O_RDONLY) = 3
The problem is that most packages don't have "English" translations:
drow@nevyn:/big/fsf/local/glibc/intl% ls /usr/share/locale/de/LC_MESSAGES | wc
190 190 2405
drow@nevyn:/big/fsf/local/glibc/intl% ls /usr/share/locale/en/LC_MESSAGES | wc
3 3 29
Normally, you get the final fallback, which is C. Like so:
drow@nevyn:~% LANG=en_US LANGUAGE=en_US:de_DE:en_US cat -h
cat: Ungültige Option -- h
,,cat --help" gibt weitere Informationen.
drow@nevyn:~% LANG=en_US LANGUAGE=en_US:C:de_DE:en_US cat -h
cat: invalid option -- h
Try `cat --help' for more information.
Did that help?
--
Daniel Jacobowitz
CodeSourcery, LLC
Reply to: