Hello,
I have a problem with changing of the current locale of my MDI
application at runtime. Switching my own translation isn't a problem,
but switching it for the standard gui elements does not work as
expected. E.g. switching the menu of my MDI window does not change the
translation of the 'window' menu.
I did provide the wxstd.mo files in my setup and actually after
providing them my 'window' menu always shows up in german translation.
Before installing the wxstd files I always got englich menu entries.
Below is the outline of my code. Is there anything wrong with it or
did I miss an important part? Is it possible at all to switch the
language at runtime for all ui elements?
class I18NApp(wx.App):
def OnInit(self):
...
self.locale = None
self.UpdateLanguage(wx.LANGUAGE_DEFAULT, False)
...
def UpdateLanguage(self, lang, update_ui):
if self.locale:
assert sys.getrefcount(self.locale) <= 2
del self.locale
self.locale = wx.Locale(lang)
if self.locale.IsOk():
APPDIR = self.GetAppDir()
LOCALEDIR = os.path.join(APPDIR, "locale")
LOCALEDOMAIN = self.GetGenericAppName()
wx.Locale.AddCatalogLookupPathPrefix(LOCALEDIR)
self.locale.AddCatalog(LOCALEDOMAIN)
self.locale.AddCatalog('wxstd')
if update_ui and self.frame:
self.frame.UpdateUI() # rebuild menubar etc.
else:
self.locale = None
wx.GetApp().UpdateLanguage(lang, True) is called on language change
request.
Any help is really appreciated.
Best,
Johannes