/** * Represents a file-based translation structure where translations are stored in a single file. * The file path is determined by the locale only. */ type FileStructure = { type: 'file'; absolute_file_path: (locale: string, file_name?: undefined) => string; file_name?: undefined; }; /** * Represents a folder-based translation structure where translations are organized in folders. * Each folder contains translation files, and the file path is determined by both locale and file name. */ type FolderStructure = { type: 'folder'; absolute_file_path: (locale: string, file_name: string) => string; file_name: string; }; /** * Configuration type for translation requests. * Can be either a file-based or folder-based structure, with locale being required in both cases. */ type Configuration = { locale: string; } & (FileStructure | FolderStructure); type TranslationStatusState = { status: 'pending' | 'resolved' | 'rejected'; translations: { [key: string]: object; }; }; type BackwardCompatAbilityType = { oldTranslations: Record | undefined; enableCDN: boolean | undefined; }; /** * Main translation request hook that orchestrates the translation loading process. * This hook serves as the primary entry point for requesting translations and * coordinates between saving and loading translations. * * The hook combines: * 1. Translation state management (via useSaveTranslations) * 2. Loading of translations (via useLoadTranslations) * * @param config - Configuration object containing translation request details * @param nonStandardTranslations - Optional pre-loaded translations * @param oldTranslations - Optional pre-loaded translations * @param enableCDN - Optional flag to enable CDN translations * @returns Object containing translation status and data */ declare function useRequestTranslations(config: Configuration, nonStandardTranslations: Record, backwardCompatAbility?: BackwardCompatAbilityType): TranslationStatusState; /** * Custom hook that preloads translations for a given configuration. * It checks if the translations are already cached in nonStandardTranslations * and if not, it preloads them by publishing a subscription request. * * @param config - Configuration object containing translation request details * @param nonStandardTranslations - Optional pre-loaded translations */ declare function usePreloadTranslations(config: Configuration, enableCDN: boolean | undefined): void; /** * Main translation request hook that orchestrates the translation loading process. * This hook serves as the primary entry point for requesting translations and * coordinates between saving and loading translations. * * The hook combines: * 1. Translation state management (via useFetchTranslations) * 2. Backward compatibility with traditional translation loading * 3. CDN feature flag integration * * @param config - Configuration object containing translation request details * @param nonStandardTranslations - Optional pre-loaded translations * @param backwardCompatAbility - Object containing backward compatibility options * @param backwardCompatAbility.oldTranslations - Optional pre-loaded translations from traditional method * @param backwardCompatAbility.enableCDN - Optional flag to enable CDN translations * @returns Object containing translation status and data */ declare function useMFETranslations(config: Configuration, nonStandardTranslations: Record, backwardCompatAbility?: BackwardCompatAbilityType): TranslationStatusState; /** * Fallback List Generation System * Creates an ordered list of locales to try when loading translations, * ensuring no duplicate locales and maintaining a consistent fallback hierarchy. */ /** * Generates a prioritized list of locales to try when loading translations. * The list includes: * 1. The requested locale * 2. The overridden locale (if different from requested) * 3. English ('en') as the final fallback * * Duplicates are removed while maintaining the priority order. * * @param locale - The primary locale to request translations for * @returns An array of unique locales in priority order */ declare function getFallbackList(locale: string): string[]; /** * The key used to store/retrieve the feature flag in local storage. */ declare const CDN_TRANSLATION_FEATURE_FLAG_KEY = "cdn-translation"; /** * Checks if the CDN feature flag is enabled. * @param i18n - The i18n object containing the enableCDN flag * @returns The current state of the feature flag (true/false) or null if not set */ declare function isCDNFeatureFlagEnabled(i18n: { enableCDN?: boolean; } | undefined, value?: boolean): boolean; /** * Retrieves the LD ID for the CDN translation feature flag based on the domain. * @param domain - The domain to determine the LD ID for * @returns The LD ID for the CDN translation feature flag */ declare const getCDNTranslationLDId: (domain: string) => "67e17b925ace3c08088c4bd2" | "570f2f6e348a2806d7006b6f" | "570e9423348a2806d7004354" | "570f37b4eee8b907140070c5"; declare const getTranslations: (fullPath: string, locale: string) => Promise<{ [x: string]: any; } | undefined>; export { CDN_TRANSLATION_FEATURE_FLAG_KEY, type Configuration, getCDNTranslationLDId, getFallbackList, getTranslations as getTranslationsFromCDN, isCDNFeatureFlagEnabled, useMFETranslations, usePreloadTranslations, useRequestTranslations };