Skip to main content

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 \n in locale file
  • locale.<string> (or locale.get(<string>)) returning instance of str class and might be formatted via format() 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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

locale_lib-1.0.3.tar.gz (2.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

locale_lib-1.0.3-py3-none-any.whl (2.5 kB view details)

Uploaded Python 3

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

Hashes for locale_lib-1.0.3.tar.gz
Algorithm Hash digest
SHA256 2fa583c75377ea6ac6ad5adf99119939176fa67847490af33fe2c24d889dee3a
MD5 ea93827d6bee9311748bc86097b8161e
BLAKE2b-256 3410a30449ff14986eebff4dcd5f30a65c89a69fbb4eb44ad7aa610eda43899a

See more details on using hashes here.

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

Hashes for locale_lib-1.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 6b043c510f5c9994d378b72ce039f9aa3aa318173fadca0c4a69baba61bda8c7
MD5 a3515682a64a6174b5ddf0a3ea067c02
BLAKE2b-256 056259cb8a917ffd5976383329589627994b2a4b0eda3512de99f2fe004ae141

See more details on using hashes here.

Supported by

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