ex_cldr_units
is an addon library for ex_cldr that provides localisation and formatting for units such as weights, lengths, areas, volumes and so on.
The primary api is Cldr.Unit.to_string/2
. The following examples demonstrate:
iex> Cldr.Unit.to_string 123, :volume_gallon
{:ok, "123 gallons"}
iex> Cldr.Unit.to_string 1234, :volume_gallon, format: :long
{:ok, "1 thousand gallons"}
iex> Cldr.Unit.to_string 1234, :volume_gallon, format: :short
{:ok, "1K gallons"}
iex> Cldr.Unit.to_string 1234, :frequency_megahertz
{:ok, "1,234 megahertz"}
For help in iex
:
iex> h Cldr.Unit.to_string
Primary documentation is available as part of the hex documentation for ex_cldr
Note that :ex_cldr_units
requires Elixir 1.5 or later.
Add ex_cldr_dates_time
as a dependency to your mix
project:
defp deps do
[
{:ex_cldr_units, "~> 0.1.3"}
]
end
then retrieve ex_cldr_units
from hex:
mix deps.get
mix deps.compile