rsilva
20th April 2011, 04:39
I'm trying to translate my app and the only thing that i can translate is the Qt texts with loading "qt_pt.qm" but when I try to load my "app.qm" the text doesn't get translated.
I've tried everything i know, but it isn't working.
So, made another project and tried to translate words in Console App, same problem.
Can you help me ?
This is the .ts file:
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE TS>
<TS version="2.0" language="pt" sourcelanguage="en">
<context>
<name></name>
<message>
<source>old</source>
<translation>velho</translation>
</message>
<message>
<source>novo</source>
<translation>new</translation>
</message>
</context>
</TS>
This is my code:
#include <QtCore/QCoreApplication>
#include <QTranslator>
#include <QDebug>
int main(int argc, char *argv[])
{
QCoreApplication a(argc, argv);
QTranslator* tr = new QTranslator;
qDebug() << "loaded: " << tr->load("translator.qm", "C:\\C++\\Qt Projects\\Translator\\Translator");
qDebug() << "------------------";
qDebug() << QObject::tr("old");
qDebug() << QObject::tr("velho");
qDebug() << QObject::tr("new");
qDebug() << QObject::tr("novo");
qDebug() << "------------------";
a.installTranslator(tr);
qDebug() << "------------------";
qDebug() << QObject::tr("old");
qDebug() << QObject::tr("velho");
qDebug() << QObject::tr("new");
qDebug() << QObject::tr("novo");
qDebug() << "------------------";
return a.exec();
}
and I get this output:
loaded: true
------------------
"old"
"velho"
"new"
"novo"
------------------
------------------
"old"
"velho"
"new"
"novo"
------------------
It doesn't translate my text, link in my App, what I can do ?
What is wrong in the code ?
What I need to do to fix it ?
(Using Qt 4.7.2)
I've tried everything i know, but it isn't working.
So, made another project and tried to translate words in Console App, same problem.
Can you help me ?
This is the .ts file:
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE TS>
<TS version="2.0" language="pt" sourcelanguage="en">
<context>
<name></name>
<message>
<source>old</source>
<translation>velho</translation>
</message>
<message>
<source>novo</source>
<translation>new</translation>
</message>
</context>
</TS>
This is my code:
#include <QtCore/QCoreApplication>
#include <QTranslator>
#include <QDebug>
int main(int argc, char *argv[])
{
QCoreApplication a(argc, argv);
QTranslator* tr = new QTranslator;
qDebug() << "loaded: " << tr->load("translator.qm", "C:\\C++\\Qt Projects\\Translator\\Translator");
qDebug() << "------------------";
qDebug() << QObject::tr("old");
qDebug() << QObject::tr("velho");
qDebug() << QObject::tr("new");
qDebug() << QObject::tr("novo");
qDebug() << "------------------";
a.installTranslator(tr);
qDebug() << "------------------";
qDebug() << QObject::tr("old");
qDebug() << QObject::tr("velho");
qDebug() << QObject::tr("new");
qDebug() << QObject::tr("novo");
qDebug() << "------------------";
return a.exec();
}
and I get this output:
loaded: true
------------------
"old"
"velho"
"new"
"novo"
------------------
------------------
"old"
"velho"
"new"
"novo"
------------------
It doesn't translate my text, link in my App, what I can do ?
What is wrong in the code ?
What I need to do to fix it ?
(Using Qt 4.7.2)