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:
python3 -m pip install pycord-i18n
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)
i18n = I18n(bot, consider_user_locale=True, de=german)
- Internationalize your commands:
@i18n.localize
@bot.slash_command()
async def hello(ctx):
await ctx.respond(_("Hello, this sentence is in English"))
i18n.localize_commands()
Changelog
v1.2.1
- Fixed an issue with Pycord v2.5 compatibility
v1.2.0
v1.1.0
- Added option localization support