zjm1126
zjm1126

Reputation: 35662

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 Internationalization using mako ,

thanks

Upvotes: 1

Views: 1024

Answers (1)

Filip Dupanović
Filip Dupanović

Reputation: 33650

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>

Upvotes: 1

Related Questions