Localize

Locale-aware formatting, validation, and data access for Elixir, built on the Unicode CLDR repository.
Localize consolidates the functionality of the ex_cldr_* library family into a single package. No compile-time backend modules or code generation is required — all CLDR data is loaded at runtime and cached in :persistent_term.
Localize 1.4 is built on CLDR 49; Localize.version/0 reports the CLDR release a given version ships.
Try it without installing anything at the Localize playground.
Features
-
Numbers — format integers, decimals, percentages, and currencies with locale-appropriate grouping, decimal separators, and symbols.
-
Number parsing — parse locale-formatted strings back into numbers, including scanning numbers out of arbitrary text.
-
RBNF — rule-based number formatting: spell-out ("one hundred twenty-three"), ordinals ("42nd"), Roman numerals, and other algorithmic systems.
-
Plural rules — classify numbers into CLDR cardinal and ordinal plural categories for grammatically correct pluralization.
-
Minimal pairs — CLDR's worked examples of a locale's plural, ordinal, case and gender forms, useful for showing a sample or checking that a rule selects the form it should.
-
Dates and times — format Date, Time, DateTime, and NaiveDateTime values using CLDR calendar patterns, classical skeletons, or TR35 semantic skeletons that ask for a date by meaning ("YMDE", "MDTZ"), and parse them back, including text written with a Calendar.strftime/3 format rather than by field, and parse locale-formatted text back into them. CLDR 49's ordinal days — the ddd field, as in "Jul 6th, 2024" — are a technical preview; see Localize.Date.
-
Relative times — format time differences as human-readable phrases like "2 hours ago" or "in 3 days".
-
Intervals — format date, time, and datetime ranges.
-
Durations — format elapsed time as calendar-unit strings ("11 months, 30 days") or numeric time strings ("37:48:12").
-
Units — format units of measure with plural-aware patterns and territory-based usage preferences.
-
Lists — join items with locale-appropriate conjunctions (e.g., "a, b, and c").
-
Territories — display names, containment hierarchies, subdivisions, and emoji flags.
-
Languages — localized language display names.
-
Scripts — localized script display names.
-
Currencies — validation, territory-to-currency mapping, and currency history.
-
Collation — locale-sensitive string sorting using the Unicode Collation Algorithm with CLDR tailoring.
-
Locale display — full locale display names (e.g., "English (United States)").
-
Affirmative and negative responses — the forms a locale accepts as yes and no, from CLDR's POSIX data, with case-folding matchers for prompts.
-
Calendars — era names, month names, day names, and day period names for all CLDR calendars.
-
MessageFormat 2 — parse and evaluate ICU MessageFormat 2 message strings.
-
Inflection — inflect words, pronouns and quantities for number, gender, case and definiteness, from the Unicode inflection project's data, as functions and as MessageFormat 2's i: functions. Inflection is a technical preview; see Localize.Inflection. With unicode_string installed, Chinese, Japanese and Thai phrases are broken into dictionary words first.
Supported Elixir and OTP versions
Localize requires Elixir 1.17+ and Erlang/OTP 26+.
On OTP 26, also add the json_polyfill package — it provides the OTP 27+ :json module that Localize uses for JSON decoding. OTP 27 and later need no extra dependency.
Installation
Add localize to your dependencies in mix.exs:
def deps do
[
{:localize, "~> 1.12"}
]
end
On OTP 26 only:
def deps do
[
{:localize, "~> 1.12"},
{:json_polyfill, "~> 0.2 or ~> 1.0"}
]
end
By default the :localize OTP application starts automatically and brings up its own supervision tree. Applications that prefer to mount Localize under their own supervisor can do so by marking the dependency runtime: false and adding Localize.Supervisor to their children list — see the Supervision guide.
Quick start
iex> # Numbers
iex> Localize.Number.to_string(1_234_567.89)
{:ok, "1,234,567.89"}