Packages
ex_cldr_numbers
2.1.1
2.38.3
2.38.2
2.38.1
2.38.0
2.37.0
2.36.0
2.35.2
2.35.1
2.35.0
2.34.1
2.34.0
2.33.6
2.33.5
2.33.4
2.33.3
2.33.2
2.33.1
2.33.0
2.32.4
2.32.3
2.32.2
2.32.1
2.32.0
retired
2.31.3
retired
2.31.2
2.31.1
2.31.0
2.30.1
2.30.0
2.29.0
2.28.0
2.27.3
2.27.2
2.27.1
2.27.0
2.26.0
2.25.2
2.25.1
2.25.0
2.24.0
2.23.3
2.23.2
2.23.1
2.23.0
2.23.0-rc.4
2.23.0-rc.3
2.23.0-rc.2
2.23.0-rc.1
2.23.0-rc.0
2.22.1
2.22.0
2.21.0
2.20.0
2.19.0
2.18.4
2.18.3
2.18.2
2.18.1
2.18.0
2.17.0
2.17.0-rc.1
2.17.0-rc.0
2.16.1
2.16.0
2.16.0-rc.0
2.15.4
2.15.3
2.15.2
2.15.1
2.15.0
2.14.0
2.13.2
2.13.1
2.13.0
2.13.0-rc.0
2.12.1
2.12.0
2.11.0
2.10.0
2.9.0
2.8.0
2.7.2
2.7.1
2.7.0
2.6.4
2.6.3
2.6.2
2.6.1
2.6.0
2.5.0
2.4.4
2.4.3
2.4.2
2.4.1
2.4.0
2.3.0
2.2.0
2.1.1
2.1.0
2.0.0
2.0.0-rc.0
1.6.0
1.5.2
1.5.1
1.5.0
1.4.4
1.4.3
1.4.2
1.4.1
1.4.0
1.3.1
1.3.0
1.3.0-rc.1
1.3.0-rc.0
retired
1.2.0
1.1.0
1.0.1
1.0.0
1.0.0-rc.0
retired
0.3.3
0.3.2
retired
0.3.1
retired
0.3.0
retired
0.2.3
0.2.2
0.2.1
0.2.0
0.1.0
Number and currency localization and formatting functions for the Common Locale Data Repository (CLDR).
Current section
Files
Jump to
Current section
Files
lib/backend/rbnf.ex
defmodule Cldr.Number.Backend.Rbnf do
@moduledoc false
def define_number_modules(config) do
backend = config.backend
quote location: :keep do
defmodule Rbnf.NumberSystem do
@moduledoc """
Functions to implement the number system rule-based-number-format rules of CLDR.
These rules are defined only on the "root" locale and represent specialised
number formatting.
The standard public API for RBNF is via the `Cldr.Number.to_string/2` function.
The functions on this module are defined at compile time based upon the RBNF rules
defined in the Unicode CLDR data repository. Available rules are identified by:
iex> #{inspect(__MODULE__)}.rule_sets("root")
[:tamil, :roman_upper, :roman_lower, :hebrew_item, :hebrew_0_99, :hebrew,
:greek_upper, :greek_lower, :georgian, :ethiopic_p1, :ethiopic,
:cyrillic_lower_1_10, :cyrillic_lower, :armenian_upper, :armenian_lower]
A rule can then be invoked on an available rule_set. For example
iex> #{inspect(__MODULE__)}.roman_upper(123, "root")
"CXXIII"
This call is equivalent to the call through the public API of:
iex> #{inspect(unquote(backend))}.Number.to_string(123, format: :roman)
{:ok, "CXXIII"}
"""
import Kernel, except: [and: 2]
use Cldr.Rbnf.Processor, backend: unquote(backend)
define_rules(:NumberingSystemRules, unquote(backend), __ENV__)
end
defmodule Rbnf.Spellout do
@moduledoc """
Functions to implement the spellout rule-based-number-format rules of CLDR.
As CLDR notes, the data is incomplete or non-existent for many languages. It
is considered complete for English however.
The standard public API for RBNF is via the `Cldr.Number.to_string/2` function.
The functions on this module are defined at compile time based upon the RBNF rules
defined in the Unicode CLDR data repository. Available rules are identified by:
iex> #{inspect(__MODULE__)}.rule_sets("en")
[:spellout_ordinal_verbose, :spellout_ordinal, :spellout_numbering_year,
:spellout_numbering_verbose, :spellout_numbering, :spellout_cardinal_verbose,
:spellout_cardinal]
A rule can then be invoked on an available rule_set. For example:
iex> #{inspect(__MODULE__)}.spellout_ordinal(123, "en")
"one hundred twenty-third"
This call is equivalent to the call through the public API of:
iex> #{inspect(unquote(backend))}.Number.to_string(123, format: :spellout)
{:ok, "one hundred twenty-three"}
"""
import Kernel, except: [and: 2]
use Cldr.Rbnf.Processor, backend: unquote(backend)
define_rules(:SpelloutRules, unquote(backend), __ENV__)
end
defmodule Rbnf.Ordinal do
@moduledoc """
Functions to implement the ordinal rule-based-number-format rules of CLDR.
As CLDR notes, the data is incomplete or non-existent for many languages. It
is considered complete for English however.
The standard public API for RBNF is via the `Cldr.Number.to_string/2` function.
The functions on this module are defined at compile time based upon the RBNF rules
defined in the Unicode CLDR data repository. Available rules are identified by:
iex> #{inspect(__MODULE__)}.rule_sets("en")
[:digits_ordinal]
A rule can then be invoked on an available rule_set. For example
iex> #{inspect(__MODULE__)}.digits_ordinal(123, "en")
"123rd"
This call is equivalent to the call through the public API of:
iex> #{inspect(unquote(backend))}.Number.to_string(123, format: :ordinal)
{:ok, "123rd"}
"""
import Kernel, except: [and: 2]
use Cldr.Rbnf.Processor, backend: unquote(backend)
define_rules(:OrdinalRules, unquote(backend), __ENV__)
end
end
end
end