| 1 |
// Copyright (C) 2017 André Bargull. All rights reserved. |
| 2 |
// This code is governed by the BSD license found in the LICENSE file. |
| 3 |
|
| 4 |
/*--- |
| 5 |
esid: sec-intl.getcanonicallocales |
| 6 |
description: > |
| 7 |
Implementations are allowed to canonicalize extension subtag sequences. |
| 8 |
info: | |
| 9 |
8.2.1 Intl.getCanonicalLocales (locales) |
| 10 |
1. Let ll be ? CanonicalizeLocaleList(locales). |
| 11 |
2. Return CreateArrayFromList(ll). |
| 12 |
|
| 13 |
9.2.1 CanonicalizeLocaleList (locales) |
| 14 |
... |
| 15 |
7. Repeat, while k < len |
| 16 |
... |
| 17 |
c. If kPresent is true, then |
| 18 |
... |
| 19 |
v. Let canonicalizedTag be CanonicalizeLanguageTag(tag). |
| 20 |
... |
| 21 |
|
| 22 |
6.2.3 CanonicalizeLanguageTag (locale) |
| 23 |
The specifications for extensions to BCP 47 language tags, such as |
| 24 |
RFC 6067, may include canonicalization rules for the extension subtag |
| 25 |
sequences they define that go beyond the canonicalization rules of |
| 26 |
RFC 5646 section 4.5. Implementations are allowed, but not required, |
| 27 |
to apply these additional rules. |
| 28 |
---*/ |
| 29 |
|
| 30 |
var locale = "it-u-nu-latn-ca-gregory"; |
| 31 |
|
| 32 |
// RFC 6067: The canonical order of keywords is in US-ASCII order by key. |
| 33 |
var sorted = "it-u-ca-gregory-nu-latn"; |
| 34 |
|
| 35 |
var canonicalLocales = Intl.getCanonicalLocales(locale); |
| 36 |
assert.sameValue(canonicalLocales.length, 1); |
| 37 |
|
| 38 |
var canonicalLocale = canonicalLocales[0]; |
| 39 |
assert((canonicalLocale === locale) || (canonicalLocale === sorted)); |