Skip to main content

An i18n library based on the banana message format

Project description

A localization library for Python based on the banana message file format. This library was originally developed inside of Pywikibot and then forked into a separate library for easier reuse.

Message specification

For the most part we use the upstream banana file format, with a few Python tweaks.

Parameters to messages are specified through printf-style formatting:

"bot-change-page": "Bot: Changing %(num)s {{PLURAL:%(num)d|page|pages}}.",

All parameters are named. Gender, grammar, and bidi support has not yet been implemented.

Usage

Assuming the directory with your JSON files is named i18n:

from banana_i18n import BananaI18n

banana = BananaI18n('i18n')
text = banana.translate('de', 'example')

Parameters must be passed as a dictionary:

text = banana.translate('de', 'bot-change-page', {'num': 2})

If the parameter is going to be used in {{PLURAL:}}, it must be the int type.

A list of all localized languages can be accesssed through banana.known_languages().

License

banana-i18n is available under the terms of the MIT license.

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 banana-i18n, version 0.1.3
Filename, size File type Python version Upload date Hashes
Filename, size banana_i18n-0.1.3-py3-none-any.whl (8.9 kB) File type Wheel Python version py3 Upload date Hashes View hashes
Filename, size banana-i18n-0.1.3.tar.gz (9.1 kB) File type Source Python version None Upload date Hashes View hashes

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