这是代码:
{% load i18n %}
{% trans 'hello test' %}
但是,此代码无法读取mako
,
那么如何使用国际化mako
,
谢谢
这是代码:
{% load i18n %}
{% trans 'hello test' %}
但是,此代码无法读取mako
,
那么如何使用国际化mako
,
谢谢
我检查了文档,它描述了 Mako 将Babel用于 i18n。因此,您可以使用它,或者像@Yuji 建议的那样,通过调用任意 Python 代码来使用 Django 的 i18n。
但我认为使用 Babel 更漂亮:
# /myproj/babel.cfg
# this loads all Django templates,
# e.g. /myproj/templates/myapp/hello_world.html
[mako: **/templates/**.*]
# /myproj/templates/myapp/hello_world.html
<html>
<body>
${_('Hello world!')}
</body>
</html>