Flask-Banana
Localize your Flask application using the banana file format, popularized by MediaWiki.
Usage
In your app.py:
from flask import Flask from flask_banana import Banana from pathlib import Path app = Flask(__name__) banana = Banana(app, Path(__file__).resolve().parent / 'i18n')
You can also use the init_app pattern as well.
In your template the _(...) function is aliased to banana.translate():
<body>
<p>{{ _('some-message-key') }}</p>
</body>
To change the language, set the banana.language property. You might also want to try the Flask-ULS library for better client-side support for changing the interface language.
Flask-ULS integration
Flask-Banana can automatically configure and integrate with Flask-ULS, just pass the ULS instance to Banana during setup:
app = Flask(__name__) uls = ULS(app) banana = Banana(app, Path(__file__).resolve().parent / 'i18n', uls)
Banana will configure ULS to enable all of the languages that have translations and then default to using the language configured through ULS.
Configuration
BANANA_DEFAULT_LANGUAGE (default: 'en'): the language to default to if one hasn’t been manually set through Banana nor ULS.
License
Flask-Banana is available under the terms of the GPL, version 3 or any later version.
Metadata
Release files for Flask-Banana 0.1.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| Flask-Banana-0.1.2.tar.gz | 2.8 kB | Without provenance | Details for Flask-Banana-0.1.2.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| Flask_Banana-0.1.2-py3-none-any.whl | Python 3 | none | any | Details for Flask_Banana-0.1.2-py3-none-any.whl |
Total release size: 6.1 kB
Release files / Flask-Banana-0.1.2.tar.gz
| Download URL | Flask-Banana-0.1.2.tar.gz |
|---|---|
| Size | 2.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
da586ad99b1ae476f387d2f4def8e672fd9a1d9c07fbf18ef2b25538e1065c70
|
|
BLAKE2b-256 checksum How to use checksums |
b80a5bacec10657ffc0a20073d2ff311d7edf0afd246065ea668b1effe7ed01c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/45.0.0 requests-toolbelt/0.9.1 tqdm/4.42.1 CPython/3.7.6
|
Release files / Flask_Banana-0.1.2-py3-none-any.whl
| Download URL | Flask_Banana-0.1.2-py3-none-any.whl |
|---|---|
| Size | 3.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
50011f85d777ef1a3b58030c27bb2beb9ea8ec518084fc63f0101febaaa81521
|
|
BLAKE2b-256 checksum How to use checksums |
651df4e75945d3b72c4997ae8278873069d765a82c75693e10c12e078b3fc97f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/45.0.0 requests-toolbelt/0.9.1 tqdm/4.42.1 CPython/3.7.6
|
Security for Flask-Banana 0.1.2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.