From 33058f2b292b3a581333bdfb21b8f671898c5060 Mon Sep 17 00:00:00 2001 From: Peter Bengtsson Date: Tue, 8 Dec 2020 14:40:17 -0500 Subject: initial commit --- .../global_objects/intl/pluralrules/index.html | 86 ++++++++++++++++++++++ .../intl/pluralrules/select/index.html | 84 +++++++++++++++++++++ .../intl/pluralrules/supportedlocalesof/index.html | 83 +++++++++++++++++++++ 3 files changed, 253 insertions(+) create mode 100644 files/ja/web/javascript/reference/global_objects/intl/pluralrules/index.html create mode 100644 files/ja/web/javascript/reference/global_objects/intl/pluralrules/select/index.html create mode 100644 files/ja/web/javascript/reference/global_objects/intl/pluralrules/supportedlocalesof/index.html (limited to 'files/ja/web/javascript/reference/global_objects/intl/pluralrules') diff --git a/files/ja/web/javascript/reference/global_objects/intl/pluralrules/index.html b/files/ja/web/javascript/reference/global_objects/intl/pluralrules/index.html new file mode 100644 index 0000000000..da798e66e2 --- /dev/null +++ b/files/ja/web/javascript/reference/global_objects/intl/pluralrules/index.html @@ -0,0 +1,86 @@ +--- +title: Intl.PluralRules +slug: Web/JavaScript/Reference/Global_Objects/Intl/PluralRules +tags: + - Class + - Internationalization + - Intl + - JavaScript + - PluralRules +translation_of: Web/JavaScript/Reference/Global_Objects/Intl/PluralRules +--- +
{{JSRef}}
+ +

Intl.PluralRules オブジェクトは、複数形が影響する書式や言語ルールを使用できるようにします。

+ +

コンストラクター

+ +
+
{{jsxref("PluralRules.PluralRules()", "Intl.PluralRules.PluralRules()")}}
+
新しい Intl.PluralRules オブジェクトを生成します。
+
+ +

静的メソッド

+ +
+
{{jsxref("Intl/PluralRules/supportedLocalesOf", "Intl.PluralRules.supportedLocalesOf()")}}
+
指定したロケールのうち、ランタイムの既定のロケールにフォールバックすることなく対応されているものが入った配列を返します。
+
+ +

インスタンスメソッド

+ +
+
{{jsxref("Intl/PluralRules/resolvedOptions", "Intl.PluralRules.prototype.resolvedOptions()")}}
+
オブジェクトの初期化中に計算されたロケールとコレクションのオプションを反映したプロパティを持った新しいオブジェクトを返します。
+
{{jsxref("Intl/PluralRules/select", "Intl.PluralRules.prototype.select()")}}
+
ロケールを意識した書式化に使用する複数形を示す {{jsxref("String")}} を返します。
+
+ +

+ +

locales の使用

+ +

この例では、ローカライズされた複数形ルールのいくつかをお見せします。アプリケーションのユーザーインターフェイスで使う言語のフォーマットを取得するには、 locales 引数に言語 (および必要に応じてフォールバック言語) を指定してください。

+ +
// アラビア語は別な複数形の規則を持っています。
+
+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'
+
+ +

仕様書

+ + + + + + + + + + + + +
仕様書
{{SpecName('ES Int Draft', '#pluralrules-objects', 'Intl.PluralRules')}}
+ +

ブラウザーの互換性

+ +
+ + +

{{Compat("javascript.builtins.Intl.PluralRules")}}

+
+ +

関連情報

+ + diff --git a/files/ja/web/javascript/reference/global_objects/intl/pluralrules/select/index.html b/files/ja/web/javascript/reference/global_objects/intl/pluralrules/select/index.html new file mode 100644 index 0000000000..af854453f6 --- /dev/null +++ b/files/ja/web/javascript/reference/global_objects/intl/pluralrules/select/index.html @@ -0,0 +1,84 @@ +--- +title: Intl.PluralRules.select() +slug: Web/JavaScript/Reference/Global_Objects/Intl/PluralRules/select +tags: + - Internationalization + - Intl + - JavaScript + - Method + - PluralRules + - メソッド + - 国際化 +translation_of: Web/JavaScript/Reference/Global_Objects/Intl/PluralRules/select +--- +
{{JSRef}}
+ +

Intl.PluralRules.prototype.select メソッドは、ロケールを考慮した書式設定に使用する複数形ルールを示す String を返します。

+ +

構文

+ +
pluralCategory = pluralRule.select(number)
+ +

引数

+ +
+
number
+
複数のルールを取得するための数値です。
+
+ +

返値

+ +

数字の複数形のカテゴリを表す string で、 zero, one, two, few, many, other のいずれかになります。

+ +

解説

+ +

この関数は、 {{jsxref("PluralRules")}} オブジェクトのロケールや書式オプションに応じて、複数形のカテゴリを選択します。

+ +

+ +

select() の使用

+ +
 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'
+
+ +

仕様書

+ + + + + + + + + + + + +
仕様書
{{SpecName('ES Int Draft', '#sec-intl.pluralrules.prototype.select', 'Intl.PluralRules.select()')}}
+ +

ブラウザーの互換性

+ +
+ + +

{{Compat("javascript.builtins.Intl.PluralRules.select")}}

+
+ +

関連情報

+ + diff --git a/files/ja/web/javascript/reference/global_objects/intl/pluralrules/supportedlocalesof/index.html b/files/ja/web/javascript/reference/global_objects/intl/pluralrules/supportedlocalesof/index.html new file mode 100644 index 0000000000..ea219a5f0c --- /dev/null +++ b/files/ja/web/javascript/reference/global_objects/intl/pluralrules/supportedlocalesof/index.html @@ -0,0 +1,83 @@ +--- +title: Intl.PluralRules.supportedLocalesOf() +slug: Web/JavaScript/Reference/Global_Objects/Intl/PluralRules/supportedLocalesOf +tags: + - Internationalization + - Intl + - JavaScript + - Method + - PluralRules + - メソッド + - 国際化 +translation_of: Web/JavaScript/Reference/Global_Objects/Intl/PluralRules/supportedLocalesOf +--- +
{{JSRef}}
+ +

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

+ +

構文

+ +
Intl.PluralRules.supportedLocalesOf(locales[, options])
+ +

引数

+ +
+
locales
+
BCP 47 言語タグを持つ文字列、またはそのような文字列の配列です。 locales 引数の一般的な形式については、 {{jsxref("Intl", "Intl のページ", "#Locale_identification_and_negotiation", 1)}}を参照してください。
+
options
+
+

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

+ +
+
localeMatcher
+
使用するロケールの一致アルゴリズムです。指定可能な値は lookup および best fit で、既定値は best fit です。このオプションの詳細は、 {{jsxref("Intl", "Intl のページ", "#Locale_negotiation", 1)}}を参照してください。
+
+
+
+ +

返値

+ +

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

+ +

解説

+ +

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

+ +

+ +

supportedLocalesOf() の使用

+ +

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

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

仕様書

+ + + + + + + + + + +
仕様書
{{SpecName('ES Int Draft', '#sec-intl.pluralrules.supportedlocalesof', 'Intl.PluralRules.supportedLocalesOf')}}
+ +

ブラウザーの互換性

+ +
+ + +

{{Compat("javascript.builtins.Intl.PluralRules.supportedLocalesOf")}}

+
+ +

関連情報

+ + -- cgit v1.2.3-54-g00ecf