Skip to main content

EzJsonPy

EzJsonPy is a Python library for loading and managing languages ​​and settings in JSON format.

Installation

To install ezjsonpy, simply use the pip install command

pip install ezjsonpy

Usage

Simple use of language functions.

You need the language files in your project in their respective path

from ezjsonpy import (
    load_language,
    load_languages,
    set_language,
    translate_message,
    get_current_language,
    get_languages
)

# Load a single language
load_language('en', 'path/to/en.json')

# Load multiple languages
languages = [
    {'name': 'en', 'path': 'path/to/en.json'},
    {'name': 'es', 'path': 'path/to/es.json'}
]
load_languages(languages)

# Set the current language
set_language('en')

# Translate a message
message = translate_message('greeting.hello')
print(message)  # Output: Hello (if the translation exists in en.json)

# Get the current language
current_language = get_current_language()
print(current_language)  # Output: en

# Get all loaded languages
loaded_languages = get_languages()
print(loaded_languages)  # Output: {'en': {...}, 'es': {...}}

You can load the language in the main file and get the translations in other files.

main.py

from ezjsonpy import load_language, set_language
from test import example_function

load_language('en', 'en.json')
set_language('en')
example_function()
test.py
from ezjsonpy import translate_message

def example_function():
    print(translate_message('helloWorld'))  # Output: Hello World
    print(translate_message('messages.example'))  # Output: Example Message

en.json

{
    "messages": {
        "example": "Example Message"
    },
    "helloWorld": "Hello World"
}

Complete documentation of language features here

Simple use of settings functions.

You need the setting file in your project in their respective path

from ezjsonpy import (
    load_configuration,
    load_configurations,
    get_config_value,
    set_config_value,
    get_configuration,
    get_configurations,
    remove_configuration,
    remove_all_configurations
)

# Load a single configuration
load_configuration('config1', 'path/to/config1.json')

# Load multiple configurations
configs = [
    {'name': 'config1', 'path': 'path/to/config1.json'},
    {'name': 'config2', 'path': 'path/to/config2.json'}
]
load_configurations(configs)

# Get a value from a configuration
value = get_config_value('some.key', 'config1')
print(f"Value from config1: {value}")

# Set a value in a configuration
set_config_value('some.key', 'new_value', 'config1')

# Verify the value was set
updated_value = get_config_value('some.key', 'config1')
print(f"Updated value from config1: {updated_value}")

# Get the loaded configuration
config = get_configuration('config1')
print(f"Loaded config1: {config}")

# Get all loaded configurations
all_configs = get_configurations()
print(f"All loaded configurations: {all_configs}")

# Remove a specific configuration
remove_configuration('config1')
print(f"Configurations after removing config1: {get_configurations()}")

# Remove all configurations
remove_all_configurations()
print(f"Configurations after removing all: {get_configurations()}")

Like the language, you can load the configuration in your main file and in the modules get the configuration directly

main.py

from ezjsonpy import load_configuration
from test import example_function

load_configuration('default', 'config.json')
load_configuration('anotherConfig', 'anotherConfig.json')
example_function()
test.py
from ezjsonpy import get_config_value


def example_function():
    print(get_config_value('key1', 'default'))  # Output: 'defaultValue'
    print(get_config_value('key1'))  # Default config_name is 'default'. Output: 'defaultValue'
    print(get_config_value('key2', 'anotherConfig'))  # Output: 'anotherValue'

config.json

{
    "key1": "defaultValue"
}

anotherConfig.json

{
    "key2": "anotherValue"
}

Complete documentation of language features here

Metadata

Release files for ezjsonpy 1.0.5

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for ezjsonpy 1.0.5
File Size Uploaded Provenance
ezjsonpy-1.0.5.tar.gz 8.7 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for ezjsonpy 1.0.5
File Interpreter ABI Platform
ezjsonpy-1.0.5-py3-none-any.whl Python 3 none any Details

Total release size: 16.0 kB

Release files / ezjsonpy-1.0.5.tar.gz

Download URL ezjsonpy-1.0.5.tar.gz
Size 8.7 kB
Tags Source
SHA-256 checksum
How to use checksums
e63b485c52c3442697c8c369a9b4457b61d97d308a2828f69826cfb74a77deb6
BLAKE2b-256 checksum
How to use checksums
b16d1559fa9351ae4b1fda0dc7e87254fe018ac6832b240f36bf588ce897e633
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.12.5

Release files / ezjsonpy-1.0.5-py3-none-any.whl

Download URL ezjsonpy-1.0.5-py3-none-any.whl
Size 7.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
0ec148bf83860ef45c67a4fbfef153af5bab8b7ec8975006ad3fe08dc33b4a72
BLAKE2b-256 checksum
How to use checksums
0cd81b71a0f7fec6202d55bcc1541c10b98ca5bc13890169db518cb7cdd69d87
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.12.5

Security for ezjsonpy 1.0.5

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page