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 / Locale

    Locale

    Bindings to JavaScript's Intl.Locale.

    t

    RESCRIPT
    type t

    options

    RESCRIPT
    type options = { baseName?: string, calendar?: Intl_Common.calendar, collation?: Intl_Common.collation, hourCycle?: [#h11 | #h12 | #h23 | #h24], caseFirst?: [#"false" | #lower | #upper], numberingSystem?: Intl_Common.numberingSystem, numeric?: bool, language?: string, script?: string, region?: string, }

    make

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

    Creates a new Intl.Locale object from a locale identifier and optional modifiers.

    See Intl.Locale on MDN.

    Examples

    RESCRIPT
    let locale = Intl.Locale.make("en-US") locale->Intl.Locale.language == "en"

    baseName

    RESCRIPT
    let baseName: t => string

    baseName(locale) returns the canonical base name (without Unicode extensions).

    See Intl.Locale.prototype.baseName on MDN.

    Examples

    RESCRIPT
    let locale = Intl.Locale.make("fr-CA") locale->Intl.Locale.baseName == "fr-CA"

    calendar

    RESCRIPT
    let calendar: t => option<string>

    calendar(locale) returns the specified calendar, if present.

    See Intl.Locale.prototype.calendar on MDN.

    Examples

    RESCRIPT
    let locale = Intl.Locale.make("en", ~options={calendar: #gregory}) locale->Intl.Locale.calendar == Some("gregory")

    caseFirst

    RESCRIPT
    let caseFirst: t => option<string>

    caseFirst(locale) returns the case-first ordering setting, if present.

    See Intl.Locale.prototype.caseFirst on MDN.

    Examples

    RESCRIPT
    let locale = Intl.Locale.make("en", ~options={caseFirst: #upper}) locale->Intl.Locale.caseFirst == Some("upper")

    collation

    RESCRIPT
    let collation: t => option<string>

    collation(locale) returns the collation type, if present.

    See Intl.Locale.prototype.collation on MDN.

    Examples

    RESCRIPT
    let locale = Intl.Locale.make("en", ~options={collation: #phonebk}) locale->Intl.Locale.collation == Some("phonebk")

    hourCycle

    RESCRIPT
    let hourCycle: t => option<string>

    hourCycle(locale) returns the preferred hour cycle, if present.

    See Intl.Locale.prototype.hourCycle on MDN.

    Examples

    RESCRIPT
    let locale = Intl.Locale.make("en", ~options={hourCycle: #h12}) locale->Intl.Locale.hourCycle == Some("h12")

    language

    RESCRIPT
    let language: t => string

    language(locale) returns the primary language subtag.

    See Intl.Locale.prototype.language on MDN.

    Examples

    RESCRIPT
    let locale = Intl.Locale.make("pt-BR") locale->Intl.Locale.language == "pt"

    numberingSystem

    RESCRIPT
    let numberingSystem: t => option<string>

    numberingSystem(locale) returns the numbering system identifier, if present.

    See Intl.Locale.prototype.numberingSystem on MDN.

    Examples

    RESCRIPT
    let locale = Intl.Locale.make("en", ~options={numberingSystem: #latn}) locale->Intl.Locale.numberingSystem == Some("latn")

    numeric

    RESCRIPT
    let numeric: t => bool

    numeric(locale) indicates whether numeric ordering should be used for region subtags.

    See Intl.Locale.prototype.numeric on MDN.

    Examples

    RESCRIPT
    let locale = Intl.Locale.make("en", ~options={numeric: true}) locale->Intl.Locale.numeric == true

    region

    RESCRIPT
    let region: t => option<string>

    region(locale) returns the region subtag, if present.

    See Intl.Locale.prototype.region on MDN.

    Examples

    RESCRIPT
    let locale = Intl.Locale.make("en-US") locale->Intl.Locale.region == Some("US")

    script

    RESCRIPT
    let script: t => option<string>

    script(locale) returns the script subtag, if present.

    See Intl.Locale.prototype.script on MDN.

    Examples

    RESCRIPT
    let locale = Intl.Locale.make("sr-Cyrl") locale->Intl.Locale.script == Some("Cyrl")

    maximize

    RESCRIPT
    let maximize: t => t

    maximize(locale) adds likely subtags to produce the most specific locale.

    See Intl.Locale.prototype.maximize on MDN.

    Examples

    RESCRIPT
    let locale = Intl.Locale.make("en") locale->Intl.Locale.maximize->Intl.Locale.region == Some("US")

    minimize

    RESCRIPT
    let minimize: t => t

    minimize(locale) removes unnecessary subtags while preserving semantics.

    See Intl.Locale.prototype.minimize on MDN.

    Examples

    RESCRIPT
    let locale = Intl.Locale.make("en-Latn-US") locale->Intl.Locale.minimize->Intl.Locale.baseName == "en"

    ignore

    RESCRIPT
    let ignore: t => unit

    ignore(locale) ignores the provided locale 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
      options
    • v
      make
    • v
      baseName
    • v
      calendar
    • v
      caseFirst
    • v
      collation
    • v
      hourCycle
    • v
      language
    • v
      numberingSystem
    • v
      numeric
    • v
      region
    • v
      script
    • v
      maximize
    • v
      minimize
    • v
      ignore

    © 2025 The ReScript Project

    About
    • Community
    • ReScript Association
    Find us on