View Source Timex.Translator (timex v3.7.11)

Link to this section Summary

Functions

Returns the active locale for the process in which this function is called

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.

Link to this section Functions

@spec current_locale() :: String.t()

Returns the active locale for the process in which this function is called

@spec get_day_periods(locale :: String.t()) :: %{required(atom()) => String.t()}

Returns a map of day period types to translated day period names

examples

Examples

iex> day_periods = Timex.Translator.get_day_periods("en")
...> {day_periods[:am], day_periods[:AM]}
{"am", "AM"}
@spec get_months(locale :: String.t()) :: %{required(integer()) => String.t()}

Returns a map of ordinal months to month names

Link to this function

get_months_abbreviated(locale)

View Source
@spec get_months_abbreviated(locale :: String.t()) :: %{
  required(integer()) => String.t()
}

Returns a map of ordinal months to month abbreviations

@spec get_weekdays(locale :: String.t()) :: %{required(integer()) => String.t()}

Returns a map of ordinal weekdays to weekday names, where Monday = 1, translated in the given locale

Link to this function

get_weekdays_abbreviated(locale)

View Source
@spec get_weekdays_abbreviated(locale :: String.t()) :: %{
  required(integer()) => String.t()
}

Returns a map of ordinal weekdays to weekday abbreviations, where Mon = 1

Link to this function

translate(locale, domain, msgid)

View Source
@spec translate(locale :: String.t(), domain :: String.t(), msgid :: String.t()) ::
  String.t()

Translates a string for a given locale and domain.

examples

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"
Link to this function

translate_plural(locale, domain, msgid, msgid_plural, n)

View Source
@spec translate_plural(
  locale :: String.t(),
  domain :: String.t(),
  msgid :: String.t(),
  msgid_plural :: String.t(),
  n :: integer()
) :: String.t()

Translates a string for a given locale and domain, following the pluralization rules of that language.

examples

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"
Link to this macro

with_locale(locale, list)

View Source (macro)