Locale-derived display data for number form inputs.
Returns the decimal/grouping separator characters, the active number system, the locale's minus sign and its digit grouping — 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
Locale display data resolved by number_for_locale/1.
Functions
Resolves display data for the given locale.
Types
@type t() :: %Localize.Inputs.Number.Symbols{ decimal: String.t(), group: String.t(), grouping: %{first: non_neg_integer(), rest: non_neg_integer()}, 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 fullLocalize.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.:grouping— the integer digit grouping of the locale's standard number format::firstis the size of the group next to the decimal separator and:restthe size of every group to its left (%{first: 3, rest: 3}for1,234,567,%{first: 3, rest: 2}for12,34,567).
Functions
@spec number_for_locale(Localize.LanguageTag.t() | atom() | String.t() | nil) :: {:ok, t()} | {:error, Exception.t()}
Resolves display data for the given locale.
Arguments
localeis a locale identifier (atom, string, orLocalize.LanguageTag.t/0). Defaults toLocalize.get_locale/0.
Returns
{:ok, t()}on success.{:error, Exception.t()}when the locale can't be parsed (Localize.InvalidLocaleError), the number system can't be resolved, no symbols are available (Localize.Inputs.Number.NoNumberSymbolsError), or the locale's number formats can't be loaded.
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}
{",", "."}
iex> {:ok, info} = Localize.Inputs.Number.Symbols.number_for_locale(:hi)
iex> info.grouping
%{first: 3, rest: 2}