PDA

View Full Version : setText translation



weixj2003ld
20th April 2009, 11:00
1.I create a QTreeWidgetItem


QTreeWidgetItem *cities = new QTreeWidgetItem(this);
cities->setText(0, tr("Cities"));

and use lupdate and linguist to translate "Cities" into other languages.but it can not ,and "Cities" still exist.Why?
By the way,I create a Menu,

fileMenu = menuBar()->addMenu(tr("&File"));
and the program can do translation.

jpn
20th April 2009, 11:12
What steps did you take? Did you actually install a translator?

weixj2003ld
20th April 2009, 13:15
What I have done as follows:
1. add TRANSLATIONS = hellotr_la.ts to the xxx.pro
2.lupdate –verbose xxxx.pro
3.Linguist hellotr_la.ts translate what need to,and release the file
4.compile and run my program.

jpn
20th April 2009, 14:25
Yes, but in your program. Do you install a translator as explained in the Internationalization with Qt document?

weixj2003ld
20th April 2009, 15:59
I think I have done,the following is my code in main function


main()
{
...
QTranslator appTranslator;
appTranslator.load("coin3dtr_la");
QApplication::installTranslator(&appTranslator);
...
}

By the way,I create a Menu,

fileMenu = menuBar()->addMenu(tr("&File"));
and the program can does translation.