timex v2.1.1 Timex.Translator

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 symbol names to symbol strings for the given locale

Returns a map of unit types to translated unit names

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

Same as translate/3, except takes bindings for use in an interpolated translation

Macros

This macro sets the locale during execution of a given block of code

Functions

current_locale()

Specs

current_locale :: String.t

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

default_locale()

Specs

default_locale :: String.t

Returns the currently configured default locale. If not set, “en” is used.

get_day_periods(locale)

Specs

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

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)

Specs

get_months(locale :: String.t) :: %{integer => String.t}

Returns a map of ordinal months to month names

get_months_abbreviated(locale)

Specs

get_months_abbreviated(locale :: String.t) :: %{integer => String.t}

Returns a map of ordinal months to month abbreviations

get_symbols(locale)

Specs

get_symbols(String.t) :: %{atom => String.t}

Returns a map of symbol names to symbol strings for the given locale

get_units(locale)

Specs

get_units(locale :: String.t) :: %{atom => String.t}

Returns a map of unit types to translated unit names

Examples

iex> units = Timex.Translator.get_units("en")
...> {units[:second], units[:years]}
{"second", "years"}
get_weekdays(locale)

Specs

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

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

get_weekdays_abbreviated(locale)

Specs

get_weekdays_abbreviated(locale :: String.t) :: %{integer => String.t}

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

translate(locale, domain, msgid)

Specs

translate(locale :: String.t, domain :: String.t, msgid :: String.t) :: String.t

Translates a string for a given locale and domain.

Examples

iex> Timex.Translator.translate(“ru_RU”, “units”, “year”) “год”

iex> Timex.Translator.translate(“invalid_locale”, “units”, “year”) “year”

translate(locale, domain, msgid, bindings)

Specs

translate(locale :: String.t, domain :: String.t, msgid :: String.t, bindings :: Map.t) :: String.t

Same as translate/3, except takes bindings for use in an interpolated translation

Examples

iex> Timex.Translator.translate(“ru_RU”, “relative_time”, “in %{n} seconds”, n: 5) “через 5 секунды”

iex> Timex.Translator.translate(“invalid_locale”, “relative_time”, “in %{n} seconds”, n: 5) “in 5 seconds”

Macros

with_locale(locale, list)

This macro sets the locale during execution of a given block of code.