The resolvedOptions() method of Intl.PluralRules instances returns a new object with properties reflecting the locale and plural formatting options computed during initialization of this Intl.PluralRules object.
On this page
Intl.PluralRules.prototype.resolvedOptions()
Try it
Syntax
resolvedOptions()
Parameters
None.
Return value
A new object with properties reflecting the locale and plural formatting options computed during the initialization of the given Intl.PluralRules object.
The object has the following properties:
-
locale -
The BCP 47 language tag for the locale actually used. If any Unicode extension values were requested in the input BCP 47 language tag that led to this locale, the key-value pairs that were requested and are supported for this locale are included in
locale. -
pluralCategories -
An
Arrayof plural categories used by the given locale, selected from the list"zero","one","two","few","many"and"other". -
type -
The type used (
cardinalorordinal). roundingModeExperimental-
The rounding mode. This is the value provided for the
options.roundingModeargument in the constructor, or the default value:halfExpand. roundingPriorityExperimental-
The priority for resolving rounding conflicts if both "FractionDigits" and "SignificantDigits" are specified. This is the value provided for the
options.roundingPriorityargument in the constructor, or the default value:auto. roundingIncrementExperimental-
The rounding-increment precision (the increment used when rounding numbers). This is the value specified in the
options.roundingIncrementargument in the constructor. trailingZeroDisplayExperimental-
The strategy for displaying trailing zeros on whole numbers. This is the value specified in the
options.trailingZeroDisplayargument in the constructor, or the default value:"auto".
Only one of the following two groups of properties is included:
minimumIntegerDigits,minimumFractionDigits,maximumFractionDigits-
The values provided for these properties in the
optionsargument or filled in as defaults. These properties are present only if neitherminimumSignificantDigitsnormaximumSignificantDigitswas provided in theoptionsargument. minimumSignificantDigits,maximumSignificantDigits-
The values provided for these properties in the
optionsargument or filled in as defaults. These properties are present only if at least one of them was provided in theoptionsargument.
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
| Desktop | Mobile | Server | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Chrome | Edge | Firefox | Opera | Safari | Chrome Android | Firefox for Android | Opera Android | Safari on IOS | Samsung Internet | WebView Android | Deno | Node.js | ||
resolvedOptions |
63 | 18 | 58 | 50 | 13 | 63 | 58 | 46 | 13 | 8.0 | 63 | 1.8 |
10.0.0Before version 13.0.0, only the locale data foren-US is available by default. See the PluralRules() constructor for more details.
|
|
result_roundingIncrement_property |
No | No | 116 | No | No | No | 116 | No | No | No | No | No | No | |
result_roundingMode_property |
No | No | 116 | No | No | No | 116 | No | No | No | No | No | No | |
result_roundingPriority_property |
No | No | 116 | No | No | No | 116 | No | No | No | No | No | No | |
result_trailingZeroDisplay_property |
No | No | 116 | No | No | No | 116 | No | No | No | No | No | No | |
See also
© 2005–2023 MDN contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/PluralRules/resolvedOptions