Linguist v0.3.0 Linguist.Compiler View Source

Link to this section Summary

Functions

Compiles keyword list of transactions into function definitions AST

Link to this section Functions

Compiles keyword list of transactions into function definitions AST

Examples

iex> Linguist.Compiler.compile(en: [ hello: "Hello %{name}", alert: "Alert!" ])

quote do def t(locale, path, binding \ [])

def t("en", "hello", bindings), do: "Hello " <> Keyword.fetch!(bindings, :name) def t("en", "alert", bindings), do: "Alert!"

def t(_locale, _path, _bindings), do: {:error, :no_translation} def t!(locale, path, bindings \ []) do

case t(locale, path, bindings) do
  {:ok, translation} -> translation
  {:error, :no_translation} ->
    raise %NoTranslationError{message: "#{locale}: #{path}"}
end

end end