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”,它根本不加载。
我不知道错误在哪里。