This project demonstrates how to set up gettext localization and integrate it into discord.py v2.0.
Check out the onboarding if you want to learn how gettext and the package works. If you just want to test out the package, then:
-
Install this repository
python -m pip install git+https://github.com/thegamecracks/discord.py-i18n-demo
-
Create a config.toml file with your bot token
[bot] token = "Bot token from https://discord.com/developers/applications"
-
Start the bot
python -m dpygt
-
Use the "<@mention> sync" text command to register application commands
- Python 3.11 or greater
gettext
and its associated utilities, particularlymsgfmt
- Not sure how to get this? See the onboarding
discord.py can be used with any translation library, not just gettext. If you are interested in alternatives, consider using Project Fluent via the fluent-compiler package which provides more comprehensive localization features such as arbitrarily-defined message variants, message cross-references, and automatic numeric/datetime formatting (see also Fluent vs. gettext).
Want to add translations? Fork this repository, create a new branch, commit your changes there, then make a pull request. You may want to read the onboarding to learn how localizations are done, or look at how existing localizations are written.