title | slug |
---|---|
Intl.DisplayNames.prototype.of() |
Web/JavaScript/Reference/Global_Objects/Intl/DisplayNames/of |
{{JSRef}}
Intl.DisplayNames.prototype.of()
メソッドは、コードを受け取り、Intl.DisplayNames をインスタンス化するときに指定されたロケールとオプションに基づいて文字列を返します。
{{EmbedInteractiveExample("pages/js/intl-displaynames.html")}}
of(code);
-
code
-
: 与える
code
は、type
によって変わります。- type が "region" である場合、コードは ISO-3166 地域の 2 文字コードまたは three digits UN M49 Geographic Regions である必要があります。
- type が "script" である場合、コードは ISO-15924 文字体系の 4 文字コードである必要があります。
- type が "language" である場合、コードは languageCode ["-" scriptCode] ["-" regionCode ] *("-" variant ) の形である必要があり、これは UTS 35's Unicode Language and Locale Identifiers grammar の unicode_language_id の構文です。 languageCode は 2 文字の ISO 639-1 言語コードまたは 3 文字の ISO 639-2 言語コードです。
- type が "currency" である場合、コードは 3 文字の ISO 4217 通貨コードである必要があります。
-
その言語における書式化された文字列です。
let regionNames = new Intl.DisplayNames(["en"], { type: "region" });
regionNames.of("419"); // "Latin America"
let languageNames = new Intl.DisplayNames(["en"], { type: "language" });
languageNames.of("fr"); // "French"
let currencyNames = new Intl.DisplayNames(["en"], { type: "currency" });
currencyNames.of("EUR"); // "Euro"
{{Specifications}}
{{Compat}}
- {{jsxref("Intl.DisplayNames")}}