Intl.DisplayNames.prototype.of()

Intl.DisplayNames.prototype.of() メソッドは、コードを受け取り、Intl.DisplayNames をインスタンス化するときに指定されたロケールとオプションに基づいて文字列を返します。

試してみましょう

構文

of(code)

引数

code

与える code は、 type によって変わります。

返値

その言語における書式化された文字列です。

of メソッドの使用

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"

仕様書

Specification
ECMAScript Internationalization API Specification
# sec-Intl.DisplayNames.prototype.of

ブラウザーの互換性

BCD tables only load in the browser

関連情報