Skip to main content

Integrates the banana i18n library into Flask applications

Project description

Localize your Flask application using the banana file format, popularized by MediaWiki.


In your

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():

<p>{{ _('some-message-key') }}</p>

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.


  • BANANA_DEFAULT_LANGUAGE (default: 'en'): the language to default to if one hasn’t been manually set through Banana nor ULS.


Flask-Banana is available under the terms of the GPL, version 3 or any later version.

Project details

Download files

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

Files for Flask-Banana, version 0.1.2
Filename, size File type Python version Upload date Hashes
Filename, size Flask_Banana-0.1.2-py3-none-any.whl (3.2 kB) File type Wheel Python version py3 Upload date Hashes View
Filename, size Flask-Banana-0.1.2.tar.gz (2.8 kB) File type Source Python version None Upload date Hashes View

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page