我正在尝试从 Pyramid 项目中的模板文件中翻译文本。或多或少在这个例子中: http: //docs.pylonsproject.org/projects/pyramid_cookbook/en/latest/chameleon_i18n.html
现在我如何摆脱<dynamic element>我的 .pot 文件的评论?我想查看其余代码及其标签。
我的变色龙模板(.pt):
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> 
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" xmlns:tal="http://xml.zope.org/namespaces/tal"
  xmlns:i18n="http://xml.zope.org/namespaces/i18n"
  i18n:domain="MyDomain">
<head>
    ...
</head>
<body>
    <div i18n:translate="MyID">
        This will appear in the comments.
        <span>This will NOT.</span>
        While this will again appear.
    </div>
</body>
</html>
我使用 Babel 和 Lingua 在 setup.py 中使用以下选项提取消息:
message_extractors = { '.': [
        ('**.py', 'lingua_python', None ),
        ('**.pt', 'lingua_xml', None ),
        ]}
我的 .pot 文件中的相关输出如下所示:
#. Default: This will appear in the comments. <dynamic element> While this will
#. again appear.
#: myproject/templates/base.pt:10
msgid "MyID"
msgstr ""