【发布时间】:2017-09-06 13:20:47
【问题描述】:
使用xgettext 工具时,可以自动添加注释以帮助翻译人员正确命名(如documented)。
文档建议在命令行中添加以下内容:
--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 ""
【问题讨论】: