PhoenixKitComments.Gettext (PhoenixKitComments v0.2.13)

Copy Markdown View Source

Gettext backend for the comments module's own translations.

The module's LiveView / LiveComponent use PhoenixKitWeb, which binds the gettext/1, ngettext/3, … macros to core's PhoenixKitWeb.Gettext. Those modules additionally use Gettext, backend: PhoenixKitComments.Gettext, which rebinds the macros to this backend, so the comments strings resolve against this module's catalogs (priv/gettext) instead of core's. That keeps the comments translations self-contained in this package — extract + translate with the module's own mix gettext.extract / mix gettext.merge.

Naming new locale catalogs

This backend has no per-backend locale wiring; it reads the process-global locale that core sets via Gettext.put_locale/1. Core stores the resolved dialect there (PhoenixKit…DialectMapper), not the base code — e.g. en becomes en-US, de becomes de-DE. So a new catalog must be named by the dialect code, otherwise Gettext won't find it and the UI falls back to the English source. ru and et work as plain base codes only because the mapper maps them to themselves; de would need priv/gettext/de-DE/…, not de.

Summary

Functions

handle_missing_bindings(exception, incomplete)

Callback implementation for Gettext.Backend.handle_missing_bindings/2.

handle_missing_plural_translation(locale, domain, msgctxt, msgid, msgid_plural, n, bindings)

Callback implementation for Gettext.Backend.handle_missing_plural_translation/7.

handle_missing_translation(locale, domain, msgctxt, msgid, bindings)

Callback implementation for Gettext.Backend.handle_missing_translation/5.