mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-12-06 13:11:46 +00:00
Merge pull request #26780 from noamkfir/vuex-i18n
vuex-i18n - Nested Translations interface and support for translateIn with two parameters
This commit is contained in:
Vendored
+7
-3
@@ -1,6 +1,7 @@
|
||||
// Type definitions for vuex-i18n 1.7
|
||||
// Project: https://github.com/dkfbasel/vuex-i18n
|
||||
// Definitions by: Cedric Kemp <https://github.com/jaeggerr>
|
||||
// Noam Kfir <https://github.com/noamkfir>
|
||||
// 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
|
||||
|
||||
@@ -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");
|
||||
|
||||
Reference in New Issue
Block a user