Babel Bundle¶
The babel bundle provides support for internationalization and localization by integrating Flask BabelEx with Flask Unchained.
Installation¶
The babel bundle comes enabled by default.
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.
-
Commands¶
flask babel¶
Babel translations commands.
flask babel COMMAND [<args>...] [OPTIONS]
compile¶
Compile translations into a distributable .mo
file.
flask babel compile [OPTIONS]
Options
-
-d
,
--domain
<domain>
¶
extract¶
Extract newly added translations keys from source code.
flask babel extract [OPTIONS]
Options
-
-d
,
--domain
<domain>
¶
init¶
Initialize translations for a language code.
flask babel init <lang> [OPTIONS]
Options
-
-d
,
--domain
<domain>
¶
Arguments
-
LANG
¶
Required argument
update¶
Update language-specific translations files with new keys discovered by
flask babel extract
.
flask babel update [OPTIONS]
Options
-
-d
,
--domain
<domain>
¶
API Docs¶
See Babel Bundle API