Locale-sensitive display name resolution, modelled on
Intl.DisplayNames.
Returns the localized display name for a given code based on its type: region, language, currency, script, calendar, or date-time field.
Delegates to Localize.Territory, Localize.Language,
Localize.Currency, Localize.Script, and Localize.Calendar
for the underlying lookups.
Summary
Functions
Returns the localized display name for the given code.
Returns the localized display name, raising on error.
Functions
Returns the localized display name for the given code.
Arguments
codeis a string or atom identifying the entity (for example,"US"for a region,"fr"for a language, or"EUR"for a currency).optionsis a keyword list of options.
Options
:typeis a required option. One of:region,:language,:currency,:script,:calendar, or:date_time_field.:localeis a locale identifier string or atom. The default is the current process locale.:styleis:standard,:short,:long,:menu, or:variantwhere applicable. The default varies by type.
Returns
{:ok, display_name}on success.{:error, reason}if the code or type is invalid.
Examples
iex> Intl.DisplayNames.of("US", type: :region, locale: :en)
{:ok, "United States"}
iex> Intl.DisplayNames.of("fr", type: :language, locale: :en)
{:ok, "French"}
iex> Intl.DisplayNames.of("EUR", type: :currency, locale: :en)
{:ok, "Euro"}
iex> Intl.DisplayNames.of(:Latn, type: :script, locale: :en)
{:ok, "Latin"}
iex> Intl.DisplayNames.of(:gregorian, type: :calendar, locale: :en)
{:ok, "Gregorian Calendar"}
iex> Intl.DisplayNames.of(:year, type: :date_time_field, locale: :en)
{:ok, "year"}
Returns the localized display name, raising on error.
Same as of/2 but returns the string directly or raises.
Arguments
codeis a string or atom identifying the entity.optionsis a keyword list of options.
Returns
- A display name string.
Examples
iex> Intl.DisplayNames.of!("US", type: :region, locale: :en)
"United States"