timex v3.5.0 Timex.Translator View Source
Link to this section Summary
Functions
Returns the active locale for the process in which this function is called
Returns the currently configured default locale. If not set, "en" is used
Returns a map of day period types to translated day period names
Returns a map of ordinal months to month names
Returns a map of ordinal months to month abbreviations
Returns a map of ordinal weekdays to weekday names, where Monday = 1, translated in the given locale
Returns a map of ordinal weekdays to weekday abbreviations, where Mon = 1
Translates a string for a given locale and domain
Translates a string for a given locale and domain, following the pluralization rules of that language
This macro sets the locale during execution of a given block of code
Link to this section Functions
current_locale()
View Source
current_locale() :: String.t()
current_locale() :: String.t()
Returns the active locale for the process in which this function is called
default_locale()
View Source
default_locale() :: String.t()
default_locale() :: String.t()
Returns the currently configured default locale. If not set, "en" is used.
get_day_periods(locale) View Source
Returns a map of day period types to translated day period names
Examples
iex> day_periods = Timex.Translator.get_day_periods("en")
...> {day_periods[:am], day_periods[:AM]}
{"am", "AM"}
get_months(locale) View Source
Returns a map of ordinal months to month names
get_months_abbreviated(locale) View Source
Returns a map of ordinal months to month abbreviations
get_weekdays(locale) View Source
Returns a map of ordinal weekdays to weekday names, where Monday = 1, translated in the given locale
get_weekdays_abbreviated(locale) View Source
Returns a map of ordinal weekdays to weekday abbreviations, where Mon = 1
translate(locale, domain, msgid) View Source
Translates a string for a given locale and domain.
Examples
iex> Timex.Translator.translate("ru", "weekdays", "Saturday")
"суббота"
iex> Timex.Translator.translate("it", "weekdays", "Saturday")
"Sabato"
iex> Timex.Translator.translate("invalid_locale", "weekdays", "Saturday")
"Saturday"
translate_plural(locale, domain, msgid, msgid_plural, n) View Source
Translates a string for a given locale and domain, following the pluralization rules of that language.
Examples
iex> Timex.Translator.translate_plural("ru", "relative_time", "in %{count} second", "in %{count} seconds", 5)
"через 5 секунд"
iex> Timex.Translator.translate_plural("it", "relative_time", "in %{count} second", "in %{count} seconds", 5)
"in 5 secondi"
iex> Timex.Translator.translate_plural("invalid_locale", "relative_time", "in %{count} second", "in %{count} seconds", 5)
"in 5 seconds"
with_locale(locale, list) View Source (macro)
This macro sets the locale during execution of a given block of code.