jinja i18n 

command
init

pybabel extract -F ./babel.cfg -o ./locale/messages.pot ./
pybabel init -l en_US -d ./locale -i ./locale/messages.pot
pybabel init -l th_TH -d ./locale -i ./locale/messages.pot

update text

pybabel update -l en_US -d ./locale -i ./locale/messages.pot
pybabel update -l th_TH -d ./locale -i ./locale/messages.pot

compile to mo

your_project_root $ django-admin.py compilemessages

usage by assign locale

 @webapp2.cached_property
 def jinja2(self):
    return jinja2.get_jinja2(app=self.app)</pre>
 def get(self):
    i18n.get_i18n().set_locale('th_TH')
    args = {}
    self.jinja2.render_template(template_dir, **args)

ref : mikeshilkov

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s