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 (False) |
BABEL_DEFAULT_LOCALE |
Set default locale (en) |
BABEL_LOCALES_DIR |
A path to directory with locales files (locales) |
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.
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
File details
Details for the file muffin-babel-0.0.4.tar.gz
.
File metadata
- Download URL: muffin-babel-0.0.4.tar.gz
- Upload date:
- Size: 6.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 117087f8eea543f606a69749c3866a8e2cdd85bba5c5df972454847136f5df91 |
|
MD5 | 60ab402ee9d0ca0a40da524e8d4ab17a |
|
BLAKE2b-256 | 2f57cfd0e4bd0fbaeecdff35c10a0d7d13f7e8de13febe7ba600dc5141821daf |
File details
Details for the file muffin_babel-0.0.4-py2.py3-none-any.whl
.
File metadata
- Download URL: muffin_babel-0.0.4-py2.py3-none-any.whl
- Upload date:
- Size: 7.9 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 553e44d6e8b98328351edb90e110e75a22949ddd6be8534878be6b71e1d4b381 |
|
MD5 | 41d2a3be3e5421110ba6ab3d354083d5 |
|
BLAKE2b-256 | ba13b34358a62dac2acb79ee87900ad59689ef7bbc9971fbdd382897014808ca |