使用xgettext工具时,可以自动添加注释以帮助翻译人员了解专有名称(如文档所示)。
该文档建议将以下内容添加到命令行:
--keyword='proper_name:1,"This is a proper name. See the gettext manual, section Names."'
这导致正确的名称被提取到.pot
文件中,如下所示:
#. This is a proper name. See the gettext manual, section Names.
#: ../Foo.cpp:18
msgid "Bob"
msgstr ""
这个问题;是没有为该字符串定义特定的上下文。理想情况下,以下是正确名称的提取方式:
#. This is a proper name. See the gettext manual, section Names.
#: ../Foo.cpp:18
msgctxt "Proper Name"
msgid "Bob"
msgstr ""
我尝试了以下但没有成功:
# Hoping that 0 would be the function name 'proper_name'.
--keyword='proper_name:0c,1,"This is a proper name. See the gettext manual, section Names."'
# Hoping that -1 would be the function name 'proper_name'.
--keyword='proper_name:-1c,1,"This is a proper name. See the gettext manual, section Names."'
# Hoping that the string would be used as the context.
--keyword='proper_name:"Proper Name"c,1,"This is a proper name. See the gettext manual, section Names."'
# Hoping that the string would be used as the context.
--keyword='proper_name:c"Proper Name",1,"This is a proper name. See the gettext manual, section Names."'
有没有办法强制使用特定msgctxt
关键字提取的所有字符串(proper_name
例如上面的示例)?
如果无法按xgettext
原样实现此目的,那么我考虑使用以下方法:
--keyword='proper_name:1,"<PROPERNAME>"'
结果:
#. <PROPERNAME>
#: ../Foo.cpp:18
msgid "Bob"
msgstr ""
那么问题就变成了;如何自动将结果.pot
文件中出现的所有 this 转换为以下内容:
#. This is a proper name. See the gettext manual, section Names.
#: ../Foo.cpp:18
msgctxt "Proper Name"
msgid "Bob"
msgstr ""