i18n-ai-translate
Version:
AI-powered localization CLI, Node library, and GitHub Action. Translate i18next JSON, Gettext PO, Java .properties, and iOS .strings with ChatGPT, Claude, Gemini, or local Ollama models.
67 lines (66 loc) • 3.26 kB
TypeScript
import type Glossary from "../interfaces/glossary";
import type OverridePrompt from "../interfaces/override_prompt";
/**
* Prompt an AI to convert a given input from one language to another
* @param inputLanguageCode - The ISO-639-1 code of the input
* @param outputLanguageCode - The ISO-639-1 code of the output
* @param input - The input to be translated
* @param options - Optional override/context knobs
* @returns A prompt for the AI to translate the input
*/
export declare function generationPrompt(inputLanguageCode: string, outputLanguageCode: string, input: string, options?: {
overridePrompt?: OverridePrompt;
context?: string;
glossary?: Glossary;
}): string;
/**
* Prompt an AI to correct a failed translation
* @param inputLanguageCode - The ISO-639-1 code of the input
* @param outputLanguageCode - The ISO-639-1 code of the output
* @param source - The original source string that should have been translated
* @param failedOutput - The previous failed attempt at translating it
* @returns A prompt for the AI to retry the translation
*/
export declare function failedTranslationPrompt(inputLanguageCode: string, outputLanguageCode: string, source: string, failedOutput: string): string;
/**
* Prompt an AI to ensure a translation is valid
*
* This is a single rubric that replaces the old separate accuracy and
* styling ACK/NAK prompts. The response is still text: NAK if any
* translation is incorrect on either accuracy or styling grounds,
* ACK otherwise. Merging the two prompts halves the round-trip cost
* and fixes the line-alignment fragility that showed up when one of
* the two prompts disagreed on line counts.
*
* @param inputLanguageCode - The ISO-639-1 code of the input
* @param outputLanguageCode - The ISO-639-1 code of the output
* @param input - The original input, one item per line
* @param output - The translated output, one item per line
* @param options - Optional override/context knobs
* @returns A prompt for the AI to verify the translation
*/
export declare function translationVerificationPrompt(inputLanguageCode: string, outputLanguageCode: string, input: string, output: string, options?: {
overridePrompt?: OverridePrompt;
context?: string;
glossary?: Glossary;
}): string;
/**
* Legacy standalone styling prompt.
*
* Kept for backwards compatibility with custom override-prompt files
* that still reference `stylingVerificationPrompt`. New code should use
* `translationVerificationPrompt` above, which checks both accuracy and
* styling in a single pass. Calling this function without a matching
* override returns an ACK (no-op) — the merged prompt above already
* handles styling.
* @param inputLanguageCode - The ISO-639-1 code of the input
* @param outputLanguageCode - The ISO-639-1 code of the output
* @param input - The original input
* @param output - The translated output
* @param options - Optional override/context knobs
* @returns A prompt for the AI, or a sentinel indicating no standalone check
*/
export declare function stylingVerificationPrompt(inputLanguageCode: string, outputLanguageCode: string, input: string, output: string, options?: {
overridePrompt?: OverridePrompt;
context?: string;
}): string;