Locale

Bindings to JavaScript's Intl.Locale.

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")

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.

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"

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"

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"

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

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, }

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")

t

RESCRIPT
type t