Search documentation of Localize

# API Reference Localize v#0.39.0

Copy Markdown View Source

## Modules

Localize

Locale-aware formatting, validation, and data access built on the Unicode CLDR repository.

Localize.BindError

Exception raised when interpreting a message and one or more variable bindings are missing.

Localize.Calendar

Calendar localization functions for retrieving locale-specific names for eras, months, days, quarters, and day periods.

Localize.Chars

Protocol for locale-aware string formatting.

Localize.Collation

Implements the Unicode Collation Algorithm (UCA) as extended by CLDR.

Localize.Collation.Element

A Collation Element (CE) with primary, secondary, and tertiary weights.

Localize.Collation.FastLatin

Fast lookup table for Basic Latin and Latin Extended-A codepoints.

Localize.Collation.Han

Han character ordering using radical-stroke indexes.

Localize.Collation.ImplicitWeights

Computes implicit collation elements for codepoints not in the DUCET/CLDR allkeys table.

Localize.Collation.Insensitive

Case-insensitive string comparator for use with `Enum.sort/2`.

Localize.Collation.Nif

Collation NIF interface providing high-performance Unicode collation via ICU4C.

Localize.Collation.Normalizer

Unicode NFD normalization for collation. Delegates to Erlang's `:unicode` module.

Localize.Collation.Numeric

Numeric collation support (kn=true / numeric=true).

Localize.Collation.Options

Collation options corresponding to BCP47 -u- extension keys.

Localize.Collation.Reorder

Script reordering for collation (kr= / reorder option).

Localize.Collation.Sensitive

Case-sensitive string comparator for use with `Enum.sort/2`.

Localize.Collation.SortKey

Constructs binary sort keys from processed collation elements.

Localize.Collation.Table

Persistent-term-backed collation element table.

Localize.Collation.Table.Parser

Parses the FractionalUCA.txt file into a map of codepoint sequences to collation elements.

Localize.Collation.Tailoring

CLDR locale-specific collation tailoring.

Localize.Collation.Tailoring.LocaleDefaults

Preset collation option defaults for common locales.

Localize.Collation.Variable

Variable weight handling for the collation algorithm.

Localize.Currency

Defines a currency structure and functions to manage currency codes, validate currencies, and retrieve currency metadata.

Localize.CurrencyNoDisplayNameError

Exception raised when a currency has no display name available for the requested locale.

Localize.CurrencyNotLocalizedError

Exception raised when a known currency code has no localized data in the requested locale.

Localize.DataLoader

A GenServer that serializes ETF data file loading to prevent race conditions.

Localize.Date

Provides localized formatting of `Date` structs and date-like maps.

Localize.DateTime

Provides localized formatting of `DateTime`, `NaiveDateTime`, and datetime-like maps.

Localize.DateTime.Relative

Formats relative time strings such as "3 days ago", "tomorrow", or "in 10 seconds".

Localize.DateTime.Timezone

Provides timezone data access and timezone formatting for CLDR date/time format symbols.

Localize.DateTimeFormatError

Exception raised when a date, time, or datetime format pattern cannot be processed.

Localize.DateTimeIntervalFormatError

Exception raised when an interval format cannot be resolved.

Localize.DateTimeInvalidInputError

Exception raised when a date, time, or datetime value does not have the required keys for formatting.

Localize.DateTimeUnresolvedFormatError

Exception raised when a date, time, or datetime format skeleton cannot be resolved to a pattern for the given locale.

Localize.Duration

Functions to create and format durations — the difference between two dates, times, or datetimes expressed in calendar units.

Localize.Exception

Conventions and a small behaviour shared by structured Localize exceptions.

Localize.FormatCache

An ETS-backed cache for compiled format patterns.

Localize.FormatError

Exception raised when a value cannot be formatted by the requested message format function due to an incompatible type or missing configuration.

Localize.Gettext

Gettext backend for the Localize library.

Localize.Gettext.Interpolation

Gettext interpolation module for ICU MessageFormat 2 (MF2) messages.

Localize.Interval

Formats date and time intervals as localized strings.

Localize.InvalidLocaleError

Exception raised when a locale identifier cannot be parsed into a valid language tag.

Localize.InvalidSubtagError

Exception raised when an extension key or value is not valid for a BCP 47 language tag.

Localize.InvalidValueError

Exception raised when a value does not meet the expected type or constraints for an operation.

Localize.ItemNotFoundError

Exception raised when a key path cannot be resolved in locale data.

Localize.Language

Provides language name localization functions built on the Unicode CLDR repository.

Localize.LanguageTag

Represents a language tag as defined in rfc5646 with extensions "u" and "t" as defined in BCP 47.

