A simple language manager for Python projects.
Project description
Lang Custom v1.1.2
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.2?
- ✅ Auto-initialization: Database and JSON files are loaded on
import lang_custom. No need forlanguage_setup(). - ✅ Support for full reload or single-language reload from JSON.
- ✅ Smart warnings: Suggests corrections for invalid
group,name, ortype(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.2
🚀 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 orDO_NOT_DELETE.dbfile while the app is running. - To update translations, edit JSON files and call
reload()orreload_language().
💬 Feedback & Issues
Join our Discord: 👉 https://discord.gg/pGcSyr2bcY
Thank you for using Lang Custom! 🚀
Lang Custom v1.1.2
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.2?
- ✅ Tự động khởi tạo: Database và JSON được load ngay khi
import lang_custom. Không cần gọilanguage_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ặctypesai (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.2
🚀 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 fileDO_NOT_DELETE.dbkhi ứng dụng đang chạy. - Cập nhật bản dịch? Chỉnh file JSON và gọi
reload()hoặcreload_language().
💬 Góp ý & Báo lỗi
Tham gia Discord: 👉 https://discord.gg/pGcSyr2bcY
Cảm ơn bạn đã sử dụng Lang Custom! 🚀
Project details
Release history Release notifications | RSS feed
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
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file lang_custom-1.1.2.tar.gz.
File metadata
- Download URL: lang_custom-1.1.2.tar.gz
- Upload date:
- Size: 7.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
821e2369e9f279855f46d151c3a46a263d88e82bea45524d7187a1462bb3bfb9
|
|
| MD5 |
326d229149e6a244a0c410a3cc865cf5
|
|
| BLAKE2b-256 |
496e2334d03c5e2bfc06e614fc70499311d8c15006f45c90b1fb258ce5addc09
|
File details
Details for the file lang_custom-1.1.2-py3-none-any.whl.
File metadata
- Download URL: lang_custom-1.1.2-py3-none-any.whl
- Upload date:
- Size: 6.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e4e54795f563bb2f620f40596c9e88b3416dbe13b55b5de529aaaeb3db66cbfa
|
|
| MD5 |
7eb5b1c048b6a512fa337b0941955018
|
|
| BLAKE2b-256 |
67f3c9133c24057c5297bd3d22473bea9c36d840b25bad11eca70a5dd0ed0fb5
|