/** * Translation Service * * Provides translation query and loading operations. * Uses pre-computed data from translation-registry for O(1) operations. * * @module TranslationService */ import { TranslationLoader } from '@nextsparkjs/registries/translation-registry'; /** * Translation Service - Provides runtime translation queries * * This service layer abstracts translation registry access, making the registry * a pure data structure (Data-Only pattern). All query logic lives here. * * Performance: All operations are O(1) or O(n) with zero I/O. */ export declare class TranslationService { /** * Get theme translation loader function * Returns a lazy-loading function (doesn't load until called) * * @param theme - Theme name (e.g., 'default') * @param locale - Locale code (e.g., 'en', 'es') * @returns Lazy-loading function or null if not found * * @example * ```typescript * const loader = TranslationService.getLoader('default', 'en') * if (loader) { * const translations = await loader() * } * ``` */ static getLoader(theme: string, locale: string): TranslationLoader | null; /** * Load theme translation (executes the loader) * Convenience wrapper that calls the loader function * * @param theme - Theme name * @param locale - Locale code * @returns Translation data or empty object if not found * * @example * ```typescript * const translations = await TranslationService.load('default', 'en') * // Returns translation object or {} if not found * ``` */ static load(theme: string, locale: string): Promise>; /** * Get available locales for a theme * * @param theme - Theme name * @returns Array of locale codes * * @example * ```typescript * const locales = TranslationService.getLocales('default') * // Returns ['en', 'es'] * ``` */ static getLocales(theme: string): string[]; /** * Get all themes with translations * * @returns Array of theme names * * @example * ```typescript * const themes = TranslationService.getThemes() * // Returns ['default'] * ``` */ static getThemes(): string[]; /** * Check if theme has translation for locale * * @param theme - Theme name * @param locale - Locale code * @returns True if translation exists * * @example * ```typescript * if (TranslationService.has('default', 'en')) { * // Translation exists, safe to load * } * ``` */ static has(theme: string, locale: string): boolean; /** * Get entity translation loader function * Returns a lazy-loading function (doesn't load until called) * * @param theme - Theme name (e.g., 'default') * @param entity - Entity name (e.g., 'products', 'blog') * @param locale - Locale code (e.g., 'en', 'es') * @returns Lazy-loading function or null if not found * * @example * ```typescript * const loader = TranslationService.getEntityLoader('default', 'products', 'en') * if (loader) { * const translations = await loader() * } * ``` */ static getEntityLoader(theme: string, entity: string, locale: string): TranslationLoader | null; /** * Load entity translation (executes the loader) * Convenience wrapper that calls the loader function * * @param theme - Theme name * @param entity - Entity name * @param locale - Locale code * @returns Translation data or empty object if not found * * @example * ```typescript * const translations = await TranslationService.loadEntity('default', 'products', 'en') * // Returns translation object or {} if not found * ``` */ static loadEntity(theme: string, entity: string, locale: string): Promise>; /** * Load plugin entity translation as fallback * Searches all plugins for an entity with the given name and locale * * @param entity - Entity name (e.g., 'leadforms') * @param locale - Locale code (e.g., 'en', 'es') * @returns Merged plugin translations or empty object */ private static loadPluginEntityFallback; /** * Deep merge two objects. Values in `override` take priority over `base`. * Only plain objects are merged recursively; other values are replaced. */ private static deepMerge; /** * Get available locales for an entity in a theme * * @param theme - Theme name * @param entity - Entity name * @returns Array of locale codes * * @example * ```typescript * const locales = TranslationService.getEntityLocales('default', 'products') * // Returns ['en', 'es'] * ``` */ static getEntityLocales(theme: string, entity: string): string[]; /** * Get all entities with translations for a theme * * @param theme - Theme name * @returns Array of entity names * * @example * ```typescript * const entities = TranslationService.getEntities('default') * // Returns ['products', 'blog'] * ``` */ static getEntities(theme: string): string[]; /** * Check if entity has translation for locale * * @param theme - Theme name * @param entity - Entity name * @param locale - Locale code * @returns True if translation exists * * @example * ```typescript * if (TranslationService.hasEntity('default', 'products', 'en')) { * // Translation exists, safe to load * } * ``` */ static hasEntity(theme: string, entity: string, locale: string): boolean; /** * Load all entity translations for a theme and locale * Useful for preloading all entity translations at once * * @param theme - Theme name * @param locale - Locale code * @returns Object with entity names as keys and translations as values * * @example * ```typescript * const allEntityTranslations = await TranslationService.loadAllEntities('default', 'en') * // Returns { products: {...}, blog: {...} } * ``` */ static loadAllEntities(theme: string, locale: string): Promise>>; } //# sourceMappingURL=translation.service.d.ts.map