LANG, locale, unicode, setup.py and Debian packaging
"Martin v. Löwis"
martin at v.loewis.de
Mon Jan 14 16:48:28 EST 2008
> Given that getlocale() is not to be used, what's the best way to get the
> locale later in the app?
You get the full locale name with locale.setlocale(category) (i.e.
without the second argument)
> I need that two-letter code that's hidden in a
> typical locale like en_ZA.utf8 -- I want that 'en' part.
Not sure why you want that. Notice that the locale name is fairly system
specific, in particular on non-POSIX systems. It may be
"English_SouthAfrica" on some systems.
If you are certain that *your* locale names will only ever be of the
form <languagecode>[_<countrycode>][.<encoding][@modifier] (or whatever
the syntax is), take anything before the underscore as the language code.
However, you should reevaluate why you need that.
> BTW - things are hanging-together much better now, thanks to your info. I have
> it running in locale 'C' as well as my other test locales. What a relief!
Great!
Martin
More information about the Python-list
mailing list