-
Notifications
You must be signed in to change notification settings - Fork 115
Description
There are already two languages for specifying options to a locale:
- A simple locale tag (e.g.,
"en-US") plus an object with further options ({ tz: "Asia/Jerusalem" }) - A BCP 47 string representing the combination of the two (e.g.,
"en-US-u-tz-jerusalm")
Each has some advantages:
- The options object is easier for programmers to read and write, and easier to manipulate one field of.
- The BCP47 tag is easier to pass over the network, and it can passed around as a single object for all the possible locale information (TODO: confirm that everything we represent in options objects has a BCP47 subtag)
An idea here: resolvedOptions() shouldn't return just a plain old object, but an instance of a special class whose toString() method returns the BCP47 locale for those options! This way, we get the best of all worlds. The output of resolvedOptions() can also then be used as the first (and only) argument to constructors like Intl.DateTimeFormat.
These Intl.Locale objects can be used generally as the way of representing locale information within ECMAScript. HTML could include an Array of relevant complex Locales (not just simple locales like "en-US") in navigator.locales, which would be usable either as a string or to get these higher-level properties; detailed user preferences could be reflected in the Locale which would be difficult to reflect in the simple navigator.language. Locales would still have own properties for things that resolvedOptions() currently includes as own properties, and would therefore probably be web-compatible as an upgrade. We probably couldn't just replace navigator.language with a Locale for web compatibility reasons, but there's no reason that the string first argument to formatters can't be more flexible (if it isn't already) by continuing to call ToString() and then parsing the BCP47.
(To clarify, this isn't my idea but was something a group of us came up with yesterday.)
Metadata
Metadata
Assignees
Labels
Type
Projects
Status