-
-
Notifications
You must be signed in to change notification settings - Fork 765
/
types.ts
90 lines (83 loc) · 1.97 KB
/
types.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
/* tslint:disable no-explicit-any */
import {
I18nContext,
useTranslation,
Trans,
withTranslation,
WithTranslation as ReactI18nextWithTranslation,
Translation,
} from 'react-i18next'
import {
InitOptions,
i18n as I18NextClient,
TFunction as I18NextTFunction,
TypeOptions,
} 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)
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[]
}
export type UseTranslation = typeof useTranslation
export type AppWithTranslation = typeof appWithTranslation
export type TFunction = I18NextTFunction
export type I18n = I18NextClient
export type WithTranslationHocType = typeof withTranslation
export type WithTranslation = ReactI18nextWithTranslation
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,
}