Skip to main content

Easy to use abstractions for localizing your python apps.

Project description

# Localizator

Purpose of this simple package is to give easy to use abstractions for localizing your python app. Generally this package was made just for my telegram bots.

## Initialization
Firstly, you have to create localizator object:
from localizator import Localizator

localizator = Localizator()

Also, you could pass `LocalizationsProvider` and default language. LocalizationsProvider is fabric that creates `Localization`s objects by language name.
By default it will use YAML implementation that looks for `*.yaml` files inside `localizations` directory, but you could create your own localizations provider or at least change directory if it's necessary.

If you did not change anything in localizator initialization, create directory inside working directory called `localizations` and create file `en.yaml` with example content:
foo: bar

bar: foo

world: "{} world"
formatting: "Hello, {}!"
named_formatting: "Hello, {world}!"

## Simple use

After that you can start using localizator:

from localizator import LocalizationDescription
from localizator import Localizator

localizator = Localizator()

print(localizator.get_localization(LocalizationDescription(['extended_foo', 'bar'])))

## Describer
Looks not really simple? Yeah, it's, but do not stop here! We have _brand new_ `Describer`. It allows to make your localization really simple, i mean, just look:

from localizator import LocalizationDescriber
from localizator import Localizator

d = LocalizationDescriber()
localizator = Localizator()


# And even more!

# Moar!

Also, if you want to highlight your paths to localizations as strings, you could use string:

Project details

Download files

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

Files for localizator, version 0.1.0
Filename, size File type Python version Upload date Hashes
Filename, size localizator-0.1.0.tar.gz (4.4 kB) File type Source Python version None Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Huawei Huawei PSF Sponsor Microsoft Microsoft PSF Sponsor NVIDIA NVIDIA PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page