Localize.Inputs.Number.Symbols (Localize.Inputs.Number v0.1.1)

Copy Markdown View Source

Locale-derived display data for number form inputs.

Returns the decimal/grouping separator characters, the active number system, and the locale's minus sign — everything a JS hook needs to render a number in the user's locale.

All locale lookups go through Localize.validate_locale/1; the resulting Localize.LanguageTag.t/0's :cldr_locale_id is the canonical id reported back. Number system resolution goes through Localize.Number.System.number_system_from_locale/1 so Arabic-Indic, Persian, and other non-Latin digit systems work out of the box.

Summary

Types

t()

Locale display data resolved by number_for_locale/1.

Functions

Resolves display data for the given locale.

Types

t()

@type t() :: %Localize.Inputs.Number.Symbols{
  decimal: String.t(),
  group: String.t(),
  language_tag: Localize.LanguageTag.t(),
  locale: atom(),
  minus_sign: String.t(),
  number_system: atom()
}

Locale display data resolved by number_for_locale/1.

  • :locale — the canonical CLDR locale id (atom).

  • :language_tag — the full Localize.LanguageTag.t/0.

  • :number_system — the active number system (:latn, :arab, :arabext, …).

  • :decimal — the locale's decimal separator character.

  • :group — the locale's grouping separator character.

  • :minus_sign — the locale's minus sign character.

Functions

number_for_locale(locale \\ nil)

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

Resolves display data for the given locale.

Arguments

Returns

Examples

iex> {:ok, info} = Localize.Inputs.Number.Symbols.number_for_locale(:en)
iex> {info.decimal, info.group, info.number_system}
{".", ",", :latn}

iex> {:ok, info} = Localize.Inputs.Number.Symbols.number_for_locale(:de)
iex> {info.decimal, info.group}
{",", "."}