Skip to content

Internationalization

Bots built in DialoX automatically have the ability to speak in multiple languages.

By default, a bot only speaks 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.

It is also possible to specify a locale code, e.g. en_US and en_UK, if you have bots that need to talk differently in the UK and in the US. In DialoX's web client, the browser's language is used initially to select the right locale string.

Formal vs informal speech

Some languages have different forms of addressing the user, informal or formal. By adding the .FORMAL suffix to a language, you can set up a formal variant of the language, even allowing the bot to switch between informal and formal languages.

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.

Runtime language switching

The language that is used to speak to the user can be changed while the conversation is going on by calling the switch_language statement:

dialog main do
  say _"Hi again"
  say _"Let's continue in dutch"

  switch_language "nl"

  say _"Hi again"
end