From 279425d25fbe4e7a3a3ae5ff429c0c0124c23473 Mon Sep 17 00:00:00 2001 From: Lucy He Date: Fri, 5 Jun 2015 18:04:26 -0400 Subject: [PATCH 1/2] Add typing for addResources. Export i18next-client module. --- i18next/i18next-tests.ts | 18 ++++++++++++++++++ i18next/i18next.d.ts | 5 +++++ 2 files changed, 23 insertions(+) diff --git a/i18next/i18next-tests.ts b/i18next/i18next-tests.ts index b1732de11..741f12982 100644 --- a/i18next/i18next-tests.ts +++ b/i18next/i18next-tests.ts @@ -665,6 +665,24 @@ describe('i18next', function () { }); + describe('adding resources after initialisation', function () { + + var frResource = { 'simple_fr': 'ok_from_fr' }; + var enResource = { 'simple_en': 'ok_from_en' }; + + beforeEach(function (done) { + i18n.init({ resStore: {} }, + function (t) { done(); }); + }); + + it('it should use resources for translation added after initialisation', function () { + i18n.addResources('fr', 'translation', frResource); + i18n.addResources('en', 'translation', enResource); + expect(i18n.t('simple_fr', { lng: 'fr' })).to.be('ok_from_fr'); + expect(i18n.t('simple_en', { lng: 'en' })).to.be('ok_from_en'); + }); + + }); }); describe('translation functionality', function () { diff --git a/i18next/i18next.d.ts b/i18next/i18next.d.ts index 3463f2426..4d7d5945b 100644 --- a/i18next/i18next.d.ts +++ b/i18next/i18next.d.ts @@ -66,6 +66,7 @@ interface I18nextOptions { interface I18nextStatic { + addResources(language: string, namespace: string, resources: IResourceStoreKey): void; addPostProcessor(name: string, fn: (value: any, key: string, options: any) => string): void; detectLanguage(): string; functions: { @@ -130,4 +131,8 @@ declare var i18n: I18nextStatic; declare module 'i18next' { export = i18n; +} + +declare module 'i18next-client' { + export = i18n; } \ No newline at end of file From f3797dc8504128fba6810be381c2983e7cfc05e8 Mon Sep 17 00:00:00 2001 From: Lucy He Date: Fri, 5 Jun 2015 18:10:15 -0400 Subject: [PATCH 2/2] Move function so typings are alphabetical. --- i18next/i18next.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/i18next/i18next.d.ts b/i18next/i18next.d.ts index 4d7d5945b..f39095459 100644 --- a/i18next/i18next.d.ts +++ b/i18next/i18next.d.ts @@ -66,8 +66,8 @@ interface I18nextOptions { interface I18nextStatic { - addResources(language: string, namespace: string, resources: IResourceStoreKey): void; addPostProcessor(name: string, fn: (value: any, key: string, options: any) => string): void; + addResources(language: string, namespace: string, resources: IResourceStoreKey): void; detectLanguage(): string; functions: { extend(target: any, ...objs: any[]): Object;