Intl.ListFormat.supportedLocalesOf()

Baseline Widely available

This feature is well established and works across many devices and browser versions. It’s been available across browsers since April 2021.

Intl.ListFormat.supportedLocalesOf() メソッドは、指定したロケールのうち、ランタイムの既定のロケールに代替する必要なくリストの書式化に対応しているロケールを含む配列を返します。

構文

js
Intl.ListFormat.supportedLocalesOf(locales);
Intl.ListFormat.supportedLocalesOf(locales, options);

引数

locales

BCP 47 言語タグを持つ文字列、またはそのような文字列の配列です。 locales 引数の一般的な形式については、 Intl のページを参照してください。

options 省略可

以下のプロパティを持つ可能性があるオブジェクトです。

localeMatcher

使用するロケールの照合アルゴリズムです。指定可能な値は "lookup" および "best fit" で、既定値は "best fit" です。このオプションの詳細は、 Intl のページを参照してください。

返値

指定したロケールタグのサブセットを表す文字列の配列で、ランタイムの既定のロケールで代替する必要なくリストの書式化に対応されているものを含みます。

解説

locales で提供されている言語タグのサブセットを含む配列を返します。返される言語タグは、ランタイムがリストの書式化に対応しているロケールで、使用しているロケール照合アルゴリズムで一致しているとみなされているものです。

supportedLocalesOf() の使用

リストの書式化でインドネシア語とドイツ語に対応しており、バリ語に対応していないランタイムを想定すると、 supportedLocalesOf はインドネシア語とドイツ語の言語タグを変更せずに返しますが、 pinyin の照合はリストの書式化には関係なく、インドネシア語でも使用されません。ここでの lookup アルゴリズムの仕様に注意してください — バリ語話者のほとんどはインドネシア語も理解しているので、 best fit のマッチャーはインドネシア語がバリ語に適切に一致すると判断し、バリ語の言語タグも返すかもしれません。

js
const locales = ["ban", "id-u-co-pinyin", "de-ID"];
const options = { localeMatcher: "lookup" };
console.log(Intl.ListFormat.supportedLocalesOf(locales, options).join(", "));
// → "id-u-co-pinyin, de-ID"

仕様書

Specification
ECMAScript® 2025 Internationalization API Specification
# sec-Intl.ListFormat.supportedLocalesOf

ブラウザーの互換性

Report problems with this compatibility data on GitHub
desktopmobileserver
Chrome
Edge
Firefox
Opera
Safari
Chrome Android
Firefox for Android
Opera Android
Safari on iOS
Samsung Internet
WebView Android
WebView on iOS
Deno
Node.js
supportedLocalesOf

Legend

Tip: you can click/tap on a cell for more information.

Full support
Full support
Partial support
Partial support
See implementation notes.
Has more compatibility info.

関連情報