1 | import * as i18next from 'i18next';
|
2 |
|
3 | interface CookieOptions {
|
4 | maxAge?: number;
|
5 | expires?: Date;
|
6 | httpOnly?: boolean;
|
7 | path?: string;
|
8 | domain?: string;
|
9 | secure?: boolean;
|
10 | sameSite?: boolean | 'lax' | 'strict' | 'none';
|
11 | }
|
12 |
|
13 | interface DetectorOptions {
|
14 | |
15 |
|
16 |
|
17 | order?: Array<
|
18 | 'querystring' | 'cookie' | 'sessionStorage' | 'localStorage' | 'navigator' | 'htmlTag' | string
|
19 | >;
|
20 |
|
21 | |
22 |
|
23 |
|
24 | lookupQuerystring?: string;
|
25 | lookupCookie?: string;
|
26 | lookupSessionStorage?: string;
|
27 | lookupLocalStorage?: string;
|
28 | lookupFromPathIndex?: number;
|
29 | lookupFromSubdomainIndex?: number;
|
30 |
|
31 | |
32 |
|
33 |
|
34 | caches?: string[];
|
35 |
|
36 | |
37 |
|
38 |
|
39 | excludeCacheFor?: string[];
|
40 |
|
41 | |
42 |
|
43 |
|
44 |
|
45 | cookieMinutes?: number;
|
46 |
|
47 | |
48 |
|
49 |
|
50 | cookieDomain?: string;
|
51 |
|
52 | |
53 |
|
54 |
|
55 | cookieOptions?: CookieOptions
|
56 |
|
57 | |
58 |
|
59 |
|
60 |
|
61 | htmlTag?: HTMLElement | null;
|
62 | }
|
63 |
|
64 | interface CustomDetector {
|
65 | name: string;
|
66 | cacheUserLanguage?(lng: string, options: DetectorOptions): void;
|
67 | lookup(options: DetectorOptions): string | string[] | undefined;
|
68 | }
|
69 |
|
70 | export default class I18nextBrowserLanguageDetector implements i18next.LanguageDetectorModule {
|
71 | constructor(services?: any, options?: DetectorOptions);
|
72 | /**
|
73 | * Adds detector.
|
74 | */
|
75 | addDetector(detector: CustomDetector): I18nextBrowserLanguageDetector;
|
76 |
|
77 | /**
|
78 | * Initializes detector.
|
79 | */
|
80 | init(services?: any, options?: DetectorOptions): void;
|
81 |
|
82 | detect(detectionOrder?: DetectorOptions['order']): string | string[] | undefined;
|
83 |
|
84 | cacheUserLanguage(lng: string, caches?: string[]): void;
|
85 |
|
86 | type: 'languageDetector';
|
87 | detectors: { [key: string]: any };
|
88 | services: any;
|
89 | i18nOptions: any;
|
90 | }
|
91 |
|
92 | declare module 'i18next' {
|
93 | interface PluginOptions {
|
94 | detection?: DetectorOptions;
|
95 | }
|
96 | }
|