Locale Names v1.0.1 Locale View Source
Utilities for working with locales (in the form of en-US
).
The main goal is to be able to display a list of languages in their own spelling (en-US
is “American English”, fr-CA
is “Français canadien”).
The Locale struct
The fields are:
direction
- In what direction is that language writtenenglish_name
- The English name of this languagelocale_code
- The locale code of this Localename
- The name of that language in its own spelling
Link to this section Summary
Link to this section Types
Link to this type
direction_type()
View Source
direction_type() :: :left_to_right | :right_to_left | :unknown_direction
Link to this type
locale()
View Source
locale() :: %Locale{ direction: direction_type(), english_name: String.t(), locale_code: locale_code(), name: String.t() }
Link to this section Functions
Link to this function
locale(locale_code)
View Source
locale(locale_code()) :: {:ok, locale()} | {:error, :locale_not_found}
Returns a tuple {:ok, locale()} where locale()
is a Locale
struct detailing the locale from the locale code
passed or a tuple {:error, :locale_not_found}
Examples
iex> Locale.locale("en-US")
{:ok,
%Locale{
direction: :left_to_right,
english_name: "American English",
locale_code: "en-US",
name: "American English"
}
}
iex> Locale.locale("fr-FR")
{:ok,
%Locale{
direction: :left_to_right,
english_name: "French",
locale_code: "fr-FR",
name: "Français"
}
}