我的 Jinja2 模板之一中有一个可翻译的字符串:
Project can’t end sooner than it starts
(注意“不能”中的 UTF-8 撇号。)
当我提取消息并更新我的翻译文件时,模板 ( .pot
) 和翻译 ( .po
) 文件都具有以下内容msgid
:
msgid "Project canât end sooner than it starts"
Babel 似乎“翻译”了 UTF-8 字符,就好像它们在某种 8 位字符集中一样。
我babel.cfg
的很短:
[python: **.py]
[jinja2: **/templates/**.html]
extensions=jinja2.ext.autoescape,jinja2.ext.with_,webassets.ext.jinja2.AssetsExtension
Babel 有没有办法注意到模板已经在 UTF-8 中,而不是从它认为的任何字符集转换它?pybabel extract --help
我在nor的帮助输出中看不到任何相关选项pybabel extract --help
。
为了记录,我专门使用 Python3。