views:

236

answers:

1

Hello

While developing a Qt Application, I ran into a problem in using QTranslator. After a little research, I found out that the problem was with lupdate from Qt having problem with the

using namespace;

directive. Following the instructions found in here, I discovered that I have to use special comments in my code, to help lupdate understand that the classes are inside a namespace. The special comment is something like this:

 /*
 TRANSLATOR namespace::MyClass
 */

So, I added this comments in all my sources that had QStrings being managed by tr. But, still, the applications is not being translated. The installTranslator method of QTranslator is returning true. The actual code I'm using to install the Translator is

Application app(argc,argv); //Application is a subclass of QApplication
QTextCoded::setCodecForTr(QTextCodec::codecForName("utf8"));
QTranslator translator;
translator.load(QString("..//language//") + locale);
app.installTranslator(&translator);
app.exec();

Have anyone ran into the same problem? What am I doing wrong?

EDIT--

Corrected one little mistake in the code above, but still no results.

A: 

You do install the translator but do not load any translation for it.

The documentation you link to specifies exactly:

int main(int argc, char *argv[])
{
     QApplication app(argc, argv);

     QTranslator translator;
     translator.load(QString("arrowpad_") + locale); // here load translation
     app.installTranslator(&translator);

     app.exec()
}
Marcin Gil
Ops... I forgot this step, but that is not the problem (I've tryed it before). I'm editing the question.
cake