Skip to main content

No project description provided

Project description

Muffin-Babel – an extension to Muffin that adds localization support with help of babel.

Build Status http://img.shields.io/pypi/v/muffin-babel.svg?style=flat-square http://img.shields.io/pypi/dm/muffin-babel.svg?style=flat-square Donate

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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

muffin-babel-0.0.5.tar.gz (6.9 kB view details)

Uploaded Source

Built Distribution

muffin_babel-0.0.5-py2.py3-none-any.whl (8.0 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file muffin-babel-0.0.5.tar.gz.

File metadata

File hashes

Hashes for muffin-babel-0.0.5.tar.gz
Algorithm Hash digest
SHA256 c19af0ed42013df41c0668385d1f9327f87166afafe285507c13e9dba123fb75
MD5 5e65e0179fed743ebac3cb2b5ee601e3
BLAKE2b-256 363265ac6414a641c3eb8962e62807facfe122606c831707ee943604a68d2c04

See more details on using hashes here.

File details

Details for the file muffin_babel-0.0.5-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for muffin_babel-0.0.5-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 0b296b2b74e937133fb7326c6b265c235b8318343acbe47b0ffa852c8b261f2c
MD5 b837ba5a39b711ca592aee05292199be
BLAKE2b-256 4ecb7d4c9d707f21535ddefa8f5cf78faf7dde58f957584aa2f5f7708a3c2097

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page