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

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

Re: Accessing a message catalog independently of the system locales


From: Sylvain Beucler
Subject: Re: Accessing a message catalog independently of the system locales
Date: Sun, 24 Oct 2010 18:47:26 +0200
User-agent: Mutt/1.5.20 (2009-06-14)

Hi again,

On Sun, Oct 24, 2010 at 05:37:46PM +0200, Bruno Haible wrote:
> > Well, I guess that if I want to provide a one-click way to select the
> > game language, I can embed .mo parsing in the application.
> > 
> > Or detect the missing locale and warn the user.
> > 
> > Or wait until all distros pre-install all locale definitions :)
> 
> This is more than you need. Just
>   1) test whether an en_US.UTF-8 locale is present. If not, warn the user.
>   2) Set the LC_CTYPE and LC_MESSAGES categories of the locale to en_US.UTF-8,
>      via setlocale(), and set the LANGUAGE environment variable, using 
> setenv().

Indeed, combining the different methods (this, and searching through
'locale -a' without the encoding part), 95% of GNU/Linux installs will
get a translation, the remaining 5% will get a warning, and I'll get a
headache ;)

I implemented this at:
http://git.savannah.gnu.org/cgit/freedink/dfarc.git/tree/src/DFArcFrame.cpp
(look for DFArcFrame::OnPlay)

-- 
Sylvain





reply via email to

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