Botsquad documentation logo

Multi-language support

Bots built in Botsquad have the ability to speak in multiple languages.

By default, a bot can only speak in a single language. However, by enabling multiple languages in the bot’s settings, both the bot’s utterings (say …) and the bot’s content (as configured on the CMS), can be made multilingual.

Configuring multilanguage support

To enable support for multiple locales, go to the bot’s settings dialog (reachable from the home page):

bot settings

The locale needs to be a valid 2-letter language code, for instance nl, en, de, fr, et cetera.

Translating bot scripts

Translating the bot’s scripts works a lot like how normal software translation works, namely, in the code, each string that should be translatable, needs to be marked.

In Bubblescript, this is done by wrapping each string with the _() function, like this:

say _"Hello world!"

Interpolation (variable substitution) is also possible in translation strings, e.g. say _"Hello #{name}"

For more complicated statements, it is sometimes needed to add parentheses around the string: say _("Hello ") + name

When you have added extra locales to your bot, in the bot editor an ‘update translations’ button is visible. Clicking this will generate a CSV file that contains the translation strings:

update translations

As soon as the translation strings are generated, an item in the CMS section of the studio is added, containing the translations for the bot.

bot settings

In this spreadsheet, you can edit each language version of the strings that are used in the bot’s scripts.

Using the bot simulator, you can immediately see the result of the translated strings. You might need to stop and start the simulator in order for all translations to have effect.

When done editing the translations, click the publish button as usual to deploy the changes to your live bot.

Translating dynamic content

Content that is editable in the CMS section can also be translated. For this, each field that needs translations, needs to be marked in the DDL yaml file.

As soon as this is done, each translatable field gets a language indicator next to it, like the following:

translatable content

See the CMS documentation for more information about translatable content.