Yatapp (Yatapp v0.3.0) View Source

Yata integration hex package.

Link to this section Summary

Functions

See Yatapp.Config.default_locale/0.

Search for translation in given locale based on provided key.

Link to this section Functions

See Yatapp.Config.default_locale/0.

Link to this function

translate(locale, key, values \\ %{})

View Source

Specs

translate(String.t(), String.t(), map() | Keyword.t()) :: String.t() | none()

Search for translation in given locale based on provided key.

Parameters

  • locale: String with name of locale.
  • key: String with path to translation.
  • values: Map with values that will be interpolated.

Examples

iex> Yatapp.translate("en", "hello")
"Hello world"

iex> Yatapp.translate("en", "hello_name", name: "Joe")
"Hello Joe"

iex> Yatapp.translate("en", "invalid")
** (ArgumentError) Missing translation for key: en.invalid

iex> Yatapp.translate("en", "hello_name", name: %{"1" => "2"})
** (ArgumentError) Only string, boolean or number allowed for values.