import { ReactElement, ReactNode } from 'react'; import type { NextConfig } from 'next'; export interface TranslationQuery { [name: string]: any; } export type DataForStoreType = { lang: string; namespaces: Record; config: LoaderConfig; }; export type Translate = (i18nKey: string | TemplateStringsArray, query?: TranslationQuery | null, options?: { returnObjects?: boolean; fallback?: string | string[]; default?: T | string; ns?: string; }) => T; export interface I18n { t: Translate; lang: string; } export interface I18nProviderProps { lang?: string; namespaces?: Record; children?: ReactNode; config?: I18nConfig; } export interface TransProps { i18nKey: string; components?: ReactElement[] | Record; values?: TranslationQuery; fallback?: string | string[]; defaultTrans?: string; ns?: string; returnObjects?: boolean; } export type PageValue = string[] | ((context: object) => string[]); export type LocaleLoader = (language: string | undefined, namespace: string) => Promise; export type Optional = Pick, K> & Omit; export type RawNextI18nConfig = Exclude; export type NextI18nConfig = Optional; export interface I18nConfig extends NextI18nConfig { loadLocaleFrom?: LocaleLoader; localesToIgnore?: string[]; pages?: Record; logger?: I18nLogger; loggerEnvironment?: 'node' | 'browser' | 'both'; staticsHoc?: Function; extensionsRgx?: string; loader?: boolean; logBuild?: boolean; revalidate?: number; pagesInDir?: string; interpolation?: { format?: (value: TranslationQuery[string], format: any, lang: string | undefined) => string; prefix?: string; suffix?: string; }; keySeparator?: string | false; nsSeparator?: string | false; defaultNS?: string; allowEmptyStrings?: boolean; } export interface LoaderConfig extends I18nConfig { locale?: string; router?: { locale: string; }; pathname?: string; skipInitialProps?: boolean; loaderName?: string; isLoader?: boolean; [key: string]: any; } export interface LoggerProps { namespace: string | undefined; i18nKey: string; } export interface I18nLogger { (context: LoggerProps): void; } export interface I18nDictionary { [key: string]: string | I18nDictionary; } export interface DynamicNamespacesProps { dynamic?: LocaleLoader; namespaces?: string[]; fallback?: ReactNode; children?: ReactNode; } declare global { var i18nConfig: LoaderConfig; var __NEXT_TRANSLATE__: { namespaces: Record; lang: string; config: LoaderConfig; }; namespace NodeJS { interface Global { i18nConfig: LoaderConfig; __NEXT_TRANSLATE__: { namespaces: Record; lang: string; }; } } interface Window { i18nConfig: LoaderConfig; __NEXT_TRANSLATE__: { namespaces: Record; lang: string; }; } } type RemovePlural = Key extends `${infer Prefix}${'_zero' | '_one' | '_two' | '_few' | '_many' | '_other' | `_${number}`}` ? Prefix : Key; type Join = S1 extends string ? S2 extends string ? `${S1}.${S2}` : never : never; export type Paths = RemovePlural<{ [K in Extract]: T[K] extends Record ? Join> : K; }[Extract]>; declare function nextTranslate(nextConfig?: NextConfig): NextConfig; export default nextTranslate;