// Test all getters return the expected results. var langtag = "de-latn-de-fonipa-1996-u-ca-gregory-co-phonebk-hc-h23-kf-true-kn-false-nu-latn"; var loc = new Intl.Locale(langtag);
assert.sameValue(loc.toString(), "de-Latn-DE-1996-fonipa-u-ca-gregory-co-phonebk-hc-h23-kf-kn-false-nu-latn"); assert.sameValue(loc.baseName, "de-Latn-DE-1996-fonipa"); assert.sameValue(loc.language, "de"); assert.sameValue(loc.script, "Latn"); assert.sameValue(loc.region, "DE"); assert.sameValue(loc.variants, "1996-fonipa"); assert.sameValue(loc.calendar, "gregory"); assert.sameValue(loc.collation, "phonebk"); assert.sameValue(loc.hourCycle, "h23"); if ("caseFirst" in loc) { assert.sameValue(loc.caseFirst, "");
} if ("numeric" in loc) { assert.sameValue(loc.numeric, false);
} assert.sameValue(loc.numberingSystem, "latn");
// Replace all components through option values and validate the getters still // return the expected results. var loc = new Intl.Locale(langtag, {
language: "ja",
script: "jpan",
region: "jp",
variants: "Hepburn",
calendar: "japanese",
collation: "search",
hourCycle: "h24",
caseFirst: "false",
numeric: "true",
numberingSystem: "jpanfin",
});
assert.sameValue(loc.toString(), "ja-Jpan-JP-hepburn-u-ca-japanese-co-search-hc-h24-kf-false-kn-nu-jpanfin"); assert.sameValue(loc.baseName, "ja-Jpan-JP-hepburn"); assert.sameValue(loc.language, "ja"); assert.sameValue(loc.script, "Jpan"); assert.sameValue(loc.region, "JP"); assert.sameValue(loc.variants, "hepburn"); assert.sameValue(loc.calendar, "japanese"); assert.sameValue(loc.collation, "search"); assert.sameValue(loc.hourCycle, "h24"); if ("caseFirst" in loc) { assert.sameValue(loc.caseFirst, "false");
} if ("numeric" in loc) { assert.sameValue(loc.numeric, true);
} assert.sameValue(loc.numberingSystem, "jpanfin");
// Replace only some components through option values and validate the getters // return the expected results. var loc = new Intl.Locale(langtag, {
language: "fr",
region: "ca",
collation: "standard",
hourCycle: "h11",
});
assert.sameValue(loc.toString(), "fr-Latn-CA-1996-fonipa-u-ca-gregory-co-standard-hc-h11-kf-kn-false-nu-latn"); assert.sameValue(loc.baseName, "fr-Latn-CA-1996-fonipa"); assert.sameValue(loc.language, "fr"); assert.sameValue(loc.script, "Latn"); assert.sameValue(loc.region, "CA"); assert.sameValue(loc.variants, "1996-fonipa"); assert.sameValue(loc.calendar, "gregory"); assert.sameValue(loc.collation, "standard"); assert.sameValue(loc.hourCycle, "h11"); if ("caseFirst" in loc) { assert.sameValue(loc.caseFirst, "");
} if ("numeric" in loc) { assert.sameValue(loc.numeric, false);
} assert.sameValue(loc.numberingSystem, "latn");
// Check that "und" language subtag returns "und" for `language` getter var loc = new Intl.Locale("und");
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.