我被xgettext
HTML 模板中缺少的标签属性所困扰,例如:
xgettext --keyword=_ --language=Python -o - - <<EOF
<!DOCTYPE html>
<html>
<head>
% msg = _('A translatable string')
<title>{{ _('Page title') }}</title>
</head>
<body>
<a href="#" title="{{ _('title') }}">_('Link text')</a>
</body>
</html>
EOF
返回
# SOME DESCRIPTIVE TITLE.
# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
# This file is distributed under the same license as the PACKAGE package.
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
#
#, fuzzy
msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2021-10-20 11:52+0200\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
"Language: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=CHARSET\n"
"Content-Transfer-Encoding: 8bit\n"
#: standard input:4
msgid "A translatable string"
msgstr ""
#: standard input:5
msgid "Page title"
msgstr ""
#: standard input:8
msgid "Link text"
msgstr ""
wherea
的title
属性被跳过。
FWIW,模板语言是 Pythonbottle
的SimpleTemplate Engine,与标准不兼容pybabel
。
(说实话,你会得到相同的结果——即标记属性被忽略——使用pybabel
的 javascript 提取器,我宁愿将其与以下内容一起使用babel.cfg
)
[python: **/**.py]
[javascript: views/**.html]
我做过的其他尝试:使用与 SimpleTemplate Engine 的模板继承语法不兼容的 Jinja2 提取器{{!base}}