DocsPlaygroundBlogCommunityPackages
  • Playground
  • Blog
  • Community
  • Packages
  • X
  • Bluesky
  • GitHub
  • Forum
Language ManualAPISyntax LookupReact
v11v9.1 - v10.1v8.2 - v9.0v6.0 - v8.1
Overview
Stdlib
submodules
  • Array
  • ArrayBuffer
  • AsyncIterator
  • BigInt
  • BigInt64Array
    • Constants
    BigUint64Array
    • Constants
  • Bool
  • Console
  • DataView
  • Date
    • UTC
  • Dict
  • Error
    • URIError
    • TypeError
    • SyntaxError
    • ReferenceError
    • RangeError
    • EvalError
  • Exn
  • Float
    • Constants
    Float32Array
    • Constants
    Float64Array
    • Constants
    Int
    • Ref
    • Bitwise
    • Constants
    Int16Array
    • Constants
    Int32Array
    • Constants
    Int8Array
    • Constants
  • IntervalId
  • Intl
    • Segments
    • Segmenter
    • RelativeTimeFormat
    • PluralRules
    • NumberFormat
      • Grouping
    • Locale
    • ListFormat
    • DateTimeFormat
    • Collator
    • Common
  • Iterator
  • JSON
    • Decode
    • Encode
    • Classify
    JsError
    • URIError
    • TypeError
    • SyntaxError
    • ReferenceError
    • RangeError
    • EvalError
  • JsExn
  • Lazy
  • List
  • Map
  • Math
    • Int
    • Constants
  • Null
  • Nullable
  • Object
  • Option
  • Ordering
  • Pair
  • Promise
  • RegExp
    • Result
  • Result
  • Set
  • String
  • Symbol
  • TimeoutId
  • Type
    • Classify
  • TypedArray
  • Uint16Array
    • Constants
    Uint32Array
    • Constants
    Uint8Array
    • Constants
    Uint8ClampedArray
    • Constants
  • WeakMap
  • WeakSet
  • Docs / API / Pluralrules

    PluralRules

    t

    RESCRIPT
    type t

    localeType

    RESCRIPT
    type localeType = [#cardinal | #ordinal]

    options

    RESCRIPT
    type options = { localeMatcher?: Intl_Common.localeMatcher, \"type"?: localeType, minimumIntegerDigits?: Intl_Common.oneTo21, minimumFractionDigits?: Intl_Common.zeroTo20, maximumFractionDigits?: Intl_Common.zeroTo20, minimumSignificantDigits?: Intl_Common.oneTo21, maximumSignificantDigits?: Intl_Common.oneTo21, }

    pluralCategories

    RESCRIPT
    type pluralCategories = [ | #few | #many | #one | #other | #two | #zero ]

    resolvedOptions

    RESCRIPT
    type resolvedOptions = { locale: string, pluralCategories: array<pluralCategories>, \"type": localeType, minimumIntegerDigits?: Intl_Common.oneTo21, minimumFractionDigits?: Intl_Common.zeroTo20, maximumFractionDigits?: Intl_Common.zeroTo20, minimumSignificantDigits?: Intl_Common.oneTo21, maximumSignificantDigits?: Intl_Common.oneTo21, }

    supportedLocalesOptions

    RESCRIPT
    type supportedLocalesOptions = { localeMatcher: Intl_Common.localeMatcher, }

    make

    RESCRIPT
    let make: (~locales: array<string>=?, ~options: options=?) => t

    Creates a new Intl.PluralRules instance to determine plural categories.

    See Intl.PluralRules on MDN.

    Examples

    RESCRIPT
    let rules = Intl.PluralRules.make(~locales=["en"]) let category = rules->Intl.PluralRules.select(1.0) category == #one

    supportedLocalesOf

    RESCRIPT
    let supportedLocalesOf: ( array<string>, ~options: supportedLocalesOptions=?, ) => array<string>

    supportedLocalesOf(locales, ~options) filters locales to those supported for plural rules.

    See Intl.PluralRules.supportedLocalesOf on MDN.

    Examples

    RESCRIPT
    Intl.PluralRules.supportedLocalesOf(["en-US", "klingon"]) == ["en-US"]

    resolvedOptions

    RESCRIPT
    let resolvedOptions: t => resolvedOptions

    resolvedOptions(rules) returns the plural rule configuration in use.

    Examples

    RESCRIPT
    let rules = Intl.PluralRules.make(~locales=["en"]) Intl.PluralRules.resolvedOptions(rules).locale == "en"

    rule

    RESCRIPT
    type rule = [#few | #many | #one | #other | #two | #zero]

    select

    RESCRIPT
    let select: (t, float) => rule

    select(rules, value) returns the plural category for the given number.

    Examples

    RESCRIPT
    let rules = Intl.PluralRules.make(~locales=["en"]) rules->Intl.PluralRules.select(1.) == #one

    selectInt

    RESCRIPT
    let selectInt: (t, int) => rule

    selectInt(rules, value) is like select but accepts an integer.

    Examples

    RESCRIPT
    let rules = Intl.PluralRules.make(~locales=["en"]) rules->Intl.PluralRules.selectInt(2) == #other

    selectRange

    RESCRIPT
    let selectRange: (t, ~start: float, ~end: float) => rule

    selectRange(rules, ~start, ~end) returns the category for numbers in the range.

    Examples

    RESCRIPT
    let rules = Intl.PluralRules.make(~locales=["en"]) rules->Intl.PluralRules.selectRange(~start=1., ~end=2.) == #other

    selectRangeInt

    RESCRIPT
    let selectRangeInt: (t, ~start: int, ~end: int) => rule

    selectRangeInt(rules, ~start, ~end) is the integer version of selectRange.

    Examples

    RESCRIPT
    let rules = Intl.PluralRules.make(~locales=["en"]) rules->Intl.PluralRules.selectRangeInt(~start=1, ~end=1) == #other

    ignore

    RESCRIPT
    let ignore: t => unit

    ignore(pluralRules) ignores the provided pluralRules and returns unit.

    This helper is useful when you want to discard a value (for example, the result of an operation with side effects) without having to store or process it further.

    Types and values
    • t
      t
    • t
      localeType
    • t
      options
    • t
      pluralCategories
    • t
      resolvedOptions
    • t
      supportedLocalesOptions
    • v
      make
    • v
      supportedLocalesOf
    • v
      resolvedOptions
    • t
      rule
    • v
      select
    • v
      selectInt
    • v
      selectRange
    • v
      selectRangeInt
    • v
      ignore

    © 2025 The ReScript Project

    About
    • Community
    • ReScript Association
    Find us on