-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
Add navigator.locales to expose additional locale details #3046
Conversation
In existing browser implementations, navigator.languages seems to expose the basics of a locale--language, possibly region and script. However, there are additional locale-related settings which are taken as parameters by ECMA 402 and which fit into BCP 47 language tags. It is possible that just changing the value of navigator.languages could break existing sites. For example, localizations which are selected based on the exact value of navigator.language would find an unknwon language if a Unicode extension tag is appended. For this reason, rather than attempting to expose those options via BCP 47 Unicode extension tags, this patch adds a navigator.locales property. navigator.locales is a FrozenArray of Intl.Locale objects. Intl.Locale is a new proposal in TC39 which makes it easier to parse and manipulate language tags.
By switching over to the actual diff, I found the repository. I will take this line of questioning there: tc39/proposal-intl-locale#3 |
Talking with the W3C I18N WG, there are some concerns with using the Locale as the means of exposing all of these settings, as opposed to some sort of separate settings object. Separately, @jungshik expressed some concern about how/whether we should get these OS settings. Until we resolve these issues, this PR won't be able to move ahead. Closing for now. |
In existing browser implementations, navigator.languages seems
to expose the basics of a locale--language, possibly region and
script. However, there are additional locale-related settings
which are taken as parameters by ECMA 402 and which fit into
BCP 47 language tags.
It is possible that just changing the value of navigator.languages
could break existing sites. For example, localizations which
are selected based on the exact value of navigator.language would
find an unknwon language if a Unicode extension tag is appended.
For this reason, rather than attempting to expose those options
via BCP 47 Unicode extension tags, this patch adds a navigator.locales
property. navigator.locales is a FrozenArray of Intl.Locale objects.
Intl.Locale is a new proposal in TC39 which makes it easier to
parse and manipulate language tags.
This PR is just intended to start a conversation. There are a few open questions:
navigator.locales
, rather than saying that the core of Intl defaults to those values, makes it a bit factored out.navigator.locale
for ergonomics, though there's not much point when you can usenavigator.locales[0]
.navigator.locales[0].language
to get the main language. A downside is that this feature is blocked on Intl.Locale making it through TC39.I'd be interested in any feedback you would have.