From 3ae8647ef0786498126cbccccac2431a1defde38 Mon Sep 17 00:00:00 2001 From: Daniel Waxweiler Date: Thu, 7 Jun 2018 12:22:53 +0200 Subject: [PATCH 1/4] initial release --- types/i18next-ko/i18next-ko-tests.ts | 24 ++++++++++++++++++++++++ types/i18next-ko/index.d.ts | 26 ++++++++++++++++++++++++++ types/i18next-ko/tsconfig.json | 23 +++++++++++++++++++++++ types/i18next-ko/tslint.json | 6 ++++++ 4 files changed, 79 insertions(+) create mode 100644 types/i18next-ko/i18next-ko-tests.ts create mode 100644 types/i18next-ko/index.d.ts create mode 100644 types/i18next-ko/tsconfig.json create mode 100644 types/i18next-ko/tslint.json diff --git a/types/i18next-ko/i18next-ko-tests.ts b/types/i18next-ko/i18next-ko-tests.ts new file mode 100644 index 0000000000..2bf683aaf6 --- /dev/null +++ b/types/i18next-ko/i18next-ko-tests.ts @@ -0,0 +1,24 @@ +import * as i18next from 'i18next'; +import i18nextko = require('i18nextko'); +import * as ko from 'knockout'; + +const resourceStore = { + en: { + translation: { + testTranslation: 'Test translation' + } + }, + + de: { + translation: { + testTranslation: 'Test-Übersetzung' + } + } +}; +i18nextko.init(resourceStore, 'en', ko); + +i18nextko.setLanguage('de'); + +i18nextko.i18n; + +i18nextko.t('testTranslation'); diff --git a/types/i18next-ko/index.d.ts b/types/i18next-ko/index.d.ts new file mode 100644 index 0000000000..6fdc771031 --- /dev/null +++ b/types/i18next-ko/index.d.ts @@ -0,0 +1,26 @@ +// Type definitions for i18next-ko 3.0 +// Project: https://github.com/leMaik/i18next-ko +// Definitions by: Daniel Waxweiler +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +/// + +declare module 'i18nextko' { + import i18next = require('i18next'); + + const i18n: i18next.i18n; + + function init(resourceStore: i18nextkoResourceStore, language: string, ko: KnockoutStatic): void; + + function setLanguage(language: string): void; + + function t(key: string): KnockoutComputed; + + interface i18nextkoResourceStore { + [language: string]: { + translation: { + [key: string]: string + } + }; + } +} diff --git a/types/i18next-ko/tsconfig.json b/types/i18next-ko/tsconfig.json new file mode 100644 index 0000000000..9509fa509e --- /dev/null +++ b/types/i18next-ko/tsconfig.json @@ -0,0 +1,23 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "i18next-ko-tests.ts" + ] +} diff --git a/types/i18next-ko/tslint.json b/types/i18next-ko/tslint.json new file mode 100644 index 0000000000..075fa88707 --- /dev/null +++ b/types/i18next-ko/tslint.json @@ -0,0 +1,6 @@ +{ + "extends": "dtslint/dt.json", + "rules": { + "no-single-declare-module": false + } +} From b33addce043fe7402f18b3ca4230592af4f85366 Mon Sep 17 00:00:00 2001 From: Daniel Waxweiler Date: Thu, 7 Jun 2018 12:27:33 +0200 Subject: [PATCH 2/4] harmonize imports --- types/i18next-ko/i18next-ko-tests.ts | 2 +- types/i18next-ko/index.d.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/types/i18next-ko/i18next-ko-tests.ts b/types/i18next-ko/i18next-ko-tests.ts index 2bf683aaf6..a84a2bdbd7 100644 --- a/types/i18next-ko/i18next-ko-tests.ts +++ b/types/i18next-ko/i18next-ko-tests.ts @@ -1,5 +1,5 @@ import * as i18next from 'i18next'; -import i18nextko = require('i18nextko'); +import * as i18nextko from 'i18nextko'; import * as ko from 'knockout'; const resourceStore = { diff --git a/types/i18next-ko/index.d.ts b/types/i18next-ko/index.d.ts index 6fdc771031..11436a6211 100644 --- a/types/i18next-ko/index.d.ts +++ b/types/i18next-ko/index.d.ts @@ -6,7 +6,7 @@ /// declare module 'i18nextko' { - import i18next = require('i18next'); + import * as i18next from 'i18next'; const i18n: i18next.i18n; From 1e48ff58545a6561a5e8840ef91db27390681e35 Mon Sep 17 00:00:00 2001 From: Daniel Waxweiler Date: Thu, 7 Jun 2018 12:37:21 +0200 Subject: [PATCH 3/4] add same TypeScript version as i18next requires --- types/i18next-ko/index.d.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/types/i18next-ko/index.d.ts b/types/i18next-ko/index.d.ts index 11436a6211..28d33c5817 100644 --- a/types/i18next-ko/index.d.ts +++ b/types/i18next-ko/index.d.ts @@ -2,6 +2,7 @@ // Project: https://github.com/leMaik/i18next-ko // Definitions by: Daniel Waxweiler // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.3 /// From 035c2747a87485f7c28a261046e4afe1426f2ebc Mon Sep 17 00:00:00 2001 From: Daniel Waxweiler Date: Wed, 13 Jun 2018 15:43:39 +0200 Subject: [PATCH 4/4] remove module declaration --- types/i18next-ko/i18next-ko-tests.ts | 2 +- types/i18next-ko/index.d.ts | 24 +++++++++++------------- types/i18next-ko/tslint.json | 5 +---- 3 files changed, 13 insertions(+), 18 deletions(-) diff --git a/types/i18next-ko/i18next-ko-tests.ts b/types/i18next-ko/i18next-ko-tests.ts index a84a2bdbd7..1b8cd90904 100644 --- a/types/i18next-ko/i18next-ko-tests.ts +++ b/types/i18next-ko/i18next-ko-tests.ts @@ -1,5 +1,5 @@ import * as i18next from 'i18next'; -import * as i18nextko from 'i18nextko'; +import * as i18nextko from 'i18next-ko'; import * as ko from 'knockout'; const resourceStore = { diff --git a/types/i18next-ko/index.d.ts b/types/i18next-ko/index.d.ts index 28d33c5817..e9d3c2c639 100644 --- a/types/i18next-ko/index.d.ts +++ b/types/i18next-ko/index.d.ts @@ -6,22 +6,20 @@ /// -declare module 'i18nextko' { - import * as i18next from 'i18next'; +import * as i18next from 'i18next'; - const i18n: i18next.i18n; +export const i18n: i18next.i18n; - function init(resourceStore: i18nextkoResourceStore, language: string, ko: KnockoutStatic): void; +export function init(resourceStore: i18nextkoResourceStore, language: string, ko: KnockoutStatic): void; - function setLanguage(language: string): void; +export function setLanguage(language: string): void; - function t(key: string): KnockoutComputed; +export function t(key: string): KnockoutComputed; - interface i18nextkoResourceStore { - [language: string]: { - translation: { - [key: string]: string - } - }; - } +export interface i18nextkoResourceStore { + [language: string]: { + translation: { + [key: string]: string + } + }; } diff --git a/types/i18next-ko/tslint.json b/types/i18next-ko/tslint.json index 075fa88707..f93cf8562a 100644 --- a/types/i18next-ko/tslint.json +++ b/types/i18next-ko/tslint.json @@ -1,6 +1,3 @@ { - "extends": "dtslint/dt.json", - "rules": { - "no-single-declare-module": false - } + "extends": "dtslint/dt.json" }