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¶
- Name: tipfy.ext.i18n
- Author: Rodrigo Moraes
- License: BSD
- Tags: i18n, internationalization, l10n, localization, translations
- URL: http://www.tipfy.org/wiki/extensions/i18n/
- PyPi page: http://pypi.python.org/pypi/tipfy.ext.i18n/
- Source code: http://code.google.com/p/tipfy-ext-i18n/
- Issue tracker: http://code.google.com/p/tipfy-ext-i18n/issues/list
- Version: latest
- Edited by garcia.marc on 9/25/10 8:37 PM
- Save on Delicious | Submit to Reddit
- History
- Edit
