Locales-0.0.2
توضیحات
Module for multilingual solutions
| ویژگی | مقدار |
|---|---|
| سیستم عامل | OS Independent |
| نام فایل | Locales-0.0.2 |
| نام | Locales |
| نسخه کتابخانه | 0.0.2 |
| نگهدارنده | [] |
| ایمیل نگهدارنده | [] |
| نویسنده | vffuunnyy |
| ایمیل نویسنده | vffuunnyy@gmail.com |
| آدرس صفحه اصلی | https://github.com/vffuunnyy/Locales |
| آدرس اینترنتی | https://pypi.org/project/Locales/ |
| مجوز | - |
# Locales
Locales - module for multilingual projects
## Getting Started
### Prerequisites
Locales uses only standard library **json**. You need to write the translations in *json format*
```json
{
"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:
```python
import Locales
Locales().example()
```
### Installing
You can install Locales using pip
```sh
$ pip install locales
```
or download `Locales.py` and drop to folder with your project
### Using
```python
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](https://t.me/vffuunnyy)
نحوه نصب
نصب پکیج whl Locales-0.0.2:
pip install Locales-0.0.2.whl
نصب پکیج tar.gz Locales-0.0.2:
pip install Locales-0.0.2.tar.gz