-
-
Notifications
You must be signed in to change notification settings - Fork 52
/
Copy pathindex.d.ts
77 lines (67 loc) · 3.04 KB
/
index.d.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
import * as express from 'express';
import * as i18next from 'i18next';
declare module 'i18next-express-middleware' {
type I18next = i18next.i18n;
type IgnoreRoutesFunction = (req: express.Request, res: express.Response, options: HandleOptions, i18next: I18next) => boolean;
type App = express.Application | express.Router;
type I18NextRequest = express.Request & {
language: string;
languages: string[];
i18n:i18next.i18n;
t:i18next.TFunction;
}
interface HandleOptions {
ignoreRoutes?: string[] | IgnoreRoutesFunction;
removeLngFromUrl?: boolean;
}
interface GetResourcesHandlerOptions {
maxAge?: number;
cache?: boolean;
lngParam?: string;
nsParam?: string;
}
interface MissingKeyHandlerOptions {
lngParam?: string;
nsParam?: string;
}
export function handle(i18next: I18next, options?: HandleOptions): express.Handler;
export function getResourcesHandler(i18next: I18next, options?: GetResourcesHandlerOptions): express.Handler;
export function missingKeyHandler(i18next: I18next, options?: MissingKeyHandlerOptions): express.Handler;
export function addRoute(i18next: I18next, route: string, lngs: string[], app: App, verb: string, fc: express.RequestHandler): void;
export function addRoute(i18next: I18next, route: string, lngs: string[], app: App, fc: express.RequestHandler): void;
// LanguageDetector
type LanguageDetectorServices = any;
type LanguageDetectorOrder = string[];
type LanguageDetectorCaches = boolean | string[];
interface LanguageDetectorOptions {
order?: LanguageDetectorOrder;
lookupQuerystring?: string;
lookupCookie?: string;
lookupSession?: string;
lookupFromPathIndex?: number;
caches?: LanguageDetectorCaches;
cookieExpirationDate?: Date;
cookieDomain?: string;
}
interface LanguageDetectorAllOptions {
fallbackLng: boolean | string | string[];
}
interface LanguageDetectorInterfaceOptions {
[name: string]: any;
}
interface LanguageDetectorInterface {
name: string;
lookup: (req: express.Request, res: express.Response, options?: LanguageDetectorInterfaceOptions) => string | string[];
cacheUserLanguage?: (req: express.Request, res: express.Response, lng: string, options?: object) => void;
}
export class LanguageDetector implements i18next.Module {
type: "languageDetector";
constructor(services: LanguageDetectorServices, options?: LanguageDetectorOptions, allOptions?: LanguageDetectorAllOptions);
constructor(options?: LanguageDetectorOptions, allOptions?: LanguageDetectorAllOptions);
init(services: LanguageDetectorServices, options?: LanguageDetectorOptions, allOptions?: LanguageDetectorAllOptions): void;
init(options?: LanguageDetectorOptions, allOptions?: LanguageDetectorAllOptions): void;
addDetector(detector: LanguageDetectorInterface): void;
detect(req: express.Request, res: express.Response, detectionOrder: LanguageDetectorOrder): void;
cacheUserLanguage(req: express.Request, res: express.Response, lng: string, caches: LanguageDetectorCaches): void;
}
}