Multilang data JSONB helpers — read merged language data from a
record and write language-specific overrides through the entity's own
update function.
Public surface is re-exported from PhoenixKitCatalogue.Catalogue.
Summary
Functions
Gets translated field data for a record in a specific language. Returns merged data (primary language as base + overrides for the requested language).
Replaces :name (and :description where present) on each record
with the locale-resolved display text, so list/detail surfaces can
render record.name untouched and still honor the viewer's locale.
Single-record localize/2.
Updates the multilang data field for a record with language-specific
field data. For primary language: stores ALL fields. For secondary
languages: stores only overrides (differences from primary).
Same contract as translated_name/2, for :description.
The display name for locale: the locale's translation override
(either the "_name" shape the shared multilang helper writes or the
legacy bare "name"), falling back to the primary-language column.
Safe on records without translations and on plain maps.
Functions
Gets translated field data for a record in a specific language. Returns merged data (primary language as base + overrides for the requested language).
Replaces :name (and :description where present) on each record
with the locale-resolved display text, so list/detail surfaces can
render record.name untouched and still honor the viewer's locale.
Resolve-early by design (the same shape as resolved_group/2): the
alternative — threading a locale attr through every table/tile/cell
component — spreads the concern across dozens of render sites.
Records without a :data map (folders) pass through unchanged, as
does everything when locale is nil. Struct identity is preserved
(%{record | ...}), and mutations are unaffected: status/move/
reorder writes never take :name from these list structs.
Single-record localize/2.
@spec set_translation(map(), String.t(), map(), function(), keyword()) :: {:ok, term()} | {:error, term()}
Updates the multilang data field for a record with language-specific
field data. For primary language: stores ALL fields. For secondary
languages: stores only overrides (differences from primary).
update_fn is the entity's update function. It receives (record, attrs)
for 2-arity or (record, attrs, opts) for 3-arity when activity-logging
opts are provided.
Same contract as translated_name/2, for :description.
The display name for locale: the locale's translation override
(either the "_name" shape the shared multilang helper writes or the
legacy bare "name"), falling back to the primary-language column.
Safe on records without translations and on plain maps.