Localize.Number.Symbol (Localize v0.22.0)

Copy Markdown View Source

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

Number symbols define the characters used for decimal separators, grouping separators, percent signs, and other formatting elements. Each locale may define symbols for one or more number systems (e.g., :latn, :arab, :thai).

Symbol data is retrieved at runtime from locale data via the configured locale provider.

Summary

Functions

Returns a map of Localize.Number.Symbol.t() structs of the number symbols for each number system of a locale.

Returns the number symbols for a specific locale and number system.

Types

t()

@type t() :: %Localize.Number.Symbol{
  approximately_sign: String.t(),
  decimal: String.t() | map(),
  exponential: String.t(),
  group: String.t() | map(),
  infinity: String.t(),
  list: String.t(),
  minus_sign: String.t(),
  nan: String.t(),
  per_mille: String.t(),
  percent_sign: String.t(),
  plus_sign: String.t(),
  superscripting_exponent: String.t(),
  time_separator: String.t()
}

Functions

number_symbols_for(locale)

@spec number_symbols_for(Localize.LanguageTag.t() | atom() | String.t()) ::
  {:ok, map()} | {:error, Exception.t()}

Returns a map of Localize.Number.Symbol.t() structs of the number symbols for each number system of a locale.

Arguments

Returns

  • {:ok, symbols_map} where symbols_map is a map of %{system_name => Localize.Number.Symbol.t()}.

  • {:error, exception} if the locale data cannot be loaded.

number_symbols_for(locale, number_system)

@spec number_symbols_for(
  Localize.LanguageTag.t() | atom() | String.t(),
  atom() | String.t()
) ::
  {:ok, t()} | {:error, Exception.t()}

Returns the number symbols for a specific locale and number system.

Arguments

  • locale is a locale identifier atom, string, or a Localize.LanguageTag.t/0 struct.

  • number_system is a number system name atom or string (e.g., :latn, :arab).

Returns

  • {:ok, Localize.Number.Symbol.t()} with the symbols for the requested number system.

  • {:error, exception} if the locale data cannot be loaded or no symbols exist for the number system.