UNPKG

next-i18next

Version:

The easiest way to translate your NextJs apps.

56 lines (55 loc) 2.48 kB
import { I18nContext, useTranslation, Trans, withTranslation, WithTranslation as ReactI18nextWithTranslation, Translation, FallbackNs, UseTranslationOptions, UseTranslationResponse } from 'react-i18next'; import { InitOptions, i18n as I18NextClient, TFunction as I18NextTFunction, TypeOptions, FlatNamespace, KeyPrefix } from 'i18next'; import { appWithTranslation, i18n } from './'; /** * Inlined from `import('next').NextConfig.i18n` v13.0.6. As we support * multiple nextjs versions it's safer to inline and keep it up-to-date. */ type NextJsI18NConfig = { defaultLocale: string; domains?: { defaultLocale: string; domain: string; http?: true; locales?: string[]; }[]; localeDetection?: false; locales: string[]; }; type DefaultNamespace = TypeOptions['defaultNS']; export type UserConfig = { i18n: NextJsI18NConfig; localeExtension?: string; localePath?: string | ((locale: string, namespace: string, missing: boolean) => string) | null; localeStructure?: string; onPreInitI18next?: (i18n: I18n) => void; reloadOnPrerender?: boolean; serializeConfig?: boolean; use?: any[]; } & InitOptions; export type InternalConfig = Omit<UserConfig, 'i18n'> & NextJsI18NConfig & { errorStackTraceLimit: number; preload: string[]; supportedLngs: string[]; }; type $Tuple<T> = readonly [T?, ...T[]]; export type UseTranslation<Ns extends FlatNamespace | $Tuple<FlatNamespace> | undefined = undefined, KPrefix extends KeyPrefix<FallbackNs<Ns>> = undefined> = (ns?: Ns, options?: UseTranslationOptions<KPrefix>) => UseTranslationResponse<FallbackNs<Ns>, KPrefix>; export type AppWithTranslation = typeof appWithTranslation; export type TFunction = I18NextTFunction; export type I18n = I18NextClient; export type WithTranslationHocType = typeof withTranslation; export type WithTranslation<Ns extends FlatNamespace | $Tuple<FlatNamespace> | undefined = undefined, KPrefix extends KeyPrefix<FallbackNs<Ns>> = undefined> = ReactI18nextWithTranslation<Ns, KPrefix>; export type InitPromise = Promise<TFunction>; export type CreateClientReturn = { i18n: I18n; initPromise: InitPromise; }; export type SSRConfig = { _nextI18Next?: { initialI18nStore: any; initialLocale: string; ns: string[]; userConfig: UserConfig | null; }; }; export { i18n, I18nContext, appWithTranslation, useTranslation, Trans, Translation, withTranslation, DefaultNamespace, };