From ba5d6f9610d6bb352eecfa3ded1bb99bc9892916 Mon Sep 17 00:00:00 2001 From: Peter Bengtsson Date: Fri, 11 Dec 2020 19:00:14 -0500 Subject: dump 2020-12-11 --- .../intl/listformat/format/index.html | 81 +++++++++++++++++++ .../intl/listformat/listformat/index.html | 90 ++++++++++++++++++++++ .../intl/listformat/supportedlocalesof/index.html | 84 ++++++++++++++++++++ 3 files changed, 255 insertions(+) create mode 100644 files/ja/web/javascript/reference/global_objects/intl/listformat/format/index.html create mode 100644 files/ja/web/javascript/reference/global_objects/intl/listformat/listformat/index.html create mode 100644 files/ja/web/javascript/reference/global_objects/intl/listformat/supportedlocalesof/index.html (limited to 'files/ja/web/javascript/reference/global_objects/intl') diff --git a/files/ja/web/javascript/reference/global_objects/intl/listformat/format/index.html b/files/ja/web/javascript/reference/global_objects/intl/listformat/format/index.html new file mode 100644 index 0000000000..6e2b3436e6 --- /dev/null +++ b/files/ja/web/javascript/reference/global_objects/intl/listformat/format/index.html @@ -0,0 +1,81 @@ +--- +title: Intl​.ListFormat.prototype​.format() +slug: Web/JavaScript/Reference/Global_Objects/Intl/ListFormat/format +tags: + - Internationalization + - Intl + - JavaScript + - ListFormat + - Method + - Prototype +translation_of: Web/JavaScript/Reference/Global_Objects/Intl/ListFormat/format +--- +
{{JSRef}}
+ +

format() メソッドは、リストの言語固有の表現を文字列で返します。

+ +
{{EmbedInteractiveExample("pages/js/intl-listformat.html", "taller")}}
+ +

構文

+ +
listFormat.format([list])
+ +

引数

+ +
+
list
+
Array などの反復可能オブジェクトです。
+
+ +

返値

+ +

リストのすべての要素を表現する、言語に依存した文字列表現です。

+ +

解説

+ +

format() メソッドは、 Intl.ListFormat オブジェクトで提供された引数に基づいて書式化された文字列を返します。 localesoptions 引数で format() の動作をカスタマイズし、アプリケーションがリストを書式化する言語の慣習を指定することができます。

+ +

+ +

format の使用

+ +

以下の例では、英語を使用したリストのフォーマッターの作り方を紹介します。

+ +
const list = ['Motorcycle', 'Bus', 'Car'];
+
+ console.log(new Intl.ListFormat('en-GB', { style: 'long', type: 'conjunction' }).format(list));
+// > Motorcycle, Bus and Car
+
+ console.log(new Intl.ListFormat('en-GB', { style: 'short', type: 'disjunction' }).format(list));
+// > Motorcycle, Bus or Car
+
+ console.log(new Intl.ListFormat('en-GB', { style: 'narrow', type: 'unit' }).format(list));
+// > Motorcycle Bus Car
+
+ +

仕様書

+ + + + + + + + + + + + +
仕様書
{{SpecName('Intl.ListFormat', '#sec-Intl.ListFormat.prototype.format', 'format()')}}
+ +

ブラウザーの互換性

+ + + +

{{Compat("javascript.builtins.Intl.ListFormat.format")}}

+ +

関連情報

+ + diff --git a/files/ja/web/javascript/reference/global_objects/intl/listformat/listformat/index.html b/files/ja/web/javascript/reference/global_objects/intl/listformat/listformat/index.html new file mode 100644 index 0000000000..dd6aab0010 --- /dev/null +++ b/files/ja/web/javascript/reference/global_objects/intl/listformat/listformat/index.html @@ -0,0 +1,90 @@ +--- +title: Intl.ListFormat() コンストラクター +slug: Web/JavaScript/Reference/Global_Objects/Intl/ListFormat/ListFormat +tags: + - Constructor + - Intl + - JavaScript + - ListFormat + - Reference +translation_of: Web/JavaScript/Reference/Global_Objects/Intl/ListFormat/ListFormat +--- +
{{JSRef}}
+ +

