Adding typings for vex-i18n

This commit is contained in:
Cedric Kemp
2017-10-31 01:29:52 -04:00
parent 00cb71a36a
commit e54bbf3cda
5 changed files with 195 additions and 0 deletions
+64
View File
@@ -0,0 +1,64 @@
// Type definitions for vuex-i18n 1.7.0
// Project: https://github.com/dkfbasel/vuex-i18n
// Definitions by: Cedric Kemp <https://github.com/jaeggerr>
// 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<Ii18n>
}
+5
View File
@@ -0,0 +1,5 @@
{
"dependencies": {
"vue": ">=2.0.0"
}
}
+26
View File
@@ -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"
]
}
+79
View File
@@ -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
}
}
+21
View File
@@ -0,0 +1,21 @@
// Type definitions for vuex-i18n 1.7.0
// Project: https://github.com/dkfbasel/vuex-i18n
// Definitions by: Cedric Kemp <https://github.com/jaeggerr>
// 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<V extends Vue = Vue> {
i18n: Ii18n;
}
}