semvec/pypi-packages huggingface dataset:
pydang 1.0.1
A simple language manager for large and small multi-language programs in a very simple way.
License: MIT

# PyDang - Language Manager

A simple language manager for large and small multi-language programs in a very simple way.

# Installation
Python 3.x is recommended
```sh
# Linux/macOS
python3 -m pip install -U pydang

# Windows
py -3 -m pip install -U pydang
```

# Quick Example
```python
# Import the init method
from pydang import init

# init method returns a class with 2 public methods, set and get
translator = init()

# By default it loads all languages â€‹â€‹according to the folder name "locales/<lang>"
en = translator.get('en-US')
# That is, if the <lang> folder is called "en-US" it is the key to obtain it
# By default, if it cannot find the language indicated in the "get()" method, the default language will be en-US.
# The folder "locals" will only look for it from the cwd
# This folder and the default language can be changed in the init method options

# the method "get()" if it gets the language it returns a function

print(en('common:HelloWorld')) 
#  "common" is the name of the JSON, ":" indicates that the following is a property of said JSON

print(en('path/to/file:PropertyInJson'))
# it will look in file "locales/<lang>/path/to/file" for the property "PropertyInJson"
# If the property is a list it will automatically join this list with a line break
```
With options
```python
from pydang import init

translator = init({
    'locales': 'path/to/locales', # start from cwd
    'fallbackLang': 'pt-BR' # Default language if it cannot find the language specified in the get() method
})

en = translator.get('en-US')

print(en('common:Yes'))
```
With arguments, it allows you to pass values â€‹â€‹to string strings in an easy way
```python
from pydang import init

translator = init()

en = translator.get('en-US')

word = en('common:Test', {'value': 81})
# In the JSON common.Test:
# "the value of this key is #{value}"
print(word)

# replaces the content inside the "string template" and becomes like a key of a list
# " #{key1} #{key2} #{aaaa}"
# -> en('file:Property', { 'key1': 'value', 'key2', 'value2', 'aaaa': 8 })
```
a "string template" uses: `#{thing}` then "thing" will become the key as an argument to incorporate it as a value there.

> Note: It does not evaluate python code!

This package is created for personal use but I decided to put it public and as a package if it can be used by someone.