The Intl.ListFormat() コンストラクターは、言語に応じたリストの書式化を可能にするオブジェクトを生成します。

+ +
{{EmbedInteractiveExample("pages/js/intl-listformat.html", "taller")}}
+ + + +

構文

+ +
new Intl.ListFormat([locales[, options]])
+ +

引数

+ +
+
locales {{optional_inline}}
+
+

BCP47 言語タグの文字列、または、そのような文字列の配列です。locales 引数の一般的な形式と解釈は、 {{jsxref("Global_Objects/Intl", "Intl", "#Locale_identification_and_negotiation", 1)}} のページをご覧ください。

+
+
options {{optional_inline}}
+
+

以下のプロパティの一部またはすべてを持つオブジェクトです。

+ +
+
localeMatcher
+
使用するロケール一致アルゴリズム。利用可能な値は lookupbest fit です。既定値は best fit です。このオプションについての詳細は、 {{jsxref("Global_Objects/Intl", "Intl のページ", "#Locale_negotiation", 1)}}をご覧ください。
+
type
+
出力メッセージの書式です。可能な値は "and" ベースのリストを表す conjunction (既定値、例えば A, B, and C)、または "or" ベースのリストを表す disjunction (例えば A, B, or C)、単位付きの値のリストを表す unit (例えば 5 pounds, 12 ounces) です。
+
style
+
書式化されたメッセージの長さです。利用可能な値は、 long (既定値、例えば A, B, and C)、 short (例えば A, B, C)、 narrow (例えば A B C) です。 styleshort または narrow であった場合、 type オプションには unit のみが許可されます。
+
+
+
+ +

+ +

format の使用

+ +

次の例では、英語を使用するリストのフォーマッターを生成する方法を示します。

+ +
const list = ['Motorcycle', 'Bus', 'Car'];
+
+ console.log(new Intl.ListFormat('en-GB', { style: 'long', type: 'conjunction' }).format(list));
+// > Motorcycle, Bus and Car
+
+ console.log(new Intl.ListFormat('en-GB', { style: 'short', type: 'disjunction' }).format(list));
+// > Motorcycle, Bus or Car
+
+ console.log(new Intl.ListFormat('en-GB', { style: 'narrow', type: 'unit' }).format(list));
+// > Motorcycle Bus Car
+ +

仕様書

+ + + + + + + + + + + + +
仕様書
{{SpecName('Intl.ListFormat', '#sec-intl-listformat-constructor', 'ListFormat()')}}
+ +

ブラウザーの互換性

+ +
+ + +

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

+
+ +

関連情報

+ + diff --git a/files/ja/web/javascript/reference/global_objects/intl/listformat/supportedlocalesof/index.html b/files/ja/web/javascript/reference/global_objects/intl/listformat/supportedlocalesof/index.html new file mode 100644 index 0000000000..61ef765440 --- /dev/null +++ b/files/ja/web/javascript/reference/global_objects/intl/listformat/supportedlocalesof/index.html @@ -0,0 +1,84 @@ +--- +title: Intl.ListFormat.supportedLocalesOf() +slug: Web/JavaScript/Reference/Global_Objects/Intl/ListFormat/supportedLocalesOf +tags: + - Internationalization + - Intl + - JavaScript + - ListFormat + - Method + - supportedLocalesOf +translation_of: Web/JavaScript/Reference/Global_Objects/Intl/ListFormat/supportedLocalesOf +--- +

{{JSRef}}

+ +

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

+ +

構文

+ +
Intl.ListFormat.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 のマッチャーはインドネシア語がバリ語に適切に一致すると判断し、バリ語の言語タグも返すかもしれません。

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

仕様書

+ + + + + + + + + + + + +
仕様書
{{SpecName('Intl.ListFormat', '#sec-Intl.ListFormat.supportedLocalesOf', 'supportedLocalesOf()')}}
+ +

ブラウザーの互換性

+ +
+ + +

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

+
+ +

関連情報

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