# `DialectoInContext.Gettext`
[🔗](https://github.com/dialecto-eu/dialecto-phoenix/blob/v0.1.0/lib/dialecto_in_context/gettext.ex#L1)

Marks a Gettext backend's translations for the in-context editor
(spec-0017 §1.1). Opt in after `use Gettext.Backend`, guarded so it compiles
away wherever the dev-only dependency is absent:

    defmodule MyAppWeb.Gettext do
      use Gettext.Backend, otp_app: :my_app
      if Code.ensure_loaded?(DialectoInContext.Gettext), do: @before_compile(DialectoInContext.Gettext)
    end

`__before_compile__/1` runs after Gettext's own (hooks run in the order they
are registered), makes the generated `lgettext/5` and `lngettext/7`
overridable and wraps them: the original lookup runs (`super`) — unless a
saved draft replaces it — and, only while marking is on, the text is
wrapped in a marker whose payload is `domain US key US locale RS argsJSON`
(`DialectoInContext.Marker`, `DialectoInContext.Args`). `key` is the msgid,
or `msgctxt <> U+0004 <> msgid`. Results other than `{:ok, _}` and
`{:default, _}` (gettext's missing-bindings error) pass through untouched.

With marking off and no drafts, a lookup costs two ETS reads on top of
gettext's own.

# `__lgettext__`

The wrapped `lgettext/5` of `backend`: `lookup` is the original (`super`).
Called by the generated override; not for direct use.

# `__lngettext__`

The wrapped `lngettext/7` of `backend`: `lookup` is the original (`super`).
Called by the generated override; not for direct use.

# `key`

```elixir
@spec key(String.t() | nil, String.t()) :: String.t()
```

The marker key of a message: its msgid, or `msgctxt <> U+0004 <> msgid`.

# `plural_form`

```elixir
@spec plural_form(module(), String.t(), String.t(), number()) :: non_neg_integer()
```

The plural form `backend` uses for `n` in `locale` — from the catalog's
`Plural-Forms` when `{locale, domain}` has one, else the locale's rules;
gettext's own fallback (`n == 1` ⇒ 0) for a locale its plural module
doesn't know.

---

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