PhoenixKit.Modules.Publishing.Web.Editor.Translation (phoenix_kit v1.7.71)
Copy Markdown View SourceAI translation functionality for the publishing editor.
Handles translation workflow, Oban job enqueuing, and translation progress tracking.
Summary
Functions
Checks if AI translation is available (AI module enabled + endpoints configured).
Builds warnings for the translation confirmation modal.
Checks if the default translation prompt already exists.
Actually enqueues the translation job (after confirmation if needed).
Enqueues translation job with validation and warnings. Returns {:noreply, socket} for use in handle_event.
Generates the default translation prompt in the AI prompts system. Returns {:ok, prompt} or {:error, changeset}.
Gets all target languages for translation (all except primary).
Gets the default AI endpoint UUID from settings.
Gets the default AI prompt UUID for translation from settings.
Gets target languages for translation (missing languages only).
Lists available AI endpoints for translation.
Lists available AI prompts for translation.
Clears completed translation status when switching languages.
Restores translation status from an active Oban job if one exists for this post. Call on mount to survive page refreshes.
Checks if the source content is blank.
Returns the source language for translation based on the post's primary language or the system default.
Starts translation to the current (non-primary) language.
Functions
Checks if AI translation is available (AI module enabled + endpoints configured).
Builds warnings for the translation confirmation modal.
Checks if the default translation prompt already exists.
Actually enqueues the translation job (after confirmation if needed).
Enqueues translation job with validation and warnings. Returns {:noreply, socket} for use in handle_event.
Generates the default translation prompt in the AI prompts system. Returns {:ok, prompt} or {:error, changeset}.
Gets all target languages for translation (all except primary).
Gets the default AI endpoint UUID from settings.
Gets the default AI prompt UUID for translation from settings.
Gets target languages for translation (missing languages only).
Lists available AI endpoints for translation.
Lists available AI prompts for translation.
Clears completed translation status when switching languages.
Restores translation status from an active Oban job if one exists for this post. Call on mount to survive page refreshes.
Checks if the source content is blank.
Returns the source language for translation based on the post's primary language or the system default.
Starts translation to the current (non-primary) language.