GettextTranslator.Dashboard.PromptTemplates (gettext_translator v0.7.0)

Copy Markdown View Source

Locale-aware prompt templates for quick LLM translation actions.

Each action (regenerate, short_version, rephrase, synonyms) has a prompt written in the target language to help the LLM produce more natural output. Falls back to English for unsupported locales.

Summary

Functions

Returns a human-readable label for a quick action.

Returns the list of available quick actions.

Returns the prompt for a given action and language code.

Types

action()

@type action() :: :regenerate | :short_version | :rephrase | :synonyms

Functions

action_label(atom)

@spec action_label(action()) :: String.t()

Returns a human-readable label for a quick action.

Examples

iex> PromptTemplates.action_label(:short_version)
"Short Version"

actions()

@spec actions() :: [action()]

Returns the list of available quick actions.

Examples

iex> PromptTemplates.actions()
[:regenerate, :short_version, :rephrase, :synonyms]

get_prompt(action, language_code)

@spec get_prompt(action(), String.t()) :: String.t()

Returns the prompt for a given action and language code.

The language code is a POSIX locale (e.g., "uk", "es", "pt_BR"). Falls back to English if the locale is not supported.

Examples

iex> PromptTemplates.get_prompt(:rephrase, "uk")
"Перефразуй переклад іншими словами, збережи той самий зміст але використай інші конструкції"

iex> PromptTemplates.get_prompt(:regenerate, "pt_BR")
"Traduza este texto novamente, ofereça uma nova alternativa de tradução"

iex> PromptTemplates.get_prompt(:short_version, "ja")
"Make the translation as short as possible while keeping the core meaning"