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

What use cases is this intended to support? #3

Open
gibson042 opened this issue Dec 3, 2020 · 5 comments
Open

What use cases is this intended to support? #3

gibson042 opened this issue Dec 3, 2020 · 5 comments

Comments

@gibson042
Copy link

A relevant observation about how users don't really have locale preference rankings, at least not in many cases: https://twitter.com/hsivonen/status/1301456494534234117

The user’s preference order of languages is the big fallacy of language negotiation in software. In reality, the top-preferred languages don’t have a fixed order but form an accept set and the user wants the least translated version within the accept set.

The ECMA-402 algorithms are not necessarily well-adapted to support that.

@longlho
Copy link
Collaborator

longlho commented Dec 4, 2020

Maybe I've misunderstood, but would this be equivalent to a weighted list of locales with everything having the same weight?

@lifaon74
Copy link

Well actually, I would love to have this functionality.

Here is a practical example:

  • you have many translations for your application (lets say 'fr.json', 'en.json', 'de.json')
  • your user is French Canadian. Its locales will be ['fr-CA', 'en'] (navigator.languages)

Calling Intl.LocaleMatcher.match(navigator.languages, ["fr", "en", "de"], "en"); would help to resolve the best fitting translation file for your app.

=> 'fr.json' in the case of our French Canadian

@longlho
Copy link
Collaborator

longlho commented Jan 25, 2021

yes that's the primary use case we're proposing to support.

@tkrotoff
Copy link

tkrotoff commented Apr 29, 2024

Intl.LocaleMatcher.match(navigator.languages, ["fr", "en", "de"], "en");

yes that's the primary use case we're proposing to support.

@longlho

Then why Intl.LocaleMatcher.match requestedLocales doesn't take (also) a string?

Do we have to manually parse HTTP header Accept-Language or navigator.languages string? (e.g. 'fr-CH, fr;q=0.9, en;q=0.8, de;q=0.7, *;q=0.5')
What about * which is a valid Accept-Language value?

@longlho
Copy link
Collaborator

longlho commented Apr 29, 2024

Yeah you should parse it

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

No branches or pull requests

4 participants