/i18n
Unicode CLDR internationalization powered by ICU4X: locale-aware numbers, currencies, dates, plurals, collation, and grapheme segmentation.
Structs#
Bundle#
structStructured i18n translation bundle with normalized locale catalogs and explicit fallbacks.
| Field | Type | Default | Constraints / Notes |
|---|---|---|---|
default-locale | String | — | — |
locales | Map | — | — |
fallbacks | Map | — | — |
Constants#
Functions & symbols#
Bundle-construct#
Constructs a normalized `Bundle` from `{:en {...} :el {...}}` (plus optional opts) or `{:default-locale "en" :locales {...} :fallbacks {...}}`.
| Parameter | Type | Optional | Description |
|---|---|---|---|
input | Any | required | — |
rest | Any | optional | — |
Anycanonical-locale#
Normalizes a BCP 47 locale tag to CLDR canonical capitalization and subtag form.
| Parameter | Type | Optional | Description |
|---|---|---|---|
tag | String | required | BCP 47 locale tag |
Any(i18n/canonical-locale "en_us") ; -> "en-US"clear-registered-bundles!#
Clears all entries from the global bundle registry (intended for isolated test suites).
Anycurrent-bundle#
Returns the currently bound translation bundle from dynamic scope (or ()).
Anycurrent-language#
Returns the normalized lowercase base language subtag (e.g. "el-GR" -> "el").
Anycurrent-locale#
Returns the active locale tag from dynamic scope, defaulting to "en".
Anyfold-case#
Applies Unicode case folding for locale-consistent case-insensitive matching.
| Parameter | Type | Optional | Description |
|---|---|---|---|
s | String | required | Input string |
locale | String | optional | Optional BCP 47 locale (e.g. "tr" Turkic case folding) |
Any(i18n/fold-case "Straße")format#
Polymorphically formats numbers, /chrono temporal and duration values, and sequences according to locale rules.
| Parameter | Type | Optional | Description |
|---|---|---|---|
value | Any | required | Number, /chrono temporal/duration value, or Array/List |
locale-or-opts | Any | required | Optional BCP 47 locale tag or options Map |
Any(i18n/format 1234567.89d "el-GR")(i18n/format ["Αθήνα" "Θεσσαλονίκη"] "el")format-date-time#
Formats a /chrono temporal value according to CLDR calendar and locale conventions.
| Parameter | Type | Optional | Description |
|---|---|---|---|
temporal | Any | required | /chrono Date, Time, Date-Time, Zoned-Date-Time, Instant, or ISO String |
locale-or-opts | Any | required | Optional BCP 47 locale tag or options Map (:style, :date-style, :time-style, :fields, :calendar, :hour-cycle, :time-zone, :time-zone-name) |
Any(i18n/format-date-time (chrono/Date 2025 3 25) {:locale "el-GR" :style :long})format-display-name#
Formats localized CLDR display names for languages, regions, scripts, and currencies.
| Parameter | Type | Optional | Description |
|---|---|---|---|
code | String | required | Language, region, script, or currency subtag code |
kind | KeySymbol | optional | Entity kind (:language, :region, :script, :currency) |
options | Map | optional | Optional {:locale ... :style :long|:short} |
Any(i18n/format-display-name "JP" :region {:locale "fr"})format-duration#
Formats a /chrono Duration, Span, or unit Map into localized unit lists or digital clock notation.
| Parameter | Type | Optional | Description |
|---|---|---|---|
duration | Any | required | /chrono Duration, Span, or unit Map |
locale-or-opts | Any | required | Optional locale tag or options Map (:style :long | :short | :narrow | :digital) |
Any(i18n/format-duration {:hours 2 :minutes 45} {:locale "el" :style :long})format-list#
Formats a sequence of items using locale-specific list conjunctions or disjunctions.
| Parameter | Type | Optional | Description |
|---|---|---|---|
items | Array | required | Sequence of items to join |
locale-or-opts | Any | required | Optional locale tag or {:type :conjunction | :disjunction | :unit :style :long | :short | :narrow} |
Any(i18n/format-list ["Αθήνα" "Πάτρα" "Κρήτη"] "el")format-number#
Formats a number with locale-specific grouping, decimal separators, currency symbols, percentages, or compact notation.
| Parameter | Type | Optional | Description |
|---|---|---|---|
n | Number | required | Numeric value (Dec, Int, Float, or U8) |
locale-or-opts | Any | required | Optional BCP 47 locale tag or options Map (:style, :currency, :notation, :min-scale, :max-scale, :grouping, :sign-display, :rounding-mode) |
Any(i18n/format-number 1234.5d {:locale "el-GR" :style :currency :currency "EUR"})(i18n/format-number 1250000 {:locale "en-US" :notation :compact})format-relative#
Formats relative time phrases such as "yesterday", "χθες", or "in 3 hours".
| Parameter | Type | Optional | Description |
|---|---|---|---|
delta | Any | required | Signed integer delta, /chrono Span/Duration, or temporal value |
unit | Symbol | required | Time unit (:year, :month, :week, :day, :hour, :minute, :second) |
Any(i18n/format-relative -1 :day "el")graphemes#
Segments a string into an Array of UAX #29 extended grapheme clusters.
| Parameter | Type | Optional | Description |
|---|---|---|---|
text | String | required | Input UTF-8 string |
Any(i18n/graphemes "👨👩👧👦🇬🇷")locale-comparator#
Returns a 2-argument comparator function sorting strings according to UCA/CLDR locale collation rules.
| Parameter | Type | Optional | Description |
|---|---|---|---|
locale | String | optional | Optional BCP 47 locale |
options | Map | optional | Collation options {:strength :numeric :case-first} |
Any(sort names (i18n/locale-comparator "el"))locale-compare#
Compares two strings using the Unicode Collation Algorithm, returning -1, 0, or 1.
| Parameter | Type | Optional | Description |
|---|---|---|---|
a | String | required | First string |
b | String | required | Second string |
locale-or-opts | Any | required | Optional locale tag or {:sensitivity :base | :accent | :case | :variant :numeric true} |
Any(i18n/locale-compare "α" "ά" {:locale "el" :sensitivity :base})locale-sort#
Returns a new sequence sorted by locale collation rules, supporting :key and :reverse.
| Parameter | Type | Optional | Description |
|---|---|---|---|
items | Array | required | Sequence of strings, maps, or structs to sort |
locale-or-opts | Any | required | Optional locale tag or {:locale ... :key :field :reverse false :numeric true} |
Any(i18n/locale-sort ["Ωμέγα" "Αθήνα" "Άρτα"] "el")localize-field#
Resolves a localized field from a domain entity (`entity:names`, `entity:field` map, `field-<lang>`, or fallback string).
| Parameter | Type | Optional | Description |
|---|---|---|---|
entity | Any | required | — |
field | Any | required | — |
rest | Any | optional | — |
Anymaximize-locale#
Applies CLDR likely-subtags maximization to infer missing script and region subtags.
| Parameter | Type | Optional | Description |
|---|---|---|---|
tag | String | required | BCP 47 locale tag |
Any(i18n/maximize-locale "el") ; -> "el-Grek-GR"minimize-locale#
Applies CLDR likely-subtags minimization to strip redundant script/region subtags.
| Parameter | Type | Optional | Description |
|---|---|---|---|
tag | String | required | BCP 47 locale tag |
Any(i18n/minimize-locale "en-Latn-US") ; -> "en"parse-locale#
Parses and canonicalizes a BCP 47 locale tag into a Map of subtags and Unicode extension preferences.
| Parameter | Type | Optional | Description |
|---|---|---|---|
tag | Any | required | BCP 47 locale tag string or symbol |
Any(i18n/parse-locale "el-GR-u-ca-gregory-hc-h23")plural#
Selects a localized plural form from a category map or formats a singular/plural noun pair.
| Parameter | Type | Optional | Description |
|---|---|---|---|
n | Number | required | Item count |
forms-map | Map | required | Map of CLDR plural categories (:zero, :one, :other, etc.) or singular noun |
Any(i18n/plural 5 "μήνυμα" "μηνύματα" "el")plural-category#
Returns the CLDR plural category (:zero, :one, :two, :few, :many, :other) for a number.
| Parameter | Type | Optional | Description |
|---|---|---|---|
n | Number | required | Count or ordinal value |
locale-or-opts | Any | required | Optional locale tag or {:locale ... :type :cardinal | :ordinal} |
Any(i18n/plural-category 1 "el")register-bundle#
Registers a `Bundle` under namespace `ns` (overwriting any existing entry for `ns`) and returns it.
| Parameter | Type | Optional | Description |
|---|---|---|---|
ns | Any | required | — |
bundle | Any | required | — |
Anyregistered-bundle#
Looks up a previously registered `Bundle` by namespace `ns` (returns `()` if unregistered).
| Parameter | Type | Optional | Description |
|---|---|---|---|
ns | Any | required | — |
Anysegment#
Splits `text` into UAX #29 extended grapheme clusters.
| Parameter | Type | Optional | Description |
|---|---|---|---|
text | String | required | UTF-8 string to segment |
locale | String | optional | Optional BCP 47 locale |
Any(i18n/segment "café 👨👩👧")sentences#
Splits `text` into locale-aware sentence boundaries via UAX #29 / ICU4X.
| Parameter | Type | Optional | Description |
|---|---|---|---|
text | String | required | Input prose string |
locale | String | optional | Optional BCP 47 locale |
options | Map | optional | Segmentation options |
Any(i18n/sentences "Hello world. Next sentence!")strip-accents#
Removes combining diacritical marks via NFD decomposition and NFC recomposition.
| Parameter | Type | Optional | Description |
|---|---|---|---|
s | String | required | Input string |
Any(i18n/strip-accents "Καλημέρα Αθήνα café")t#
Translates `key` against registered `:ns/key` bundles or dynamic `*bundle*` and `*locale*`.
| Parameter | Type | Optional | Description |
|---|---|---|---|
key | Any | required | — |
rest | Any | optional | — |
Anyt-html#
Renders a translation message into an `#html`-spliceable fragment Array preserving structured HTML params.
| Parameter | Type | Optional | Description |
|---|---|---|---|
key | Any | required | — |
rest | Any | optional | — |
Anyto-locale-lower-case#
Converts `s` to lowercase respecting language-sensitive Unicode/CLDR case rules.
| Parameter | Type | Optional | Description |
|---|---|---|---|
s | String | required | Input string |
locale | String | optional | Optional BCP 47 locale (handles Turkish İ/ı, Greek sigma) |
Any(i18n/to-locale-lower-case "İSTANBUL" "tr")to-locale-title-case#
Converts `s` to Unicode titlecase using locale-specific case mapping rules.
| Parameter | Type | Optional | Description |
|---|---|---|---|
s | String | required | Input string |
locale | String | optional | Optional BCP 47 locale |
Any(i18n/to-locale-title-case "hello world" "en")to-locale-upper-case#
Converts a string to uppercase using locale-specific Unicode case mapping rules.
| Parameter | Type | Optional | Description |
|---|---|---|---|
s | String | required | Input string |
locale | Any | required | Optional BCP 47 locale (e.g. "el" strips Greek tonos in all-caps, "tr" maps i -> İ) |
Any(i18n/to-locale-upper-case "Καλημέρα Ελλάδα" "el")unregister-bundle#
Removes any registered bundle for namespace `ns`.
| Parameter | Type | Optional | Description |
|---|---|---|---|
ns | Any | required | — |
Anyvalidate-bundle#
Validates locale parity across all keys, plural `:other` fallbacks, and `{var}` placeholders.
| Parameter | Type | Optional | Description |
|---|---|---|---|
bundle | Any | required | — |
Anyvalidate-registered-bundles#
Validates all currently registered bundles with `validate-bundle` and aggregates parity reports.
Anyweek-info#
Returns CLDR week metadata `{:first-day :mon|:sun ... :weekend [...]}` for `locale`.
| Parameter | Type | Optional | Description |
|---|---|---|---|
locale | String | optional | Optional BCP 47 locale (defaults to `*locale*`) |
Any(i18n/week-info "en-US")words#
Extracts word-like tokens from a string using UAX #29 word boundary rules.
| Parameter | Type | Optional | Description |
|---|---|---|---|
text | String | required | Input UTF-8 string |
Any(i18n/words "Καλημέρα κόσμε!")