A utility for translations, based on BombSquad
Project description
LangStr
langstr (or, Language String) is a library created for the express purpose of getting
resources from a existing language file and being used as strings.
It's really lightweight, requiring absolutely no other libraries,
and having little to a single class that handles most logic. Inspired by BombSquad's Lstrs.
In terms of usage, you'd first want to set the path of where your language files are:
import langstr
langstr.set_path('path\to\your\languages_folder')
Then, it's as simple as creating a LangStr object.
langstr.LangStr(resource='myCoolResource')
# or, if you prefer:
langstr.LangStr(r='myCoolResource')
LangStr's also support subs, which allow you to replace certain
values of the resource (eg. ${NAME}) to another string.
langstr.LangStr(resource='myCoolResourceWithValues', subs=[ ('${NAME}', 'John') ])
# Assuming myCoolResourceWithValues is 'Welcome, ${NAME}', full text will be 'Welcome, John'
Then, whenever you want an actually usable string, just evaluate (or stringify) the LangStr object.
mylangstr = langstr.LangStr(resource='myCoolResource')
print(mylangstr.evaluate())
# or;
print(str(mylangstr))
# both will output something like 'Hello!',
# or whatever your resource says
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 langstr-0.1.1.tar.gz.
File metadata
- Download URL: langstr-0.1.1.tar.gz
- Upload date:
- Size: 4.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e0a7214b9fba21a6b32b889074c4cf546020cbc710ceee51f335394ea05ab248
|
|
| MD5 |
94dc38d23fd814071cdb2ec66ddc1419
|
|
| BLAKE2b-256 |
93e15e3e611a5e4f9a71a01881e857e332fa431088e0ad9aa2cd7c5971cd3ed1
|
File details
Details for the file langstr-0.1.1-py3-none-any.whl.
File metadata
- Download URL: langstr-0.1.1-py3-none-any.whl
- Upload date:
- Size: 4.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d8ae68009f861fe8664ea75a1aea312c7c10590819c48cd9f387dc3121e66239
|
|
| MD5 |
72a2e71efa89fd693d5d6c4dcfd2e59a
|
|
| BLAKE2b-256 |
1c4013b1cc4548a71f0b9a93c45b1c78efa8ebd5ea526f49c3ee1a63b583b6fc
|