How to deal with Internationalization when using mako on django ,
this is code :
{% load i18n %}
{% trans 'hello test' %}
but , this code cant be read by mako
,
so how to Internation开发者_开发知识库alization using mako
,
thanks
I've checked the documentation and it describes that Mako uses Babel for i18n. So you can either use that, or as @Yuji suggests, use Django's i18n by calling arbitrary Python code.
But I think using Babel is prettier:
# /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>
精彩评论