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 (
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
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)
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:
When test the bot in the Emulator you get the following responses:
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.
In the Project Settings page, select Manage bot languages from the Bot language section.
In the pop-up window, there are three settings that need to be updated:
The first setting is the language to copy resources from. You can leave this as English.
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
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.
You'll then see the language being added to the following language list:
You'll also see the locale changed from
zh-cnin the Composer 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.
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.
Make sure you select all the required dialogs and manually translate all responses.
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.
Make sure you select all required dialogs and add manual translations for all user input.
Before testing the bot, set the added language as your default language.
Testing in Emulator:
Testing in Web Chat: