[Pythonmac-SIG] Setting up locale on Mac - how should this been done?

Barry Scott barry at barrys-emacs.org
Sun Oct 4 19:53:42 CEST 2009


I have a wxPython application  (PySVN WorkBench) that is a bundle.

When the app runs the environment does not contain any of the usual
variables that would be used to into the locale, LANG, LC_ALL etc.

What I can see in the environment is __CF_USER_TEXT_ENCODING.
I have failed to find details of how to interpret the value of this  
environment
variable which leads me to believe I should not do processing it  
directly.

The trick that works on windows does not work. Windows init:

	locale.setlocale( locale.LC_ALL, '' )

$ python2.6
Python 2.6.2 (r262:71600, Apr 16 2009, 09:17:39)
[GCC 4.0.1 (Apple Computer, Inc. build 5250)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
 >>> import locale
 >>> locale.getdefaultlocale()
(None, 'mac-roman')
 >>> locale.getlocale()
(None, None)
 >>> locale.setlocale( locale.LC_ALL, '' )
'C'
 >>> locale.getlocale()
(None, None)
 >>>

The default locale of (None, 'mac-roman') is useless as it
does not say which locale the user has selected in
System Preferences, Language and Text.

How should I init the locale to the users choice?

Barry



More information about the Pythonmac-SIG mailing list