/** * LLM-Based Translation with Symbol Preservation * * This module provides utilities for translating AAC files while preserving * symbol-to-word associations across different formats (gridset, OBF, Snap, etc.). * * The key insight: Different AAC formats have different internal structures, * but they all share common concepts: * - Buttons with labels and messages * - Symbols attached to specific words * - Need to preserve symbol positions during translation * * This module provides a format-agnostic way to: * 1. Extract symbol information for LLM processing * 2. Apply LLM translations with preserved symbols * * Usage: * 1. Processor extracts buttons and calls extractSymbolsForLLM() * 2. LLM translates and returns aligned symbols * 3. Processor calls processLLMTranslations() to apply results */ /** * Represents a symbol attached to text in a format-agnostic way */ export interface SymbolInfo { text: string; image?: string; symbolLibrary?: string; symbolPath?: string; } /** * Button data extracted for translation (format-agnostic) */ export interface ButtonForTranslation { buttonId: string; pageId?: string; pageName?: string; label: string; message: string; textToTranslate: string; symbols: SymbolInfo[]; grammar?: any; } /** * LLM translation result with symbol mappings */ export interface LLMLTranslationResult { buttonId: string; translatedLabel?: string; translatedMessage?: string; symbols?: Array<{ text: string; image?: string; }>; } /** * Extract symbols from a button for LLM-based translation. * * This is a format-agnostic helper that processors can use to normalize * their button data into a common format for LLM processing. * * @param buttonId - Unique identifier for the button * @param label - Button label text * @param message - Button message/speak text * @param symbols - Array of symbols from the button * @param context - Optional page context * @returns Normalized button data for translation */ export declare function normalizeButtonForTranslation(buttonId: string, label: string, message: string, symbols: SymbolInfo[], context?: { pageId?: string; pageName?: string; }, grammar?: any): ButtonForTranslation; /** * Extract symbols from various button formats. * * This helper handles different ways symbols might be stored in button data: * - semanticAction.richText.symbols (gridset format) * - symbolLibrary + symbolPath fields * - image field with [library]path format * * @param button - Button object from any AAC format * @returns Array of symbol info, or undefined if no symbols */ export declare function extractSymbolsFromButton(button: any): SymbolInfo[] | undefined; /** * Extract all buttons from a file for LLM translation. * * This is a convenience method that processors can use to extract all * translatable buttons with their symbols in a format-agnostic way. * * @param buttons - Array of button objects from any AAC format * @param contextFn - Optional function to provide page context for each button * @returns Array of normalized button data ready for LLM translation */ export declare function extractAllButtonsForTranslation(buttons: any[], contextFn?: (button: any) => { pageId?: string; pageName?: string; }): ButtonForTranslation[]; /** * Create a prompt for LLM translation with symbol preservation. * * This generates a structured prompt that instructs the LLM to translate * while preserving symbol-to-word associations. * * @param buttons - Buttons to translate * @param targetLanguage - Target language for translation * @returns Prompt string for LLM */ export declare function createTranslationPrompt(buttons: ButtonForTranslation[], targetLanguage: string): string; /** * Validate LLM translation results before applying. * * @param translations - LLM translation results * @param originalButtonIds - Expected button IDs (optional, for validation) * @param options - Validation options * @throws Error if validation fails */ export declare function validateTranslationResults(translations: LLMLTranslationResult[], originalButtonIds?: string[], options?: { allowPartial?: boolean; }): void;