Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[PORT] Pass Locale info from Activity to Adaptive-Expression and support locale in formatNumber prebuilt functions #2692

Merged
merged 23 commits into from
Oct 20, 2020

Conversation

cosmicshuai
Copy link
Contributor

@cosmicshuai cosmicshuai commented Aug 12, 2020

closes: #2202
closes: #2652

  1. Locale is obtained from 'turn.activity.locale' when an incoming activity is recieved and the locale info will be set to 'turn.locale' in memory. Also user can use TurnContext.Locale to get and set locale.

  2. After a locale is set in TurnContext. It will be passed to EvaluationOptions in TemplateEngineLanguageGenerator. Then Options in Adaptive-Expressions will be updated.

Now formatNumber prebuilt function support locale, for example:
formatNumber(12000.3, 4, "de-DE") -> '12.000,3000'

Note: we only make formatNumber to support locale in this PR, the other datetime and string functions need further investigations to keep the input arguments as the same as C#.
Since toLocaleString does not work correctly unless a specified nodejs version.
Moment.js only support locale like 'en', 'de' which is different from our current solution.
#2691 is tracking this issue.

@coveralls
Copy link

coveralls commented Aug 12, 2020

Pull Request Test Coverage Report for Build 168327

  • 45 of 47 (95.74%) changed or added relevant lines in 13 files are covered.
  • 1 unchanged line in 1 file lost coverage.
  • Overall coverage increased (+0.09%) to 83.38%

Changes Missing Coverage Covered Lines Changed/Added Lines %
libraries/adaptive-expressions/src/functionUtils.ts 9 10 90.0%
libraries/botbuilder-lg/src/evaluationOptions.ts 0 1 0.0%
Files with Coverage Reduction New Missed Lines %
libraries/botbuilder-lg/src/evaluationOptions.ts 1 87.32%
Totals Coverage Status
Change from base Build 167849: 0.09%
Covered Lines: 15556
Relevant Lines: 17749

💛 - Coveralls

@boydc2014
Copy link
Contributor

LGTM, i modified some description to highlight the known issue.

@boydc2014 boydc2014 changed the title Pass Locale info from Activity to Adaptive-Expression and support locale in formatNumber prebuilt functions [PORT] Pass Locale info from Activity to Adaptive-Expression and support locale in formatNumber prebuilt functions Aug 12, 2020
@cleemullins
Copy link
Contributor

I don't think we're quite ready to take this. Checked w/ @EricDahlvang and @carlosscastro and we'll push this issue and related PR to R11.

@cosmicshuai cosmicshuai requested a review from a team as a code owner August 20, 2020 08:06
@gabog gabog added this to the R11 milestone Sep 2, 2020
@gabog gabog removed the R11 label Sep 2, 2020
@joshgummersall joshgummersall changed the base branch from master to main September 29, 2020 16:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[PORT] Locale awareness in Adaptive-Expressions [Expressions] formatNumber needs to support locale
8 participants