Andy Earnshaw (2013-07-13T10:17:51.000Z)
domenic at domenicdenicola.com (2013-07-16T00:12:56.548Z)
On Thu, Jul 11, 2013 at 11:52 PM, Zbigniew Braniecki <zbraniecki at mozilla.com> wrote > 1) CanonicalizeLanguageTag [1] > > Because language tags come from developers and users, ability to > canonicalize them is crucial to us. ECMA 402 specifies this function and > all we need is to expose it in the API I was thinking the same thing recently, at least for CanonicalizeLanguageTag. I was working with a platform that gave me a language tag in non-canonical form, meaning I had to either canonicalize it or rename my language files to match the same non-canonical form. Exposing it as `Intl.canonicalizeLanguageTag(tag)` seems like a good idea. > 1.1) CanonicalizeLocaleList [2] > > That would also be nice to have :) I don't think you could expose CanonicalizeLocaleList directly without altering it to return an array, you'd have to do something similar to step 5 of LookupSupportedLocales. I'm not sure we could change that function in the spec without other abstracts potentially being affected by tainted a Array.prototype, so I guess you'd need to specify a new function. In which case I'm wondering if maybe you'd be better off with `Intl.canonicalizeTags(tags)` which would cover both CanonicalizeLanguageTag() and CanonicalizeLocaleList(). > 2) LookupAvailableLocales > > This function has almost identical heuristic to LookupSupportedLocales [3] > with a single difference being in step d). > > Replace: > >> "If *availableLocale* is not *undefined*, then append *locale* to the end of *subset*." > > with: > >> "If *availableLocale* is not *undefined*, then append *availableLocale* to the end of *subset*." > > The reason behind this is that localization frameworks need to choose the > *available* locales that closest match the user preferences. If we used > LookupSupportedLocales, we will receive the locales that user requested, > not ones that are available on the system. > In result on each of those, we'd have to call BestAvailableLocale [4] to > receive the tag name that we can pull resources for. > You can at least work around this for a single locale with Intl.NumberFormat(tag).resolvedOptions().locale. If you're already using the native localisation APIs, this might not be too much of a hindrance. What you're suggesting would need to be a function property of the constructors, e.g. `Intl.NumberFormat.availableLocalesOf()`. I'm not so sure this approach makes sense, though; wouldn't you still have a problem if your own API provided variant data where the system does not?