diff --git a/i18next-xhr-backend/i18next-xhr-backend-tests.ts b/i18next-xhr-backend/i18next-xhr-backend-tests.ts new file mode 100644 index 0000000000..404eb30297 --- /dev/null +++ b/i18next-xhr-backend/i18next-xhr-backend-tests.ts @@ -0,0 +1,21 @@ +/// +/// + +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); \ No newline at end of file diff --git a/i18next-xhr-backend/i18next-xhr-backend.d.ts b/i18next-xhr-backend/i18next-xhr-backend.d.ts new file mode 100644 index 0000000000..fb3223ad7a --- /dev/null +++ b/i18next-xhr-backend/i18next-xhr-backend.d.ts @@ -0,0 +1,34 @@ +// Type definitions for i18next-xhr-backend 1.2.0 +// Project: http://i18next.com/ +// Definitions by: Jan Mühlemann +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +declare module 'i18next-xhr-backend' { + + interface Interpolator { + interpolate: () => string + } + interface Services { + interpolator: Interpolator + } + + export default class Backend { + type: 'backend'; + services: Services; + options: { + loadPath: string | Function, + addPath: string, + allowMultiLoading: boolean, + parse: () => {}, + crossDomain: boolean, + withCredentials: boolean, + ajax: () => void + }; + constructor(services: Services, options?: {}); + init(services: Services, options?: {}): void; + readMulti(languages: any[], namespaces: any[], callback: () => void): void; + read(language: {}, namespace: {}, callback: () => void): void; + loadUrl(url: string, callback: () => void): void; + create(languages: any[], namespace: string, key: string, fallbackValue: string): void; + } +} \ No newline at end of file