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

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

Re: Where can I find gettext_l


From: Bruno Haible
Subject: Re: Where can I find gettext_l
Date: Wed, 14 Jun 2006 19:41:53 +0200
User-agent: KMail/1.9.1

Hello,

Arnold Daniels wrote:
> I'm trying to create an alternative php extension for gettext
> (http://www.php.net/gettext).
> Instead of using environment settings, the extension should simply store
> the locale setting in a variable and pass it to gettext. I found a post
> of you with a function to test gettext_l, witch exactly has the
> functionality I need to create the extension. Unfortunately gettext_l
> isn't part of gclib 2.4.

I believe with glibc you can write the gettext_l function in C++ like this:


  #define _GNU_SOURCE 1
  #include <locale.h>
  const char * gettext_l (const char *msgid, locale_t loc)
  {
    locale_t oldlocale = uselocale (NULL);
    const char *result:
    try
      {
        uselocale (loc);
        result = gettext (msgid);
      }
    catch (...)
      {
        uselocale (oldlocale);
        throw;
      }
    return result;
  }


This should work with glibc >= 2.4. (Older versions had a bug in the
gettext-internal cache.)

Bruno




reply via email to

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