Locales
Locales - module for multilingual projects
Getting Started
Prerequisites
Locales uses only standard library json. You need to write the translations in json format
{
"languages": {
"ru": "Р СѓСЃСЃРєРёР№", "eng": "English", "sp": "EspaГ±ol"
},
"messages": {
"welcome": {
"ru": "Добро пожаловать!",
"eng": "Welcome!"
},
"goodbye": {
"ru": "РџРѕРєР°",
"eng": "Goodbye",
"sp": "AdiГіs"
}
}
}
Keys languages and messages required.
To generate the same file use:
import Locales
Locales().example()
Installing
You can install Locales using pip
$ pip install locales
or download Locales.py and drop to folder with your project
Using
import Locales
loc = Locales("filename.json")
loc.set_default_lang("eng") # Set the language by default
print(loc.get("welcome"))
# Welcome!
print(loc.get("welcome", "ru"))
# Добро пожаловать!
print(loc.get_all("goodbye")
# dict of key "goodbye" -> {'ru': 'РџРѕРєР°', 'eng': 'Goodbye', 'sp': 'AdiГіs'}
print(loc.get_by_name("English"))
# returns the abbreviation(key) of the language -> eng
Authors
- vffuunnyy - Initial work - @vffuunnyy
Metadata
Release files for Locales 0.0.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 | |
|---|---|---|---|---|
| Locales-0.0.2.tar.gz | 2.6 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| Locales-0.0.2-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 6.3 kB
Release files / Locales-0.0.2.tar.gz
| Download URL | Locales-0.0.2.tar.gz |
|---|---|
| Size | 2.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
c286ae770cbc5bacce074a2981c7cf6092a89cf10fc3aa7df9214f56fcdf7742
|
|
BLAKE2b-256 checksum How to use checksums |
a94989c3242769d5fdcf96d437601fa182fcb65209153567911c06ee5a5132e5
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.12.1 pkginfo/1.5.0.1 requests/2.20.0 setuptools/40.7.2 requests-toolbelt/0.9.1 tqdm/4.30.0 CPython/3.7.0
|
Release files / Locales-0.0.2-py3-none-any.whl
| Download URL | Locales-0.0.2-py3-none-any.whl |
|---|---|
| Size | 3.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
e4a438d394565b59965822d19c6d3207948019f255f7f87845019ea5ffbb03a2
|
|
BLAKE2b-256 checksum How to use checksums |
0aa1f0d0341907c1bd5991bb110e14306888ec4d94bd2e0b06b1489990e33c9e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.12.1 pkginfo/1.5.0.1 requests/2.20.0 setuptools/40.7.2 requests-toolbelt/0.9.1 tqdm/4.30.0 CPython/3.7.0
|
Security for Locales 0.0.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.