Cldr.Unit.measurement_system_from_locale

You're seeing just the function measurement_system_from_locale, go back to Cldr.Unit module for more information.
Link to this function

measurement_system_from_locale(locale \\ Cldr.get_locale(), key \\ :default)

View Source (since 3.4.0)

Specs

measurement_system_from_locale(
  Cldr.LanguageTag.t() | Cldr.Locale.locale_name(),
  measurement_system_key()
) :: measurement_system() | {:error, {module(), String.t()}}

Determines the preferred measurement system from a locale.

See also Cldr.Unit.known_measurement_systems/0.

Arguments

  • locale is any valid locale name returned by Cldr.known_locale_names/0 or a t:Cldr.LanguageTag struct. The default is Cldr.get_locale/0.

  • key is any measurement system key. The known keys are :default, :temperature and :paper_size. The default key is :default.

Examples

iex> Cldr.Unit.measurement_system_from_locale "en"
:ussystem

iex> Cldr.Unit.measurement_system_from_locale "en-GB"
:uksystem

iex> Cldr.Unit.measurement_system_from_locale "en-AU"
:metric

iex> Cldr.Unit.measurement_system_from_locale "en-AU-u-ms-ussystem"
:ussystem

iex> Cldr.Unit.measurement_system_from_locale "en-GB", :temperature
:uksystem

iex> Cldr.Unit.measurement_system_from_locale "en-AU", :paper_size
:a4

iex> Cldr.Unit.measurement_system_from_locale "en-GB", :invalid
{:error,
 {Cldr.Unit.InvalidSystemKeyError,
  "The key :invalid is not known. Valid keys are :default, :paper_size and :temperature"}}
Link to this function

measurement_system_from_locale(locale, backend, key)

View Source