Problem when translating my app
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 :
Code:
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();
}
....
}
Code:
{
configure(myApp);
}
{
// all that is correct because the ui is translated !
translator.
load(QString("MuRef_") + locale
);
myApp->installTranslator(&translator);
...
ui.setupUi(this);
...
}
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...
Re: Problem when translating my app
Quote:
Originally Posted by agent007se
tr() && QApplication::translate() are too ineffective
What makes you think so?
Quote:
Originally Posted by agent007se
but I do correctly all the other manipulations : lupdate, qtlinguist (made changements, saved), lrelease and launching the program).
Can you see that button text when you open .ts file in Qt Linguist?
Re: Problem when translating my app
Quote:
Originally Posted by jacek
What makes you think so?
For the best reason : I tested before asking ;) !
Quote:
Originally Posted by jacek
Can you see that button text when you open .ts file in Qt Linguist?
For sure I can (if not, how could I translate it since I use Qt Linguist ?).
Note : it appears in the context "MainWindow" and the source text panel is "Music" and I 'translated' it to "No music".
Edit :
this is a MINIMAL .pro file (I just want to translate the button, that will be a nice beginning :p !)
Code:
TEMPLATE = app
TARGET +=
DEPENDPATH += .
INCLUDEPATH += .
# Input
HEADERS +=
FORMS += muref.ui
SOURCES += main.cpp
TRANSLATIONS += MuRef_fr.ts
when I try with tr() I got this error :
Quote:
main.cpp:23: error: `tr' undeclared (first use this function)
main.cpp:23: error: (Each undeclared identifier is reported only once for each function it appears in.)
:: === Build finished: 2 errors, 0 warnings ===
Re: Problem when translating my app
Quote:
Originally Posted by agent007se
For the best reason : I tested before asking
And why it isn't effective?
Quote:
Originally Posted by agent007se
it appears in the context "MainWindow" and the source text panel is "Music" and I 'translated' it to "No music".
Are you sure that your application loads the newest .qm file?
Quote:
when I try with tr() I got this error :
tr() is a static method of QObject class.
Re: Problem when translating my app
Quote:
Originally Posted by jacek
And why it isn't effective?
Because it doesn't work in my case ! (and of course I have a problem because that's very useful functions... there's no doubt about this)
Quote:
Originally Posted by jacek
Are you sure that your application loads the newest .qm file?
How can I be ? There's only one .qm file and thus if it load the ui translation, it must load the others... (I don't really know about this).
Quote:
Originally Posted by jacek
tr() is a static method of QObject class.
Correct ! I understood that while I was reading the chapter 15 (internationalisation) of the Qt 3 online book ;) !
edit : of course, I deleted the .ts and the .qm and made new ones to be sure that is a "proper" translation but that didn't change anything to my problem ! Do you need more source code or screenshots ?
Re: Problem when translating my app
Quote:
Originally Posted by agent007se
Because it doesn't work in my case
Ah, OK. "too ineffective" == "doesn't work in my case"
Quote:
Originally Posted by agent007se
There's only one .qm file and thus if it load the ui translation, it must load the others...
Then delete that file, start your application and check if no translation was loaded, create a new .qm file and check your application again.
Re: Problem when translating my app
Quote:
Originally Posted by jacek
Ah, OK. "too ineffective" == "doesn't work in my case"
Yes I'm sorry English isn't my native language thus sometimes I may use some incorrect way of putting things togheter but I try to be at least readable ;).
Quote:
Originally Posted by jacek
Then delete that file, start your application and check if no translation was loaded, create a new .qm file and check your application again.
Ok I'll try that tomorrow ! (it's midnight here :p (Beligum))
Already thanks for trying to help me ;) that's not the first time :p !
Re: Problem when translating my app
I've just took another look on your configure() method. You create the translator on the stack, so it gets destroyed when configure() returns.
It should be:
Code:
{
...
translator->load
(QString("MuRef_") + locale
);
myApp->installTranslator( translator );
...
}
Re: Problem when translating my app
Quote:
Originally Posted by jacek
I've just took another look on your configure() method. You create the translator on the stack, so it gets destroyed when configure() returns.
It should be:
Code:
{
...
translator->load
(QString("MuRef_") + locale
);
myApp->installTranslator( translator );
...
}
Yes yes yes !!! That works :D thanks a lot !