# `PhoenixKitWeb.Gettext`
[🔗](https://github.com/BeamLabEU/phoenix_kit/blob/v2.32.1/lib/phoenix_kit_web/gettext.ex#L1)

A module providing Internationalization with a gettext-based API.

By using [Gettext](https://hexdocs.pm/gettext),
your module gains a set of macros for translations, for example:

    use Gettext, backend: PhoenixKitWeb.Gettext

    # Simple translation
    gettext("Here is the string to translate")

    # Plural translation
    ngettext("Here is the string to translate",
             "Here are the strings to translate",
             3)

    # Domain-based translation
    dgettext("errors", "Here is the error message to translate")

See the [Gettext Docs](https://hexdocs.pm/gettext) for detailed usage.

This backend does **not** `use Gettext.Backend`. That macro compiles each
message into a function clause, and ~2.7k messages × 7 translated locales
is superlinear in the Erlang compiler (a clean `mix compile --force` spent
~13s on this file even after `split_module_by: [:locale]`, tripping the
">10s" notice). Translations are parsed from `priv/gettext` at compile
time into a nested map, embedded as a compressed binary, and looked up
with `Map.get/2`. Callers still go through `Gettext.dgettext/3` and friends;
only the storage changes.

# `warm_catalog`

```elixir
@spec warm_catalog() :: :ok
```

Decodes the embedded catalogue into `:persistent_term` ahead of the first
lookup.

Called from `PhoenixKit.Application.start/2`. The decode costs ~20ms and
`:persistent_term.put/2` scans every process, so leaving it to the first
`gettext` call puts both on a random request instead of on boot.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
