Babel Bundle API¶
flask_unchained.bundles.babel
The Babel Bundle. |
|
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). |
|
Like |
|
Like |
|
Like |
flask_unchained.bundles.babel.config
Default configuration options for the Babel Bundle. |
|
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 theunchained
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 theunchained
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.
-