Amit
Amit

Reputation: 21

BotFramework-WebChat - dynamically change language

I am using BotFramework-WebChat in multilingual site, where I want to set bot locale on language change which I select from dropdown, can any one guide me for implementing this.

Even after passing changes local it stays with initial set locale, I am using it in Angular 4.

 ngAfterViewInit() {
    BotChat.App({
      directLine: {
        secret: '',
        webSocket: false
      },
      user: {
        id: 'userid',
        name: 'me',
      },
      bot: {
        id: 'botid',
        name: 'bot'
      },
      resize: 'detect',
      formatOptions:
      {
      showHeader: true
      },
      locale: this.translate.currentLang
    }, document.getElementById("bot"));
    console.log(this.translate.currentLang)

  }

Language change is working fine for site but how to change language of chat control?

Upvotes: 2

Views: 1201

Answers (1)

nwxdev
nwxdev

Reputation: 4635

Specify the lang attribute in your top-level HTML tag: <html lang="es">.

Or use the HTML meta tag to define your WebChat client's intended audience language.

https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Language

Next add your localized content strings to the WebChat src/Strings.ts file scoped to your locale code, as described here: https://github.com/Microsoft/BotFramework-WebChat/tree/v3#strings

Finally, build and deploy your customized WebChat instance as described in this section: https://github.com/Microsoft/BotFramework-WebChat/tree/v3#building-web-chat

Upvotes: 3

Related Questions