diff --git a/types/vuex-i18n/index.d.ts b/types/vuex-i18n/index.d.ts index 2332ef4436..e1f607ef39 100644 --- a/types/vuex-i18n/index.d.ts +++ b/types/vuex-i18n/index.d.ts @@ -1,6 +1,7 @@ // Type definitions for vuex-i18n 1.7 // Project: https://github.com/dkfbasel/vuex-i18n // Definitions by: Cedric Kemp +// Noam Kfir // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.3 @@ -17,13 +18,16 @@ declare module "vue/types/vue" { } export interface Translations { - [key: string]: string; + [key: string]: string | Translations; } export interface Ii18n { /** get the current locale */ locale(): string; + /** get all the registered locales */ + locales(): string[]; + /** set the current locale (i.e. 'de', 'en') */ set(locale: string): void; @@ -64,12 +68,12 @@ export interface Ii18n { /** * get localized string from store in a given language if available. */ - translateIn(locale: string, key: string, options: any, pluralization?: number): string | undefined; + translateIn(locale: string, key: string, options?: any, pluralization?: number): string | undefined; /** * get localized string from store in a given language if available. */ - translateIn(locale: string, key: string, defaultValue: string, options: any, pluralization?: number): string | undefined; + translateIn(locale: string, key: string, defaultValue: string, options?: any, pluralization?: number): string | undefined; /** * check if the given locale translations are present in the store diff --git a/types/vuex-i18n/vuex-i18n-tests.ts b/types/vuex-i18n/vuex-i18n-tests.ts index 218bd12ccf..82d9d864d9 100644 --- a/types/vuex-i18n/vuex-i18n-tests.ts +++ b/types/vuex-i18n/vuex-i18n-tests.ts @@ -23,7 +23,10 @@ Vue.use(vuexI18n.plugin, store); // structured as object trees and will automatically be flattened by the the // plugin const translationsEn = { - content: "This is some {type} content" + content: "This is some {type} content", + tree: { + nested: "This is nested content" + } }; // translations can be kept in separate files for each language @@ -39,3 +42,5 @@ Vue.i18n.add("de", translationsDe); // set the start locale to use Vue.i18n.set("en"); + +Vue.i18n.translateIn("en", "tree.nested");