From 13ba45ebc58799c2b400761f463897b92e902d1c Mon Sep 17 00:00:00 2001 From: Masahiro FUJIMOTO Date: Tue, 20 Apr 2021 21:41:09 +0900 Subject: Intl.RelativeTimeFormat() を更新 (#446) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 2021/03/20 時点の英語版に同期 --- .../relativetimeformat/index.html | 110 ++++++++++----------- 1 file changed, 55 insertions(+), 55 deletions(-) (limited to 'files/ja/web/javascript/reference/global_objects/intl') diff --git a/files/ja/web/javascript/reference/global_objects/intl/relativetimeformat/relativetimeformat/index.html b/files/ja/web/javascript/reference/global_objects/intl/relativetimeformat/relativetimeformat/index.html index fdc22fa753..3a7cd5722c 100644 --- a/files/ja/web/javascript/reference/global_objects/intl/relativetimeformat/relativetimeformat/index.html +++ b/files/ja/web/javascript/reference/global_objects/intl/relativetimeformat/relativetimeformat/index.html @@ -7,6 +7,7 @@ tags: - Internationalization - Intl - JavaScript + - Localization - Reference - RelativeTimeFormat translation_of: >- @@ -16,48 +17,51 @@ translation_of: >-

Intl.RelativeTimeFormat() コンストラクターは、 {{jsxref("Intl/RelativeTimeFormat", "Intl.RelativeTimeFormat")}} オブジェクトを生成します。

-

構文

+

構文

-
new Intl.RelativeTimeFormat([locales[, options]])
+
new Intl.RelativeTimeFormat([locales[, options]])
-

引数

+

引数

-
locales {{optional_inline}}
-
-

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

-
-
options {{optional_inline}}
-
以下のプロパティのうち一部またはすべてを持つオブジェクトです。 -
-
localeMatcher
-
使用するロケールの一致アルゴリズムです。指定可能な値は lookup および best fit で、既定値は best fit です。このオプションの詳細は、 {{jsxref("Global_Objects/IntlIntl", "Intl", "#Locale_negotiation")}} を参照してください。
-
numeric
-
メッセージを出力する書式です。利用可能な値は次の通りです。 -
    -
  • "always" (既定値、例えば 1 日前)
  • -
  • "auto" (例えば 昨日)。 "auto" にすると、出力に常に数値が入るとは限りません。
  • -
-
-
style
-
国際化されたメッセージの長さです。利用可能な値は次の通りです。 -
    -
  • "long" (既定値、例えば in 1 month)
  • -
  • "short" (例えば in 1 mo.)
  • -
  • "narrow" (例えば in 1 mo.) narrow スタイルは同じロケールでは short スタイルと同様になることがあります。
  • -
-
-
-
+
locales {{optional_inline}}
+
+

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

+
+
options {{optional_inline}}
+
+

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

+
+
localeMatcher
+
使用するロケールの一致アルゴリズムです。使用可能な値は "lookup" および "best fit" で、既定値は "best fit" です。このオプションの詳細は、 {{jsxref("Global_Objects/Intl", "Intl", "#Locale_negotiation", 1)}} のページを参照してください。
+
numeric
+
+ メッセージを出力する書式です。使用可能な値は次の通りです。 +
    +
  • "always" (既定値、例えば 1 日前)
  • +
  • "auto" (例えば 昨日)。 "auto" にすると、出力に常に数値が入るとは限りません。
  • +
+
+
style
+
+ 国際化されたメッセージの長さです。使用可能な値は次の通りです。 +
    +
  • "long" (既定値、例えば in 1 month)
  • +
  • "short" (例えば in 1 mo.)
  • +
  • "narrow" (例えば in 1 mo.) narrow スタイルは同じロケールでは short スタイルと同様になることがあります。
  • +
+
+
+
-

+

-

基本的な書式の使い方

+

基本的な書式の使い方

以下の例は、英語を使用した相対時間のフォーマッターの生成方法を示しています。

-
// Create a relative time formatter in your locale
+
// Create a relative time formatter in your locale
 // with default values explicitly passed in.
 const rtf = new Intl.RelativeTimeFormat("en", {
     localeMatcher: "best fit", // other values: "lookup"
@@ -73,11 +77,11 @@ rtf.format(-1, "day");
 rtf.format(1, "day");
 // > "in 1 day"
-

auto オプションの使用

+

auto オプションの使用

-

numeric:auto オプションが渡された場合は、 1 day agoin 1 day の代わりに yesterdaytomorrow の文字列が生成されます。これにより、出力に数値が含まれなくなることがあります。

+

numeric:auto オプションが渡された場合は、 yesterdaytomorrow の文字列が 1 day agoin 1 day の代わりに生成されます。これにより、出力に数値が含まれなくなることがあります。

-
// Create a relative time formatter in your locale
+
// Create a relative time formatter in your locale
 // with numeric: "auto" option value passed in.
 const rtf = new Intl.RelativeTimeFormat("en", { numeric: "auto" });
 
@@ -90,33 +94,29 @@ rtf.format(1, "day");
 // > "tomorrow"
 
-

仕様書

+

仕様書

- - - - - - - - - - - - - - + + + + + + + + + +
仕様書状態備考
{{SpecName('ES Int Draft', '#sec-intl-relativetimeformat-constructor', 'RelativeTimeFormat()')}}第 4 段階
仕様書
{{SpecName('ES Int Draft', '#sec-intl-relativetimeformat-constructor', 'RelativeTimeFormat()')}}

ブラウザーの互換性

- +
{{Compat("javascript.builtins.Intl.RelativeTimeFormat.RelativeTimeFormat")}}
-

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

- -

関連情報

+

関連情報

-- cgit v1.2.3-54-g00ecf