On 4 Oct, 2009, at 19:53, Barry Scott wrote:
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?
That depends on the version of OSX you're running.
On my system (10.6.1):
>>> locale.setlocale(locale.LC_ALL, '')
'en_US.UTF-8'
>>> locale.getlocale()
('en_US', 'UTF8')
>>>
This should also work in 10.5, but probably not 10.4.
The value of "__CF_USER_TEXT_ENCODING" is undocumented, you shouldn't
rely on that value. The only reliable way to get at the locale
settings from System Preferences is by using mac-specific API's from
CoreFoundation or Cocoa.
BTW. The usual approach for localizing an OSX app is to have language-
specific subbundles in the application bundle, for examples,
"Resources/English.lproj" for the english localization and "Resources/
nl.lproj" for the Dutch localization. Apple's APIs have specific
support for that structure, although I don't know if wxWidgets exposes
that.
Ronald
Barry
_______________________________________________
Pythonmac-SIG maillist - Pythonmac-SIG@python.org
http://mail.python.org/mailman/listinfo/pythonmac-sig
_______________________________________________
Pythonmac-SIG maillist - Pythonmac-SIG@python.org
http://mail.python.org/mailman/listinfo/pythonmac-sig