diff --git a/types/i18next/i18next-tests.ts b/types/i18next/i18next-tests.ts index 23c67cc742..e51f2f495c 100644 --- a/types/i18next/i18next-tests.ts +++ b/types/i18next/i18next-tests.ts @@ -10,12 +10,14 @@ i18n.init({ resources: { en: { translation: { - helloWorld: 'Hello, world!' + helloWorld: 'Hello, world!', + helloWorldInterpolated: 'Hello, {{name}}!' } }, ru: { translation: { - helloWorld: 'Привет, мир!' + helloWorld: 'Привет, мир!', + helloWorldInterpolated: 'Привет, {{name}}!' } } }, @@ -61,6 +63,14 @@ i18n.t('helloWorld', { count: 10 }); +i18n.t('helloWorldInterpolated', { + defaultValue: 'default', + count: 10, + name: "world" +}); + +i18n.exists("helloWorld"); + const options:i18n.Options = i18n.options; const currentLanguage:string = i18n.language; const userLanguageCodes:string[] = i18n.languages; diff --git a/types/i18next/index.d.ts b/types/i18next/index.d.ts index 958bff12a6..ee06d8d18c 100644 --- a/types/i18next/index.d.ts +++ b/types/i18next/index.d.ts @@ -49,6 +49,8 @@ declare namespace i18n { joinArrays?: string; postProcess?: string | any[]; interpolation?: InterpolationOptions; + //add an indexer to assure that interpolation arguments can be passed + [x: string]: any; } interface Options { @@ -106,7 +108,7 @@ declare namespace i18n { t(key: string, options?: TranslationOptions): string | any | Array; - exists(): boolean; + exists(key: string, options?: TranslationOptions): boolean; setDefaultNamespace(ns: string): void;