开发者

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>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