PDA

View Full Version : About locale issue



xiajingan
25th February 2009, 14:02
I study QT with a book.
I write the codes according to the samples.
But I meet an issue with the "locale"
I use the translator with "qt_zh_CN.qm", but the dialog doesn't show the right characters.

Here is the cods:


QApplication app(argc, argv);
QTextCodec::setCodecForTr(QTextCodec::codecForName ("gb18030"));

QTranslator translator;
{
QStringList environment = QProcess::systemEnvironment();
QString str;
bool bFinded = false;

bFinded = translator.load("qt_zh_CN", "/usr/share/qt4/translations/");
if(bFinded)
{
qApp->installTranslator(&translator);
qDebug() << QObject::tr("Load the chinese translations!");
}
else
qDebug() << QObject::tr("没有支持中文的QT国际化翻译文件");
}
MyDialog dlg;
return dlg.exec();

and here is my locle echo

LANG=en_US.UTF-8
LC_CTYPE=zh_CN.UTF-8
LC_NUMERIC="en_US.UTF-8"
LC_TIME="en_US.UTF-8"
LC_COLLATE="en_US.UTF-8"
LC_MONETARY="en_US.UTF-8"
LC_MESSAGES="en_US.UTF-8"
LC_PAPER="en_US.UTF-8"
LC_NAME="en_US.UTF-8"
LC_ADDRESS="en_US.UTF-8"
LC_TELEPHONE="en_US.UTF-8"
LC_MEASUREMENT="en_US.UTF-8"
LC_IDENTIFICATION="en_US.UTF-8"
LC_ALL=


Anyone can help me?

wysota
25th February 2009, 20:16
What's wrong exactly?

xiajingan
26th February 2009, 14:18
What's wrong exactly?
the dialog can not show chinese character exactly by the above codes.

wysota
26th February 2009, 21:18
What does load() return?