/** * Auto Translator * Automatically translates block-level elements in DOM content. * Uses ContentUnit model for key parity with WordPress TS, PHP, and edge proxy. * * Missing translations are reported via the event bus (translation:not-found), * picked up by MissingTranslationQueue, and synced through NetworkRepository. */ import type { LionRapidCore } from '../lionRapid.js'; import { ExcludePatterns } from './exclude-filter.js'; export interface AutoTranslatorConfig { excludePatterns?: Partial; excludeSelectors?: string[]; minTextLength?: number; debounceMs?: number; } export declare class AutoTranslator { private core; private blockExtractor; private attributeExtractor; private domObserver; private locale; private sourceLocale; private namespace; private debounceMs; private pendingElements; private debounceTimer; private translatedCount; constructor(config?: AutoTranslatorConfig); /** * Set the core instance */ setCore(core: LionRapidCore): void; /** * Initialize locale and namespace for cache key construction */ init(config: { namespace: string; locale: string; sourceLocale: string; }): void; /** * Update locale (after language change) */ updateLocale(locale: string): void; /** * Check if ready */ isReady(): boolean; /** * Generate auto key for text (exposed for testing) */ generateAutoKey(text: string): string; /** * Queue an element for translation (debounced) */ queueElement(element: Element): void; /** * Translate an element immediately */ translateElement(element: Element): number; /** * Translate the entire page */ translatePage(): number; /** * Start observing DOM for dynamic content */ observe(): void; /** * Stop observing DOM */ stopObserving(): void; /** * Schedule debounced processing */ private scheduleProcessing; /** * Process all pending elements */ private processPendingElements; /** * Translate extracted blocks using ContentUnit model */ private translateBlocks; /** * Translate extracted attribute units against the cache. * * Mirrors translateBlocks but for attribute values. For each hit, the * original attribute value is preserved in `data-lr-orig-{name}` so * retranslate() can restore source. The element accumulates a comma- * separated `data-lionrapid-client-attrs` list naming every attr the * client touched — so we can find them all on retranslate without * iterating a fixed selector set. * * Cache misses emit `translation:not-found` with empty styles, so the * existing MissingTranslationQueue + NetworkRepository sync queue * picks them up unchanged. */ private translateAttributesIn; /** * Get translated count */ getTranslatedCount(): number; /** * Restore every client-translated attribute on `el` from its * `data-lr-orig-*` backup, then strip the stamps. Mirrors the block-side * restoration in retranslate() so language switch / editor reset clears * attributes too. */ private restoreClientAttributes; /** * Re-translate a single element (for editor live preview reset) */ retranslateElement(element: Element): void; /** * Re-translate the page (after language change) */ retranslate(): void; } //# sourceMappingURL=auto-translator.d.ts.map