Merge pull request #8749 from DefinitelyTyped/update-i18next-sprintf-postprocessor-tests

improve i18next-sprintf-postprocessor/i18next-sprintf-postprocessor.d.ts
This commit is contained in:
Masahiro Wakame
2016-03-29 23:13:35 +09:00
3 changed files with 35 additions and 22 deletions
@@ -1,10 +1,23 @@
///<reference path="i18next-sprintf-postprocessor.d.ts"/>
///<reference path="./i18next-sprintf-postprocessor.d.ts"/>
import * as i18next from "i18next";
import sprintf from "i18next-sprintf-postprocessor";
import * as sprintfA from "i18next-sprintf-postprocessor";
import sprintfB from "i18next-sprintf-postprocessor/dist/commonjs";
function initTest() {
const i18nextOptions = {};
i18next.use(sprintf).init(i18nextOptions);
i18next.init({ overloadTranslationOptionHandler: sprintf.overloadTranslationOptionHandler });
i18next
.use(sprintfA)
.use(sprintfB)
.init(i18nextOptions);
i18next
.init({ overloadTranslationOptionHandler: sprintfA.overloadTranslationOptionHandler });
i18next
.init({ overloadTranslationOptionHandler: sprintfB.overloadTranslationOptionHandler });
}
function tTest() {
i18next.t('interpolationTest1', 'a', 'b', 'c', 'd');
i18next.t('interpolationTest3', 'z');
i18next.t('interpolationTest4', 0);
}
@@ -3,29 +3,32 @@
// Definitions by: Cyril Schumacher <https://github.com/cyrilschumacher>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
///<reference path="../express/express.d.ts"/>
///<reference path="../i18next/i18next-2.0.17.d.ts"/>
///<reference path="../i18next/i18next.d.ts"/>
declare namespace I18next {
interface I18nextOptions extends i18nextSprintfPostProcessor.I18nextOptions {}
}
declare namespace i18nextSprintfPostProcessor {
interface I18nextOptions {
overloadTranslationOptionHandler?(args: Array<any>): void;
process?(value: any, key: string, options: Object): void;
}
interface I18n {
t(key: string, ...args: any[]): string;
}
}
declare module "i18next-sprintf-postprocessor" {
import i18next = require("i18next");
interface i18nextSprintfPostProcessor {
(): any;
process(value: any, key: string, options: Object): void;
overloadTranslationOptionHandler(args: Array<any>): void;
interface I18nextSprintfPostProcessor {
name: string;
type: string;
process(value: any, key: string, options: any): any;
overloadTranslationOptionHandler(args: string[]): {
postProcess: "sprintf",
sprintf: string[]
};
}
var sprintf: i18nextSprintfPostProcessor;
var sprintf: I18nextSprintfPostProcessor;
export = sprintf;
}
declare module "i18next-sprintf-postprocessor/dist/commonjs" {
import sprintf = require("i18next-sprintf-postprocessor");
export default sprintf;
}
-3
View File
@@ -5,10 +5,7 @@
// 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 {}