When using the wx.Locale and wx.GetTranslation, is there a way to update all GUI widgets with a newly-set locale? In my program I allow the user to change the language from a preferences dialog, but haven't figured out how to apply the locale to the current runtime - the new locale is used when the application is loaded next.
When using the wx.Locale and wx.GetTranslation, is there a
way to update
all GUI widgets with a newly-set locale? In my program I
allow the user
to change the language from a preferences dialog, but haven't figured
out how to apply the locale to the current runtime - the new
locale is
used when the application is loaded next.
Any suggestions?
I wrote a "ChangeLanguage()" method, which I call when the user selects a
different language in my app.
That method knows what dialogs are open in my app at any given time (usually
between 4 and 6 because of the needs of my program), changes the locale, and
calls a "ChangeLanguage()" method in each of the open dialogs. Each
dialog's ChangeLanguage() method just updates all the visible labels, which
because the locale has been changed, get changed to the correct language.
It was surprisingly straight forward, once I figured out a good way to track
whether certain of my dialogs were open when I needed to know. The only
thing it can't do is update the language of dialogs that come from the OS,
such as the File Dialog.
If it will help, you can see my source code at Transana download | SourceForge.net. Start in the MenuWindow.py
module, looking at the OnOptionsLanguage() method, which implements the menu
calls for all of the supported languages. Then ControlObjectClass.py's
ChangeLanguages() method calls ChangeLanguages() in whatever modules it
needs to, including MenuWindow, so look for the ChangeLanguages() method to
see how I update my menu items.
cool, I'll give it a look over and see what I can deduce from it.
thanks
···
On 05/07/2011 21:04, David wrote:
Hello all,
When using the wx.Locale and wx.GetTranslation, is there a
way to update
all GUI widgets with a newly-set locale? In my program I
allow the user
to change the language from a preferences dialog, but haven't figured
out how to apply the locale to the current runtime - the new
locale is
used when the application is loaded next.
Any suggestions?
I wrote a "ChangeLanguage()" method, which I call when the user selects a
different language in my app.
That method knows what dialogs are open in my app at any given time (usually
between 4 and 6 because of the needs of my program), changes the locale, and
calls a "ChangeLanguage()" method in each of the open dialogs. Each
dialog's ChangeLanguage() method just updates all the visible labels, which
because the locale has been changed, get changed to the correct language.
It was surprisingly straight forward, once I figured out a good way to track
whether certain of my dialogs were open when I needed to know. The only
thing it can't do is update the language of dialogs that come from the OS,
such as the File Dialog.
If it will help, you can see my source code at Transana download | SourceForge.net. Start in the MenuWindow.py
module, looking at the OnOptionsLanguage() method, which implements the menu
calls for all of the supported languages. Then ControlObjectClass.py's
ChangeLanguages() method calls ChangeLanguages() in whatever modules it
needs to, including MenuWindow, so look for the ChangeLanguages() method to
see how I update my menu items.