Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
默认情况下,pybabel 可以${_("mystr")}很好地从我的 mako 模板中提取字符串,但是当我尝试${pgettext("myctx", "mystr")}用于上下文翻译时,它似乎没有找到并提取它们。
${_("mystr")}
${pgettext("myctx", "mystr")}
我的 babel 配置非常基本:
[mako: templates/**.mako] encoding = utf-8
有谁知道如何让 pybabel 从 mako 模板中提取 pgettext 翻译?
使用 Flask,我实现了它为 Mako 导入 pgettext:
kw['imports'] = ['from flask.ext.babel import gettext as _, pgettext']