Hi all !
I'm trying to translate my application. All is ok with the files which come from .ui . But with aller QMessageBox (just an exemple), I have a problem :
here's the main.cpp :
int main(int argc, char **argv)
{
...
else if(argc == 1)
{
// the translation is loaded in the contructor of ui_murefImpl (see below this code)
ui_murefImpl window(0, &app);
window.show();
// I'm doing this because I saw this in the ui.h file (and tr() && QApplication::translate() are too ineffective
hello.resize(100, 30);
hello.show();
return app.exec();
}
....
}
int main(int argc, char **argv)
{
...
else if(argc == 1)
{
// the translation is loaded in the contructor of ui_murefImpl (see below this code)
ui_murefImpl window(0, &app);
window.show();
// I'm doing this because I saw this in the ui.h file (and tr() && QApplication::translate() are too ineffective
QPushButton hello(QApplication::translate("MainWindow", "Music", 0, QApplication::UnicodeUTF8));
hello.resize(100, 30);
hello.show();
return app.exec();
}
....
}
To copy to clipboard, switch view to plain text mode
{
configure(myApp);
}
{
// all that is correct because the ui is translated !
translator.
load(QString("MuRef_") + locale
);
myApp->installTranslator(&translator);
...
ui.setupUi(this);
...
}
ui_murefImpl::ui_murefImpl(QWidget *parent, QApplication *myApp) : QMainWindow(parent)
{
configure(myApp);
}
void ui_murefImpl::configure(QApplication *myApp)
{
// all that is correct because the ui is translated !
QTranslator translator;
QString locale = QLocale::system().name();
translator.load(QString("MuRef_") + locale);
myApp->installTranslator(&translator);
...
ui.setupUi(this);
...
}
To copy to clipboard, switch view to plain text mode
The problem is that (of course) the text in the button is not translated (but I do correctly all the other manipulations : lupdate, qtlinguist (made changements, saved), lrelease and launching the program).
Thanks for reading !
P.S.: I'm doing tests on a "hello button" because I don't want to recompile each time the whole app. But if it work on a QPushButton, it will still work with a QMessageBox...
Bookmarks