import { ReactNode } from 'react'; export type Locale = 'en' | 'es' | 'fr' | 'de' | 'ja' | 'zh' | 'ta' | 'hi' | 'ar'; export interface TranslationDictionary { [key: string]: string | TranslationDictionary; } export interface I18nContextValue { locale: Locale; translations: TranslationDictionary; setLocale: (locale: Locale) => void; t: (key: string, fallbackOrParams?: string | Record, params?: Record) => string; /** Whether translations are currently being fetched */ isLoading: boolean; /** Error message if translation fetch failed */ error: string | null; } /** * Function to fetch translations for a specific locale. * Used when dynamic API-based translations are enabled. */ export type FetchTranslationsFn = (locale: Locale) => Promise; export interface I18nProviderProps { children: ReactNode; defaultLocale?: Locale; /** * Static translations (used as fallback or when fetchTranslations is not provided) */ translations?: Record; storageKey?: string; /** * Active profile ID for profile-scoped locale storage. * When provided, locale is also read from / written to bf-p-{profileId}-locale. * Profile-scoped locale takes priority over the global storageKey on init. */ profileId?: string | null; /** * Optional function to fetch translations dynamically from an API. * When provided, translations will be fetched on mount and locale change. * Static translations prop is used as fallback during loading or on error. */ fetchTranslations?: FetchTranslationsFn; /** * Whether to show children during initial translation fetch. * Default: true (show children with fallback translations while loading) */ showChildrenWhileLoading?: boolean; /** * Custom loading component to show while fetching translations. * Only used when showChildrenWhileLoading is false. */ loadingComponent?: ReactNode; } /** * Deep merge translation dictionaries. * * Why this matters: * - Static dictionaries (bundled fallback) can contain keys that are not yet * present in API-fetched payloads. * - Fetched payloads should override static keys where present, but must not * drop static keys for the same locale. */ export declare function mergeTranslationDictionaries(base: TranslationDictionary | undefined, override: TranslationDictionary | undefined): TranslationDictionary; export declare function I18nProvider({ children, defaultLocale, translations: staticTranslations, storageKey, profileId, fetchTranslations, showChildrenWhileLoading, loadingComponent, }: I18nProviderProps): import("react/jsx-runtime").JSX.Element; export declare function useI18n(): I18nContextValue; /** * Clear the global translation cache. * Call this to force a refetch of translations on the next component mount. * Useful for development, testing, or when the user explicitly wants to refresh translations. */ export declare function clearTranslationCache(): void; /** * Check if translations have been attempted for a locale. * Useful for debugging. */ export declare function isTranslationAttempted(locale: Locale): boolean; //# sourceMappingURL=I18nProvider.d.ts.map