Comparing version 1.5.1 to 1.6.0
@@ -397,6 +397,12 @@ 'use strict'; | ||
// get the current language from the store | ||
var fallback = store.state[moduleName].fallback; | ||
// get the translations from the store | ||
var translations = store.state[moduleName].translations; | ||
// get the last resort fallback from the store | ||
var fallback = store.state[moduleName].fallback; | ||
// split locale by - to support partial fallback for regional locales | ||
// like de-CH, en-UK | ||
var localeRegional = locale.split('-'); | ||
// flag for translation to exist or not | ||
@@ -408,3 +414,2 @@ var translationExist = true; | ||
translationExist = false; | ||
// check if the key exists in the store. return the key if not | ||
@@ -420,2 +425,8 @@ } else if (translations[locale].hasOwnProperty(key) === false) { | ||
// check if a regional locale translation would be available for the key | ||
// i.e. de for de-CH | ||
if (localeRegional.length > 1 && translations.hasOwnProperty(localeRegional[0]) === true && translations[localeRegional[0]].hasOwnProperty(key) === true) { | ||
return render(localeRegional[0], translations[localeRegional[0]][key], options, pluralization); | ||
} | ||
// check if a vaild fallback exists in the store. | ||
@@ -430,3 +441,3 @@ // return the default value if not | ||
if (translations[fallback].hasOwnProperty(key) === false) { | ||
return render(locale, defaultValue, options, pluralization); | ||
return render(fallback, defaultValue, options, pluralization); | ||
} | ||
@@ -433,0 +444,0 @@ |
@@ -395,6 +395,12 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { | ||
// get the current language from the store | ||
var fallback = store.state[moduleName].fallback; | ||
// get the translations from the store | ||
var translations = store.state[moduleName].translations; | ||
// get the last resort fallback from the store | ||
var fallback = store.state[moduleName].fallback; | ||
// split locale by - to support partial fallback for regional locales | ||
// like de-CH, en-UK | ||
var localeRegional = locale.split('-'); | ||
// flag for translation to exist or not | ||
@@ -406,3 +412,2 @@ var translationExist = true; | ||
translationExist = false; | ||
// check if the key exists in the store. return the key if not | ||
@@ -418,2 +423,8 @@ } else if (translations[locale].hasOwnProperty(key) === false) { | ||
// check if a regional locale translation would be available for the key | ||
// i.e. de for de-CH | ||
if (localeRegional.length > 1 && translations.hasOwnProperty(localeRegional[0]) === true && translations[localeRegional[0]].hasOwnProperty(key) === true) { | ||
return render(localeRegional[0], translations[localeRegional[0]][key], options, pluralization); | ||
} | ||
// check if a vaild fallback exists in the store. | ||
@@ -428,3 +439,3 @@ // return the default value if not | ||
if (translations[fallback].hasOwnProperty(key) === false) { | ||
return render(locale, defaultValue, options, pluralization); | ||
return render(fallback, defaultValue, options, pluralization); | ||
} | ||
@@ -431,0 +442,0 @@ |
@@ -401,6 +401,12 @@ (function (global, factory) { | ||
// get the current language from the store | ||
var fallback = store.state[moduleName].fallback; | ||
// get the translations from the store | ||
var translations = store.state[moduleName].translations; | ||
// get the last resort fallback from the store | ||
var fallback = store.state[moduleName].fallback; | ||
// split locale by - to support partial fallback for regional locales | ||
// like de-CH, en-UK | ||
var localeRegional = locale.split('-'); | ||
// flag for translation to exist or not | ||
@@ -412,3 +418,2 @@ var translationExist = true; | ||
translationExist = false; | ||
// check if the key exists in the store. return the key if not | ||
@@ -424,2 +429,8 @@ } else if (translations[locale].hasOwnProperty(key) === false) { | ||
// check if a regional locale translation would be available for the key | ||
// i.e. de for de-CH | ||
if (localeRegional.length > 1 && translations.hasOwnProperty(localeRegional[0]) === true && translations[localeRegional[0]].hasOwnProperty(key) === true) { | ||
return render(localeRegional[0], translations[localeRegional[0]][key], options, pluralization); | ||
} | ||
// check if a vaild fallback exists in the store. | ||
@@ -434,3 +445,3 @@ // return the default value if not | ||
if (translations[fallback].hasOwnProperty(key) === false) { | ||
return render(locale, defaultValue, options, pluralization); | ||
return render(fallback, defaultValue, options, pluralization); | ||
} | ||
@@ -437,0 +448,0 @@ |
{ | ||
"name": "vuex-i18n", | ||
"version": "1.5.1", | ||
"version": "1.6.0", | ||
"description": "Easy localization for vue-components using vuex as data store", | ||
@@ -5,0 +5,0 @@ "directories": { |
@@ -126,2 +126,3 @@ # vuex-i18n | ||
</div> | ||
``` | ||
@@ -170,3 +171,3 @@ Dynamic parameters that can be passed to the translation method in the form of | ||
// or "2 bērni" if the third argument is 2 | ||
// or "1 bērns" if the third argument is 1 | ||
// or "1 bērns" if the third argument is 1 | ||
// or "0 bērnu" if the third argument is 0 | ||
@@ -173,0 +174,0 @@ {{ $t('{count} bērns ::: {count} bērni ::: {count} bērnu', {count: 5}, 5) }} |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
77833
1672
215