我找不到任何有关 QT_TRANSLATE_NOOP_UTF8 宏的官方文档。 它是如何工作的以及什么是“范围”论证?是命名空间吗?如果是,如何指定嵌套命名空间?
最佳答案
我找到了它的文档(很难找到,但有文档记录):
- Global Qt Declarations | Qt Core 6.3.2
QT_TR_NOOP(sourceText)
Marks the UTF-8 encoded string literal sourceText for delayed translation in the current context (class).
The macro tells lupdate to collect the string, and expands to sourceText itself.
Example:
FriendlyConversation::greeting(int type) { static const char *greeting_strings[] = { QT_TR_NOOP("Hello"), QT_TR_NOOP("Goodbye") }; return tr(greeting_strings[type]); }
The macro QT_TR_NOOP_UTF8() is identical and obsolete; this applies to all other _UTF8 macros as well.
See also QT_TRANSLATE_NOOP() and Internationalization with Qt.
注意粗体部分。因此,这适用于 QT_TR_NOOP
并不重要,它也适用于:
- Global Qt Declarations | Qt Core 6.3.2
QT_TRANSLATE_NOOP(context, sourceText)
Marks the UTF-8 encoded string literal sourceText for delayed translation in the given context. The context is typically a class name and also needs to be specified as a string literal.
The macro tells lupdate to collect the string, and expands to sourceText itself.
Example:
static const char *greeting_strings[] = { QT_TRANSLATE_NOOP("FriendlyConversation", "Hello"), QT_TRANSLATE_NOOP("FriendlyConversation", "Goodbye") }; QString FriendlyConversation::greeting(int type) { return tr(greeting_strings[type]); } QString global_greeting(int type) { return qApp->translate("FriendlyConversation", greeting_strings[type]); }
See also QT_TR_NOOP(), QT_TRANSLATE_NOOP3(), and Internationalization with Qt.
关于c++ - Qt 中的 QT_TRANSLATE_NOOP_UTF8 是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/73048664/