bug-gnu-utils
[Top][All Lists]
Advanced

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

Re: Changing language multiple times in one process


From: Bruno Haible
Subject: Re: Changing language multiple times in one process
Date: Mon, 31 Oct 2005 11:33:50 +0100
User-agent: KMail/1.5

Hello,

Francis Irving wrote:
> I'm using gettext with multiple languages in one process, altering the
> LANG environment variable and calling it.

When doing so, you also need to remove the LC_ALL, LC_MESSAGES, LC_CTYPE
environment variables, because they override LANG. Or you alter the value
of LC_ALL, not of LANG.

> I've discovered a problem with the tsearch code in intl/dcigettext.c.
> It caches the results of queries, but does not check against the
> language. This means that sometimes you get the results from the wrong
> language back again.

You need to call  textdomain (textdomain (NULL))  in order to make gettext
aware of the change. Just setting an environment variable doesn't tell
gettext() to invalidate its cache.

> This problem manifests itself on FreeBSD, which has tsearch, and not
> on Linux, which doesn't by default.

Linux/glibc has tsearch() as well, but here the code uses the up-to-date
locale name.

> Should this caching code be fixed to work, or be disabled/removed?

The caching code is essential for speed. Use
    textdomain (textdomain (NULL))
in your program.

Bruno





reply via email to

[Prev in Thread] Current Thread [Next in Thread]