[Pythonmac-SIG] Locale on MacOS 9

Francois Granger fgranger@altern.org
Thu, 24 Jan 2002 10:50:05 +0100


on 23/01/02 23:55, Jack Jansen at Jack.Jansen@oratrix.nl wrote:

> If someone wants to put some effort into getting the locale
> module to work on MacOSX (and maybe even OS9: I think the APIs
> are available there too) that would be very welcome.

I wonder how difficult it is for MacOS 9 if the only aim is getting the
language and country code instead of 'none' as an answser to
locale.getdefaultlocale().

I don't know where to look in the rich MacPython lib for a way to get the
MacOS language and country ?

A stupid proposal in the mean time could be to insert the following at line
326 of lib:locale.py

        elif sys.platform == "mac":
            import os
            for variable in ['LANGUAGE', 'LANG']:
                localename = os.environ.get(variable,None)
                if localename is not None:
                    break
            if localename is not None:
                code = localename


This allow one to do in his own script:

os.environ['LANGUAGE'] = 'fr_FR'
lang, encoding = locale.getdefaultlocale()