我想在Qt应用程序中加载本地化字符串。为此,我将遵循一些步骤。如果我错了就纠正我。
注:适用于
QString
但不是为了
const char*
-
翻译语言
-
生成
.ts
语言学家。生成
.qm
文件使用
更新和删除。
-
从特定的
地点。
以下是我的
看:
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)
}
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”提供任何替代拉丁字符串,它根本不加载。
我不知道错在哪里。