From e54bbf3cdaa27e8908a05d205b95cc69529f8c15 Mon Sep 17 00:00:00 2001 From: Cedric Kemp Date: Tue, 31 Oct 2017 01:29:52 -0400 Subject: [PATCH] Adding typings for vex-i18n --- types/vuex-i18n/index.d.ts | 64 ++++++++++++++++++++++++++++ types/vuex-i18n/package.json | 5 +++ types/vuex-i18n/tsconfig.json | 26 ++++++++++++ types/vuex-i18n/tslint.json | 79 +++++++++++++++++++++++++++++++++++ types/vuex-i18n/vue.d.ts | 21 ++++++++++ 5 files changed, 195 insertions(+) create mode 100644 types/vuex-i18n/index.d.ts create mode 100644 types/vuex-i18n/package.json create mode 100644 types/vuex-i18n/tsconfig.json create mode 100644 types/vuex-i18n/tslint.json create mode 100644 types/vuex-i18n/vue.d.ts diff --git a/types/vuex-i18n/index.d.ts b/types/vuex-i18n/index.d.ts new file mode 100644 index 0000000000..dc79a847ff --- /dev/null +++ b/types/vuex-i18n/index.d.ts @@ -0,0 +1,64 @@ +// Type definitions for vuex-i18n 1.7.0 +// Project: https://github.com/dkfbasel/vuex-i18n +// Definitions by: Cedric Kemp +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +/// TypeScript Version: 2.3 + +import _Vue, { PluginObject } from "vue"; + +// augment typings of Vue.js +import "./vue"; + +export declare interface ITranslations { + [key: string]: string +} + +export declare interface Ii18n { + /** get the current locale */ + locale(): string + + /** set the current locale (i.e. 'de', 'en') */ + set(locale: string): void + + /** add locale translation to the storage. this will extend existing information + (i.e. 'de', {'message': 'Eine Nachricht'}) */ + add(locale: string, translations: ITranslations): void + + /** replace locale translations in the storage. this will remove all previous + locale information for the specified locale */ + replace(locale: string, translations: ITranslations): void + + /** remove the given locale from the store */ + remove(locale: string): void + + /** set a fallback locale if translation for current locale does not exist */ + fallback(locale: string): void + + /** get localized string from store. note that we pass the arguments passed + to the function directly to the translateInLanguage function */ + translate(key: string, options: any, pluralization?: number): string | undefined + + /** get localized string from store. note that we pass the arguments passed + to the function directly to the translateInLanguage function */ + translate(key: string, defaultValue: string, options: any, pluralization?: number): string | undefined + + /** get localized string from store in a given language if available. + * get localized string from store in a given language if available. + */ + translateIn(locale: string, key: string, options: any, pluralization?: number): string | undefined + + /** get localized string from store in a given language if available. + * get localized string from store in a given language if available. + */ + translateIn(locale: string, key: string, defaultValue: string, options: any, pluralization?: number): string | undefined + + /** check if the given locale translations are present in the store */ + localeExists(locale: string): boolean + + /** check if the given key is available in the current or fallback locale */ + keyExists(key: string): boolean +} + +declare module 'vuex-i18n' { + const plugin: PluginObject +} diff --git a/types/vuex-i18n/package.json b/types/vuex-i18n/package.json new file mode 100644 index 0000000000..acec5c3904 --- /dev/null +++ b/types/vuex-i18n/package.json @@ -0,0 +1,5 @@ +{ + "dependencies": { + "vue": ">=2.0.0" + } +} diff --git a/types/vuex-i18n/tsconfig.json b/types/vuex-i18n/tsconfig.json new file mode 100644 index 0000000000..22d8f832eb --- /dev/null +++ b/types/vuex-i18n/tsconfig.json @@ -0,0 +1,26 @@ +{ + "compilerOptions": { + "module": "commonjs", + "target": "es5", + "lib": [ + "es5", + "es2015" + ], + "types": [], + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "noEmit": true, + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "forceConsistentCasingInFileNames": true, + "version": 2.3 + }, + "files": [ + "index.d.ts", + "vue.d.ts" + ] +} \ No newline at end of file diff --git a/types/vuex-i18n/tslint.json b/types/vuex-i18n/tslint.json new file mode 100644 index 0000000000..a41bf5d19a --- /dev/null +++ b/types/vuex-i18n/tslint.json @@ -0,0 +1,79 @@ +{ + "extends": "dtslint/dt.json", + "rules": { + "adjacent-overload-signatures": false, + "array-type": false, + "arrow-return-shorthand": false, + "ban-types": false, + "callable-types": false, + "comment-format": false, + "dt-header": false, + "eofline": false, + "export-just-namespace": false, + "import-spacing": false, + "interface-name": false, + "interface-over-type-literal": false, + "jsdoc-format": false, + "max-line-length": false, + "member-access": false, + "new-parens": false, + "no-any-union": false, + "no-boolean-literal-compare": false, + "no-conditional-assignment": false, + "no-consecutive-blank-lines": false, + "no-construct": false, + "no-declare-current-package": false, + "no-duplicate-imports": false, + "no-duplicate-variable": false, + "no-empty-interface": false, + "no-for-in-array": false, + "no-inferrable-types": false, + "no-internal-module": false, + "no-irregular-whitespace": false, + "no-mergeable-namespace": false, + "no-misused-new": false, + "no-namespace": false, + "no-object-literal-type-assertion": false, + "no-padding": false, + "no-redundant-jsdoc": false, + "no-redundant-jsdoc-2": false, + "no-redundant-undefined": false, + "no-reference-import": false, + "no-relative-import-in-test": false, + "no-self-import": false, + "no-single-declare-module": false, + "no-string-throw": false, + "no-unnecessary-callback-wrapper": false, + "no-unnecessary-class": false, + "no-unnecessary-generics": false, + "no-unnecessary-qualifier": false, + "no-unnecessary-type-assertion": false, + "no-useless-files": false, + "no-var-keyword": false, + "no-var-requires": false, + "no-void-expression": false, + "no-trailing-whitespace": false, + "object-literal-key-quotes": false, + "object-literal-shorthand": false, + "one-line": false, + "one-variable-per-declaration": false, + "only-arrow-functions": false, + "prefer-conditional-expression": false, + "prefer-const": false, + "prefer-declare-function": false, + "prefer-for-of": false, + "prefer-method-signature": false, + "prefer-template": false, + "radix": false, + "semicolon": false, + "space-before-function-paren": false, + "space-within-parens": false, + "strict-export-declare-modifiers": false, + "trim-file": false, + "triple-equals": false, + "typedef-whitespace": false, + "unified-signatures": false, + "void-return": false, + "whitespace": false + } +} diff --git a/types/vuex-i18n/vue.d.ts b/types/vuex-i18n/vue.d.ts new file mode 100644 index 0000000000..f20b24462d --- /dev/null +++ b/types/vuex-i18n/vue.d.ts @@ -0,0 +1,21 @@ +// Type definitions for vuex-i18n 1.7.0 +// Project: https://github.com/dkfbasel/vuex-i18n +// Definitions by: Cedric Kemp +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +/// TypeScript Version: 2.3 + +/** + * Extends interfaces in Vue.js + */ +import Vue from "vue"; +import { Ii18n } from "./index"; + +declare module "vue/types/vue" { + interface Vue { + $i18n: Ii18n; + } + + interface VueConstructor { + i18n: Ii18n; + } +}