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.

Source Distribution

banana-i18n-0.1.3.tar.gz (9.1 kB view details)

Uploaded Source

Built Distribution

banana_i18n-0.1.3-py3-none-any.whl (8.9 kB view details)

Uploaded Python 3

File details

Details for the file banana-i18n-0.1.3.tar.gz.

File metadata

  • Download URL: banana-i18n-0.1.3.tar.gz
  • Upload date:
  • Size: 9.1 kB
  • Tags: Source
  • Uploaded using 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

File hashes

Hashes for banana-i18n-0.1.3.tar.gz
Algorithm Hash digest
SHA256 0c55a561dfc20c7ff08c6225ad9ff9ba5c24ef792f3a1816d23b7183b6333efc
MD5 b5e5eb6641a060f5dc2c8390edab66a5
BLAKE2b-256 441676390dd7a0dbee5ec9cec4c7f774186cec2c07344ab03a4ec6d44072d37c

See more details on using hashes here.

Provenance

File details

Details for the file banana_i18n-0.1.3-py3-none-any.whl.

File metadata

  • Download URL: banana_i18n-0.1.3-py3-none-any.whl
  • Upload date:
  • Size: 8.9 kB
  • Tags: Python 3
  • Uploaded using 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

File hashes

Hashes for banana_i18n-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 43f44965a5e5e5466e378bedaab109e4f0c4d5a3f622f3d883ae12d44772e0f0
MD5 dd45320678cc3257e0dbe74f02a65ec0
BLAKE2b-256 8030324b81444863c7b0586d3a2da2798cae9f83cd883fa5013cfc47955b283f

See more details on using hashes here.

Provenance

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page