Giter Club home page Giter Club logo

Comments (6)

jelhan avatar jelhan commented on June 4, 2024 2

Extending IntlService and overwriting private property _locale could be used as a workaround:

import BaseIntlService from 'ember-intl/services/intl';
import { tracked } from '@glimmer/tracking';

export default class IntlService extends BaseIntlService {
  @tracked _locale = 'en';
}

Maybe _locale should default to a default value specified in intl configuration?

from ember-intl.

jelhan avatar jelhan commented on June 4, 2024 1

What I didn't understand from your description, though, are:

* What issue(s) you encountered because `en-us` is present

* Why you set `_locale` to `'en'` (i.e. which public API did you need that depends on the value of `_locale`?)

Can you explain the issue(s) to me, maybe from the perspective of your end-users?

I don't think it's causing a bug from end-user perspective. I only noticed in a test, which ensures that the list of locales shown in language selector is in sync with the list of translations existing in the project. The language selector is not using IntlService.locales as the source of truth to render the options in the language selector. So no bug from end-user perspective.

from ember-intl.

nirud avatar nirud commented on June 4, 2024 1

Hi,

we hit the same bug, and it was visible to the end user. We used the IntService.locales property as source of truth and we had some custom logic to choose the locale based on the browser language from the list of available translations (= IntService.locales ).

In short, for language that did not have an exact match, we choose another one so that for "en-us" we would choose the "en-gb" translations.

Now there is an exact match for "en-us" the app tries to use "en-us" and then shows "missing translation" texts.

from ember-intl.

ijlee2 avatar ijlee2 commented on June 4, 2024

Hi, @jelhan. Thanks for reporting a bug and providing a minimal reproduction. In your repro app, I could see that en-us is added by default. (My guess is, perhaps as a fallback when a translation is missing.)

At the moment, due to another issue with ember-intl@v6 around TypeScript, I get the impression that we'll want to rethink about ember-intl's API and implementation, and whether there are ways to simplify them. (That is, it may take me a while.)

What I didn't understand from your description, though, are:

  • What issue(s) you encountered because en-us is present
  • Why you set _locale to 'en' (i.e. which public API did you need that depends on the value of _locale?)

Can you explain the issue(s) to me, maybe from the perspective of your end-users?

from ember-intl.

NullVoxPopuli avatar NullVoxPopuli commented on June 4, 2024

This also seems related: #1826
except this crashes the app.

from ember-intl.

ijlee2 avatar ijlee2 commented on June 4, 2024

I have a possible fix in #1847, but it requires a breaking change in the test helper setupIntl(). If the fix is correct, the change would be made in [email protected].

from ember-intl.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.