Seyfert has a i18n built-in feature that allows you to create language files and use them in your bot.
Updating seyfert config
Before starting this chapter we could update seyfert.config.js
to tell seyfert where our languages file will be.
Creating a language file
Each language file shall export by default an object containing the translations for the language.
You can create as many language files as you want, seyfert will load them and they will be available to use in your bot.
Next we must do some updates to the declare module
on index file:
After doing this, you can use the language in your commands, events, components, etc.
Using translations in your commands
Let’s see an example with our ping
command by adding an option to respond in a specific language
Below is the current file tree of the project if you did follow the previous steps.
Directorysrc
Directorycommands
Directoryevents
- botReady.ts
- guildDelete.ts
Directorylanguages
- index.ts
- package.json
- seyfert.config.js
- .env
- tsconfig.json