mirror of
https://github.com/zhigang1992/DefinitelyTyped.git
synced 2026-05-28 16:45:10 +08:00
Merge pull request #11384 from bryanjjohnson/i18next-xhr-backend
add i18next-xhr-backend definitions
This commit is contained in:
21
i18next-xhr-backend/i18next-xhr-backend-tests.ts
Normal file
21
i18next-xhr-backend/i18next-xhr-backend-tests.ts
Normal file
@@ -0,0 +1,21 @@
|
||||
/// <reference path="../i18next/i18next"/>
|
||||
/// <reference path="i18next-xhr-backend.d.ts"/>
|
||||
|
||||
import * as i18next from 'i18next';
|
||||
import XHR from 'i18next-xhr-backend';
|
||||
|
||||
let options = {
|
||||
loadPath: '',
|
||||
addPath: '',
|
||||
allowMultiLoading: false,
|
||||
parse: function(data:string) { return data.replace(/a/g, ''); },
|
||||
crossDomain: false,
|
||||
withCredentials: false,
|
||||
ajax: function (url:string, options:Object, callback: Function, data: Object) {}
|
||||
};
|
||||
|
||||
i18next.use(XHR).init({
|
||||
backend: options
|
||||
});
|
||||
|
||||
let xhr = new XHR(null, options);
|
||||
36
i18next-xhr-backend/i18next-xhr-backend.d.ts
vendored
Normal file
36
i18next-xhr-backend/i18next-xhr-backend.d.ts
vendored
Normal file
@@ -0,0 +1,36 @@
|
||||
// Type definitions for i18next-xhr-backend 1.2.0
|
||||
// Project: https://github.com/i18next/i18next-xhr-backend
|
||||
// Definitions by: Jan Mühlemann <https://github.com/jamuhl>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
declare module 'i18next-xhr-backend' {
|
||||
|
||||
interface Interpolator {
|
||||
interpolate: () => string
|
||||
}
|
||||
interface Services {
|
||||
interpolator: Interpolator
|
||||
}
|
||||
|
||||
interface BackendOptions {
|
||||
loadPath?: string | Function,
|
||||
addPath?: string,
|
||||
allowMultiLoading?: boolean,
|
||||
parse?: Function,
|
||||
crossDomain?: boolean,
|
||||
withCredentials?: boolean,
|
||||
ajax?: Function
|
||||
}
|
||||
|
||||
export default class Backend {
|
||||
type: 'backend';
|
||||
services: Services;
|
||||
options: BackendOptions;
|
||||
constructor(services?: Services, options?: BackendOptions);
|
||||
init(services?: Services, options?: BackendOptions): void;
|
||||
readMulti(languages: any[], namespaces: any[], callback: Function): void;
|
||||
read(language: {}, namespace: {}, callback: Function): void;
|
||||
loadUrl(url: string, callback: Function): void;
|
||||
create(languages: any[], namespace: string, key: string, fallbackValue: string): void;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user