Log in

tipfy.ext.i18n

Warning:

This extension is not documented in the wiki yet. You can only check a simple example for now.

Add I18nMiddleware to installed middleware in your configuration file.

config.py

config = {}

config['tipfy'] = {
    'middleware': [
        'tipfy.ext.i18n.I18nMiddleware',
    ],
}

Create translation catalogs:

locale/{ YOUR_LANGUAGE_CODE }/LC_MESSAGES/messages.po
locale/{ YOUR_LANGUAGE_CODE }/LC_MESSAGES/messages.mo

where { YOUR_LANGUAGE_CODE } is the language of your translations (for example pt_BR)

handlers.py

# -*- coding: utf-8 -*-
from tipfy import RequestHandler, Response
from tipfy.ext.jinja2 import render_response
from tipfy.ext.i18n import gettext as _

class I18nHandler(RequestHandler):
    def get(self):
        return render_response('i18n.html', message=_('Translated text!'))

Test it using lang GET argument.

http://localhost:8080/?lang=pt_BR

Extension Reference


Powered by Moe. Yeah, the name is Moe. Powered by Google App Engine