rebar3_erli18n_keywords (rebar3_erli18n v0.1.0)

Copy Markdown View Source

Name-AND-arity keyword spec for the erli18n facade family.

Extraction keys every recognized call site by {Name, Arity} and reads the literal-bearing argument slots from a data-driven table. Keying by arity is mandatory: the d/dc families put Domain in the FIRST argument, which shifts Context/Msgid/MsgidPlural one slot right relative to the bare family, and the Phase 1 f-family APPENDS a trailing Bindings map that the spec ignores for msgid extraction (the leading slots are identical to the non-f sibling).

Each row is a slots() map giving 1-based argument indices:

  • domain — index of a literal-atom Domain argument (d/dc families), or from_macro when the call carries no Domain slot (the bare family, which the extractor keys under the module's ?GETTEXT_DOMAIN).
  • context — index of a literal msgctxt argument (p/np families), absent otherwise.
  • msgid — index of the literal msgid (always present).
  • plural — index of the literal msgid_plural (n/np families), absent otherwise.

Slots are verified against the erli18n clause heads. A call whose referenced slot is not a compile-time literal (string/charlist or, for domain, a literal atom) is skipped by the extractor — never mis-keyed.

Summary

Types

Whether a recognized call yields a singular or a plural catalog entry.

The literal-bearing argument slots for one {Name, Arity} row.

Functions

Look up the slots for a {Name, Arity} call site.

The full {Name, Arity} => slots() table for the erli18n facade.

Types

kind()

-type kind() :: singular | plural.

Whether a recognized call yields a singular or a plural catalog entry.

slots()

-type slots() ::
          #{domain := pos_integer() | from_macro,
            msgid := pos_integer(),
            context => pos_integer(),
            plural => pos_integer(),
            kind := kind()}.

The literal-bearing argument slots for one {Name, Arity} row.

domain is either a 1-based argument index (when the function carries a Domain slot) or the atom from_macro, meaning "no Domain argument; the extractor supplies the module's ?GETTEXT_DOMAIN". context/plural are present only for the families that carry them.

Functions

lookup(Name, Arity)

-spec lookup(atom(), arity()) -> {ok, slots()} | error.

Look up the slots for a {Name, Arity} call site.

Returns {ok, slots()} for a recognized facade function, or error for any other call (which the extractor leaves untouched).

spec()

-spec spec() -> #{{atom(), arity()} => slots()}.

The full {Name, Arity} => slots() table for the erli18n facade.

Covers the gettext/ngettext/pgettext/npgettext families, their d/dc variants, and the Phase 1 interpolating f-family — roughly fifty arities in all.

The table is a single literal map, so the compiler builds it once and every call returns the same shared constant. lookup/2 is therefore a single maps:find over a constant — no per-call construction or merge.