Localize.LanguageTag.Parser

Parses a CLDR language tag (also referred to as locale string).

Localize.LanguageTag.Sigil

Implements a `sigil_l/2` macro for constructing `t:Localize.LanguageTag` structs.

Localize.LanguageTag.T

Defines the struct for the BCP 47 `t` extension.

Localize.LanguageTag.U

Defines the struct for the BCP 47 `u` extension.

Localize.LikelySubtagsError

Exception raised when likely subtags data cannot be found for a given locale identifier.

Localize.List

Formats lists into locale-aware strings using CLDR list formatting patterns.

Localize.List.Pattern

Defines the structure for list formatting patterns.

Localize.Locale

Locale utility functions for resolution, validation, and per-locale data access.

Localize.Locale.Loader

A GenServer that serializes locale data loading to prevent race conditions.

Localize.Locale.LocaleDisplay

Implements the CLDR locale display name algorithm to format locale identifiers for presentation.

Localize.Locale.Provider

Defines the behaviour for locale data providers.

Localize.Locale.Provider.Cache

On-disk cache for downloaded locale data files.

Localize.Locale.Provider.PersistentTerm

A locale data provider that stores locale data in `:persistent_term`.

Localize.LocaleCacheWriteError

Exception raised when a locale file cannot be written to the locale cache directory.

Localize.LocaleDisplayError

Exception raised when locale display name data is not available for a requested locale.

Localize.LocaleDownloadError

Exception raised when a locale file cannot be downloaded from its remote URL.

Localize.LocaleIsStaleError

Exception raised when a cached locale file's version does not match the current `Localize.version/0`.

Localize.LocaleMatchError

Exception raised when no matching locale can be found within the specified distance threshold.

Localize.LocaleNotFoundInCacheError

Exception raised when a locale file is not found in the locale cache directory, or cannot be read for another I/O reason.

Localize.Message

Implements ICU MessageFormat 2 with functions to parse and interpolate messages.

Localize.Message.Formatter

Dispatch module for rendering MF2 highlight tokens.

Localize.Message.Formatter.ANSI

ANSI terminal formatter for MF2 highlight tokens.

Localize.Message.Formatter.HTML

HTML formatter for MF2 highlight tokens.

Localize.Message.Formatter.Plain

Plain-text formatter for MF2 highlight tokens.

Localize.Message.Formatter.Plugin

`mix format` plugin that canonicalises ICU MessageFormat 2 (MF2) messages.

Localize.Message.Function

Behaviour for custom MF2 formatting functions.

Localize.Message.Highlighter

Produces a classified token stream from an MF2 AST for syntax highlighting.

Localize.Message.Interpreter

Interprets a MessageFormat 2 AST and produces formatted output.

Localize.Message.JSON

Converts between MF2 ASTs and the JSON interchange data model defined in TR35 §8.

Localize.Message.Parser

Implements a parser for ICU MessageFormat 2.

Localize.Message.Print

Converts a MessageFormat 2 AST back to its canonical string form.

Localize.Message.Sigils

Implements sigils for ICU MessageFormat 2 messages.

Localize.Nif

Optional NIF interface to ICU4C for high-performance locale operations.

Localize.NoCertificateStoreError

Exception raised when no certificate trust store can be located.

Localize.NoParentError

Exception raised when a parent locale is requested for the root locale (`und`) which has no parent.

Localize.NoParentTerritoryError

Exception raised when a territory has no parent container in the CLDR territory containment data.

Localize.NoPracticalDifferenceError

Exception raised when two date or datetime values are considered equal at every field used by `Localize.Interval.greatest_difference/2`, so no greater-than-zero interval field can be returned.

Localize.Number

Functions for formatting numbers in a locale-aware manner.

Localize.Number.Format

Functions to manage the collection of number format patterns defined in CLDR.

Localize.Number.Format.Compiler

Compiles number format patterns into metadata for fast runtime interpretation.

Localize.Number.Format.Meta

Describes the metadata that drives number formatting and provides functions to update the struct.

Localize.Number.Formatter.Ratio

Formats numbers as rational fractions using CLDR rational format patterns.

Localize.Number.Parser

Functions for parsing numbers and currencies from strings in a locale-aware manner.

Localize.Number.PluralRule

Defines plural rule modules for cardinal and ordinal number categories according to the CLDR plural rules specification.

Localize.Number.PluralRule.Cardinal

Implements cardinal plural rules for numbers.

Localize.Number.PluralRule.Ordinal

Implements ordinal plural rules for numbers.

Localize.Number.Rbnf

Rules-Based Number Formatting (RBNF) for algorithmic number systems and spellout forms.

Localize.Number.Symbol

