mirror of
https://github.com/wassname/DefinitelyTyped.git
synced 2026-08-21 11:09:53 +08:00
Merge pull request #8581 from mxl/i18next
Updated i18next definitions to 2.3.4.
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
/// <reference path="../i18next/i18next.d.ts"/>
|
||||
/// <reference path="../i18next/i18next-2.0.17.d.ts"/>
|
||||
/// <reference path="i18next-browser-languagedetector.d.ts"/>
|
||||
|
||||
import * as i18next from 'i18next';
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
///<reference path="../express/express.d.ts"/>
|
||||
///<reference path="../i18next/i18next.d.ts"/>
|
||||
///<reference path="../i18next/i18next-2.0.17.d.ts"/>
|
||||
|
||||
declare namespace I18next {
|
||||
interface I18nextStatic extends i18nextBrowserLanguageDetector.I18nextStatic { }
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
///<reference path="../i18next/i18next.d.ts"/>
|
||||
///<reference path="../i18next/i18next-2.0.17.d.ts"/>
|
||||
///<reference path="i18next-express-middleware.d.ts"/>
|
||||
|
||||
import * as express from "express";
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
///<reference path="../express/express.d.ts"/>
|
||||
///<reference path="../i18next/i18next.d.ts"/>
|
||||
///<reference path="../i18next/i18next-2.0.17.d.ts"/>
|
||||
|
||||
declare namespace I18next {
|
||||
interface I18nextOptions extends i18nextExpressMiddleware.I18nextOptions { }
|
||||
|
||||
+1
-1
@@ -3,7 +3,7 @@
|
||||
// Definitions by: Cyril Schumacher <https://github.com/cyrilschumacher>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
///<reference path="../i18next/i18next.d.ts"/>
|
||||
///<reference path="../i18next/i18next-2.0.17.d.ts"/>
|
||||
|
||||
declare namespace I18next {
|
||||
interface I18nextOptions extends i18nextNodeFsBackEnd.I18nextOptions { }
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
///<reference path="../express/express.d.ts"/>
|
||||
///<reference path="../i18next/i18next.d.ts"/>
|
||||
///<reference path="../i18next/i18next-2.0.17.d.ts"/>
|
||||
|
||||
declare namespace I18next {
|
||||
interface I18nextOptions extends i18nextSprintfPostProcessor.I18nextOptions {}
|
||||
|
||||
Vendored
+160
@@ -0,0 +1,160 @@
|
||||
// Type definitions for i18next v2.0.17
|
||||
// Project: http://i18next.com
|
||||
// Definitions by: Maarten Docter <https://github.com/mdocter>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
// Sources: https://github.com/jamuhl/i18next/
|
||||
|
||||
/// <reference path="../express/express.d.ts" />
|
||||
/// <reference path="../jquery/jquery.d.ts" />
|
||||
/// <reference path="../i18next-express-middleware/i18next-express-middleware.d.ts" />
|
||||
/// <reference path="../i18next-sprintf-postprocessor/i18next-sprintf-postprocessor.d.ts" />
|
||||
|
||||
declare namespace I18next {
|
||||
export interface I18nextStatic {}
|
||||
export interface I18nextOptions {}
|
||||
}
|
||||
|
||||
interface IResourceStore {
|
||||
[language: string]: IResourceStoreLanguage;
|
||||
}
|
||||
interface IResourceStoreLanguage {
|
||||
[namespace: string]: IResourceStoreKey;
|
||||
}
|
||||
interface IResourceStoreKey {
|
||||
[key: string]: any;
|
||||
}
|
||||
|
||||
interface I18nTranslateOptions extends I18nextOptions {
|
||||
defaultValue?: any; // normally a string
|
||||
// NOTE https://github.com/DefinitelyTyped/DefinitelyTyped/pull/5590
|
||||
toAdd?: any;
|
||||
child?: any;
|
||||
sprintf?: any;
|
||||
count?: any;
|
||||
context?: any;
|
||||
}
|
||||
|
||||
interface I18nextOptions extends I18next.I18nextOptions {
|
||||
lng?: string; // Default value: undefined
|
||||
load?: string; // Default value: 'all'
|
||||
preload?: string[]; // Default value: []
|
||||
lowerCaseLng?: boolean; // Default value: false
|
||||
returnObjectTrees?: boolean; // Default value: false
|
||||
fallbackLng?: string|boolean; // Default value: 'dev'
|
||||
detectLngQS?: string; // Default value: 'setLng'
|
||||
ns?: any; // Default value: 'translation' (string), can also be an object
|
||||
nsseparator?: string; // Default value: '::'
|
||||
keyseparator?: string; // Default value: '.'
|
||||
selectorAttr?: string; // Default value: 'data-i18n'
|
||||
debug?: boolean; // Default value: false
|
||||
|
||||
resGetPath?: string; // Default value: 'locales/__lng__/__ns__.json'
|
||||
resPostPath?: string; // Default value: 'locales/add/__lng__/__ns__'
|
||||
|
||||
getAsync?: boolean; // Default value: true
|
||||
postAsync?: boolean; // Default value: true
|
||||
|
||||
resStore?: IResourceStore; // Default value: undefined
|
||||
useLocalStorage?: boolean; // Default value: false
|
||||
localStorageExpirationTime?: number; // Default value: 7 * 24 * 60 * 60 * 1000 (in ms default one week)
|
||||
|
||||
dynamicLoad?: boolean; // Default value: false
|
||||
sendMissing?: boolean; // Default value: false
|
||||
sendMissingTo?: string; // Default value: 'fallback'. Other options are: current | all
|
||||
sendType?: string; // Default value: 'POST'
|
||||
|
||||
interpolationPrefix?: string; // Default value: '__'
|
||||
interpolationSuffix?: string; // Default value: '__'
|
||||
reusePrefix?: string; // Default value: '$t('
|
||||
reuseSuffix?: string; // Default value: ')'
|
||||
pluralSuffix?: string; // Default value: '_plural'
|
||||
pluralNotFound?: string; // Default value: ['plural_not_found' Math.random()].join( '' )
|
||||
contextNotFound?: string; // Default value: ['context_not_found' Math.random()].join( '' )
|
||||
|
||||
setJqueryExt?: boolean; // Default value: true
|
||||
defaultValueFromContent?: boolean; // Default value: true
|
||||
useDataAttrOptions?: boolean; // Default value: false
|
||||
cookieExpirationTime?: number; // Default value: undefined
|
||||
useCookie?: boolean; // Default value: true
|
||||
cookieName?: string; // Default value: 'i18next'
|
||||
|
||||
postProcess?: string; // Default value: undefined
|
||||
|
||||
// NOTE https://github.com/DefinitelyTyped/DefinitelyTyped/pull/5590
|
||||
replace?: any;
|
||||
}
|
||||
|
||||
interface I18nextStatic extends I18next.I18nextStatic {
|
||||
|
||||
addPostProcessor(name: string, fn: (value: any, key: string, options: any) => string): void;
|
||||
addResources(language: string, namespace: string, resources: IResourceStoreKey): void;
|
||||
detectLanguage(): string;
|
||||
functions: {
|
||||
extend(target: any, ...objs: any[]): Object;
|
||||
extend(deep: boolean, target: any, ...objs: any[]): Object;
|
||||
each(collection: any, callback: (indexInArray: any, valueOfElement: any) => any): any;
|
||||
ajax(settings: JQueryAjaxSettings): JQueryXHR;
|
||||
ajax(url: string, settings?: JQueryAjaxSettings): JQueryXHR;
|
||||
cookie: {
|
||||
create: (name: string, value: string, minutes: number) => void;
|
||||
read: (name: string) => string;
|
||||
remove: (name: string) => void;
|
||||
};
|
||||
detectLanguage(): string;
|
||||
log(message: string): void;
|
||||
toLanguages(language: string): string[];
|
||||
regexEscape(str: string): string;
|
||||
};
|
||||
init(callback?: (err: any, t: (key: string, options?: any) => string) => void ): JQueryDeferred<any>;
|
||||
init(options?: I18nextOptions, callback?: (err: any, t: (key: string, options?: any) => string) => void ): JQueryDeferred<any>;
|
||||
lng(): string;
|
||||
loadNamespace(namespace: string, callback?: () => void ): void;
|
||||
loadNamespaces(namespaces: string[], callback?: () => void ): void;
|
||||
pluralExtensions: {
|
||||
addRule(language: string, obj: {
|
||||
name: string;
|
||||
numbers: number[];
|
||||
plurals: (n: number) => number;
|
||||
}): void;
|
||||
get (language: string, count: number): number;
|
||||
rules: any;
|
||||
setCurrentLng: (language: string) => void;
|
||||
};
|
||||
preload(language: string, callback?: (err: any, t: (key: string, options?: any) => string) => void ): void;
|
||||
preload(languages: string[], callback?: (err: any, t: (key: string, options?: any) => string) => void ): void;
|
||||
setDefaultNamespace(namespace: string): void;
|
||||
setLng(language: string, callback?: (err: any, t: (key: string, options?: any) => string) => void ): void;
|
||||
sync: {
|
||||
load: (languages: string[], options: I18nextOptions, callback: (err: Error, store: IResourceStore) => void ) => void;
|
||||
postMissing: (language: string, namespace: string, key: string, defaultValue: any, languages: string[]) => void;
|
||||
};
|
||||
t(key: string, options?: I18nTranslateOptions): string;
|
||||
translate(key: string, options?: I18nTranslateOptions): string;
|
||||
exists(key: string, options?: any): boolean;
|
||||
use(module: any): I18nextStatic;
|
||||
}
|
||||
|
||||
// jQuery extensions
|
||||
interface JQueryStatic {
|
||||
i18n: I18nextStatic;
|
||||
t: (key: string, options?: any) => string;
|
||||
}
|
||||
|
||||
interface JQuery {
|
||||
/* Note: options are same options as used by the translate function. Alternatively by
|
||||
setting init option or translation option 'useDataAttrOptions = true' the Options
|
||||
for translation will be read and cached in the elements data-i18n-options attribute.
|
||||
*/
|
||||
i18n: (options?: I18nextOptions) => void;
|
||||
}
|
||||
|
||||
declare var i18n: I18nextStatic;
|
||||
|
||||
declare module 'i18next' {
|
||||
export = i18n;
|
||||
}
|
||||
|
||||
declare module 'i18next-client' {
|
||||
export = i18n;
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
+56
-1371
File diff suppressed because it is too large
Load Diff
Vendored
+113
-148
@@ -1,160 +1,125 @@
|
||||
// Type definitions for i18next v2.0.17
|
||||
// Type definitions for i18next v2.3.4
|
||||
// Project: http://i18next.com
|
||||
// Definitions by: Maarten Docter <https://github.com/mdocter>
|
||||
// Definitions by: Michael Ledin <https://github.com/mxl>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
// Sources: https://github.com/jamuhl/i18next/
|
||||
// Sources: https://github.com/i18next/i18next/
|
||||
|
||||
/// <reference path="../express/express.d.ts" />
|
||||
/// <reference path="../jquery/jquery.d.ts" />
|
||||
/// <reference path="../i18next-express-middleware/i18next-express-middleware.d.ts" />
|
||||
/// <reference path="../i18next-sprintf-postprocessor/i18next-sprintf-postprocessor.d.ts" />
|
||||
|
||||
declare namespace I18next {
|
||||
export interface I18nextStatic {}
|
||||
export interface I18nextOptions {}
|
||||
interface ResourceStore {
|
||||
[language: string]: ResourceStoreLanguage;
|
||||
}
|
||||
|
||||
interface ResourceStoreLanguage {
|
||||
[namespace: string]: ResourceStoreKey;
|
||||
}
|
||||
|
||||
interface ResourceStoreKey {
|
||||
[key: string]: any;
|
||||
}
|
||||
|
||||
interface InterpolationOptions {
|
||||
escapeValue?: boolean;
|
||||
prefix?: string;
|
||||
suffix?: string;
|
||||
prefixEscaped?: string;
|
||||
suffixEscaped?: string;
|
||||
unescapeSuffix?: string;
|
||||
unescapePrefix?: string;
|
||||
nestingPrefix?: string;
|
||||
nestingSuffix?: string;
|
||||
nestingPrefixEscaped?: string;
|
||||
nestedSuffixEscaped?: string;
|
||||
defaultVariables?: any;
|
||||
}
|
||||
|
||||
interface TranslationOptions {
|
||||
defaultValue?: string;
|
||||
count?: number;
|
||||
context?: any;
|
||||
replace?: any;
|
||||
lng?:string;
|
||||
lngs?:string[];
|
||||
fallbackLng?:string;
|
||||
ns?:string|string[];
|
||||
keySeparator?:string;
|
||||
nsSeparator?:string;
|
||||
returnObjects?:boolean;
|
||||
joinArrays?:string;
|
||||
postProcess?:string|any[];
|
||||
interpolation?: InterpolationOptions;
|
||||
}
|
||||
|
||||
interface Options {
|
||||
debug?: boolean;
|
||||
resources?: ResourceStore;
|
||||
lng?: string;
|
||||
fallbackLng?: string;
|
||||
ns?: string|string[];
|
||||
defaultNS?: string;
|
||||
fallbackNS?: string|string[];
|
||||
whitelist?:string[];
|
||||
lowerCaseLng?: boolean;
|
||||
load?: string
|
||||
preload?: string[];
|
||||
keySeparator?: string;
|
||||
nsSeparator?: string;
|
||||
pluralSeparator?: string;
|
||||
contextSeparator?: string;
|
||||
saveMissing?: boolean;
|
||||
saveMissingTo?: string;
|
||||
missingKeyHandler?: (lng:string, ns:string, key:string, fallbackValue:string) => void;
|
||||
parseMissingKeyHandler?: (key:string) => void;
|
||||
appendNamespaceToMissingKey?: boolean;
|
||||
postProcess?: string|any[];
|
||||
returnNull?: boolean;
|
||||
returnEmptyString?: boolean;
|
||||
returnObjects?: boolean;
|
||||
returnedObjectHandler?: (key:string, value:string, options:any) => void;
|
||||
joinArrays?: string;
|
||||
overloadTranslationOptionHandler?: (args:any[]) => TranslationOptions;
|
||||
interpolation?: InterpolationOptions;
|
||||
detection?: any;
|
||||
backend?: any;
|
||||
cache?: any;
|
||||
}
|
||||
|
||||
type TranslationFunction = (key:string, options?:TranslationOptions) => string;
|
||||
|
||||
class I18n {
|
||||
constructor(options?:Options, callback?:(err:any, t:TranslationFunction) => void);
|
||||
|
||||
init(options?:Options, callback?:(err:any, t:TranslationFunction) => void):I18n;
|
||||
|
||||
loadResources(callback?:(err:any) => void):void;
|
||||
|
||||
use(module:any):I18n;
|
||||
|
||||
changeLanguage(lng:string, callback?:(err:any, t:TranslationFunction) => void):void;
|
||||
|
||||
getFixedT(lng?:string, ns?:string|string[]):TranslationFunction;
|
||||
|
||||
t(key:string, options?:TranslationOptions):string;
|
||||
|
||||
exists():boolean;
|
||||
|
||||
setDefaultNamespace(ns:string):void;
|
||||
|
||||
loadNamespaces(ns:string[], callback?:() => void):void;
|
||||
|
||||
loadLanguages(lngs:string[], callback?:()=>void):void;
|
||||
|
||||
dir(lng?:string):string;
|
||||
|
||||
createInstance(options?:Options, callback?:(err:any, t:TranslationFunction) => void):I18n;
|
||||
|
||||
cloneInstance(options?:Options, callback?:(err:any, t:TranslationFunction) => void):I18n;
|
||||
}
|
||||
}
|
||||
|
||||
interface IResourceStore {
|
||||
[language: string]: IResourceStoreLanguage;
|
||||
}
|
||||
interface IResourceStoreLanguage {
|
||||
[namespace: string]: IResourceStoreKey;
|
||||
}
|
||||
interface IResourceStoreKey {
|
||||
[key: string]: any;
|
||||
}
|
||||
|
||||
interface I18nTranslateOptions extends I18nextOptions {
|
||||
defaultValue?: any; // normally a string
|
||||
// NOTE https://github.com/DefinitelyTyped/DefinitelyTyped/pull/5590
|
||||
toAdd?: any;
|
||||
child?: any;
|
||||
sprintf?: any;
|
||||
count?: any;
|
||||
context?: any;
|
||||
}
|
||||
|
||||
interface I18nextOptions extends I18next.I18nextOptions {
|
||||
lng?: string; // Default value: undefined
|
||||
load?: string; // Default value: 'all'
|
||||
preload?: string[]; // Default value: []
|
||||
lowerCaseLng?: boolean; // Default value: false
|
||||
returnObjectTrees?: boolean; // Default value: false
|
||||
fallbackLng?: string|boolean; // Default value: 'dev'
|
||||
detectLngQS?: string; // Default value: 'setLng'
|
||||
ns?: any; // Default value: 'translation' (string), can also be an object
|
||||
nsseparator?: string; // Default value: '::'
|
||||
keyseparator?: string; // Default value: '.'
|
||||
selectorAttr?: string; // Default value: 'data-i18n'
|
||||
debug?: boolean; // Default value: false
|
||||
|
||||
resGetPath?: string; // Default value: 'locales/__lng__/__ns__.json'
|
||||
resPostPath?: string; // Default value: 'locales/add/__lng__/__ns__'
|
||||
|
||||
getAsync?: boolean; // Default value: true
|
||||
postAsync?: boolean; // Default value: true
|
||||
|
||||
resStore?: IResourceStore; // Default value: undefined
|
||||
useLocalStorage?: boolean; // Default value: false
|
||||
localStorageExpirationTime?: number; // Default value: 7 * 24 * 60 * 60 * 1000 (in ms default one week)
|
||||
|
||||
dynamicLoad?: boolean; // Default value: false
|
||||
sendMissing?: boolean; // Default value: false
|
||||
sendMissingTo?: string; // Default value: 'fallback'. Other options are: current | all
|
||||
sendType?: string; // Default value: 'POST'
|
||||
|
||||
interpolationPrefix?: string; // Default value: '__'
|
||||
interpolationSuffix?: string; // Default value: '__'
|
||||
reusePrefix?: string; // Default value: '$t('
|
||||
reuseSuffix?: string; // Default value: ')'
|
||||
pluralSuffix?: string; // Default value: '_plural'
|
||||
pluralNotFound?: string; // Default value: ['plural_not_found' Math.random()].join( '' )
|
||||
contextNotFound?: string; // Default value: ['context_not_found' Math.random()].join( '' )
|
||||
|
||||
setJqueryExt?: boolean; // Default value: true
|
||||
defaultValueFromContent?: boolean; // Default value: true
|
||||
useDataAttrOptions?: boolean; // Default value: false
|
||||
cookieExpirationTime?: number; // Default value: undefined
|
||||
useCookie?: boolean; // Default value: true
|
||||
cookieName?: string; // Default value: 'i18next'
|
||||
|
||||
postProcess?: string; // Default value: undefined
|
||||
|
||||
// NOTE https://github.com/DefinitelyTyped/DefinitelyTyped/pull/5590
|
||||
replace?: any;
|
||||
}
|
||||
|
||||
interface I18nextStatic extends I18next.I18nextStatic {
|
||||
|
||||
addPostProcessor(name: string, fn: (value: any, key: string, options: any) => string): void;
|
||||
addResources(language: string, namespace: string, resources: IResourceStoreKey): void;
|
||||
detectLanguage(): string;
|
||||
functions: {
|
||||
extend(target: any, ...objs: any[]): Object;
|
||||
extend(deep: boolean, target: any, ...objs: any[]): Object;
|
||||
each(collection: any, callback: (indexInArray: any, valueOfElement: any) => any): any;
|
||||
ajax(settings: JQueryAjaxSettings): JQueryXHR;
|
||||
ajax(url: string, settings?: JQueryAjaxSettings): JQueryXHR;
|
||||
cookie: {
|
||||
create: (name: string, value: string, minutes: number) => void;
|
||||
read: (name: string) => string;
|
||||
remove: (name: string) => void;
|
||||
};
|
||||
detectLanguage(): string;
|
||||
log(message: string): void;
|
||||
toLanguages(language: string): string[];
|
||||
regexEscape(str: string): string;
|
||||
};
|
||||
init(callback?: (err: any, t: (key: string, options?: any) => string) => void ): JQueryDeferred<any>;
|
||||
init(options?: I18nextOptions, callback?: (err: any, t: (key: string, options?: any) => string) => void ): JQueryDeferred<any>;
|
||||
lng(): string;
|
||||
loadNamespace(namespace: string, callback?: () => void ): void;
|
||||
loadNamespaces(namespaces: string[], callback?: () => void ): void;
|
||||
pluralExtensions: {
|
||||
addRule(language: string, obj: {
|
||||
name: string;
|
||||
numbers: number[];
|
||||
plurals: (n: number) => number;
|
||||
}): void;
|
||||
get (language: string, count: number): number;
|
||||
rules: any;
|
||||
setCurrentLng: (language: string) => void;
|
||||
};
|
||||
preload(language: string, callback?: (err: any, t: (key: string, options?: any) => string) => void ): void;
|
||||
preload(languages: string[], callback?: (err: any, t: (key: string, options?: any) => string) => void ): void;
|
||||
setDefaultNamespace(namespace: string): void;
|
||||
setLng(language: string, callback?: (err: any, t: (key: string, options?: any) => string) => void ): void;
|
||||
sync: {
|
||||
load: (languages: string[], options: I18nextOptions, callback: (err: Error, store: IResourceStore) => void ) => void;
|
||||
postMissing: (language: string, namespace: string, key: string, defaultValue: any, languages: string[]) => void;
|
||||
};
|
||||
t(key: string, options?: I18nTranslateOptions): string;
|
||||
translate(key: string, options?: I18nTranslateOptions): string;
|
||||
exists(key: string, options?: any): boolean;
|
||||
use(module: any): I18nextStatic;
|
||||
}
|
||||
|
||||
// jQuery extensions
|
||||
interface JQueryStatic {
|
||||
i18n: I18nextStatic;
|
||||
t: (key: string, options?: any) => string;
|
||||
}
|
||||
|
||||
interface JQuery {
|
||||
/* Note: options are same options as used by the translate function. Alternatively by
|
||||
setting init option or translation option 'useDataAttrOptions = true' the Options
|
||||
for translation will be read and cached in the elements data-i18n-options attribute.
|
||||
*/
|
||||
i18n: (options?: I18nextOptions) => void;
|
||||
}
|
||||
|
||||
declare var i18n: I18nextStatic;
|
||||
|
||||
declare module 'i18next' {
|
||||
export = i18n;
|
||||
}
|
||||
var i18n:I18next.I18n;
|
||||
|
||||
declare module 'i18next-client' {
|
||||
export = i18n;
|
||||
}
|
||||
|
||||
Vendored
+1
-1
@@ -3,7 +3,7 @@
|
||||
// Definitions by: Cyril Schumacher <https://github.com/cyrilschumacher>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
/// <reference path="../i18next/i18next.d.ts" />
|
||||
/// <reference path="../i18next/i18next-2.0.17.d.ts" />
|
||||
|
||||
declare namespace angular.i18next {
|
||||
interface I18nextProvider {
|
||||
|
||||
Reference in New Issue
Block a user