Simple lib for localisation your services.
Project description
locale-lib
This is a simple lib for localisation your services.
Installation
Installation is possible using the Python pip command line tool. For you the command to install this library may look like this:
pip3 install locale-lib
Usage
To use localisation package create instance of LocaleManager and get strings via property.
from locale_lib import LocaleManager
from datetime import datetime
locale_man = LocaleManager('./locales').setup() # FileNotFoundError if not found
locale = locale_man.get(input('enter your country code: '))
...
print(locale.greeting_message)
print(locale.f_time_now.format(time=datetime.now()))
./locales/locale_en:
greeting_message: hello, user!
f_time_now: Current datetime is:/ {time}
./locales/locale_es:
greeting_message: hola, usuario!
f_time_now: La fecha actual es:/ {time}
./locales/locale_ru:
greeting_message: Привет, пользователь!!
f_time_now: Сейчас:/ {time}
Tips
:must be replaced to:/(variable_name: value is:/ value)- To add new line use
\nin locale file locale.<string>(orlocale.get(<string>)) returning instance ofstrclass and might be formatted viaformat()method- Locale file should look like
locale_<country_code>.lc, other will be skipped
How it's meant to be used
- Standard strings should look like
var_name: Variable value - F-strings should look like
f_var_name: Variable {param_a} {param_d} {param_c} value
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file locale_lib-1.0.3.tar.gz.
File metadata
- Download URL: locale_lib-1.0.3.tar.gz
- Upload date:
- Size: 2.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.4 CPython/3.12.1 Windows/10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2fa583c75377ea6ac6ad5adf99119939176fa67847490af33fe2c24d889dee3a
|
|
| MD5 |
ea93827d6bee9311748bc86097b8161e
|
|
| BLAKE2b-256 |
3410a30449ff14986eebff4dcd5f30a65c89a69fbb4eb44ad7aa610eda43899a
|
File details
Details for the file locale_lib-1.0.3-py3-none-any.whl.
File metadata
- Download URL: locale_lib-1.0.3-py3-none-any.whl
- Upload date:
- Size: 2.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.4 CPython/3.12.1 Windows/10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6b043c510f5c9994d378b72ce039f9aa3aa318173fadca0c4a69baba61bda8c7
|
|
| MD5 |
a3515682a64a6174b5ddf0a3ea067c02
|
|
| BLAKE2b-256 |
056259cb8a917ffd5976383329589627994b2a4b0eda3512de99f2fe004ae141
|