exi18n v0.2.0 ExI18n

ExI18n - key-based internationalization library.

Summary

Functions

Default locale set in configuration

Path to directory that contains all files with translations

Storage type used to store translations

Search for translation in given locale based on provided key

Functions

locale()

Default locale set in configuration.

path()

Path to directory that contains all files with translations.

storage()

Storage type used to store translations.

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

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> ExI18n.t("en", "hello")
"Hello world"

iex> ExI18n.t("en", "hello_name", name: "Joe")
"Hello Joe"

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

iex> ExI18n.t("en", "incomplete.path")
** (ArgumentError) incomplete.path is incomplete path to translation.

iex> ExI18n.t("en", "hello_name", name: %{"1" => "2"})
** (Protocol.UndefinedError) protocol String.Chars not implemented for %{"1" => "2"}