erikbrannstrom / BottleI18N

I18N plugin for bottle

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

bottle_i18n

A very simple I18N plugin for Bottle apps, base on gettext.

Here is an example:

from bottle import Bottle, view
from bottle_i18n import I18NPlugin

myapp = Bottle()

i18n = I18NPlugin(domain='myapp')
myapp.install(i18n)


@myapp.get('/')
@view('index')
def index():
    i18n_msg = myapp._('test i18n in python')
    return {'i18n_msg':i18n_msg, '_':myapp._}

Your index.tpl may look like below:

<p>
  {{ i18n_msg }}
</p>
<p>
  {{ _('test i18n in bottle template') }}
</p>

Here is a sample project: https://github.com/woodyhuang/Bottlog

About

I18N plugin for bottle

License:MIT License