blob: 4b43198903256ae91c3c147e0c7e534030517e56 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
|
---
title: Intl.PluralRules
slug: Web/JavaScript/Reference/Global_Objects/Intl/PluralRules
tags:
- Class
- Internationalization
- Intl
- JavaScript
- Localization
- PluralRules
- Reference
translation_of: Web/JavaScript/Reference/Global_Objects/Intl/PluralRules
---
<div>{{JSRef}}</div>
<p><strong><code>Intl.PluralRules</code></strong> オブジェクトは、複数形が影響する書式や言語ルールを使用できるようにします。</p>
<h2 id="Constructor">コンストラクター</h2>
<dl>
<dt>{{jsxref("PluralRules.PluralRules()", "Intl.PluralRules()")}}</dt>
<dd>新しい <code>Intl.PluralRules</code> オブジェクトを生成します。</dd>
</dl>
<h2 id="Static_methods">静的メソッド</h2>
<dl>
<dt>{{jsxref("PluralRules.supportedLocalesOf", "Intl.PluralRules.supportedLocalesOf()")}}</dt>
<dd>指定したロケールのうち、ランタイムの既定のロケールにフォールバックすることなく対応されているものが入った配列を返します。</dd>
</dl>
<h2 id="Instance_methods">インスタンスメソッド</h2>
<dl>
<dt>{{jsxref("PluralRules.resolvedOptions", "Intl.PluralRules.prototype.resolvedOptions()")}}</dt>
<dd>オブジェクトの初期化中に計算されたロケールとコレクションのオプションを反映したプロパティを持った新しいオブジェクトを返します。</dd>
<dt>{{jsxref("PluralRules.select", "Intl.PluralRules.prototype.select()")}}</dt>
<dd>ロケールを意識した書式化に使用する複数形を示す {{jsxref("String")}} を返します。</dd>
</dl>
<h2 id="Examples">例</h2>
<h3 id="Using_locales">locales の使用</h3>
<p>この例では、ローカライズされた複数形ルールのいくつかを表示します。アプリケーションのユーザーインターフェイスで使う言語の書式を取得するには、 <code>locales</code> 引数に言語 (および必要に応じてフォールバック言語) を指定してください。</p>
<pre class="brush: js">// アラビア語は様々な複数形の規則を持っています
new Intl.PluralRules('ar-EG').select(0);
// → 'zero'
new Intl.PluralRules('ar-EG').select(1);
// → 'one'
new Intl.PluralRules('ar-EG').select(2);
// → 'two'
new Intl.PluralRules('ar-EG').select(6);
// → 'few'
new Intl.PluralRules('ar-EG').select(18);
// → 'many'
</pre>
<h2 id="Polyfill">ポリフィル</h2>
<p><a href="https://formatjs.io/docs/polyfills/intl-pluralrules">formatjs Intl.PluralRules polyfill</a></p>
<h2 id="Specifications">仕様書</h2>
<table class="standard-table">
<thead>
<tr>
<th scope="col">仕様書</th>
</tr>
</thead>
<tbody>
<tr>
<td>{{SpecName('ES Int Draft', '#pluralrules-objects', 'Intl.PluralRules')}}</td>
</tr>
</tbody>
</table>
<h2 id="Browser_compatibility">ブラウザーの互換性</h2>
<div>{{Compat("javascript.builtins.Intl.PluralRules")}}</div>
<h2 id="See_also">関連情報</h2>
<ul>
<li>{{jsxref("Intl")}}</li>
</ul>
|