Ste*_*ith 4 c++ qt translation
我正在努力翻译我们的Qt gui.
我有以下代码:
// header file
static const QString Foo;
// cpp file
const QString FooConstants::Foo = "foo";
// another cpp file
editMenu->addAction(tr(FooConstants::Foo));
Run Code Online (Sandbox Code Playgroud)
这似乎不起作用.
也就是说,.ts文件中没有上述常量的条目.
如果我这样做,那么它的工作原理:
// another cpp file
editMenu->addAction(tr("foo"));
Run Code Online (Sandbox Code Playgroud)
但是,这个常量在很多地方使用,我不想手动更新每个字符串文字.(如果将来改变的话)
有人可以帮忙吗?
Tho*_*mas 10
在QT_TR_NOOP
宏中包装您的文字:
// cpp file
const QString FooConstants::Foo = QT_TR_NOOP("foo");
Run Code Online (Sandbox Code Playgroud)