Kanta.Translations.Messages (kanta v0.5.1)
Kanta Messages subcontext
Summary
Functions
Deletes a stale message and ALL its translations across ALL locales.
Merges two messages by moving all translations from one message to another.
Functions
Deletes a stale message and ALL its translations across ALL locales.
This function removes the message completely from the system, including all singular and plural translations in every locale.
Arguments
message_id- Integer ID of the message
Returns
{:ok, stats}- Map containing deletion statistics::translations_deleted- Number of translations deleted across all locales:message_deleted- Boolean indicating if message was deleted
{:error, reason}- If deletion fails
Examples
iex> Kanta.Translations.Messages.delete_message(123)
{:ok, %{translations_deleted: 5, message_deleted: true}}
Merges two messages by moving all translations from one message to another.
This operation:
- Deletes all existing translations from the target message
- Moves all translations from the source message to the target message
- Deletes the source message
This is useful when a stale message needs to be merged with its replacement (e.g., when msgid changes due to typo fixes or wording changes).
Arguments
from_message_id- ID of the source message (will be deleted)to_message_id- ID of the target message (will receive translations)
Returns
{:ok, target_message}- Target message with merged translations{:error, :not_found}- One or both messages not found{:error, reason}- Merge failed
Examples
iex> merge_messages(123, 456)
{:ok, %Message{id: 456, ...}}