Cldr.Unit.localize
localize, go back to Cldr.Unit module for more information.
Localizes a unit according to the current processes locale and backend.
The curent process's locale is set with
Cldr.put_locale/1.
See Cldr.Unit.localize/3 for futher
details.
Localizes a unit according to a territory
A territory can be derived from a t:Cldr.Locale.locale_name
or t:Cldr.LangaugeTag.
Use this function if you have a unit which
should be presented in a user interface using
units relevant to the audience. For example, a
unit #Cldr.Unit100, :meter> might be better
presented to a US audience as #Cldr.Unit328, :foot>.
Arguments
unitis any unit returned byCldr.Unit.new/2backendis any module that includesuse Cldrand therefore is aCldrbackend module.optionsis a keyword list of options
Options
:localeis any valid locale name returned byCldr.known_locale_names/0or aCldr.LanguageTagstruct. The default isbackend.get_locale/0:territoryis any valid territory code returned byCldr.known_territories/0. The default is the territory defined as part of the:locale. The option:territoryhas a precedence over the territory in a locale.:usageis the way in which the unit is intended to be used. The availableusagevaryies according to the unit category. SeeCldr.Unit.preferred_units/3.
Examples
iex> unit = Cldr.Unit.new!(1.83, :meter)
iex> Cldr.Unit.localize(unit, usage: :person_height, territory: :US)
[Cldr.Unit.new!(:foot, 6), Cldr.Unit.new!(:inch, Ratio.new(6485183463413016, 137269716642252725))]