PDA

View Full Version : how change language at runtime?



mattia
14th November 2007, 16:45
I have a translation problem in my application.
In the main i'm setting the language in this way:



QApplication app ( argc, argv );
QTranslator translator;
translator.load ( "/home/mattia/workspace/myProject/translations/trm_it" );
app.installTranslator ( &translator );
......


If i want to set as default language "en" i have to do:


translator.load ( "/home/mattia/workspace/myProject/translations/trm_en" );

and it is correctly loaded, when i'm at runtime i want to change the language and i made a dialog widget to allow the user to insert a language, for example "en", but i don't know how performe the change language at runtime.
Is it possible do it?
Thanks

DeepDiver
14th November 2007, 16:58
http://doc.trolltech.com/4.3/tools-i18n.html

wysota
14th November 2007, 17:22
In addition to that, if you want to retranslate a window which is already created (and probably visible), you need to intercept the QEvent::LanguageChange event and retranslate all texts. If you have a Designer created ui, it's enough to call retranslateUi() from the form object.

jpn
14th November 2007, 18:36
http://wiki.qtcentre.org/index.php?title=Dynamic_translation