botbuilder-python icon indicating copy to clipboard operation
botbuilder-python copied to clipboard

port: Localization: fix bugs around inconsistent locale + first step to centralize locale resolution (#5218)

Open github-actions[bot] opened this issue 5 years ago • 0 comments

The changes in Localization: fix bugs around inconsistent locale + first step to centralize locale resolution (#5218) may need to be ported to maintain parity with microsoft/botbuilder-dotnet.

Fixes #5101

Description

Current locale resolution is inconsistent and can lead to scenarios where different components honor different locales. We want to get to a point where 1) locale resolution is centralized and 2) locale resolution is configurable. We are not doing that here. The aim of this PR is to have all components receive locale first from a single location (dialogContext.GetLocale()). This location is not ideal but it is public surface and we have to support it. The result after this pr is:

  • DialogContext.GetLocale() prioritizes turn.locale > turn.activity.locale > default language
  • Dialogs and LG use DialogContext.GetLocale as main locale source
  • Locale is honored consistently in SDK
  • Locale change works smoothly

Testing

Regression testing passed and new tests added. Working on a e2e multilanguage sample with language selection based on this code (which is currently impossible to build without this PR).

What happens if we don't take this?

  • Broken scenario 1 - locale consistency: Most of the bot takes the turn.locale as source of truth. Other components (confirm input, choice input, multi language generator) will take activity locale as source of truth. Result: the bot mixes 2 locales.

  • Broken scenario 2 - Language selection: I'm a bot author. I support english and spanish. Current locale is en-us. If the user says 'espanol', I have a SetProperty that will set turn.locale=es-ar, and the bot should speak in spanish. Result without this PR: the bot will not change language.

Next steps

  • Create design for users to provide their own locale resolution logic, both code-first and declarative (ordered list of memory scopes)
  • Deprecate public area that is not consistent and / or intuitive: TurnContext.Locale, DialogContext.GetLocale(), ChoiceInput.DefaultLocale, ConfirmInput.DefaultLocale, etc

Please review and, if necessary, port the changes.

github-actions[bot] avatar Feb 16 '21 03:02 github-actions[bot]