Cldr v0.1.0 Cldr.Number.System
Functions to manage number systems which describe the numbering characteristics for a locale.
A number system defines the digits (if they exist in this number system) or or rules (if the number system does not have decimal digits).
The system name is also used as a key to define the separators that are used
when formatting a number is this number_system. See
Cldr.Number.Symbol.number_symbols_for/2
.
Summary
Functions
Return the default number system type name
The unique Cldr number systems names,
Returns a list of the known number system types
Return a map of all CLDR number systems and definitions
Returns the number systems available for a locale
Returns locale and number systems that have the same digits and separators as the supplied one
Returns a number system name for a given locale and number system reference
Number systems that have their own digit characters defined
Types
Functions
Return the default number system type name.
Currently this is :default
. Note that this is
not the number system itself but the type of the
number system. It can be used to find the
default number system for a given locale with
number_systems_for(locale)[default_number_system()]
.
Example
iex> Cldr.Number.System.default_number_system_type
:default
The unique Cldr number systems names,
Example
iex> Cldr.Number.System.number_system_names
[:adlm, :ahom, :arab, :arabext, :armn, :armnlow, :bali,
:beng, :bhks, :brah, :cakm, :cham, :cyrl, :deva, :ethi,
:fullwide, :geor, :grek, :greklow, :gujr, :guru, :hanidays,
:hanidec, :hans, :hansfin, :hant, :hantfin, :hebr, :hmng,
:java, :jpan, :jpanfin, :kali, :khmr, :knda, :lana, :lanatham,
:laoo, :latn, :lepc, :limb, :mathbold, :mathdbl, :mathmono,
:mathsanb, :mathsans, :mlym, :modi, :mong, :mroo, :mtei,
:mymr, :mymrshan, :mymrtlng, :newa, :nkoo, :olck, :orya,
:osma, :roman, :romanlow, :saur, :shrd, :sind, :sinh, :sora,
:sund, :takr, :talu, :taml, :tamldec, :telu, :thai, :tibt,
:tirh, :vaii, :wara]
Returns a list of the known number system types.
Note that not all locales support all number system types.
:default
is available for all locales, the other types
configured only in certain locales.
Example
iex> Cldr.Number.System.number_system_types
[:default, :native, :traditional, :finance]
Return a map of all CLDR number systems and definitions.
Example
iex> Cldr.Number.System.number_systems |> Enum.count
77
Returns the number systems available for a locale.
Examples
iex> Cldr.Number.System.number_systems_for "en"
%{default: :latn, native: :latn}
iex> Cldr.Number.System.number_systems_for "th"
%{default: :latn, native: :thai}
Returns locale and number systems that have the same digits and separators as the supplied one.
Transliterating between locale & number systems is expensive. To avoid unncessary transliteration we look for locale and number systems that have the same digits and separators. Typically we are comparing to locale “en” and number system “latn” since this is what the number formatting routines use as placeholders.
Returns a number system name for a given locale and number system reference.
system_name
is any name of name typelocale
is any valid locale returned byCldr.known_locales()
Number systems can be references in one of two ways:
As a number system type such as :default, :native, :traditional and :finance. This allows references to a number system for a locale in a consistent fashion for a given use
WIth the number system name directly, such as :latn, :arab or any of the other 70 or so
This function dereferences the supplied system_name
and returns the
actual system name.
Examples
ex> Cldr.Number.System.system_name_from(:default, "en")
:latn
iex> Cldr.Number.System.system_name_from("latn", "en")
:latn
iex> Cldr.Number.System.system_name_from(:finance, "en")
:finance
Note that return value is not guaranteed to be a valid number system for the given locale as demonstrated in the third example.