mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-10-03 22:37:03 +00:00
Merge pull request #30090 from barahliush/vuex-i18n
[Vuex i18n] Interface for plugin's module in store and signature for some methods
This commit is contained in:
Vendored
+19
-5
@@ -1,9 +1,10 @@
|
||||
// Type definitions for vuex-i18n 1.7
|
||||
// Type definitions for vuex-i18n 1.10
|
||||
// Project: https://github.com/dkfbasel/vuex-i18n
|
||||
// Definitions by: Cedric Kemp <https://github.com/jaeggerr>
|
||||
// Noam Kfir <https://github.com/noamkfir>
|
||||
// Suleimanov Artem <https://github.com/barahliush>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.3
|
||||
// TypeScript Version: 2.9
|
||||
|
||||
import _Vue, { PluginObject } from "vue";
|
||||
|
||||
@@ -17,13 +18,21 @@ declare module "vue/types/vue" {
|
||||
}
|
||||
}
|
||||
|
||||
export interface i18nState {
|
||||
fallback: string | null;
|
||||
locale: string | null;
|
||||
translations: {
|
||||
[key: string]: Translations;
|
||||
};
|
||||
}
|
||||
|
||||
export interface Translations {
|
||||
[key: string]: string | Translations;
|
||||
}
|
||||
|
||||
export interface Ii18n {
|
||||
/** get the current locale */
|
||||
locale(): string;
|
||||
locale(): string | null;
|
||||
|
||||
/** get all the registered locales */
|
||||
locales(): string[];
|
||||
@@ -81,9 +90,14 @@ export interface Ii18n {
|
||||
localeExists(locale: string): boolean;
|
||||
|
||||
/**
|
||||
* check if the given key is available in the current or fallback locale
|
||||
* check if the given key is available
|
||||
* optional with a second parameter to limit the scope
|
||||
* strict: only current locale (exact match)
|
||||
* locale: current locale and parent language locale (i.e. en-us & en)
|
||||
* fallback: current locale, parent language locale and fallback locale
|
||||
* the default is fallback
|
||||
*/
|
||||
keyExists(key: string): boolean;
|
||||
keyExists(key: string, scope?: string): boolean;
|
||||
}
|
||||
|
||||
declare const _default: {
|
||||
|
||||
@@ -3,11 +3,16 @@ import Vue from "vue";
|
||||
import { Store } from "vuex";
|
||||
|
||||
// load vuex i18n module
|
||||
import vuexI18n from "vuex-i18n";
|
||||
import vuexI18n, { i18nState } from "vuex-i18n";
|
||||
|
||||
// declare interface for store's root state
|
||||
interface RootState {
|
||||
i18n: i18nState;
|
||||
}
|
||||
|
||||
// initialize the vuex store using the vuex module. note that you can change the
|
||||
// name of the module if you wish
|
||||
const store = new Store({});
|
||||
// name of the module if you wish
|
||||
const store = new Store<RootState>({});
|
||||
|
||||
// initialize the internationalization plugin on the vue instance. note that
|
||||
// the store must be passed to the plugin. the plugin will then generate some
|
||||
|
||||
Reference in New Issue
Block a user