banana-i18n
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.
(C) 2004-2019 Pywikibot team
(C) 2011-2017 xqt
(C) 2020 Kunal Mehta <legoktm@member.fsf.org>
Metadata
Release files for banana-i18n 0.1.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| banana-i18n-0.1.3.tar.gz | 9.1 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| banana_i18n-0.1.3-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 18.1 kB
Release files / banana-i18n-0.1.3.tar.gz
| Download URL | banana-i18n-0.1.3.tar.gz |
|---|---|
| Size | 9.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
0c55a561dfc20c7ff08c6225ad9ff9ba5c24ef792f3a1816d23b7183b6333efc
|
|
BLAKE2b-256 checksum How to use checksums |
441676390dd7a0dbee5ec9cec4c7f774186cec2c07344ab03a4ec6d44072d37c
|
| 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 / banana_i18n-0.1.3-py3-none-any.whl
| Download URL | banana_i18n-0.1.3-py3-none-any.whl |
|---|---|
| Size | 8.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
43f44965a5e5e5466e378bedaab109e4f0c4d5a3f622f3d883ae12d44772e0f0
|
|
BLAKE2b-256 checksum How to use checksums |
8030324b81444863c7b0586d3a2da2798cae9f83cd883fa5013cfc47955b283f
|
| 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
|