A well built translator with placeholders
Project description
Fancy Translator
This library allow you to run setup a translator with ease. Just provide it the translations files and access them when ever you need them
Having an issue?
You can always find someone on our discord server here:
Wiki
The official wiki of this library will be available at GitHub
How to install
To install just use following command
pip install PyFancyTranslator
This library will have dev/beta builds on the GitHub, to install them you can use
pip install --upgrade git+https://github.com/AGM-Studio/FancyTranslator.git
Example
from FancyTranslator import Translator
# All language files must be in .ini format and be placed in a folder to be accessed
translator = Translator("./translations/")
# To access a language with name "en.ini" just call the method below
language = translator.get('en')
# To get a translation for "MyKey" in section "MySection"
translation = language.translate("MySection", "MyKey")
# To use placeholder:
class MyClass:
def __init__(self, obj):
self.obj = obj
my_class = MyClass({"name": "Nested"})
# In file: "This is an example with a normal placeholder: %%value%%"
trans1 = translator.get('en').translate("Target", "trans1", value="My Value")
# returns "This is an example with a normal placeholder: My Value"
# In file: "This is an example with a nested placeholder: %%nested.obj.name%%"
trans2 = translator.get('en').translate("Target", "trans2", nested=my_class)
# returns "This is an example with a nested placeholder: Nested"
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
Built Distribution
File details
Details for the file pyfancytranslator-1.0.1.tar.gz
.
File metadata
- Download URL: pyfancytranslator-1.0.1.tar.gz
- Upload date:
- Size: 4.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.12.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 81d8a4a34bde385aa9a424995cb829982a2dfbee1eab1459664b7c4c36f857b1 |
|
MD5 | 079f7cef420fd18be363a9eadeb402be |
|
BLAKE2b-256 | 6359b778f2573b69993c5a39acbb85a1a440b615886fcf871c19ed4ac3b06b40 |
File details
Details for the file pyfancytranslator-1.0.1-py3-none-any.whl
.
File metadata
- Download URL: pyfancytranslator-1.0.1-py3-none-any.whl
- Upload date:
- Size: 4.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.12.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 27ce4b0d90e8542e07025b63c7b8fdd698abc03cf09444d5e47af325f8ae5eef |
|
MD5 | b9980f3a4b28665cd7ba6868c560df5b |
|
BLAKE2b-256 | e34aca40f6f8e2b52f5a5f678c9c9fe8484eabd92f40dd3b2cd53c8a317dc8bc |