ReadonlylocaleCanonical BCP-47 locale identifier, e.g. "en-AU".
ReadonlymodifiersResolved modifiers (calendar / currency / timeZone).
ReadonlysubtagsParsed language / script / region subtags.
Returns a new Cosmo with likely subtags added (e.g. "en" → "en-Latn-US").
Uses Intl.Locale#maximize.
Localised calendar name (e.g. "buddhist" → "Buddhist Calendar").
Returns "" for an empty argument.
Compact number notation (e.g. 1200 → "1.2K", or "1.2 thousand").
JS-only.
full/long → long words, otherwise short.
Locale-aware comparison of two strings, suitable for Array#sort.
Returns a negative number, 0, or a positive number.
Locale-aware substring test that honours the locale's collation, so accents/case can be ignored.
base (ignore case & accents, default), accent,
case, or variant (exact). See Intl.Collator.
Localised country/region name (e.g. "AU" → "Australia").
Accepts a region code or a locale containing one. Returns "" when empty.
Localised currency name (default) or symbol.
ISO 4217 code; defaults to the currency modifier.
When true, returns the standard (disambiguated) symbol — e.g.
"A$" for AUD in en-US, not the ambiguous narrow "$".
Throw on an unknown currency instead of echoing the code back.
Formats just the date part of a moment.
Formats a moment range (e.g. "2–5 Feb 2020"). Uses DateTimeFormat#formatRange. JS-only.
Defaults to medium — short numeric dates read poorly as
a range, so this differs from Cosmo.date (which defaults to short).
Text direction of the locale (or a given language): "rtl" or "ltr".
Generic localised display name — a single entry point over the dedicated
lookups. Mirrors Intl.DisplayNames.
language, region, script, calendar, or currency.
The code to translate (e.g. "en", "AU", "Hans", "buddhist", "EUR").
Formats an undirected duration (magnitude only) given in seconds. For the directed form (with a past/future orientation, e.g. "3 days ago") see Cosmo.relativeDuration.
When true, spells out the units ("339 hours, …"),
otherwise uses the digital clock form ("339:27:40").
Requires Intl.DurationFormat (Node 22+). Both forms are produced entirely
by ICU.
Truncates text to at most max graphemes, breaking on a word boundary and
appending ellipsis. Grapheme- and word-aware via Intl.Segmenter, so it
never splits a combining sequence. Returns the original text if it already
fits.
Country flag emoji for a region (e.g. "AU" → "🇦🇺"). Defaults to the
locale's region. Uses the Unicode regional-indicator transform, so no data
table is involved.
Joins a list using the locale's conventions (e.g. "A, B, and C").
Mirrors Intl.ListFormat.
conjunction (and, default), disjunction (or), or unit.
maps to long/short/narrow list styles.
Localised language name (e.g. "en" → "English", in fa → "انگلیسی").
Accepts a bare language code or a full locale (the language subtag is used).
Returns "" for an empty/nullish argument.
Locale-aware lower-casing.
Formats an ICU MessageFormat pattern (subset: args, number, plural, select).
Formats a moment (date and/or time) using the locale's conventions.
A Date or Unix-millisecond timestamp.
none/short/medium/long/full (default short).
none/short/medium/long/full (default short).
Optionalcalendar: string | nullPass "gregorian" to force Gregorian; otherwise the
locale/modifier calendar is used.
Formats a monetary value.
No currency is inferred from the region: the Intl API exposes no
region→currency mapping, and this library bundles no data. Provide a
currency code or set the currency modifier.
The formatted amount, or "" when no currency is available
(unless strict, which throws).
Formats a monetary range (e.g. "$3.00 – $5.00"). JS-only.
"" when no currency is available (or throws if none and required).
Localised month names (January … December), following the active calendar.
Mirrors IntlDateFormatter month symbols.
Formats a number using the locale's default decimal format.
Optional rounding/grouping controls (NumberOptions).
Formats a numeric range (e.g. "3–5"). Uses NumberFormat#formatRange. JS-only.
Formats a fraction as a localised percentage (e.g. 0.2 → "20%").
Maximum fraction digits (default 3).
Optional rounding/grouping controls (NumberOptions);
an explicit maximumFractionDigits here overrides precision.
The LDML plural category a number falls into for this locale
(e.g. 1 → "one", 2 → "other" in English). Mirrors the category
selection inside ICU MessageFormat.
Use ordinal rules (1st/2nd/3rd …) instead of cardinal.
Renders a directed duration — a signed amount carrying a past/future
orientation — in the locale's words (e.g. (-3, "day") → "3 days ago",
(2, "hour") → "in 2 hours"). The directed counterpart of
Cosmo.duration, which is undirected (magnitude only). Wraps
Intl.RelativeTimeFormat.
Signed amount: negative = past ("… ago"), positive = future
("in …").
second, minute, hour, day, week, month, quarter, year.
always (default, "1 day ago") or auto (allows "yesterday").
Renders the directed duration between two moments as relative text,
auto-selecting the largest sensible unit (e.g. "in 5 days",
"3 days ago"). Computes target − reference, then formats via
Cosmo.relativeDuration. JS-only.
Returns a new Cosmo with likely subtags removed (e.g. "en-Latn-US" → "en").
Uses Intl.Locale#minimize.
Scientific notation (e.g. 12345 → "1.2345E4"). Mirrors NumberFormatter::SCIENTIFIC.
Localised script name (e.g. "Latn" → "Latin"). Defaults to the locale's
script subtag. Returns "" when there is no script.
Returns a new array sorted by the locale's collation rules.
Optionalkey: (item: T) => stringOptional accessor returning the string to sort each item by.
Optional collation tailoring (CollationOptions).
Splits text into grapheme clusters (user-perceived characters), so combining
marks and emoji ZWJ sequences stay intact. Mirrors Intl.Segmenter
granularity:"grapheme".
Splits text into sentences using the locale's sentence-boundary rules.
Splits text into words using the locale's word-boundary rules, keeping only
word-like segments (drops whitespace and punctuation). Mirrors ICU's
word BreakIterator.
The values the runtime's ICU supports for a given key (e.g. all IANA time
zones, calendars, currencies). Mirrors Intl.supportedValuesOf.
calendar, collation, currency, numberingSystem, timeZone, or unit.
Returns a single localised number symbol that the Intl API exposes via
formatToParts (decimal/group separators, percent, sign symbols, nan,
infinity). Symbols ICU keeps internal (permille, pad escape, …) are not
available and throw.
One of: decimal, group, percent, minusSign, plusSign,
nan, infinity, currency (case/_-insensitive; _separator/_symbol
suffixes are ignored).
Formats just the time (clock) part of a moment.
Localised display name of a time zone (e.g. "Australian Eastern Standard Time").
Defaults to the timeZone modifier, falling back to the runtime zone.
long (default), short, shortOffset, longOffset,
shortGeneric, or longGeneric.
Formats a measurement with a localised unit (e.g. 2.19 gigabytes).
Informational unit category (e.g. "digital"); accepted for
descriptive grouping but not required by Intl.
The unit identifier, e.g. "gigabyte", "celsius", "gram".
Must be one of the units sanctioned by ECMA-402.
Numeric value.
full/long → long, medium → short, short → narrow.
Locale-aware upper-casing (e.g. Turkish dotted/dotless I).
Localised weekday names, Sunday first (matching ICU symbol order).
Mirrors IntlDateFormatter weekday symbols.
Week conventions for the locale: first day of the week, weekend days, and
the minimal days in the first week. Mirrors IntlCalendar accessors.
StaticfromStaticfrom
BCP-47 (or underscore-separated
en_AU) locale identifier. Unicode extensions such as-u-nu-latn-ca-buddhistare honoured. Defaults to the runtime locale.