import { FormatDateOptions } from "./formatDate.js"; import { IntlListFormatOptions } from "./formatters.js"; import { FormatUnitOptions } from "./formatUnit.js"; import { ScopedTranslateFn, TranslateFn } from "./types.js"; import { FormatDistanceToNowOptions, FormatDistanceToNowStrictOptions, FormatDurationOptions, Locale } from "date-fns"; import { ReactElement, ReactNode } from "react"; import { NumberFormatOptions } from "@formatjs/ecma402-abstract"; import { BaseLocale } from "international-types"; //#region src/usei18n.d.ts type SupportedLocalesType = (locale: string) => locale is LocalSupportedType; type TranslationsByLocales = Record; type LoadTranslationsFn = ({ namespace, locale }: { namespace: string; locale: LocalSupportedType; }) => Promise<{ default: BaseLocale; }>; type LoadLocaleFn = (locale: LocalSupportedType) => Locale; type LoadLocaleFnAsync = (locale: LocalSupportedType) => Promise; type LoadDateLocaleError = (error: Error) => void; type RequiredGenericContext = keyof LocaleParam extends never ? Omit, 't' | 'namespaceTranslation'> & { t: (str: 'You must pass a generic argument to useI18n()') => void; namespaceTranslation: (str: 'You must pass a generic argument to useI18n()') => void; } : Context; type FormatDurationOptions$1 = Omit | 'clock' | 'clock-milliseconds'; type Context = { currentLocale: LocalSupportedType; dateFnsLocale?: Locale; datetime: (date: Date | number, options?: Intl.DateTimeFormatOptions) => string; formatDate: (value: Date | number | string, options?: FormatDateOptions) => string; formatList: (listFormat: string[], options?: IntlListFormatOptions) => string; formatNumber: (numb: number, options?: NumberFormatOptions) => string; formatUnit: (value: number, options: FormatUnitOptions) => string; formatDuration: (value: number, options?: FormatDurationOptions$1) => string; loadTranslations: (namespace: string, load?: LoadTranslationsFn) => Promise; namespaces: string[]; namespaceTranslation: ScopedTranslateFn; relativeTime: (date: Date | number, options?: FormatDistanceToNowOptions) => string; relativeTimeStrict: (date: Date | number, options?: FormatDistanceToNowStrictOptions) => string; setTranslations: React.Dispatch>; switchLocale: (locale: LocalSupportedType) => Promise; t: TranslateFn; translations: TranslationsByLocales; }; declare function useI18n(): RequiredGenericContext; declare function useTranslation(namespaces: [string, ...string[]], load?: LoadTranslationsFn): RequiredGenericContext & { isLoaded: boolean; }; declare const I18nContextProvider: ({ children, defaultLoad, defaultLocale, defaultTranslations, enableDebugKey, enableDefaultLocale, loadDateLocale, loadDateLocaleAsync, localeItemStorage, onLoadDateLocaleError, onTranslateError, onLoadTranslationError, isLocaleSupported }: { children: ReactNode; defaultLoad: LoadTranslationsFn; loadDateLocale?: LoadLocaleFn; loadDateLocaleAsync: LoadLocaleFnAsync; onLoadDateLocaleError?: LoadDateLocaleError; defaultLocale: LocalSupportedType; defaultTranslations: TranslationsByLocales; enableDefaultLocale: boolean; enableDebugKey: boolean; localeItemStorage: string; isLocaleSupported: SupportedLocalesType; onLoadTranslationError: (error: unknown | Error) => void; onTranslateError?: ({ error, currentLocale, value, key }: { error: Error; currentLocale: LocalSupportedType; defaultLocale: LocalSupportedType; value: string; key: string; }) => void; }) => ReactElement; //#endregion export { Context, LoadDateLocaleError, LoadLocaleFn, LoadLocaleFnAsync, LoadTranslationsFn, RequiredGenericContext, SupportedLocalesType, TranslationsByLocales, I18nContextProvider as default, useI18n, useTranslation };