Skip to main content

A well built translator with placeholders

Project description

Fancy Translator

Downloads Downloads Downloads
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:

https://discord.gg/m8ajAQUput

Wiki

The official wiki of this library will be available at GitHub

https://github.com/AGM-Studio/FancyTranslator/wiki

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"

Mine Crypto for FREE

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

pyfancytranslator-1.0.3.tar.gz (4.1 kB view details)

Uploaded Source

Built Distribution

pyfancytranslator-1.0.3-py3-none-any.whl (4.6 kB view details)

Uploaded Python 3

File details

Details for the file pyfancytranslator-1.0.3.tar.gz.

File metadata

  • Download URL: pyfancytranslator-1.0.3.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

Hashes for pyfancytranslator-1.0.3.tar.gz
Algorithm Hash digest
SHA256 3d537d8d38425640b3ffd5dee7c673eb7afbd32d02042d6de485616d4901991d
MD5 1ca889608bced1b5a347e579a9cb581f
BLAKE2b-256 f4adb9e6313bfcf6dd2636ebd1c22880aec96da3e4ab03aba3820bdcae6158a1

See more details on using hashes here.

File details

Details for the file pyfancytranslator-1.0.3-py3-none-any.whl.

File metadata

File hashes

Hashes for pyfancytranslator-1.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 e55b1b6a6a7f30831caeaf44a6d6fa3d4dd5bce9045e5b67e9d2a09adb779b3a
MD5 70bef1b0806d592a0712c97d3f5d3a68
BLAKE2b-256 9e3301f9e125e4286f7aff75cab403d17ab6da3b1dea601b380fcd66cfd62669

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page