Skip to main content

No project description provided

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.2.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.2-py3-none-any.whl (2.5 kB view details)

Uploaded Python 3

File details

Details for the file locale_lib-1.0.2.tar.gz.

File metadata

  • Download URL: locale_lib-1.0.2.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.2.tar.gz
Algorithm Hash digest
SHA256 40bae2e962d2f4819edacc017456290d9f49b6a1fdfafb92c55603752a4948ec
MD5 27751d196918e300c6a8baf6d758fa4d
BLAKE2b-256 b38391315d539acdb46d9df368bdd794c8cad43aa70ac9834d2ec6f507144339

See more details on using hashes here.

File details

Details for the file locale_lib-1.0.2-py3-none-any.whl.

File metadata

  • Download URL: locale_lib-1.0.2-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.2-py3-none-any.whl
Algorithm Hash digest
SHA256 7649d879427057f00eec6020d89298c42a8a6449c14acd458fe83f9bb00bcf48
MD5 71bca7258ca6e1c1a66daffd8ebae92f
BLAKE2b-256 6b7c3e408a876d662a7f06ae0d8ecd25a45643525be3f6d6aec53bba14b058ba

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