Intl.PluralRules.supportedLocalesOf()

Baseline Widely available

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

Intl.PluralRules.supportedLocalesOf() メソッドは、ランタイムの既定のロケールのうち、代替する必要なく複数形の書式で対応されているものが入った配列を返します。

試してみましょう

const locales = ["en-US", "ban", "ar-OM", "de-DE"];
const options = { localeMatcher: "lookup" };

console.log(Intl.PluralRules.supportedLocalesOf(locales, options));
// Expected output: Array ["en-US", "ar-OM", "de-DE"]

構文

js
Intl.PluralRules.supportedLocalesOf(locales);
Intl.PluralRules.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.PluralRules.supportedLocalesOf(locales, options).join(", "));
// → "id-u-co-pinyin, de-ID"

仕様書

Specification
ECMAScript® 2025 Internationalization API Specification
# sec-intl.pluralrules.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
See implementation notes.

関連情報