Skip to content

Release erli18n-v0.8.0

Latest

Choose a tag to compare

@github-actions github-actions released this 03 Jul 13:45

Added

  • Optional erlydtl template bridge (erli18n_erlydtl). A new optional
    module lets an erlydtl template translate
    its {% trans %} / {% blocktrans %} tags through erli18n — full gettext
    (contexts, CLDR plurals, hot-reloadable persistent_term catalogs, per-request
    locale), with erlydtl keeping ownership of {{ var }} interpolation and
    auto-escaping.

    erli18n_erlydtl:translation_fun/1 returns a render-time translation_fun (a
    fun/2) bound to a gettext domain; pass it in erlydtl's render/2 options. The
    tag mapping — performed by the pure, exported decode/2 — is {% trans %}
    gettext, contextpgettext, a counted {% blocktrans %}ngettext,
    and context + count → npgettext. The locale comes from an explicit
    binary/string locale render option, or falls back to the per-process locale
    (erli18n:which_locale/0) that erli18n_cowboy / erli18n_elli already set —
    so it composes with the request middleware with no extra wiring.

    Unlike the Cowboy/Elli adapters, the bridge is an inverted integration: it
    references zero erlydtl functions (erlydtl calls into the fun), so it is
    not an optional_applications entry and carries no
    xref/dialyzer/eqwalizer suppressions — full static analysis stays live over
    every line. The fun is total over term(): a non-integer count (a missing
    template variable) and a non-chardata runtime _(Var) value are normalized
    rather than crashing the render. On a miss it echoes the msgid — matching
    erlydtl's own source fallback for {% trans %}, and giving a count-appropriate
    two-form fallback for a counted {% blocktrans %} (a deliberate improvement on
    erlydtl's singular-only native fallback). erlydtl is a test-profile
    dependency only; the published package still requires only kernel + stdlib.

    A runnable example lives in examples/erli18n_erlydtl_demo.