0
我想在Qt應用程序中加載本地化的字符串。爲此,我遵循幾個步驟。糾正我,如果我錯了。Qt本地化:加載可本地化的字符串
注:它工作正常QString
而不是const char*
更新與 翻譯語言親文件
使用Qt 語言學家生成
.ts
&編輯。使用 lupdate和lrelease生成.qm
文件。從特定的 位置加載.qm文件。
這裏是我的const char*
的樣子:
const char* sayHello = QT_TRANSLATE_NOOP("FriendlyConversation","hello");
LocalizationWithQT::LocalizationWithQT(QWidget *parent)
: QMainWindow(parent)
{
//ui.setupUi(this);
QString str = tr("say hello");
QPushButton *pushbutton = new QPushButton(tr(sayHello));
setCentralWidget(pushbutton)
}
這裏就是我正在加載.qm文件都:
QApplication a(argc, argv);
QTranslator translator;
bool val = translator.load("c:\\Data\\test\\hellotr_la");
a.installTranslator(&translator);
LocalizationWithQT w;
w.showMaximized();
return a.exec();
的問題是,如果我提供任何替代拉丁串以「sayhello」,它根本不加載。
我不知道錯誤在哪裏。