polyglot v0.0.1 Polyglot.Data
Provides access to a subset of data from the Unicode CLDR. The following data is currently available:
key |
Example value | Description |
|---|---|---|
:weekdays |
["Sunday", "Monday", ...] |
List of weekday names |
:weekdays_abbr |
["Sun", "Mon", "Tue", ...] |
List of abbreviated weekday names |
:months |
["January", "February", ...] |
List of month names |
:months_abbr |
["Jan", "Feb", "Mar", ...] |
List of abbreviated month names |
:date_format |
"M/d/y" |
Date format |
:time_format |
"HH:mm:ss" |
Time format |
:datetime_format |
"E, MMM d, y" |
Combined date and time format |
Summary
Functions
The list of available locales according to the locales present in the Unicode CLDR data
The list of enabled locales according to your Mix configuration
Fetch the translated value for a given key and locale. If a translation is not found in the given locale, an attempt is made to fetch the key from its parent locales
Like get/2, but will return the value directly or raise an error
Functions
The list of available locales according to the locales present in the Unicode CLDR data.
Fetch the translated value for a given key and locale. If a translation is not found in the given locale, an attempt is made to fetch the key from its parent locales.
Returns one of the following:
{:ok, value}when the translation is found for the locale or any of its parent locales.{:error, :missing_translation}when the translation is not found for the locale or any of its parent locales.{:error, :invalid_key}when the key is not known.{:error, :invalid_locale}when the locale is not known or not enabled.{:error, reason}for any other errors that might occur.
Examples
iex> Polyglot.Data.get(:weekdays, :fr)
{:ok, ["dimanche", "lundi", "mardi", "mercredi", "jeudi", "vendredi", "samedi"]}
iex> Polyglot.Data.get(:weekdays_abbr, :en)
{:ok, ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"]}
Like get/2, but will return the value directly or raise an error.
Examples
iex> Polyglot.Data.get!(:weekdays, :fr)
["dimanche", "lundi", "mardi", "mercredi", "jeudi", "vendredi", "samedi"]
iex> Polyglot.Data.get!(:weekdays_abbr, :en)
["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"]