PDA

View Full Version : Localizing built-in GUI



ahmdsd_ostora
10th August 2010, 09:53
I can localize texts that I can edit in the source code or in the UI designer, but some texts are filled by Qt framework, example, the ButtonGroup class has some default buttons, ok|cancel, yes|no, save|cancel, etc. How can I localize these texts on the buttons.

And more general questions, how can I tell Qt to localize its default texts to my language, as I can do with my tr() texts?

ahmdsd_ostora
11th August 2010, 10:57
hey !!

qt ui isn't localized?
how can i get the buttonGroup with arabic ??

it's a basic question I think !!

lightning2911
11th August 2010, 11:06
from tests that i have done if have found that they are localized. if i changed my system language (on windows) i did get russian dialog boxes for example. dont know how to override these translations though.

Lykurg
11th August 2010, 11:43
it's a basic question I think !!So why don't you give the answer yourself ;)

I never have need it, but I remember you have to deploy the translator files of Qt with your application. Have a look at Internationalization with Qt in the documentation.

ahmdsd_ostora
11th August 2010, 13:27
So why don't you give the answer yourself ;)

I never have need it, but I remember you have to deploy the translator files of Qt with your application. Have a look at Internationalization with Qt in the documentation.

Yes. it's a basic question, because I have worked on many platforms and frameworks and this was so simple job. But in Qt I don't know how to do this here.

Lykurg
11th August 2010, 14:43
But in Qt I don't know how to do this here.
Well, if you wont read the proposed sites in the documentation:
1. copy the qt_XX.qm to your release folder
2. Add in your main.cpp something like:
QApplication a(argc, argv);
QTranslator qtTranslator;
qtTranslator.load("qt_" + QLocale::system().name(),
QLibraryInfo::location(QLibraryInfo::TranslationsP ath));
a.installTranslator(&qtTranslator);
and it will work.

ahmdsd_ostora
11th August 2010, 15:54
Thank you it works.

I want to add a tip considering this issue:
Qt translator file should be loaded by another QTranslator object than the one you used to load your own translation file.

So, you will need two QTranslator objects with the two .qm files. And these two translators should be installed on tou application object.

Lykurg
11th August 2010, 16:06
I want to add a tip considering this issue:
Qt translator file should be loaded by another QTranslator object than the one you used to load your own translation file.

So, you will need two QTranslator objects with the two .qm files. And these two translators should be installed on tou application object.Yes of course, I just was shorten the code. Two translations is how they do it in the mentioned "Internationalization with Qt".