pycord-i18n
Internationalization for Pycord
Key Features
- Translated responses
- Command name, description & option localization
- Based on user & server locale (no need for storage!)
Installation
To install this extension, run the corresponding command:
# linux / macOS
python3 -m pip install pycord-i18n
# windows
python -m pip install pycord-i18n
Usage
-
Setup your internationalization files just like sample-german.json. Note that all fields are optional and you can use whichever file format you want as long as you pass the translations into I18n in the given format.
-
Load your files:
import json
with open("sample-german.json", "r") as f:
german = json.load(f)
...
- Create an I18n object:
from pycord.i18n import I18n, _
i18n = I18n(bot, de=german)
# de is the locale code for German
# response translations will be based on the guild's locale, you can make the bot consider the user's locale too by using the following:
i18n = I18n(bot, consider_user_locale=True, de=german)
# all valid locales: da, de, en_GB, en_US, es_ES, fr, hr, it, lt, hu, nl, no, pl, pt_BR, ro, fi, sv_SE, vi, tr, cs, el, bg, ru, uk, hi, th, zh_CN, ja, zh_TW, ko
- Internationalize your commands:
@i18n.localize # command name and description localization
@bot.slash_command()
async def hello(ctx):
await ctx.respond(_("Hello, this sentence is in English"))
# "_()" does the translation
# if you don't want to use `@localize` on every command, simply use the following method after adding the commands to the bot:
i18n.localize_commands()
Changelog
v1.2.1
- Fixed an issue with Pycord v2.5 compatibility
v1.2.0
- Added formatting support
v1.1.0
- Added option localization support
Metadata
Release files for pycord-i18n 1.2.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| pycord-i18n-1.2.1.tar.gz | 4.9 kB | Without provenance | Details for pycord-i18n-1.2.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| pycord_i18n-1.2.1-py3-none-any.whl | Python 3 | none | any | Details for pycord_i18n-1.2.1-py3-none-any.whl |
Total release size: 10.0 kB
Release files / pycord-i18n-1.2.1.tar.gz
| Download URL | pycord-i18n-1.2.1.tar.gz |
|---|---|
| Size | 4.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
3d2f5d2d53421d8efb00021ec6c27546aa7b243a8451159d6bb89c368739b9c7
|
|
BLAKE2b-256 checksum How to use checksums |
9e91fb127364195cf7365ebf82f0d4223adee5c40ca69e92266ad72629406692
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.0.0 CPython/3.10.13
|
Release files / pycord_i18n-1.2.1-py3-none-any.whl
| Download URL | pycord_i18n-1.2.1-py3-none-any.whl |
|---|---|
| Size | 5.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
0e561b26d6a08e4d90a8bf20c2ca287ffa28353b7c44f9827d975847cc71c55f
|
|
BLAKE2b-256 checksum How to use checksums |
03faab5214a99e41be9ebbda442d706d5e80cadfaf948694718f56b53e4cac23
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.0.0 CPython/3.10.13
|
Security for pycord-i18n 1.2.1
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.