Changing languages on-the-fly...?

Changing languages on-the-fly...?

Post by Stephen Bo » Sat, 24 Jul 2004 10:21:13

I'm building an MDI application and I want to allow the users to switch
displayed languages (for menus, buttons, error messages, etc.) on-the-fly,
i.e. without having to exit from the application and restart it. In design
mode, I generate multiple resource files by specifying the text for all
controls in all the different languages I want, simply by setting
Localizable to True and changing the Language, one form at a time (I'm sure
there's a better way, but that's not my question).

At run-time, an specific menu allows the user to pick the display language
they want: I change the CultureInfo in the current Thread and, voil, all
my labels and buttons and GUI texts are changed immediately for all new
forms that are opened... but the MDI form from which the user selected the
menu (and the language) has remained open and I can't find a way to get it

How do I force the MDI to refresh/repaint using the new language, i.e. the
new resource file as defined by the Thread and, I assume, the
ResourceManager? Or will I have to manually read the resource and change the
text of all menus of the MDI based on the content of the file?

Thanks for all the help,

P.S.: watch the email before replying...

Changing languages on-the-fly...?

Post by Stephen Bo » Sun, 25 Jul 2004 07:49:12

Actually, you've inspired me for an even simpler solution. Since I'm talking
about the MDI form itself, there are few controls beside menus and a status
bar. I'm just removing all of them ( and
me.controls.clear()) and then calling me.initializeComponent(). That's about
it; I've got to make sure there are no children form open at the time
(because I don't want to have to do it for all of them) and reset the size,
position and windowState. Done.