diff options
| author | Peter Bengtsson <mail@peterbe.com> | 2020-12-08 14:40:17 -0500 |
|---|---|---|
| committer | Peter Bengtsson <mail@peterbe.com> | 2020-12-08 14:40:17 -0500 |
| commit | 33058f2b292b3a581333bdfb21b8f671898c5060 (patch) | |
| tree | 51c3e392513ec574331b2d3f85c394445ea803c6 /files/ja/web/javascript/reference/global_objects/intl/collator | |
| parent | 8b66d724f7caf0157093fb09cfec8fbd0c6ad50a (diff) | |
| download | translated-content-33058f2b292b3a581333bdfb21b8f671898c5060.tar.gz translated-content-33058f2b292b3a581333bdfb21b8f671898c5060.tar.bz2 translated-content-33058f2b292b3a581333bdfb21b8f671898c5060.zip | |
initial commit
Diffstat (limited to 'files/ja/web/javascript/reference/global_objects/intl/collator')
5 files changed, 481 insertions, 0 deletions
diff --git a/files/ja/web/javascript/reference/global_objects/intl/collator/collator/index.html b/files/ja/web/javascript/reference/global_objects/intl/collator/collator/index.html new file mode 100644 index 0000000000..0a3e9b9b42 --- /dev/null +++ b/files/ja/web/javascript/reference/global_objects/intl/collator/collator/index.html @@ -0,0 +1,112 @@ +--- +title: Intl.Collator() コンストラクター +slug: Web/JavaScript/Reference/Global_Objects/Intl/Collator/Collator +tags: + - Collator + - Constructor + - Intl + - JavaScript + - Reference +translation_of: Web/JavaScript/Reference/Global_Objects/Intl/Collator/Collator +--- +<div>{{JSRef}}</div> + +<p><strong><code>Intl.Collator</code></strong> オブジェクトは、言語を考慮した文字列の比較を可能にするオブジェクトである collator のコンストラクターです。</p> + +<div>{{EmbedInteractiveExample("pages/js/intl-collator.html")}}</div> + +<div class="hidden">このデモのソースファイルは GitHub リポジトリに格納されています。デモプロジェクトに協力していただける場合は、 <a href="https://github.com/mdn/interactive-examples">https://github.com/mdn/interactive-examples</a> をクローンしてプルリクエストを送信してください。</div> + +<h2 id="Syntax" name="Syntax">構文</h2> + +<pre class="syntaxbox notranslate">new Intl.Collator([<var>locales</var>[, <var>options</var>]])</pre> + +<h3 id="Parameters" name="Parameters">引数</h3> + +<dl> + <dt><code><var>locales</var></code></dt> + <dd> + <p>任意。 BCP47 言語タグの文字列またはその配列。 <code>locales</code> 引数の一般的な形式や解釈については {{jsxref("Global_Objects/Intl", "Intl のページ", "#Locale_identification_and_negotiation", 1)}}を参照してください。次のUnicode拡張キーが使用可能です。</p> + + <dl> + <dt><code>co</code></dt> + <dd>特定のロケールにおけるバリアントの比較方法を指定します。指定可能な値には "<code>big5han</code>", "<code>dict</code>", "<code>direct</code>", "<code>ducet</code>", "<code>gb2312</code>", "<code>phonebk</code>", "<code>phonetic</code>", "<code>pinyin</code>", "<code>reformed</code>", "<code>searchjl</code>", "<code>stroke</code>", "<code>trad</code>", "<code>unihan</code>" があります。なお "<code>standard</code>" と"<code>search</code>" については、 <code>options</code> 引数の <code>usage</code> プロパティによって代替されるため無視されます (下記参照)。</dd> + <dt><code>kn</code></dt> + <dd>"1" < "2" < "10" のように数値として比較を行うかどうかです。可能な値は "<code>true</code>" および "<code>false</code>" です。このオプションは <code><var>options</var></code> プロパティや、 Unicode 拡張キーで指定できます。両方で指定された場合、 <code><var>options</var></code> プロパティの指定が優先されます。</dd> + <dt><code>kf</code></dt> + <dd>大文字と小文字のどちらを先に並べるかを指定します。指定可能な値は "<code>upper</code>", "<code>lower</code>", "<code>false</code>" (ロケールの既定値を使用) です。このオプションは <code><var>options</var></code> プロパティや、 Unicode 拡張キーで指定できます。両方で指定された場合、 <code><var>options</var></code> プロパティの指定が優先されます。</dd> + </dl> + </dd> + <dt><code><var>options</var></code></dt> + <dd> + <p>任意。次のプロパティの一部またはすべてを持つオブジェクトです。</p> + + <dl> + <dt><code>localeMatcher</code></dt> + <dd>ロケール文字列のマッチングに使用するアルゴリズム。指定可能な値は "<code>lookup</code>" と "<code>best fit</code>" で、既定値は "<code>best fit</code>" です。このオプションの詳細については {{jsxref("Global_Objects/Intl", "Intl のページ", "#Locale_negotiation", 1)}}を参照してください。</dd> + <dt><code>usage</code></dt> + <dd>ソート用の比較をするのか、文字列検索用の比較をするのか。指定可能な値は "<code>sort</code>" または "<code>search</code>" で、既定値は "<code>sort</code>" です。</dd> + <dt><code>sensitivity</code></dt> + <dd> + <p>どの程度の文字の違いまでを区別するかです。以下の値を指定可能です。</p> + + <ul> + <li>"<code>base</code>": ベース文字が異なれば、異なる文字であると評価します。 例: <code>a ≠ b</code>、 <code>a = á</code>、 <code>a = A</code></li> + <li>"<code>accent</code>": ベース文字が異なるか、またはアクセントその他の発音区別符号が異なれば、異なる文字であると評価します。 例: <code>a ≠ b</code>、 <code>a ≠ á</code>、 <code>a = A</code></li> + <li>"<code>case</code>": ベース文字が異なるか、ベース文字が同一でも大文字小文字が異なれば、異なる文字であると評価します。 例: <code>a ≠ b</code>、 <code>a = á</code>、 <code>a ≠ A</code></li> + <li>"<code>variant</code>": ベース文字、アクセントその他の発音区別符号、および大文字小文字のいずれかが異なれば、異なる文字であると評価します。他の違いも考慮されるかもしれません。 例: <code>a ≠ b</code>、 <code>a ≠ á</code>、 <code>a ≠ A</code></li> + </ul> + + <p>既定値は、 <code>usage</code> が "<code>sort</code>" の場合は "<code>variant</code>"、 "<code>search</code>"の場合はロケール依存です。</p> + </dd> + <dt><code>ignorePunctuation</code></dt> + <dd>句読点を無視するかどうか。指定可能な値は <code>true</code> または <code>false</code> で、既定値は <code>false</code> です。</dd> + <dt><code>numeric</code></dt> + <dd>"1" < "2" < "10" のように数値として比較を行うかどうかです。可能な値は <code>true</code> および <code>false</code> です。既定値は <code>false</code> です。このオプションは <code><var>options</var></code> プロパティや、 Unicode 拡張キーで指定できます。両方で指定された場合、 <code><var>options</var></code> プロパティの指定が優先されます。実装はこのプロパティに対応することが要件とはされていません。</dd> + <dt><code>caseFirst</code></dt> + <dd>大文字と小文字のどちらを先に並べるかです。指定可能な値は "<code>upper</code>", "<code>lower</code>", "<code>false</code>" (ロケールの既定の動作) です。大文字と小文字のどちらを先に並べるかは <code><var>options</var></code> プロパティでも Unicode 拡張キーでも指定可能です。両方で指定された場合、 <code><var>options</var></code> プロパティの指定が優先されます。実装はこのプロパティに対応することが要件とはされていません。</dd> + </dl> + </dd> +</dl> + +<h2 id="Examples" name="Examples">例</h2> + +<h3 id="Using_Collator" name="Using_Collator">Collator の使用</h3> + +<p>次の例では、文字列が別の文字列の前であるか、後であるか、または同じレベルで発生したのかの様々な可能性のある結果を示しています。</p> + +<pre class="brush: js notranslate">console.log(new Intl.Collator().compare('a', 'c')); // → a negative value +console.log(new Intl.Collator().compare('c', 'a')); // → a positive value +console.log(new Intl.Collator().compare('a', 'a')); // → 0 +</pre> + +<p>上記のコードで示された結果は、ブラウザーやブラウザーのバージョンによって異なる可能性があることに注意してください。これは、値が実装固有のものであるためです。つまり、仕様では前後の値が負と正の値であることだけが要求されています。</p> + +<h2 id="Specifications" name="Specifications">仕様書</h2> + +<table class="standard-table"> + <thead> + <tr> + <th scope="col">仕様書</th> + </tr> + </thead> + <tbody> + <tr> + <td>{{SpecName('ES Int Draft', '#sec-the-intl-collator-constructor', 'Intl.Collator constructor')}}</td> + </tr> + </tbody> +</table> + +<h2 id="Browser_compatibility" name="Browser_compatibility">ブラウザーの互換性</h2> + +<div> +<div class="hidden">このページの互換性一覧表は構造化データから生成されています。データに協力していただけるのであれば、 <a class="external" href="https://github.com/mdn/browser-compat-data">https://github.com/mdn/browser-compat-data</a> をチェックアウトしてプルリクエストを送信してください。</div> + +<p>{{Compat("javascript.builtins.Intl.Collator.Collator")}}</p> +</div> + +<h2 id="See_also" name="See_also">関連情報</h2> + +<ul> + <li><code><a href="/ja/docs/Web/JavaScript/Reference/Global_Objects/Intl">Intl</a></code></li> +</ul> diff --git a/files/ja/web/javascript/reference/global_objects/intl/collator/compare/index.html b/files/ja/web/javascript/reference/global_objects/intl/collator/compare/index.html new file mode 100644 index 0000000000..947a3a596f --- /dev/null +++ b/files/ja/web/javascript/reference/global_objects/intl/collator/compare/index.html @@ -0,0 +1,88 @@ +--- +title: Intl.Collator.prototype.compare +slug: Web/JavaScript/Reference/Global_Objects/Intl/Collator/compare +tags: + - Collator + - Internationalization + - Intl + - JavaScript + - Method + - Prototype +translation_of: Web/JavaScript/Reference/Global_Objects/Intl/Collator/compare +--- +<div>{{JSRef}}</div> + +<p><strong><code>Intl.Collator.prototype.compare()</code></strong> メソッドは、2つの文字列をこの {{jsxref("Collator")}} オブジェクトのソート順に従って比較します。</p> + +<div>{{EmbedInteractiveExample("pages/js/intl-collator-prototype-compare.html")}}</div> + +<div class="hidden">このデモのソースファイルは GitHub リポジトリに格納されています。デモプロジェクトに協力していただける場合は、 <a href="https://github.com/mdn/interactive-examples">https://github.com/mdn/interactive-examples</a> をクローンしてプルリクエストを送信してください。</div> + +<h2 id="Syntax" name="Syntax">構文</h2> + +<pre class="syntaxbox notranslate"><var>collator</var>.compare(<var>string1</var>, <var>string2</var>)</pre> + +<h3 id="Parameters" name="Parameters">引数</h3> + +<dl> + <dt><code><var>string1</var></code></dt> + <dt><code><var>string2</var></code></dt> + <dd>互いに比較する文字列です。</dd> +</dl> + +<h2 id="Description" name="Description">解説</h2> + +<p><code>compare</code> ゲッター関数は、 <code>string1</code> と <code>string2</code> をこの {{jsxref("Collator")}} オブジェクトのソート順に従って比較した結果を数値で返します。 <code>string1</code> が <code>string2</code> の前にくる場合は負の値、 <code>string1</code> が <code>string2</code> の後にくる場合は正の値、等しいとみなされる場合は 0 を返します。</p> + +<h2 id="Examples" name="Examples">例</h2> + +<h3 id="Using_compare_for_array_sort" name="Using_compare_for_array_sort">配列の並べ替えにおける compare の使用</h3> + +<p>配列の並べ替えのために <code>compare</code> ゲッター関数を使用します。なお、この関数は、取得元の collator にバインドされているので、直接 {{jsxref("Array.prototype.sort()")}} に渡すことができます。</p> + +<pre class="brush: js notranslate">var a = ['Offenbach', 'Österreich', 'Odenwald']; +var collator = new Intl.Collator('de-u-co-phonebk'); +a.sort(collator.compare); +console.log(a.join(', ')); +// → "Odenwald, Österreich, Offenbach" +</pre> + +<h3 id="Using_compare_for_array_search" name="Using_compare_for_array_search">配列の検索における compare の使用</h3> + +<p>配列内の文字列の検索のために <code>compare</code> ゲッター関数を使用します。</p> + +<pre class="brush: js notranslate">var a = ['Congrès', 'congres', 'Assemblée', 'poisson']; +var collator = new Intl.Collator('fr', { usage: 'search', sensitivity: 'base' }); +var s = 'congres'; +var matches = a.filter(v => collator.compare(v, s) === 0); +console.log(matches.join(', ')); +// → "Congrès, congres" +</pre> + +<h2 id="Specifications" name="Specifications">仕様書</h2> + +<table class="standard-table"> + <tbody> + <tr> + <th scope="col">仕様書</th> + </tr> + <tr> + <td>{{SpecName('ES Int Draft', '#sec-intl.collator.prototype.compare', 'Intl.Collator.prototype.compare')}}</td> + </tr> + </tbody> +</table> + +<h2 id="Browser_compatibility" name="Browser_compatibility">ブラウザーの互換性</h2> + +<div> +<div class="hidden">このページの互換性一覧表は構造化データから生成されています。データに協力していただけるのであれば、 <a class="external" href="https://github.com/mdn/browser-compat-data">https://github.com/mdn/browser-compat-data</a> をチェックアウトしてプルリクエストを送信してください。</div> + +<p>{{Compat("javascript.builtins.Intl.Collator.compare")}}</p> +</div> + +<h2 id="See_also" name="See_also">関連情報</h2> + +<ul> + <li>{{jsxref("Collator", "Intl.Collator")}}</li> + <li>{{jsxref("String.prototype.localeCompare()")}}</li> +</ul> diff --git a/files/ja/web/javascript/reference/global_objects/intl/collator/index.html b/files/ja/web/javascript/reference/global_objects/intl/collator/index.html new file mode 100644 index 0000000000..24a3e83d2b --- /dev/null +++ b/files/ja/web/javascript/reference/global_objects/intl/collator/index.html @@ -0,0 +1,109 @@ +--- +title: Intl.Collator +slug: Web/JavaScript/Reference/Global_Objects/Intl/Collator +tags: + - Class + - Collator + - Internationalization + - Intl + - JavaScript +translation_of: Web/JavaScript/Reference/Global_Objects/Intl/Collator +--- +<div>{{JSRef}}</div> + +<p><strong><code>Intl.Collator</code></strong> オブジェクトは、言語を考慮した文字列の比較を可能にします。</p> + +<div>{{EmbedInteractiveExample("pages/js/intl-collator.html")}}</div> + +<div class="hidden">このデモのソースファイルは GitHub リポジトリに格納されています。デモプロジェクトに協力していただける場合は、 <a href="https://github.com/mdn/interactive-examples">https://github.com/mdn/interactive-examples</a> をクローンしてプルリクエストを送信してください。</div> + +<h2 id="Constructor" name="Constructor">コンストラクター</h2> + +<dl> + <dt>{{jsxref("Intl/Collator/Collator", "Intl.Collator()")}}</dt> + <dd>新しい <code>Collator</code> オブジェクトを生成します。</dd> +</dl> + +<h2 id="Static_methods" name="Static_methods">静的メソッド</h2> + +<dl> + <dt>{{jsxref("Collator.supportedLocalesOf", "Intl.Collator.supportedLocalesOf()")}}</dt> + <dd>指定したロケールのうち、ランタイムの既定のロケールに代替されることなく対応されているものを含む配列を返します。</dd> +</dl> + +<h2 id="Instance_methods" name="Instance_methods">インスタンスメソッド</h2> + +<dl> + <dt>{{jsxref("Collator.compare", "Intl.Collator.prototype.compare")}}</dt> + <dd>この {{jsxref("Global_Objects/Collator", "Intl.Collator")}} オブジェクトのソート順に応じて2つの文字列を比較する関数を返します。</dd> + <dt>{{jsxref("Collator.resolvedOptions", "Intl.Collator.prototype.resolvedOptions()")}}</dt> + <dd>ローケルを反映しているプロパティとオブジェクトの初期化中に計算された照合オプションをもった新しいオブジェクトを返します。</dd> +</dl> + +<h2 id="Examples" name="Examples">例</h2> + +<h3 id="Using_Collator" name="Using_Collator">Collator の使用</h3> + +<p>次の例では、一方の文字列が他方の文字列の前である場合、後である場合、および同じレベルである場合の比較結果を表示します。</p> + +<pre class="brush: js notranslate">console.log(new Intl.Collator().compare('a', 'c')); // → 負の値 +console.log(new Intl.Collator().compare('c', 'a')); // → 正の値 +console.log(new Intl.Collator().compare('a', 'a')); // → 0 +</pre> + +<p>上記コードの結果は、ブラウザーやブラウザーのバージョンによって異なる可能性がある点に注意してください。というのも前および後を表す数値については、それぞれ負の数および正の数であることだけが仕様によって定めています。具体的な数値は定められていないため、実装ごとに異なる数値になるかもしれません。</p> + +<h3 id="locales_の使用">locales の使用</h3> + +<p>{{jsxref("Collator.prototype.compare()")}} の結果は言語によって異なります。アプリケーションのユーザインターフェイスで使用される言語のソート順を取得するには、 <code><var>locales</var></code> 引数にその言語 (およびフォールバック用の言語も) を指定してください。</p> + +<pre class="brush: js notranslate">// in German, ä sorts with a +console.log(new Intl.Collator('de').compare('ä', 'z')); +// → 負の値 + +// in Swedish, ä sorts after z +console.log(new Intl.Collator('sv').compare('ä', 'z')); +// → 正の値 +</pre> + +<h3 id="Using_options" name="Using_options">options の使用</h3> + +<p>T{{jsxref("Collator.prototype.compare()")}} の結果は <code><var>options</var></code> 引数でカスタマイズできます。</p> + +<pre class="brush: js notranslate">// in German, ä has a as the base letter +console.log(new Intl.Collator('de', { sensitivity: 'base' }).compare('ä', 'a')); +// → 0 + +// in Swedish, ä and a are separate base letters +console.log(new Intl.Collator('sv', { sensitivity: 'base' }).compare('ä', 'a')); +// → 正の値 +</pre> + +<h2 id="Specifications" name="Specifications">仕様書</h2> + +<table class="standard-table"> + <thead> + <tr> + <th scope="col">仕様書</th> + </tr> + </thead> + <tbody> + <tr> + <td>{{SpecName('ES Int Draft', '#collator-objects', 'Intl.Collator')}}</td> + </tr> + </tbody> +</table> + +<h2 id="Browser_compatibility" name="Browser_compatibility">ブラウザーの互換性</h2> + +<div> +<div class="hidden">このページの互換性一覧表は構造化データから生成されています。データに協力していただけるのであれば、 <a class="external" href="https://github.com/mdn/browser-compat-data">https://github.com/mdn/browser-compat-data</a> をチェックアウトしてプルリクエストを送信してください。</div> + +<p>{{Compat("javascript.builtins.Intl.Collator")}}</p> +</div> + +<h2 id="See_also" name="See_also">関連情報</h2> + +<ul> + <li><code><a href="/ja/docs/Web/JavaScript/Reference/Global_Objects/Intl">Intl</a></code></li> +</ul> diff --git a/files/ja/web/javascript/reference/global_objects/intl/collator/resolvedoptions/index.html b/files/ja/web/javascript/reference/global_objects/intl/collator/resolvedoptions/index.html new file mode 100644 index 0000000000..e57ca7a74c --- /dev/null +++ b/files/ja/web/javascript/reference/global_objects/intl/collator/resolvedoptions/index.html @@ -0,0 +1,87 @@ +--- +title: Intl.Collator.prototype.resolvedOptions() +slug: Web/JavaScript/Reference/Global_Objects/Intl/Collator/resolvedOptions +tags: + - Collator + - Internationalization + - Intl + - JavaScript + - Method + - Prototype +translation_of: Web/JavaScript/Reference/Global_Objects/Intl/Collator/resolvedOptions +--- +<div>{{JSRef}}</div> + +<p><strong><code>Intl.Collator.prototype.resolvedOptions()</code></strong> メソッドは、この {{jsxref("Collator")}} オブジェクトの初期化時に計算されたロケールと照合オプションを反映したプロパティを持つ新しいオブジェクトを返します。</p> + +<div>{{EmbedInteractiveExample("pages/js/intl-collator-prototype-resolvedoptions.html")}}</div> + +<div class="hidden">このデモのソースファイルは GitHub リポジトリに格納されています。デモプロジェクトに協力していただける場合は、 <a href="https://github.com/mdn/interactive-examples">https://github.com/mdn/interactive-examples</a> をクローンしてプルリクエストを送信してください。</div> + +<h2 id="Syntax" name="Syntax">構文</h2> + +<pre class="syntaxbox notranslate"><var>collator</var>.resolvedOptions()</pre> + +<h3 id="Return_value" name="Return_value">返値</h3> + +<p>この {{jsxref("Collator")}} オブジェクトの初期化時に計算されたロケールと照合オプションを反映したプロパティを持つ新しいオブジェクトです。</p> + +<h2 id="Description" name="Description">解説</h2> + +<p>返されるオブジェクトには以下のプロパティがあります。</p> + +<dl> + <dt><code>locale</code></dt> + <dd>実際に使用したロケールの BCP 47 言語タグ。このロケールにつながる入力 BCP 47 言語タグに Unicode 拡張値が要求された場合、要求されたキーと値のペアのうち、このロケールで対応しているものが <code>locale</code> に含まれます。</dd> + <dt><code>usage</code></dt> + <dt><code>sensitivity</code></dt> + <dt><code>ignorePunctuation</code></dt> + <dd><code>options</code> 引数の同名のプロパティで提供された値、または既定値が入ります。</dd> + <dt><code>collation</code></dt> + <dd><code>locale</code> が対応している場合は、 Unicode 拡張キー <code>"co"</code> を使用して要求された値、そうでなければ <code>"default"</code> です。</dd> + <dt><code>numeric</code></dt> + <dt><code>caseFirst</code></dt> + <dd><code>options</code> 引数の同名のプロパティ、または Unicode 拡張キーの <code>"kn"</code> および <code>"kf"</code> で要求された値、または既定値が入ります。実装がこれらのプロパティに対応していない場合は、省略されます。</dd> +</dl> + +<h2 id="Examples" name="Examples">例</h2> + +<h3 id="Using_the_resolvedOptions_method" name="Using_the_resolvedOptions_method">resolvedOptions メソッドの使用</h3> + +<pre class="brush: js notranslate">var de = new Intl.Collator('de', { sensitivity: 'base' }) +var usedOptions = de.resolvedOptions(); + +usedOptions.locale; // "de" +usedOptions.usage; // "sort" +usedOptions.sensitivity; // "base" +usedOptions.ignorePunctuation; // false +usedOptions.collation; // "default" +usedOptions.numeric; // false +</pre> + +<h2 id="Specifications" name="Specifications">仕様書</h2> + +<table class="standard-table"> + <tbody> + <tr> + <th scope="col">仕様書</th> + </tr> + <tr> + <td>{{SpecName('ES Int Draft', '#sec-intl.collator.prototype.resolvedoptions', 'Intl.Collator.prototype.resolvedOptions')}}</td> + </tr> + </tbody> +</table> + +<h2 id="Browser_compatibility" name="Browser_compatibility">ブラウザーの互換性</h2> + +<div> +<div class="hidden">このページの互換性一覧表は構造化データから生成されています。データに協力していただけるのであれば、 <a class="external" href="https://github.com/mdn/browser-compat-data">https://github.com/mdn/browser-compat-data</a> をチェックアウトしてプルリクエストを送信してください。</div> + +<p>{{Compat("javascript.builtins.Intl.Collator.resolvedOptions")}}</p> +</div> + +<h2 id="See_also" name="See_also">関連情報</h2> + +<ul> + <li>{{jsxref("Collator", "Intl.Collator")}}</li> +</ul> diff --git a/files/ja/web/javascript/reference/global_objects/intl/collator/supportedlocalesof/index.html b/files/ja/web/javascript/reference/global_objects/intl/collator/supportedlocalesof/index.html new file mode 100644 index 0000000000..1fd61a49ec --- /dev/null +++ b/files/ja/web/javascript/reference/global_objects/intl/collator/supportedlocalesof/index.html @@ -0,0 +1,85 @@ +--- +title: Intl.Collator.supportedLocalesOf() +slug: Web/JavaScript/Reference/Global_Objects/Intl/Collator/supportedLocalesOf +tags: + - Collator + - Internationalization + - Intl + - JavaScript + - Method +translation_of: Web/JavaScript/Reference/Global_Objects/Intl/Collator/supportedLocalesOf +--- +<div>{{JSRef}}</div> + +<p><strong><code>Intl.Collator.supportedLocalesOf()</code></strong> メソッドは、ランタイムの既定のロケールで代替しなくても照合で対応するロケールを含む配列を返します。</p> + +<div>{{EmbedInteractiveExample("pages/js/intl-collator-prototype-supportedlocalesof.html","shorter")}}</div> + +<div class="hidden">このデモのソースファイルは GitHub リポジトリに格納されています。デモプロジェクトに協力していただける場合は、 <a href="https://github.com/mdn/interactive-examples">https://github.com/mdn/interactive-examples</a> をクローンしてプルリクエストを送信してください。</div> + +<h2 id="Syntax" name="Syntax">構文</h2> + +<pre class="syntaxbox notranslate"><code>Intl.Collator.supportedLocalesOf(<var>locales</var>[, <var>options</var>])</code></pre> + +<h3 id="Parameters" name="Parameters">引数</h3> + +<dl> + <dt><code><var>locales</var></code></dt> + <dd>BCP 47 言語タグを持つ文字列、またはそのような文字列の配列です。 <code>locales</code> 引数の一般的な形式については、 {{jsxref("Global_Objects/Intl", "Intl のページ", "#Locale_identification_and_negotiation", 1)}}を参照してください。</dd> + <dt><code><var>options</var></code></dt> + <dd> + <p>省略可能です。以下のプロパティを持つことがあるオブジェクトです。</p> + + <dl> + <dt><code>localeMatcher</code></dt> + <dd>使用するロケールの一致アルゴリズムです。指定可能な値は <code>lookup</code> および <code>best fit</code> で、既定値は <code>best fit</code> です。このオプションの詳細は、 {{jsxref("Global_Objects/IntlIntl", "Intl のページ", "#Locale_negotiation", 1)}}を参照してください。</dd> + </dl> + </dd> +</dl> + +<h3 id="Return_value" name="Return_value">返値</h3> + +<p>指定したロケールタグのサブセットを表す文字列の配列で、ランタイムの既定のロケールで代替する必要なく複数形の書式で対応されているものを含みます。</p> + +<h2 id="Description" name="Description">解説</h2> + +<p><code>locales</code> で指定されている言語タグのサブセットを含む配列を返します。返される言語タグは、ランタイムがロケールの照合に対応しているもので、使用しているロケール一致アルゴリズムが、既定のロケールで代替することなく一致するとみなすものです。</p> + +<h2 id="Examples">Examples</h2> + +<h3 id="Using_supportedLocalesOf">Using <code>supportedLocalesOf</code></h3> + +<p>インドネシア語とドイツ語に対応しているもの、バリ語に対応していないランタイムを想定すると、ピンインの照合がインドネシア語では使用されておらず、インドネシアに特化したドイツ語がサポートされている可能性が低いとしても、 <code>supportedLocalesOf</code> はインドネシア語とドイツ語の言語タグを変更せずに返します。これは <code>lookup</code> アルゴリズムの仕様であること注意してください。 <code>best fit</code> マッチャーは、ほとんどのバリ語話者がインドネシア語も理解しているので、インドネシア語がバリ語に適切であると判断し、バリ語の言語タグも返すかもしれません。</p> + +<pre class="brush: js notranslate">var locales = ['ban', 'id-u-co-pinyin', 'de-ID']; +var options = { localeMatcher: 'lookup' }; +console.log(Intl.Collator.supportedLocalesOf(locales, options).join(', ')); +// → "id-u-co-pinyin, de-ID" +</pre> + +<h2 id="Specifications" name="Specifications">仕様書</h2> + +<table class="standard-table"> + <tbody> + <tr> + <th scope="col">仕様書</th> + </tr> + <tr> + <td>{{SpecName('ES Int Draft', '#sec-intl.collator.supportedlocalesof', 'Intl.Collator.supportedLocalesOf')}}</td> + </tr> + </tbody> +</table> + +<h2 id="Browser_compatibility" name="Browser_compatibility">ブラウザーの互換性</h2> + +<div> +<div class="hidden">このページの互換性一覧表は構造化データから生成されています。データに協力していただけるのであれば、 <a class="external" href="https://github.com/mdn/browser-compat-data">https://github.com/mdn/browser-compat-data</a> をチェックアウトしてプルリクエストを送信してください。</div> + +<p>{{Compat("javascript.builtins.Intl.Collator.supportedLocalesOf")}}</p> +</div> + +<h2 id="See_also" name="See_also">関連情報</h2> + +<ul> + <li>{{jsxref("Collator", "Intl.Collator")}}</li> +</ul> |
