大网数据广告活动
Web 标准与前端开发

Intl.PluralRules.prototype.resolvedOptions()

· 52CE 我爱测

The **`resolvedOptions()`** method of Intl.PluralRules instances returns a new object with properties reflecting the options computed during initialization of this `PluralRules` object.

The resolvedOptions() method of Intl.PluralRules instances returns a new object with properties reflecting the options computed during initialization of this PluralRules object.

JavaScript Demo: Intl.PluralRules.prototype.resolvedOptions()

const pluralRules1 = new Intl.PluralRules("uk");
const options1 = pluralRules1.resolvedOptions();

const pluralRules2 = new Intl.PluralRules("bn");
const options2 = pluralRules2.resolvedOptions();

console.log(options1.pluralCategories);
// Expected output: Array ["one", "few", "many", "other"]

console.log(options2.pluralCategories);
// Expected output: Array ["one", "other"]

Syntax

resolvedOptions()

Parameters

None.

Return value

A new object with properties reflecting the options computed during the initialization of this PluralRules object. The object has the following properties, in the order they are listed:

  • locale
    • : The BCP 47 language tag for the locale actually used, determined by the locale negotiation process. No Unicode extension key will be included in the output.
  • type
    • : The value provided for this property in the options argument, with default filled in as needed. It is either "cardinal" or "ordinal". The default is "cardinal".
  • minimumIntegerDigits
    • : The value provided for this property in the options argument, with default filled in as needed.
  • minimumFractionDigits, maximumFractionDigits
    • : The value provided for these properties in the options argument, with defaults filled in as needed. They are only present if necessary; see digit options.
  • minimumSignificantDigits, maximumSignificantDigits
    • : The value provided for these properties in the options argument, with defaults filled in as needed. They are only present if necessary; see digit options.
  • pluralCategories
    • : An Array of plural categories used by the given locale, selected from the list "zero", "one", "two", "few", "many" and "other".
  • roundingIncrement
    • : The value provided for this property in the options argument, with default filled in as needed. It is one of 1, 2, 5, 10, 20, 25, 50, 100, 200, 250, 500, 1000, 2000, 2500, and 5000. The default is 1.
  • roundingMode
    • : The value provided for this property in the options argument, with default filled in as needed. It is one of "ceil", "floor", "expand", "trunc", "halfCeil", "halfFloor", "halfExpand", "halfTrunc", and "halfEven". The default is "halfExpand".
  • roundingPriority
    • : The value provided for this property in the options argument, with default filled in as needed. It is either "auto", "morePrecision", or "lessPrecision". The default is "auto".
  • trailingZeroDisplay
    • : The value provided for this property in the options argument, with default filled in as needed. It is either "auto" or "stripIfInteger". The default is "auto".

Examples

Using the resolvedOptions() method

The code below shows the construction of a PluralRules object, followed by logging of each of the resolved options.

// Create a PluralRules instance
const de = new Intl.PluralRules("de-DE", {
  maximumSignificantDigits: 2,
  trailingZeroDisplay: "auto",
});

// Resolve the options
const usedOptions = de.resolvedOptions();
console.log(usedOptions.locale); // "de-DE"
console.log(usedOptions.pluralCategories); // Array ["one", "other"]
console.log(usedOptions.type); // "cardinal"
console.log(usedOptions.minimumIntegerDigits); // 1
console.log(usedOptions.minimumFractionDigits); // undefined (maximumSignificantDigits is set)
console.log(usedOptions.maximumFractionDigits); // undefined (maximumSignificantDigits is set)
console.log(usedOptions.minimumSignificantDigits); // 1
console.log(usedOptions.maximumSignificantDigits); // 2
console.log(usedOptions.roundingIncrement); // 1
console.log(usedOptions.roundingMode); // "halfExpand"
console.log(usedOptions.roundingPriority); // "auto"
console.log(usedOptions.trailingZeroDisplay); // "auto"

Specifications

Browser compatibility

See also

  • Intl.PluralRules

来源:MDN Web Docs / Mozilla 贡献者 · 作者与贡献记录 · CC BY-SA 2.5。离线整理了版式、链接和媒体显示。

资料来源与适用范围

资料来源
MDN Web Docs / Mozilla 贡献者
适用范围
请按文中版本与环境说明核对
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 2.5

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。