How change window language with wx.locale

Hello.

I need change language wehn I select it, but I don’t know if i am using wx.locale correctly. When select spanish, the interfaz continue in english. Here this source:

import wx

class Frame(wx.Frame):
def init(self, parent, title):
super().init(parent, title= title)
self.Show()
self.panel = wx.Panel(self)
self.message = wx.StaticText(self.panel, -1, wx.GetTranslation(‘hello World’))
self.selectMenu = wx.ComboBox(self.panel, -1, choices= [‘Spanish’, ‘English’], style= wx.CB_READONLY)
self.selectMenu.SetFocus()
self.Bind(wx.EVT_COMBOBOX, self.changeLanguage, self.selectMenu)
self.locale = wx.Locale(wx.LANGUAGE_ENGLISH)
self.locale.AddCatalogLookupPathPrefix(‘locale’)
self.locale.AddCatalog(‘ventana’)
self.locale.AddCatalog(‘wxstd’)

self.sizer = wx.BoxSizer(wx.VERTICAL)
self.sizer.Add(self.message)
self.sizer.Add(self.selectMenu)
self.panel.SetSizer(self.sizer)

def changeLanguage(self, event):
	if self.selectMenu.GetValue() == 'Spanish':
		self.locale = wx.Locale(wx.LANGUAGE_SPANISH)
		self.Refresh()
	else:
		self.locale = wx.Locale(wx.LANGUAGE_ENGLISH)
		self.Refresh()

app = wx.App()
Frame(None, ‘Translator’)
app.MainLoop()

In the documentation for wx.Locale.__init__() it says:

“this wx.Locale object becomes the new current global locale for the application and so all subsequent calls to wx.GetTranslation will try to translate the messages using the message catalogs for this locale.”

Notice that it says subsequent calls, which suggests to me that simply changing the locale and calling Refresh will have no effect on translations that were already made under the previous locale.

Cody Precord’s book “wxPython Application Development Cookbook” has an example of a program (pages 219-222) which uses a config file to store the language to be used. When the program is started its Application’s OnInit() method attempts to read the config file. If the file doesn’t exist, the program uses LANGUAGE_DEFAULT. The program then allows the user to set the language to either English or Japanese and that setting is saved to the config file. However, the user then has to restart the program so that the controls are recreated using the new language setting.