Internationalization on Qt 4.8
-
13-11-2019 - |
题
I am trying to set a traslation to may app. I'm from Brazil so the app should be pt br and en-us, when coding I used english. I found this post on how to use QTranslator:
Qt Linguist - set translator for application
but when running the app on a pt-br system it shows up in english. Am I missing something? P.S. didn't find the Q Command Prompt so I used the Menu Tools -> External -> Linguist -> Update Translation (lupdate).
Also have created the .qm file, here´s a piece of my code:
QApplication a(argc, argv);
QTranslator *trans = new QTranslator();
trans->load("C:/SVN/trunk/rcs/frameworkIdentity_ptbr.qm");
a.installTranslator(trans);
FIdMain w;
解决方案
That is pretty much what I do in my own application where translation is working (snipped below).
The problem is not in the snippets you've shown. As suggested in the comments it maybe that the widgets are created before the translator
int main( int argc, char** argv )
{
QApplication app( argc, argv );
QTranslator translator;
if ( !Settings::value("monitor/languageFile").isNull() )
{
translator.load( Settings::value("monitor/languageFile").value<QString>() );
app.installTranslator(&translator);
}
MainWindow mainWindow;
mainWindow.show();
return app.exec();
}
不隶属于 StackOverflow