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

set locale normalizes localeName while getOrCreateIntl does not #1707

Closed
2 tasks done
dagroe opened this issue Jul 21, 2022 · 0 comments · Fixed by #1888
Closed
2 tasks done

set locale normalizes localeName while getOrCreateIntl does not #1707

dagroe opened this issue Jul 21, 2022 · 0 comments · Fixed by #1888

Comments

@dagroe
Copy link

dagroe commented Jul 21, 2022

  • I am on the latest ember-intl version
  • I have searched the issues of this repo and believe that this is not a duplicate

Environment

  • Ember Version: 3.28.9
  • Ember CLI Version: 4.5.0
  • Ember Intl Version: 6.0.0-beta.3
  • Browser(s): Chrome 103.0.5060.134
  • Node Version: 12.14.1

Steps to Reproduce

My browsers locale is set to de-DE. I am setting the locales on the intl service as

this.intl.setLocale(['de-DE', 'en-gb']);

During setLocale(locale) the following happens:

setLocale(locale) {
  (true && !(locale) && (0, _debug.assert)(`[ember-intl] no locale has been set!  See: https://ember-intl.github.io/ember-intl/docs/quickstart#4-configure-ember-intl`, locale));
  this.locale = locale;
  this.getOrCreateIntl(locale);
}

Via this.locale = locale the setter is called, which normalizes the passed locales and sets this._locale = ['de-de', 'en-gb'].
Then getOrCreateIntl creates the intl but doesn't normalize de-DE to de-de, which creates an entry in this._intls under key de-DE.

Now if I translate via the t helper in a template, in serviceFormatterProxy the locale is set via this.locale is set to ['de-de', 'en-gb'] (via this._locale).
However, intl = this.getIntl(locale); sets intl to undefined since there is no entry for de-DE in this._intls.

As a consequence, the format method in FormatMessage throws an error since intl is undefined.

Happens only in chrome when language is set to German.

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 a pull request may close this issue.

1 participant