Functions to manage the number symbol definitions for a locale and number system.

Localize.Number.System

Functions to manage number systems for a locale.

Localize.Number.Transliterate

Functions to transliterate digits between number systems.

Localize.ParseError

Exception raised when a language tag, unit identifier, or MF2 message cannot be parsed.

Localize.Rfc5646.Parser

Implements parsing for RFC5646 language tags with BCP47 extensions.

Localize.Script

Provides script name localization functions built on the Unicode CLDR repository.

Localize.Substitution

Compiles substitution templates of the form `"{0} something {1}"` into token lists for efficient parameter substitution at runtime.

Localize.Supervisor

The `:localize` runtime supervisor.

Localize.Territory

Provides territory and subdivision localization functions built on the Unicode CLDR repository.

Localize.Territory.Subdivision

Territory subdivision localization functions.

Localize.Time

Provides localized formatting of `Time` structs and time-like maps.

Localize.Unit

Represents and formats CLDR units of measure.

Localize.Unit.BaseUnit

Converts parsed unit ASTs into their CLDR base unit equivalents.

Localize.Unit.Canonical

Canonicalises CLDR unit identifier ASTs and names.

Localize.Unit.Conversion

Converts numeric values between CLDR units of measure.

Localize.Unit.Conversion.Beaufort

Nonlinear conversion between the Beaufort wind force scale and meters per second.

Localize.Unit.CustomRegistry

Runtime registry for user-defined units backed by `:persistent_term`.

Localize.Unit.Data

Compile-time extraction of CLDR unit data from a pre-built ETF file.

Localize.Unit.Math

Arithmetic operations on `Localize.Unit` structs.

Localize.Unit.Operators

Overloaded arithmetic operators for `Localize.Unit.t()` values.

Localize.Unit.Parser

Parses CLDR Unit of Measure identifier strings into structured ASTs.

Localize.Unit.Preference

Returns the preferred units for a given unit, territory, and usage.

Localize.UnitConversionError

Exception raised when a unit conversion cannot be performed.

Localize.UnitNoValueError

Exception raised when a unit operation requires a numeric value but the unit struct has `nil` as its value.

Localize.UnitPreferenceError

Exception raised when a unit preference cannot be determined for a given unit, region, or usage combination.

Localize.UnknownCalendarError

Exception raised when a calendar name is not a known CLDR calendar type.

Localize.UnknownCurrencyError

Exception raised when a currency code is not a known ISO 4217 or registered custom currency.

Localize.UnknownLanguageError

Exception raised when a language code cannot be found in the locale display name data.

Localize.UnknownLocaleError

Exception raised when a locale identifier does not correspond to any known CLDR locale.

Localize.UnknownMeasurementSystemError

Exception raised when a measurement system type is not a known CLDR measurement system.

Localize.UnknownNumberSystemError

Exception raised when a number system name is not a known CLDR number system.

Localize.UnknownPluralRulesError

Exception raised when no plural rules are available for a given locale.

Localize.UnknownRbnfRuleError

Exception raised when an RBNF rule name cannot be resolved for a given locale.

Localize.UnknownScriptError

Exception raised when a script code is not a known ISO 15924 or CLDR script subtag.

Localize.UnknownStyleError

Exception raised when a display name style is not one of the known styles (`:short`, `:standard`, `:variant`).

Localize.UnknownSubdivisionError

Exception raised when a territory subdivision code is not a known ISO 3166-2 subdivision.

Localize.UnknownTerritoryError

Exception raised when a territory code is not a known ISO 3166 territory or CLDR region code.

Localize.UnknownTimezoneError

Exception raised when a timezone identifier cannot be resolved to a known IANA timezone.

Localize.UnknownUnitError

Exception raised when a unit identifier cannot be resolved to a known CLDR unit.

Localize.Utils

Utility functions and namespace for Localize utility submodules.

Localize.Utils.Decimal

Compatibility layer for `Decimal` library operations.

Localize.Utils.Digits

Abstract representation of number (integer, float, Decimal) in tuple form and functions for transformations on number parts.

Localize.Utils.Enum

Enumerable utility functions not provided in the standard library.

Localize.Utils.Helpers

General purpose helper functions for Localize.

Localize.Utils.Http

Supports securely downloading HTTPS content.

Localize.Utils.Json

JSON decoding utilities wrapping the OTP `:json` module.

Localize.Utils.Map

Functions for transforming maps, keys and values.

Localize.Utils.Math

Mathematical helper functions for number formatting and Localize subsystems.

Localize.Utils.String

String manipulation functions not provided in the standard library.

## Mix Tasks

mix localize.download_locales

Downloads locale ETF files from the Localize CDN and stores them in the configured locale cache directory.