No project description provided
Project description
Muffin-Babel – an extension to Muffin that adds localization support with help of babel.
Requirements
python >= 3.3
Installation
Muffin-Babel should be installed using pip:
pip install muffin-babel
Usage
Add muffin_babel to PLUGINS in your Muffin application config:
import muffin app = muffin.Application( 'example', PLUGINS=( 'muffin_jinja2', 'muffin_babel', ) )
Setup a locale selector function:
@app.ps.babel.locale_selector def set_locale(request): """ Return locale from GET lang-param or automatically. """ return request.GET.get( 'lang', # Get locale based on user settings app.ps.babel.select_locale_by_request(request) )
Use app.ps.babel.gettext, app.ps.babel.pgettext, app.ps.babel.lazy_gettext function in your code:
@app.register('/') def index(request): return app.ps.babel.gettext('Hello!')
Options
BABEL_CONFIGURE_JINJA2 |
Install i18n support to Muffin-Jinja2 (True) |
BABEL_DEFAULT_LOCALE |
Set default locale (en) |
BABEL_DOMAIN |
Set default domain (messages) |
BABEL_LOCALES_DIRS |
List of directories where locales are leaving |
BABEL_SOURCES_MAP |
Babel sources map |
BABEL_OPTIONS_MAP |
Babel options map |
Commands
The plugin adds two commands to your Muffin application.
Extract messages
Extract strings from your application to locales:
$ muffin app_module extract_messages [OPTIONS] appdir
Translate .po files and compile translations:
$ muffin app_module compile_messages [OPTIONS]
Bug tracker
If you have any suggestions, bug reports or annoyances please report them to the issue tracker at https://github.com/klen/muffin-babel/issues
Contributing
Development of Muffin-Babel happens at: https://github.com/klen/muffin-babel
Contributors
klen (Kirill Klenov)
License
Licensed under a MIT license.
If you wish to express your appreciation for the project, you are welcome to send a postcard to:
Kirill Klenov pos. Severny 8-3 MO, Istra, 143500 Russia
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for muffin_babel-0.0.6-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6f0b50a85b99d8f203e166f98be8a167733a1c9906eca7177c5e34b571034b7f |
|
MD5 | 0894c20e294014516eab945afa10c300 |
|
BLAKE2b-256 | 0a4c653144bd51676128827ac8b5567e26dc24d6c30e0bd2ecac302c27ba8a65 |