Idiom.Cache (idiom v0.6.1)
Cache for translations.
Idiom is flexible in terms of which source translations can be retrieved from. It comes with a few different ones out of the box, and can also be extended
through plugins. Idiom.Cache
provides utilities to interact with the ETS that acts as a central storage for translations, both for adding/updating keys
and retrieving values. table
Summary
Functions
Retrieves a translation from the cache.
Starts a new cache.
Adds a map of keys to the cache.
Functions
Link to this function
get_translation(locale, namespace, key, table_name \\ :idiom_cache)
Retrieves a translation from the cache.
Examples
iex> Cache.get_translation("de", "default", "butterfly")
"Schmetterling"
Link to this function
init(initial_state \\ %{}, table_name \\ :idiom_cache)
Starts a new cache.
Allows adding initial state by passing it as first parameter.
Examples
iex> initial_state = %{
...> "en" => %{"signup" => %{"Create your account" => "Create your account"}},
...> "de" => %{"signup" => %{"Create your account" => "Erstelle deinen Account"}}
...>}
iex> Idiom.Cache.init(initial_state)
:ok
iex> Idiom.Cache.init(%{}, :different_cache_name)
:ok
Link to this function
insert_keys(keys, table_name \\ :idiom_cache)
Adds a map of keys to the cache.
Examples
iex> Idiom.Cache.insert_keys(%{
...> "en" => %{"signup" => %{"Create your account" => "Create your account"}},
...> "de" => %{"signup" => %{"Create your account" => "Erstelle deinen Account"}}}
...>)
:ok