[Pythonmac-SIG] Get the locale on OSX

Ronald Oussoren ronaldoussoren at mac.com
Wed Dec 5 14:32:50 CET 2007


 
On Wednesday, December 05, 2007, at 02:15PM, "Chris Van Bael" <chris.van.bael at gmail.com> wrote:
>On Dec 3, 2007 9:26 AM, Chris Van Bael <chris.van.bael at gmail.com> wrote:
>> On Dec 3, 2007 8:40 AM, Nicholas Riley <njriley at uiuc.edu> wrote:
>> > On Sun, Dec 02, 2007 at 03:18:14PM +0100, Chris Van Bael wrote:
>> > > I'm trying to port an python application which runs fine on Windows
>> > > and Linux to OSX.
>> > > However, it seems "lang = locale.getdefaultlocale()[0]" doesn't work.
>> > > I've searched quite some bit on the Internet and on this mailinglist,
>> > > and apparently it is a problem, but I haven't found any solution for
>> > > it.
>> >
>> > What are you trying to do with the locale information?  Leopard's
>> > Terminal does have an option to 'set LANG environment variable on
>> > startup', which when checked does cause locale.getdefaultlocale() to
>> > work, but this is of no help in general.
>>
>> Well,
>>
>> it's for some educational games: Childsplay and Schoolsplay
>> (www.schoolsplay.org)
>> Based on the locale information, we choose different languages to use
>> in the strings and also different alphabet sound files.
>> We do have an commandline option to set the language, so "schoolsplay
>> --language=nl_BE" would give Dutch strings and sounds.
>> However the nicest option would be that it searched in the settings of the OS.
>> The program would be packed btw with py2app, so and end user wouldn't
>> have to use the Terminal (and install all Python dependencies).
>
>Anybody any ideas on how to solve my problem?

You could use PyObjC to find the right locale, and wxWidgets also seems to have functions for getting the locale (wxLocale class). 

BTW. It would have helped if you would have stated up front that schoolsplay is using wxWidgets as the GUI layer, that way there is a larger chance that the right people respond.

Ronald
>_______________________________________________
>Pythonmac-SIG maillist  -  Pythonmac-SIG at python.org
>http://mail.python.org/mailman/listinfo/pythonmac-sig
>
>


More information about the Pythonmac-SIG mailing list