diff --git a/types/i18next-ko/i18next-ko-tests.ts b/types/i18next-ko/i18next-ko-tests.ts new file mode 100644 index 0000000000..1b8cd90904 --- /dev/null +++ b/types/i18next-ko/i18next-ko-tests.ts @@ -0,0 +1,24 @@ +import * as i18next from 'i18next'; +import * as i18nextko from 'i18next-ko'; +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..e9d3c2c639 --- /dev/null +++ b/types/i18next-ko/index.d.ts @@ -0,0 +1,25 @@ +// Type definitions for i18next-ko 3.0 +// Project: https://github.com/leMaik/i18next-ko +// Definitions by: Daniel Waxweiler +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.3 + +/// + +import * as i18next from 'i18next'; + +export const i18n: i18next.i18n; + +export function init(resourceStore: i18nextkoResourceStore, language: string, ko: KnockoutStatic): void; + +export function setLanguage(language: string): void; + +export function t(key: string): KnockoutComputed; + +export 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..f93cf8562a --- /dev/null +++ b/types/i18next-ko/tslint.json @@ -0,0 +1,3 @@ +{ + "extends": "dtslint/dt.json" +}