mirror of
https://github.com/zhigang1992/DefinitelyTyped.git
synced 2026-04-24 05:06:02 +08:00
improve i18next-sprintf-postprocessor/i18next-sprintf-postprocessor.d.ts
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user