|
import * as i18next from 'i18next'; |
|
|
|
interface CookieOptions { |
|
maxAge?: number; |
|
expires?: Date; |
|
httpOnly?: boolean; |
|
path?: string; |
|
domain?: string; |
|
secure?: boolean; |
|
sameSite?: boolean | 'lax' | 'strict' | 'none'; |
|
} |
|
|
|
export interface DetectorOptions { |
|
|
|
|
|
|
|
order?: Array< |
|
'querystring' | 'cookie' | 'sessionStorage' | 'localStorage' | 'navigator' | 'htmlTag' | string |
|
>; |
|
|
|
|
|
|
|
|
|
lookupQuerystring?: string; |
|
lookupCookie?: string; |
|
lookupSessionStorage?: string; |
|
lookupLocalStorage?: string; |
|
lookupFromPathIndex?: number; |
|
lookupFromSubdomainIndex?: number; |
|
|
|
|
|
|
|
|
|
caches?: string[]; |
|
|
|
|
|
|
|
|
|
excludeCacheFor?: string[]; |
|
|
|
|
|
|
|
|
|
|
|
cookieMinutes?: number; |
|
|
|
|
|
|
|
|
|
cookieDomain?: string; |
|
|
|
|
|
|
|
|
|
cookieOptions?: CookieOptions |
|
|
|
|
|
|
|
|
|
|
|
htmlTag?: HTMLElement | null; |
|
|
|
|
|
|
|
|
|
convertDetectedLanguage?: 'Iso15897' | ((lng: string) => string); |
|
} |
|
|
|
export interface CustomDetector { |
|
name: string; |
|
cacheUserLanguage?(lng: string, options: DetectorOptions): void; |
|
lookup(options: DetectorOptions): string | string[] | undefined; |
|
} |
|
|
|
export default class I18nextBrowserLanguageDetector implements i18next.LanguageDetectorModule { |
|
constructor(services?: any, options?: DetectorOptions); |
|
|
|
|
|
|
|
addDetector(detector: CustomDetector): I18nextBrowserLanguageDetector; |
|
|
|
|
|
|
|
|
|
init(services?: any, options?: DetectorOptions): void; |
|
|
|
detect(detectionOrder?: DetectorOptions['order']): string | string[] | undefined; |
|
|
|
cacheUserLanguage(lng: string, caches?: string[]): void; |
|
|
|
type: 'languageDetector'; |
|
detectors: { [key: string]: any }; |
|
services: any; |
|
i18nOptions: any; |
|
} |
|
|
|
declare module 'i18next' { |
|
interface CustomPluginOptions { |
|
detection?: DetectorOptions; |
|
} |
|
} |
|
|