A Simple and lightweight Python internationalization (i18n) tool.
Project description
安装
pip install i18nTool
使用
首先,在工作目录下建立 translation 文件夹,创建对应语言的 json/yaml/yml 文件。
# ./translation/zh_CN.yml
test: 测试
# ./translation/en_US.yml
test: Test
# ./test.py
from i18nTool import I18n
i18n = I18n(langs=["zh_CN","en_US"],file_type="yml")
i18.lang = "zh_CN"
i18n.get("test") # '测试'
i18n.lang = "en_US"
i18.get("test") # 'Test'
i18n.get("test2") # 'test2'
i18n.get("test2", use_default_text=True) # 'Undefined'
i18m.default_text = "Another Value"
i18n.get("test2", use_default_text=True) # 'Another Value'
许可证
Python-i18nTool 使用 MIT 许可证发布。请查看 LICENSE 文件了解相关信息。
鸣谢
开源项目
- PyYAML
A full-featured YAML processing framework for Python
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
i18ntool-0.1.0.tar.gz
(3.9 kB
view details)
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 i18ntool-0.1.0.tar.gz.
File metadata
- Download URL: i18ntool-0.1.0.tar.gz
- Upload date:
- Size: 3.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: pdm/2.22.4 CPython/3.9.21 Linux/6.8.0-1021-azure
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d32a81dc08e649259049bb41d1c2cc42f3a4c647326f192ca068465bff94ae30
|
|
| MD5 |
02c1240df10adb021e67e0e6b82ce02d
|
|
| BLAKE2b-256 |
41fec5eb2c40753cae4b406df054d9fe5f7589643f520d5368697807f2068c39
|
File details
Details for the file i18ntool-0.1.0-py3-none-any.whl.
File metadata
- Download URL: i18ntool-0.1.0-py3-none-any.whl
- Upload date:
- Size: 6.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: pdm/2.22.4 CPython/3.9.21 Linux/6.8.0-1021-azure
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6703947b0b439f231dbb458ecde8465fb9112ab815f3da9a1719ec9876c57f22
|
|
| MD5 |
937a2f20f8d1f845fedde07b1869ed00
|
|
| BLAKE2b-256 |
36d6db1fdd91a21e84c77630bd3f24395397740e36eb9d9e29c9c4fa6d0c44e3
|