CLDRex v0.0.7 CLDRex.Numbers

Provide number localization including conversion to currency, percentage, and decimal values.

Summary

Functions

Localize the given number

Convert the given number to the localized currency format

Convert the given number to the localized percentage format

Types

locale :: atom | String.t

Functions

localize(number, locale, options \\ [])

Specs

localize(number, locale, Keyword.t) :: String.t

Localize the given number.

Accepted options are:

  • precision: the floating point precision. default: nil - it will not round the fractional part of the number. Valid options are 0..15.

Examples

iex> CLDRex.Numbers.localize(12345, :en)
"12,345"
iex> CLDRex.Numbers.localize(12345.789, :en)
"12,345.789"
iex> CLDRex.Numbers.localize(12345.789, :en, precision: 2)
"12,345.79"
to_currency(number, locale)

Specs

to_currency(number, locale) :: String.t

Convert the given number to the localized currency format.

to_percent(number, locale)

Specs

to_percent(number, locale) :: String.t

Convert the given number to the localized percentage format.