Building a bot that supports different languages requires you to separate your string literals from your components code.
First, you need to go to your
src/locales folder and add a js file for each language you want to support. For example:
Now, you have to export all the languages that your bot needs.
In order to use these locales in your responses, you need to import the
You can access an object from locales with the
this.context.getString method. We suggest you import
_, as it will make your code more concise. Then you can access the string with
stringID is the dotted path to access the string in you locales object.
If you want to change the language for the current user, use the method
Here is an example of a component using locales: