Skip to main content

A simple language manager for Python projects.

Project description

Lang Custom v1.1.3

Lang Custom is a Python library for managing translations from JSON files, powered by SQLite for fast queries and low memory usage. Perfect for bots or multilingual apps needing high performance and easy maintenance.


🆕 What's New in v1.1.3?

  • Auto-initialization: Database and JSON files are loaded on import lang_custom. No need for language_setup().
  • ✅ Support for full reload or single-language reload from JSON.
  • ✅ Smart warnings: Suggests corrections for invalid group, name, or type (e.g., "Did you mean 'replies'?").
  • ✅ Unified API: Replaced old lang(), group(), get_text(), random_text() with a single function:
    await lang_custom.get(language="en", group="error", type="text", name="not_found")
    

📦 Installation

pip install lang_custom==1.1.3

🚀 Usage Guide

1. Import the library

import lang_custom

Database is automatically initialized, ready to use 🎉


2. Query language data

text = await lang_custom.get(language="en", group="error", type="text", name="not_found")
print(text)  # Resource not found

random_text = await lang_custom.get(language="en", group="reply", type="random", name="greetings")
print(random_text)  # hello :D, hi :3, or hey there!
  • type="text": Returns a fixed string.
  • type="random": Returns a random item from a list.

3. List available languages

langs = await lang_custom.get_lang()
print(langs)  # ['en', 'vi', 'jp']

4. Reload language data

await lang_custom.reload()  # Reload all from JSON
await lang_custom.reload_language("vi")  # Reload only "vi"

📁 Example _data_language/en.json

{
    "reply": {
        "text": {
            "greeting": "hello :D",
            "welcome": "hi :3"
        },
        "random": {
            "greetings": ["hello :D", "hi :3", "hey there!"]
        }
    },
    "error": {
        "text": {
            "not_found": "Resource not found",
            "invalid": "Invalid input"
        },
        "random": {
            "errors": ["Oops, something went wrong!", "Uh-oh, try again!"]
        }
    }
}

⚠️ Notes

  • Do not delete the _data_language/ folder or DO_NOT_DELETE.db file while the app is running.
  • To update translations, edit JSON files and call reload() or reload_language().

💬 Feedback & Issues

Join our Discord: 👉 https://discord.gg/pGcSyr2bcY


Thank you for using Lang Custom! 🚀
Thank you


Lang Custom v1.1.3

Lang Custom là thư viện Python quản lý bản dịch từ tệp JSON, dùng SQLite để truy vấn nhanh và tiết kiệm bộ nhớ. Lý tưởng cho bot hoặc ứng dụng đa ngôn ngữ cần hiệu suất cao và dễ bảo trì.


🆕 Có gì mới trong v1.1.3?

  • Tự động khởi tạo: Database và JSON được load ngay khi import lang_custom. Không cần gọi language_setup().
  • ✅ Hỗ trợ reload toàn bộ hoặc reload một ngôn ngữ từ JSON.
  • ✅ Cảnh báo thông minh: Gợi ý khi group, name, hoặc type sai (ví dụ: "Did you mean 'replies'?").
  • ✅ Gộp hàm cũ (lang(), group(), get_text(), random_text()) thành một hàm duy nhất:
    await lang_custom.get(language="en", group="error", type="text", name="not_found")
    

📦 Cài đặt

pip install lang_custom==1.1.3

🚀 Hướng dẫn sử dụng

1. Nhập thư viện

import lang_custom

Database tự động khởi tạo, sẵn sàng sử dụng 🎉


2. Truy vấn dữ liệu ngôn ngữ

text = await lang_custom.get(language="en", group="error", type="text", name="not_found")
print(text)  # Resource not found

random_text = await lang_custom.get(language="en", group="reply", type="random", name="greetings")
print(random_text)  # hello :D, hi :3, hoặc hey there!
  • type="text": Lấy chuỗi cố định.
  • type="random": Lấy ngẫu nhiên từ danh sách.

3. Lấy danh sách ngôn ngữ

langs = await lang_custom.get_lang()
print(langs)  # ['en', 'vi', 'jp']

4. Tải lại dữ liệu ngôn ngữ

await lang_custom.reload()  # Tải lại toàn bộ từ JSON
await lang_custom.reload_language("vi")  # Tải lại ngôn ngữ "vi"

📁 Ví dụ file _data_language/en.json

{
    "reply": {
        "text": {
            "greeting": "hello :D",
            "welcome": "hi :3"
        },
        "random": {
            "greetings": ["hello :D", "hi :3", "hey there!"]
        }
    },
    "error": {
        "text": {
            "not_found": "Resource not found",
            "invalid": "Invalid input"
        },
        "random": {
            "errors": ["Oops, something went wrong!", "Uh-oh, try again!"]
        }
    }
}

⚠️ Lưu ý

  • Không xóa thư mục _data_language/ hoặc file DO_NOT_DELETE.db khi ứng dụng đang chạy.
  • Cập nhật bản dịch? Chỉnh file JSON và gọi reload() hoặc reload_language().

💬 Góp ý & Báo lỗi

Tham gia Discord: 👉 https://discord.gg/pGcSyr2bcY


Cảm ơn bạn đã sử dụng Lang Custom! 🚀
Cảm ơn

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

lang_custom-1.1.3.tar.gz (7.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

lang_custom-1.1.3-py3-none-any.whl (7.2 kB view details)

Uploaded Python 3

File details

Details for the file lang_custom-1.1.3.tar.gz.

File metadata

  • Download URL: lang_custom-1.1.3.tar.gz
  • Upload date:
  • Size: 7.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.10

File hashes

Hashes for lang_custom-1.1.3.tar.gz
Algorithm Hash digest
SHA256 dcf992363940b2ca9d191464c5e0ad0999c93b46ad18c5642725c5acde43b952
MD5 107a30e8a4c6ba2e05e6c0af51e58331
BLAKE2b-256 986619ca68b09c952c2406f2447ac56d91892fcd443a6344045f4d5c51f9e6f6

See more details on using hashes here.

File details

Details for the file lang_custom-1.1.3-py3-none-any.whl.

File metadata

  • Download URL: lang_custom-1.1.3-py3-none-any.whl
  • Upload date:
  • Size: 7.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.10

File hashes

Hashes for lang_custom-1.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 874ae5420853c85238f27dc18c5ff80a1795b58bc71ab9eaf53e09b1b1af824c
MD5 64c530885ab6ef8acc2cc1c2223461e6
BLAKE2b-256 c4414173218b3ac078a2c6dc6f3836b8e1b2157f4f95e4ca714741014cfe9a16

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