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:
{
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();
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();
To copy to clipboard, switch view to plain text mode
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?
Bookmarks