Multilingual support

APPLIES TO: Composer v1.x and v2.x

Bot Framework Composer provides multilingual support for bot development in different languages, with English as the default. With simple changes to the settings in Composer, you can author .lg and .lu files in your preferred language, and give your bot the ability to talk to users in different languages.

This articles shows how to build a basic bot in English (en-us) and walks through the process to author the bot in Chinese (zh-cn).

Note

If your bot has LUIS or QnA integrations, you'll also need to consider additional constraints of LUIS supported languages and QnA supported languages.

Prerequisites

How does multilingual support work?

Composer creates copies of your source language files so that you can add manual translation. If you build a bot with just a single dialog, you can access your bot's source code (for example, in the directory: C:\Users\UserName\Documents\Composer\CoolBot) and see the following file structure:

/coolbot
   coolbot.dialog
   /language-generation
      /en-us
            common.en-us.lg
            coolbot.en-us.lg
   /language-understanding
      /en-us
            coolbot.en-us.lu

When adding languages, Composer creates copies of the language files. For examples, if you add Chinese (zh-cn), your bot's file structure will look like the following:

/coolbot
   coolbot.dialog
   /language-generation
      /en-us
         common.en-us.lg
         coolbot.en-us.lg
      /zh-cn
         common.zh-cn.lg
         coolbot.zh-cn.lg
   /language-understanding
      /en-us
         coolbot.en-us.lu
      /zh-cn
         coolbot.zh-cn.lu

Note

Both en-us and zh-cn are locales. A locale is a set of parameters that defines the user's language, region and any special variant preferences that the user wants to see in their user interface.

After adding the languages, you can add manual translations with your source language files as reference. When you are done with the translation process, you must set the locale in the Default language field. This tells your bot in which language it must talk to the users. However, this locale setting will be overwritten by the client's (for example, Bot Framework Emulator) locale setting.

In the next sections, we will use a basic bot in English and walk through the steps to author bots in multiple languages.

Build a basic bot

To show how multilingual support works in Composer, we build a simple bot in English for demo purposes. If you already have a bot, you can skip to the update language settings section.

This bot named MultilangBot consists of a main dialog called MultilangBot, a prebuilt Greeting trigger, and an Intent recognized (LUIS) trigger named Joke with the following trigger phrases:

- Hey bot, tell me a joke.
- Tell me something funny.
- I want to hear something interesting.

The Send a response action added to the trigger node is defined as the following response:

- Here is a joke for you: Parallel lines have so much in common. It's a shame they'll never meet.

The MultilangBot is shown as follows:

Demo bot

When test the bot in the Emulator you get the following responses:

Bot response in English

Update language settings

The first step to author bots in other languages is to add languages. You can add as many languages as you need in the Project Settings page.

  1. In the Project Settings page, select Manage bot languages from the Bot language section.

  2. In the pop-up window, there are three settings that need to be updated:

    1. The first setting is the language to copy resources from. You can leave this as English.

    2. The second setting is the preferred bot authoring languages. You can select multiple languages. Let's select Chinese (Simplified, China). Hover your mouse over the selection you'll see the locale.

    3. The final setting is a check box. When checked, your selected language will be the active authoring language. In cases you have multiple sections in the second part, the first selected language becomes the active authoring language. Let's check the box and select Done.

      Select language

    You'll then see the language being added to the following language list:

    Languages image

    You'll also see the locale changed from en-us to zh-cn in the Composer title bar.

    Title bar

Author your bot in the selected language

When you are done updating the language settings, you can start authoring your bot in your selected authoring language.

  1. In the Bot Responses page, select Show code on the upper right corner of the screen to manually translate the responses in your selected authoring language.

    Translate responses

    Note

    Make sure you select all the required dialogs and manually translate all responses.

  2. In the User Input page, select Show code on the upper right corner of the screen to manually translate the user input in your selected authoring language.

    Translate user input

    Note

    Make sure you select all required dialogs and add manual translations for all user input.

Test

Before testing the bot, set the added language as your default language.

set default language

Testing in Emulator:

Test in Emulator

Testing in Web Chat:

Test in Web Chat