Localising¶
So your bot has grown, and now you need to localize localise your bot. Well thank god we support localisation then, huh?
To clarify; localisation is a feature of application commands that discord offers, this means the same command will have different names and descriptions depending on the user's locale settings.
How its made:¶
Let's take this nice and simple hello command
1 2 3 4 5 | |
1 2 3 4 5 6 | |
Localised object, and interactions.py and discord wil handle the rest for you. For extra flavour lets make this command more dynamic. 1 2 3 4 5 6 | |
"hello" to ctx.invoked_name the command will always use whatever the user typed to greet them. If you want to know what locale the user is in, simply use ctx.locale. This will work for any object with a name or description field. Simply use LocalisedDesc instead for descriptions. For example, you can localise options, choices, and subcommands.