Skip to main content

Simple localization manager

Project description

Locass - Simple and easy to use localization library written on Python

Locass Logo

LoCalization As So Simple - simple, light-weight, and simple to use library which help you to localizate your apps on different languages.

Note: This project is unstable because of the first releases not tested. We are asking you to report any bugs you found.

How to use

Step 1: Create a folder with your localization files, for example locals.

We recommend you to create it in the root of your project or in the same directory with your executable because we recommend you to use RELATIVE paths like./locals/

Step 2: Create localization files using your own markers or use default, markdown is:KEYMARKER(keyvalue)VALUEMARKER(value), consider that spaces between markers and values are forbidden. For example:

[k]HW![v]Привет Мир!

Step 3: Install and import this module in your project. Details about installing is on Installing page. Next, create a LocalManager object. Use expression like this:

man = locass.LocalManager()

Step 4: configure localization manager, using

man.configure() 

function. First argument is the path, where your localization files are, for example "./locals/"

NOTE: Please, don't lose "/" symbols!

Second argument is the dictionary, which contains the localization name as a key and name of file as a value, for example {"RU": "ru.lang", "EN": "en.lang"}

Third is the Keymarker of your markdown you used in localization files, for example "[k]"

Last is the Valuemarker of your markdown, for example "[v]"

So if you used next markdown of localization flies:

file ru.lang in ./locals/ with inside

[k]HW![v]Привет Мир!

and file en.lang in the same directory with inside

[k]HW![v]Hello World!

your call will be like:

man.configure("./locals/",{"RU": "ru.lang", "EN":"en.lang"},"[k]","[v]")

Step 5: Load language to use, using loadLang(key) where key is localization name from previous step, for example "RU":

man.loadLang("RU")

Step 6: Use it in your code, and when you need string from selected localization, only call g(key), where key from your localization file. For example after steps above we can call next:

man.g("HW!") #Returns Привет Мир!

Note: To change the loaded language, only call loadLang again with new argument, for example

man2.configure("./locals/",{"RU": "ru.lang", "EN":"en.lang"},"[k]","[v]")
man2.loadLang("RU")
man2.g("HW!") #Returns Привет Мир!
man2.loadLang("EN")
man2.g("HW!") #Returns Hello World!

Installing

Get it form PyPi: https://pypi.org/project/locass/ or in terminal run

pip install locass

or

pip3 install locass

Tests

Try and see how the library works only running tests/test.py. Run it only after installing the library or it won't work.

Bugs and errors

Now library is under development so we asking you to tell us about every bug or error you found. You should consider that library is unstable and can cause some errors.

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

locass-1.0.4.tar.gz (4.1 kB view details)

Uploaded Source

Built Distribution

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

locass-1.0.4-py3-none-any.whl (4.3 kB view details)

Uploaded Python 3

File details

Details for the file locass-1.0.4.tar.gz.

File metadata

  • Download URL: locass-1.0.4.tar.gz
  • Upload date:
  • Size: 4.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.0 CPython/3.8.13

File hashes

Hashes for locass-1.0.4.tar.gz
Algorithm Hash digest
SHA256 e418cb97dd497758e504ab7f14881f224b8526ff054fdd6a59e09e0dc5fc506a
MD5 e997b9d9d618978c08e592e7e5c82435
BLAKE2b-256 99cef654d70a7d2bdc185de95f4a88a3a76013c0b66d9906121e326f5ef4ddfe

See more details on using hashes here.

File details

Details for the file locass-1.0.4-py3-none-any.whl.

File metadata

  • Download URL: locass-1.0.4-py3-none-any.whl
  • Upload date:
  • Size: 4.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.0 CPython/3.8.13

File hashes

Hashes for locass-1.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 2047751aa51514fa8fe947dfe85a311e1c5669c7fd6e5377b6ed9d63ea6e2ad6
MD5 6bf0c71c321c4473585e0b97db9f8cef
BLAKE2b-256 48051cbb14cb42bfa9b9c3c5ea097edb0efd7013010e31bb99dceb49ec6b665d

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