JavaScript

Intl.ListFormat オブジェクト


編集:2023.01.10 by T.A.

[Edge]。→

言語を考慮したリストの書式化を可能にするオブジェクト。

コンストラクター
new Intl.ListFormat([locales[, options]])
新しい Intl.ListFormat オブジェクトを作成して返します。
静的メソッド
Intl.ListFormat.supportedLocalesOf(locales[, options])
リストの書式化で、指定ロケールで対応しているロケールの文字列の配列を返します。
インスタンス メソッド
Intl.ListFormat.format([list])
Intl.ListFormat で指定リストを書式化して文字列で返します。
Intl.ListFormat.formatToParts(list)
Intl.ListFormat で指定リストを書式化した各部分のオブジェクトの配列で返します。
Intl.ListFormat.resolvedOptions()
Intl.ListFormat でリストの書式化に計算されたプロパティを持つ新しいオブジェクトを返します。
L=['Cat', 'Dog', 'Apple'];
DA=new Intl.ListFormat('en', {style:'long', type:'conjunction'});  //英語、
D=DA.format(L);  //=[string]:Cat, Dog, and Apple
DA=new Intl.ListFormat('ja', {style:'long', type:'conjunction'});  //日本語、
D=DA.format(L);  //=[string]:Cat、Dog、Apple
DA=new Intl.ListFormat('ar', {style:'long', type:'conjunction'});  //アラビア語、
D=DA.format(L);  //=[string]:Cat وDog وApple

テスト