Dynamic Language Switching
Hi. I've got a problem. I'd like to do dynamic language switching in my application, but there's a problem. In my book it is explained how to do it designing forms manually, not by designer. I created forms using designer. The problem is, that function createLanguageMenu() is very different than usual. And (I think) I can't make it by subclassing QMainWindow. Do you know what I mean? Have you got any ideas how to do it ?Regards
Re: Dynamic Language Switching
Quote:
Originally Posted by
Salazaar
Hi. I've got a problem. I'd like to do dynamic language switching in my application, but there's a problem. In my book it is explained how to do it designing forms manually, not by designer. I created forms using designer. The problem is, that function createLanguageMenu() is very different than usual. And (I think) I can't make it by subclassing QMainWindow. Do you know what I mean? Have you got any ideas how to do it ?Regards
Chapter 17 from http://trolltech.com/developer/documentation/books/2 german version ...
the code is not on cd....
http://doc.trolltech.com/4.3/qtranslator.html detroy truncate the actual language and load a new ... translator file... on qmainwindow .
http://doc.trolltech.com/4.3/qcoreap...moveTranslator
http://doc.trolltech.com/4.3/qcoreap...tallTranslator
Re: Dynamic Language Switching
I'm not sure if I understood the problem but hopefully this wiki article helps: Dynamic translation.
Re: Dynamic Language Switching
Thanks a lot, I'll read it. Regards
Re: Dynamic Language Switching
No, that links didn't solve the problem. The problem is, that createLanguageMenu is different that, let's say, createFileMenu, and I am designing forms in designer, so I can't change createLanguageMenu without accessing ui_.h file code. And I'd like to know, how to do dynamic language switching when you were designing forms by designer, not manually. Regards
Re: Dynamic Language Switching
It's done in code for the reason that usually you don't want a static hard coded language menu (done in designer) but rather a dynamic menu loaded according to detected language files. This way new language files can be added later without recompiling the application.
Re: Dynamic Language Switching
Quote:
Originally Posted by
jpn
It's done in code for the reason that usually you don't want a static hard coded language menu (done in designer) but rather a dynamic menu loaded according to detected language files. This way new language files can be added later without recompiling the application.
I don't understand I'd like dynamic language switching, without necessity to rebuild application or run it again
Re: Dynamic Language Switching
Quote:
Originally Posted by
Salazaar
I don't understand I'd like dynamic language switching, without necessity to rebuild application or run it again
You can do this with actions created in designer. You still might want to instantiate a QActionGroup or QSignalMapper in code instead of creating separate slots for each action. Then just switch the language according to the action (it's up to you whether you use text, objectName, data, or something else).
However, I was talking about flexibility with adding new translations. If you create language actions in designer, you will have to add a new action and recompile the application if you later decide to add a new translation to your application.