Cldr.Unit.Preference.preferred_units-exclamation-mark
preferred_units-exclamation-mark, go back to Cldr.Unit.Preference module for more information.
Returns a list of the preferred units for a given unit, locale, territory and use case.
The units used to represent length, volume and so on depend on a given territory, measurement system and usage.
For example, in the US, people height is most commonly
referred to in inches, or feet and inches.
In most of the rest of the world it is centimeters.
Arguments
unitis any unit returned byCldr.Unit.new/2.backendis any Cldr backend module. That is, any module that includesuse Cldr. The default isCldr.default_backend!/0optionsis a keyword list of options or at:Cldr.Unit.Conversion.Optionsstruct. The default is[].
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.unit_category_usage/0.
Returns
unit_listorraises an exception
Note
This function, unlike Cldr.Unit.preferred_units/3 does not
return any available formatting hints.
Examples
iex> meter = Cldr.Unit.new!(:meter, 1)
iex> Cldr.Unit.Preference.preferred_units! meter, MyApp.Cldr, locale: "en-US", usage: :person_height
[:foot, :inch]
iex> Cldr.Unit.Preference.preferred_units! meter, MyApp.Cldr, locale: "en-US", usage: :person
[:inch]
iex> Cldr.Unit.Preference.preferred_units! meter, MyApp.Cldr, locale: "en-AU", usage: :person
[:centimeter]
iex> Cldr.Unit.Preference.preferred_units! meter, MyApp.Cldr, locale: "en-US", usage: :road
[:foot]
iex> Cldr.Unit.Preference.preferred_units! meter, MyApp.Cldr, locale: "en-AU", usage: :road
[:meter]