Hi,
On 2/4/2015 14:30, Ed Leafe wrote:
On Feb 3, 2015, at 8:47 PM, Neil Flowers <njflower...@gmail.com> wrote:
Here’s the relevant snippet from uiApp.OnInit:
def OnInit(self):
app = self.dApp
# As of wx3, locale must be set using wx.Locale; this can only
be created after the wx.App's initialization, so locale
# is moved here (also note setting locale is no longer
toolkit-agnostic, so other toolkit bindings would need to handle it internally)
if dabo.loadUserLocale:
self.locale = wx.Locale(wx.LANGUAGE_DEFAULT)
This seemed to be fine when placed in __init__ as well, so that’s another
option. I didn’t even see the locale issue manifest until I started testing on
Windows, but the above should work on any platform.
Would this cause a problem if the user has set a locale to something other than
the wx default?
Hhm, didn't think of that but yes it could. In my app I have this
method to change the language (which is mostly borrowed from the
wxPython demo module I18N):
def updateLanguage(self, lang):
"""Update language locale."""
# Make *sure* any existing locale is deleted before the new
# one is created. The old C++ object needs to be deleted
# before the new one is created, and if we just assign a new
# instance to the old Python variable, the old C++ locale will
# not be destroyed soon enough, likely causing a crash.
if self.locale:
assert sys.getrefcount(self.locale) <= 2
del self.locale
# create a locale object for this language
if lang in supportedLangs:
self.locale = wx.Locale(supportedLangs[lang])
if self.locale.IsOk():
self.locale.AddCatalog('twcb')
else:
self.locale = None
else:
self.locale = wx.Locale(wx.LANGUAGE_DEFAULT)
Just added the last two lines and tested it. If update language is
called with e.g. 'it' which I don't support the last else is used and
the UI shows up in English.
Not sure how to handle that in Dabo, how/where do we get the user
selected language from?
Werner
_______________________________________________
Post Messages to: Dabo-users@leafe.com
Subscription Maintenance: http://mail.leafe.com/mailman/listinfo/dabo-users
Searchable Archives: http://leafe.com/archives/search/dabo-users
This message: http://leafe.com/archives/byMID/54d231fb.20...@gmx.ch