Skip to main content

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


Download files

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

Source Distribution

langstr-0.1.0.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.

langstr-0.1.0-py3-none-any.whl (4.4 kB view details)

Uploaded Python 3

File details

Details for the file langstr-0.1.0.tar.gz.

File metadata

  • Download URL: langstr-0.1.0.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

Hashes for langstr-0.1.0.tar.gz
Algorithm Hash digest
SHA256 e6853fcb1a32e58f76cc3137ec557fd5a8a58077b76c4bc1333c33274d1d71e9
MD5 eb2d17cfb96b07fc8af000793beaf30e
BLAKE2b-256 2ffc9ff897fe0a617afe20a4c4fe9cc74406681b53d4d878e98ef28ce9f7388d

See more details on using hashes here.

File details

Details for the file langstr-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: langstr-0.1.0-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

Hashes for langstr-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 c45fdb2728de3897e333c4ae500ec2487ac482b8d30758354894dd9f07225c06
MD5 37a4429c14bcc472b1d47e5d4a4c138d
BLAKE2b-256 54053f914666c683a6ab1ce5b553f00f6fbd2b3b32d9ebe91de445891536c923

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