Skip to content

Commit

Permalink
new build
Browse files Browse the repository at this point in the history
  • Loading branch information
tikiatua committed Aug 4, 2017
1 parent fa9111f commit e66c86d
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 13 deletions.
19 changes: 15 additions & 4 deletions dist/vuex-i18n.cjs.js
Original file line number Diff line number Diff line change
Expand Up @@ -394,17 +394,22 @@ VuexI18nPlugin.install = function install(Vue, store) {
}
}

// 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
var translationExist = true;

// check if the language exists in the store. return the key if not
if (translations.hasOwnProperty(locale) === false) {
translationExist = false;

// check if the key exists in the store. return the key if not
} else if (translations[locale].hasOwnProperty(key) === false) {
translationExist = false;
Expand All @@ -415,6 +420,12 @@ VuexI18nPlugin.install = function install(Vue, store) {
return render(locale, translations[locale][key], options, pluralization);
}

// 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.
// return the default value if not
if (translations.hasOwnProperty(fallback) === false) {
Expand All @@ -424,7 +435,7 @@ VuexI18nPlugin.install = function install(Vue, store) {
// check if the key exists in the fallback locale in the store.
// return the default value if not
if (translations[fallback].hasOwnProperty(key) === false) {
return render(locale, defaultValue, options, pluralization);
return render(fallback, defaultValue, options, pluralization);
}

return render(locale, translations[fallback][key], options, pluralization);
Expand Down
19 changes: 15 additions & 4 deletions dist/vuex-i18n.es.js
Original file line number Diff line number Diff line change
Expand Up @@ -392,17 +392,22 @@ VuexI18nPlugin.install = function install(Vue, store) {
}
}

// 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
var translationExist = true;

// check if the language exists in the store. return the key if not
if (translations.hasOwnProperty(locale) === false) {
translationExist = false;

// check if the key exists in the store. return the key if not
} else if (translations[locale].hasOwnProperty(key) === false) {
translationExist = false;
Expand All @@ -413,6 +418,12 @@ VuexI18nPlugin.install = function install(Vue, store) {
return render(locale, translations[locale][key], options, pluralization);
}

// 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.
// return the default value if not
if (translations.hasOwnProperty(fallback) === false) {
Expand All @@ -422,7 +433,7 @@ VuexI18nPlugin.install = function install(Vue, store) {
// check if the key exists in the fallback locale in the store.
// return the default value if not
if (translations[fallback].hasOwnProperty(key) === false) {
return render(locale, defaultValue, options, pluralization);
return render(fallback, defaultValue, options, pluralization);
}

return render(locale, translations[fallback][key], options, pluralization);
Expand Down
19 changes: 15 additions & 4 deletions dist/vuex-i18n.min.js
Original file line number Diff line number Diff line change
Expand Up @@ -398,17 +398,22 @@ VuexI18nPlugin.install = function install(Vue, store) {
}
}

// 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
var translationExist = true;

// check if the language exists in the store. return the key if not
if (translations.hasOwnProperty(locale) === false) {
translationExist = false;

// check if the key exists in the store. return the key if not
} else if (translations[locale].hasOwnProperty(key) === false) {
translationExist = false;
Expand All @@ -419,6 +424,12 @@ VuexI18nPlugin.install = function install(Vue, store) {
return render(locale, translations[locale][key], options, pluralization);
}

// 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.
// return the default value if not
if (translations.hasOwnProperty(fallback) === false) {
Expand All @@ -428,7 +439,7 @@ VuexI18nPlugin.install = function install(Vue, store) {
// check if the key exists in the fallback locale in the store.
// return the default value if not
if (translations[fallback].hasOwnProperty(key) === false) {
return render(locale, defaultValue, options, pluralization);
return render(fallback, defaultValue, options, pluralization);
}

return render(locale, translations[fallback][key], options, pluralization);
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "vuex-i18n",
"version": "1.5.1",
"version": "1.6.0",
"description": "Easy localization for vue-components using vuex as data store",
"directories": {
"test": "test"
Expand Down

0 comments on commit e66c86d

Please sign in to comment.