André Bargull (2013-07-13T12:05:58.000Z)
domenic at domenicdenicola.com (2013-07-16T00:15:21.195Z)
> 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. Only exposing CanonicalizeLanguageTag does not seem useful to me without having access to IsStructurallyValidLanguageTag. Most likely a combined IsStructurallyValidLanguageTag + CanonicalizeLanguageTag function is necessary/wanted for most use cases. > 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(). I don't see why you'd need to change CanonicalizeLocaleList at all. Just let it return the internal list as-is, and then define `Intl.canonicalizeLocaleList` like so: Intl.canonicalizeLocaleList(locales): 1. Let canonicalizedLocaleList be the result of CanonicalizeLocaleList(locales). 2. ReturnIfAbrupt(canonicalizedLocaleList). 3. Return CreateArrayFromList(canonicalizedLocaleList). (ReturnIfAbrupt and CreateArrayFromList are defined in ES6 as internal abstract operations.) It also needs to be considered whether the duplicate removal in CanonicalizeLocaleList creates any issues for users of a potential `Intl.canonicalizeLocaleList` or `Intl.canonicalizeTags` function.