Re: get list of available locales

On Mon, 14 Sep 2009, Matthew Talbert wrote:

In our GTK/GNOME application, our users would like the ability to use
the program in a locale of their choice (out of the ~10 translations
we have available) rather than detecting automatically which to use.
(well, most users will be fine with automatic, but we have some
exceptions). So we've implemented this by setting LC_ALL before we
initialize GTK/GNOME. The unfortunate part of this is that there seems
to be a lot of variations in how this variable actually works on
different distros. For example, "fr_FR" is fine for Fedora, but Ubuntu
requires it to be fr_FR.UTF-8. This is true for most locales, but
there are some on Ubuntu that do not have the ending UTF-8 as well.

My question is whether there is a way, either in the gtk stack or
elsewhere, to get a list of available locales at runtime so that we
can match this up as best as possible.

We've implemented this sort of thing -- a language selector that
lets you choose between 13 supported languages -- in gretl,
another GTK app.  I'm not sure we're doing it in the best way, but
it seems to work OK.  It's definitely fiddly work. To see what we
did, look at gretl_intl.c, lines 398 to 680.

Allin Cottrell

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