| 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 |
Call Intl.getCanonicalLocales function with grandfathered language tags. |
| 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 CanonicalizeLanguageTag abstract operation returns the canonical and case-regularized |
| 24 |
form of the locale argument (which must be a String value that is a structurally valid |
| 25 |
BCP 47 language tag as verified by the IsStructurallyValidLanguageTag abstract operation). |
| 26 |
A conforming implementation shall take the steps specified in RFC 5646 section 4.5, or |
| 27 |
successor, to bring the language tag into canonical form, and to regularize the case of |
| 28 |
the subtags. Furthermore, a conforming implementation shall not take the steps to bring |
| 29 |
a language tag into "extlang form", nor shall it reorder variant subtags. |
| 30 |
|
| 31 |
The specifications for extensions to BCP 47 language tags, such as RFC 6067, may include |
| 32 |
canonicalization rules for the extension subtag sequences they define that go beyond the |
| 33 |
canonicalization rules of RFC 5646 section 4.5. Implementations are allowed, but not |
| 34 |
required, to apply these additional rules. |
| 35 |
|
| 36 |
includes: [testIntl.js] |
| 37 |
---*/ |
| 38 |
|
| 39 |
// Generated from http://www.iana.org/assignments/language-subtag-registry/language-subtag-registry |
| 40 |
// File-Date: 2017-08-15 |
| 41 |
var canonicalizedTags = { |
| 42 |
// Irregular tags. |
| 43 |
"en-gb-oed": "en-GB-oxendict", |
| 44 |
"i-ami": "ami", |
| 45 |
"i-bnn": "bnn", |
| 46 |
"i-default": "i-default", |
| 47 |
"i-enochian": "i-enochian", |
| 48 |
"i-hak": "hak", |
| 49 |
"i-klingon": "tlh", |
| 50 |
"i-lux": "lb", |
| 51 |
"i-mingo": "i-mingo", |
| 52 |
"i-navajo": "nv", |
| 53 |
"i-pwn": "pwn", |
| 54 |
"i-tao": "tao", |
| 55 |
"i-tay": "tay", |
| 56 |
"i-tsu": "tsu", |
| 57 |
"sgn-be-fr": "sfb", |
| 58 |
"sgn-be-nl": "vgt", |
| 59 |
"sgn-ch-de": "sgg", |
| 60 |
|
| 61 |
// Regular tags. |
| 62 |
"art-lojban": "jbo", |
| 63 |
"cel-gaulish": "cel-gaulish", |
| 64 |
"no-bok": "nb", |
| 65 |
"no-nyn": "nn", |
| 66 |
"zh-guoyu": "cmn", |
| 67 |
"zh-hakka": "hak", |
| 68 |
"zh-min": "zh-min", |
| 69 |
"zh-min-nan": "nan", |
| 70 |
"zh-xiang": "hsn", |
| 71 |
}; |
| 72 |
|
| 73 |
// make sure the data above is correct |
| 74 |
Object.getOwnPropertyNames(canonicalizedTags).forEach(function (tag) { |
| 75 |
var canonicalizedTag = canonicalizedTags[tag]; |
| 76 |
assert( |
| 77 |
isCanonicalizedStructurallyValidLanguageTag(canonicalizedTag), |
| 78 |
"Test data \"" + canonicalizedTag + "\" is not canonicalized and structurally valid language tag." |
| 79 |
); |
| 80 |
}); |
| 81 |
|
| 82 |
Object.getOwnPropertyNames(canonicalizedTags).forEach(function (tag) { |
| 83 |
var canonicalLocales = Intl.getCanonicalLocales(tag); |
| 84 |
assert.sameValue(canonicalLocales.length, 1); |
| 85 |
assert.sameValue(canonicalLocales[0], canonicalizedTags[tag]); |
| 86 |
}); |