Hi.
As said in the title, it seems that wx.LANGUAGE_DEFAULT doesn’t really do its job on macOS.
Here is the code I’m using to initialize the wx.Locale var :
class MyApp(wx.App):
def OnInit(self):
..........
self.InitLanguage()
..........
def InitLanguage(self):
wx.Locale.AddCatalogLookupPathPrefix("./langs")
self._locale = wx.Locale()
if self._locale.Init(wx.LANGUAGE_DEFAULT):
print("Language initialized to " + self._locale.GetCanonicalName())
else:
print("Unable to initialize language to " + self._locale.GetCanonicalName())
self._locale.AddCatalog("mypofilename")
..........
The ‘Init’ call fails, so I obtain the second print line, but without any information of the language’s canonical name.
The ‘AddCatalog’ line works fine (my specific strings are correctly translated) but the wxWidgets default ones aren’t (for example, the menus labels, …)
If I replace ‘wx.LANGUAGE_DEFAULT’ by ‘wx.LANGUAGE_FRENCH’, all works fine.
But the goal is of course to use the system language.
This code works fine on Windows and on Linux, but not on macOS.
Here are some news about this problem.
I’ve tested wx.Locale.GetSystemLanguage() but it returns wx.LANGUAGE_UNKNOWN (so we can think the problem comes from here).
I’ve also tested a similar code with C++ and it returns the correct value on my mac (witch is fr_FR).
Sorry, I’m not sure I know enough about locale switching to be able to feel confident in giving an answer. So you may want to check at trac.wxwidgets.org or on the wx-users mail list to get authoritative answers.
Some other things to check in the meantime:
Do you have any LANG or LC_* environment variables set?
Does it make any difference if you override wx.App.InitLocale to do nothing?