Merge pull request #33023 from VincentLanglet/removeI18nextBrowserLanguagedetector

[18next-browser-languagedetector] Remove types from DefinitelyTyped
This commit is contained in:
Andrew Casey
2019-02-20 15:26:16 -08:00
committed by GitHub
9 changed files with 6 additions and 290 deletions
+6
View File
@@ -726,6 +726,12 @@
"sourceRepoURL": "https://github.com/prettymuchbryce/node-http-status",
"asOfVersion": "1.2.0"
},
{
"libraryName": "i18next-browser-languagedetector",
"typingsPackageName": "i18next-browser-languagedetector",
"sourceRepoURL": "https://github.com/i18next/i18next-browser-languagedetector",
"asOfVersion": "2.0.2"
},
{
"libraryName": "i18next-xhr-backend",
"typingsPackageName": "i18next-xhr-backend",
@@ -1,61 +0,0 @@
import * as i18next from "i18next";
import * as LngDetector from "i18next-browser-languagedetector";
const options: LngDetector.DetectorOptions = {
// order and from where user language should be detected
order: ["querystring", "cookie", "localStorage", "navigator", "htmlTag"],
// keys or params to lookup language from
lookupQuerystring: "lng",
lookupCookie: "i18next",
lookupLocalStorage: "i18nextLng",
// cache user language on
caches: ["localStorage", "cookie"],
excludeCacheFor: ["cimode"], // languages to not persist (cookie, localStorage)
// optional expire and domain for set cookie
cookieMinutes: 10,
cookieDomain: "myDomain",
// optional htmlTag with lang attribute, the default is:
htmlTag: document.documentElement
};
i18next.use(LngDetector).init({
detection: options
});
const customDetector: LngDetector.CustomDetector = {
name: "myDetectorsName",
lookup(options: LngDetector.DetectorOptions) {
// options -> are passed in options
return "en";
},
cacheUserLanguage(lng: string, options: LngDetector.DetectorOptions) {
// options -> are passed in options
// lng -> current language, will be called after init and on changeLanguage
// store it
}
};
const customDetector2: LngDetector.CustomDetector = {
name: "myDetectorsName",
lookup(options: LngDetector.DetectorOptions) {
return undefined;
}
};
const lngDetector = new LngDetector(null, options);
lngDetector.init(options);
lngDetector.addDetector(customDetector);
i18next
.use(lngDetector)
.init({
detection: options
});
-65
View File
@@ -1,65 +0,0 @@
// Type definitions for i18next-browser-languagedetector 2.0
// Project: http://i18next.com/, https://github.com/i18next/i18next-browser-languagedetector
// Definitions by: Cyril Schumacher <https://github.com/cyrilschumacher>, Giedrius Grabauskas <https://github.com/GiedriusGrabauskas>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.3
declare namespace i18nextBrowserLanguageDetector {
interface DetectorOptions {
/**
* order and from where user language should be detected
*/
order?: Array<"querystring" | "cookie" | "localStorage" | "navigator" | "htmlTag" | string>;
/**
* keys or params to lookup language from
*/
lookupQuerystring?: string;
lookupCookie?: string;
lookupLocalStorage?: string;
/**
* cache user language on
*/
caches?: string[];
/**
* languages to not persist (cookie, localStorage)
*/
excludeCacheFor?: string[];
/**
* optional expire and domain for set cookie
* @default 10
*/
cookieMinutes?: number;
cookieDomain?: string;
/**
* optional htmlTag with lang attribute
* @default document.documentElement
*/
htmlTag?: HTMLElement;
}
interface CustomDetector {
name: string;
cacheUserLanguage?(lng: string, options: DetectorOptions): void;
lookup(options: DetectorOptions): string | undefined;
}
}
declare class i18nextBrowserLanguageDetector {
constructor(services?: any, options?: i18nextBrowserLanguageDetector.DetectorOptions);
/**
* Adds detector.
*/
addDetector(detector: i18nextBrowserLanguageDetector.CustomDetector): i18nextBrowserLanguageDetector;
/**
* Initializes detector.
*/
init(options?: i18nextBrowserLanguageDetector.DetectorOptions): void;
}
export = i18nextBrowserLanguageDetector;
@@ -1,24 +0,0 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6",
"dom"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"strictFunctionTypes": true,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"i18next-browser-languagedetector-tests.ts"
]
}
@@ -1 +0,0 @@
{ "extends": "dtslint/dt.json" }
@@ -1,42 +0,0 @@
import * as i18next from 'i18next';
import LngDetector from 'i18next-browser-languagedetector';
const options = {
// order and from where user language should be detected
order: ['querystring', 'cookie', 'localStorage', 'navigator'],
// keys or params to lookup language from
lookupQuerystring: 'lng',
lookupCookie: 'i18next',
lookupLocalStorage: 'i18nextLng',
// cache user language on
caches: ['localStorage', 'cookie'],
// optional expire and domain for set cookie
cookieMinutes: 10,
cookieDomain: 'myDomain'
};
const myDetector = {
name: 'myDetectorsName',
lookup(options: {}) {
// options -> are passed in options
return 'en';
},
cacheUserLanguage(lng: string, options: {}) {
// options -> are passed in options
// lng -> current language, will be called after init and on changeLanguage
// store it
}
};
i18next.use(LngDetector).init({
detection: options
});
const lngDetector = new LngDetector(null, options);
lngDetector.init(options);
lngDetector.addDetector(myDetector);
-58
View File
@@ -1,58 +0,0 @@
// Type definitions for i18next-browser-languagedetector 0.0
// Project: http://i18next.com/
// Definitions by: Cyril Schumacher <https://github.com/cyrilschumacher>, Giedrius Grabauskas <https://github.com/GiedriusGrabauskas>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.3
import * as i18next from "i18next";
declare namespace I18next {
interface I18nextStatic extends i18nextBrowserLanguageDetector.I18nextStatic { }
interface I18nextOptions extends i18nextBrowserLanguageDetector.I18nextOptions { }
}
declare namespace i18nextBrowserLanguageDetector {
/** Interface for Language detector options. */
interface LanguageDetectorOptions {
caches?: string[] | boolean;
cookieDomain?: string;
cookieExpirationDate?: Date;
lookupCookie?: string;
lookupFromPathIndex?: number;
lookupQuerystring?: string;
lookupSession?: string;
order?: string[];
}
/** Interface for custom detector. */
interface CustomDetector {
name: string;
// todo: Checks parameters type.
cacheUserLanguage(lng: string, options: {}): void;
lookup(options: {}): string;
}
/** i18next options. */
interface I18nextOptions {
detection?: LanguageDetectorOptions;
}
/** i18next interface. */
interface I18nextStatic {
use(module: LngDetector): I18nextStatic;
}
/** i18next language detection. */
class LngDetector {
constructor(services?: any, options?: LanguageDetectorOptions);
/** Adds detector. */
addDetector(detector: CustomDetector): LngDetector;
/** Initializes detector. */
init(options?: LanguageDetectorOptions): void;
}
}
export default i18nextBrowserLanguageDetector.LngDetector;
@@ -1,28 +0,0 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"strictFunctionTypes": true,
"baseUrl": "../../",
"typeRoots": [
"../../"
],
"paths": {
"i18next-browser-languagedetector": [
"i18next-browser-languagedetector/v0"
]
},
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"i18next-browser-languagedetector-tests.ts"
]
}
@@ -1,11 +0,0 @@
{
"extends": "dtslint/dt.json",
"rules": {
"interface-name": [
false
],
"no-empty-interface": [
false
]
}
}