Thanks for the shoutout. The package on hex is ex_cldr_numbers (I am the author). Some examples from the readme:
Formatting numbers as words, ordinals and roman numerals
- As words. For example, formatting 123 into “one hundred and twenty-three” for the “en” locale. The applicable format types are
:spellout
and :spellout_verbose
.
iex> MyApp.Cldr.Number.to_string 123, format: :spellout
{:ok, "one hundred twenty-three"}
iex> MyApp.Cldr.Number.to_string 123, format: :spellout, locale: "de"
{:ok, "einhundertdreiundzwanzig"}
iex> MyApp.Cldr.Number.to_string 123, format: :spellout, locale: "fr"
{:ok, "cent vingt-trois"}
iex> MyApp.Cldr.Number.to_string 123, format: :spellout, locale: "th"
{:ok, "หนึ่งร้อยยี่สิบสาม"}
iex> MyApp.Cldr.Number.to_string 123, format: :spellout, locale: "he"
{:ok, "מאה עשרים ושלוש"}
iex> MyApp.Cldr.Number.to_string 123, format: :spellout, locale: "es"
{:ok, "ciento veintitrés"}
iex> MyApp.Cldr.Number.to_string 123, format: :spellout, locale: "zh"
{:ok, "一百二十三"}
iex> MyApp.Cldr.Number.to_string 123, format: :spellout_verbose
{:ok, "one hundred and twenty-three"}
- As a year. In many languages the written form of a year is different to that used for an arbitrary number. For example, formatting 1989 would result in “nineteen eighty-nine”. The applicable format type is
:spellout_year
.
iex> MyApp.Cldr.Number.to_string 2017, format: :spellout_year
{:ok, "twenty seventeen"}
- As an ordinal. For example, formatting 123 into “123rd”. The applicable format types are
:ordinal
, :spellout_ordinal
and :spellout_ordinal_verbose
.
iex> MyApp.Cldr.Number.to_string 123, format: :ordinal
{:ok, "123rd"}
iex> MyApp.Cldr.Number.to_string 123, format: :spellout_ordinal
{:ok, "one hundred twenty-third"}
iex> MyApp.Cldr.Number.to_string 123, format: :spellout_ordinal_verbose
{:ok, "one hundred and twenty-third"}
iex> MyApp.Cldr.Number.to_string 123, format: :ordinal, locale: "fr"
{:ok, "123e"}
iex> MyApp.Cldr.Number.to_string 123, format: :ordinal, locale: "zh"
{:ok, "第123"}
- As Roman numerals. For example, formatting 123 into “CXXIII”. The applicable formats are
:roman
or :roman_lower
. Note that roman number formatting is only supported for numbers between 1 and 5,000.
iex> MyApp.Cldr.Number.to_string 123, format: :roman
{:ok, "CXXIII"}
iex> MyApp.Cldr.Number.to_string 123, format: :roman_lower
{:ok, "cxxiii"}
iex> MyApp.Cldr.Number.to_string 12345, format: :roman_lower
{:ok, "12,345"}