GettextTs.T (gettext_ts v0.2.0)

Copy Markdown View Source

The extractable translation macro, with a runtime override hook.

t(domain, msgid, bindings) expands to a dgettext call — that is what mix gettext.extract sees in the AST, so no separate catalog module is needed. Before the compiled Gettext lookup, an optional override source is consulted: config :gettext_ts, override: {Mod, :fun} where fun(locale, domain, msgid) returns {:ok, string} or :not_found. That is the hook for admin-edited translations stored in a database (the pattern mosis proved with its ETS-cached TranslationOverride).

use GettextTs.T, backend: MyAppWeb.Gettext

t("default", "Authentication required")
t("notifications", "Level %{level}!", level: 5)

Summary

Functions

%{var} interpolation for override values — Gettext's dialect.

Functions

interpolate(string, bindings)

%{var} interpolation for override values — Gettext's dialect.

t(domain, msgid, bindings \\ Macro.escape(%{}))

(macro)