locales to a command, with one entry per language:
src/commands/greet.ts
/saluer qui ton and picks “Chaleureux”; your code still receives options.who and 'warm'.
locales is what Discord shows before the command is used. A command without description in its file has them in the commands of the language files of src/messages/ instead, next to the texts of the bot: a command has its texts in one place, and the editor only offers there the commands their file does not describe. What your bot answers is translated with t.The shape of
locales is in the reference.What can be translated
- Everything is optional. Translate only what you want, in the languages you want: what is missing is shown as declared.
- Your code does not change.
options.whois stilloptions.whofor a French speaker who seesqui, and a choice is still'warm'when the person picked “Chaleureux”. - Your editor checks it. A language Discord does not know, an option the command does not have or a choice that does not exist is underlined.
- The keys of
choicesare the choices as you declared them: the values of a list ('warm'), or the keys of an object ('Small'for{ Small: 1 }). The choices of a number option are written as texts:{ '1': 'Un' }.
The languages
The keys oflocales are the languages of Discord, as the Locale values write them: fr, de, es-ES, pt-BR, ja… A language Discord does not know is refused when the file loads:
en-GB and en-US; Spanish is es-ES and es-419; Chinese is zh-CN and zh-TW.
Folders are not translated
A folder is not translated:/mod ban can be shown as /mod bannir, never as /modération bannir. The name of a folder is what Discord shows in every language. If your bot speaks one language, name the folder in that language.
What is checked
Translations are checked when the file loads, like the rest of the command:A translated name Discord refuses
A translated name Discord refuses
A description too long
A description too long
An option or a choice the command does not have
An option or a choice the command does not have
Two options with the same name in one language
Two options with the same name in one language
In each language, every option keeps a name of its own, whether translated or not:
Answering in their language
Translations change what Discord shows. To answer in the language of the person, declare the texts of your bot withlanguage(), one declaration per language, and use the t your function receives: it already speaks the language of who will read the answer. See Translated messages.
src/commands/hello.ts
interaction.locale is the language of the Discord of the person, as Discord writes it ('fr', 'en-US'…), for the rare case where you need it yourself.
Events
React to what happens on Discord.
Reference: command()
Every field and type of a command.