Babel Bundle API

flask_unchained.bundles.babel

BabelBundle

The Babel Bundle.

gettext(*args, **kwargs)

Return the localized translation of message, based on the language, and locale directory of the domain specified in the translation key (or the current global domain).

ngettext(*args, **kwargs)

Like gettext(), except it supports pluralization.

lazy_gettext(*args, **kwargs)

Like gettext(), except lazy.

lazy_ngettext(*args, **kwargs)

Like ngettext(), except lazy.

flask_unchained.bundles.babel.config

Config

Default configuration options for the Babel Bundle.

DevConfig

ProdConfig

StagingConfig

BabelBundle

class flask_unchained.bundles.babel.BabelBundle[source]

The Babel Bundle. Responsible for configuring the correct gettext callables with Jinja, as well as optionally registering endpoints for language-specific URLs (if enabled).

name: str = 'babel_bundle'

The name of the Babel Bundle.

command_group_names = ('babel',)

Names of the command groups included in this bundle.

language_code_key = 'lang_code'

Default Werkzeug parameter name to be used when registering language-specific URLs.

before_init_app(app: flask_unchained.flask_unchained.FlaskUnchained)[source]

Override this method to perform actions on the FlaskUnchained app instance before the unchained extension has initialized the application.

after_init_app(app: flask_unchained.flask_unchained.FlaskUnchained)[source]

Override this method to perform actions on the FlaskUnchained app instance after the unchained extension has initialized the application.

gettext functions

flask_unchained.gettext(*args, **kwargs)[source]

Return the localized translation of message, based on the language, and locale directory of the domain specified in the translation key (or the current global domain). This function is usually aliased as _:

from flask_unchained import gettext as _
flask_unchained.ngettext(*args, **kwargs)[source]

Like gettext(), except it supports pluralization. This function is usually aliased as _:

from flask_unchained import ngettext as _
flask_unchained.lazy_gettext(*args, **kwargs)[source]

Like gettext(), except lazy. This function is usually aliased as _:

from flask_unchained import lazy_gettext as _
flask_unchained.lazy_ngettext(*args, **kwargs)[source]

Like ngettext(), except lazy. This function is usually aliased as _:

from flask_unchained import lazy_ngettext as _

Config

class flask_unchained.bundles.babel.config.Config[source]

Default configuration options for the Babel Bundle.

LANGUAGES = ['en']

The language codes supported by the app.

BABEL_DEFAULT_LOCALE = 'en'

The default language to use if none is specified by the client’s browser.

BABEL_DEFAULT_TIMEZONE = 'UTC'

The default timezone to use.

DEFAULT_DOMAIN = <flask_babelex.Domain object>

The default Domain to use.

DATE_FORMATS = {'date': 'medium', 'date.full': None, 'date.long': None, 'date.medium': None, 'date.short': None, 'datetime': 'medium', 'datetime.full': None, 'datetime.long': None, 'datetime.medium': None, 'datetime.short': None, 'time': 'medium', 'time.full': None, 'time.long': None, 'time.medium': None, 'time.short': None}

A dictionary of date formats.

ENABLE_URL_LANG_CODE_PREFIX = False

Whether or not to enable the capability to specify the language code as part of the URL.

class flask_unchained.bundles.babel.config.DevConfig[source]
LAZY_TRANSLATIONS = False

Do not use lazy translations in development.

class flask_unchained.bundles.babel.config.ProdConfig[source]
LAZY_TRANSLATIONS = True

Use lazy translations in production.

class flask_unchained.bundles.babel.config.StagingConfig[source]
LAZY_TRANSLATIONS = True

Use lazy translations in staging.