Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

vuex-i18n

Package Overview
Dependencies
Maintainers
3
Versions
33
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

vuex-i18n - npm Package Compare versions

Comparing version 1.6.0 to 1.7.0

55

dist/vuex-i18n.cjs.js

@@ -31,4 +31,32 @@ 'use strict';

ADD_LOCALE: function ADD_LOCALE(state, payload) {
// reduce the given translations to a single-depth tree
var translations = flattenTranslations(payload.translations);
if (state.translations.hasOwnProperty(payload.locale)) {
// get the existing translations
var existingTranslations = state.translations[payload.locale];
// merge the translations
state.translations[payload.locale] = Object.assign({}, existingTranslations, translations);
} else {
// just set the locale if it does not yet exist
state.translations[payload.locale] = translations;
}
// make sure to notify vue of changes (this might break with new vue versions)
try {
if (state.translations.__ob__) {
state.translations.__ob__.dep.notify();
}
} catch (ex) {}
},
// replace existing locale information with new translations
REPLACE_LOCALE: function REPLACE_LOCALE(state, payload) {
// reduce the given translations to a single-depth tree
var translations = flattenTranslations(payload.translations);
// replace the translations entirely
state.translations[payload.locale] = translations;

@@ -45,3 +73,3 @@

// remove a new locale
// remove a locale from the store
REMOVE_LOCALE: function REMOVE_LOCALE(state, payload) {

@@ -83,3 +111,3 @@

// add a new locale with translations
// add or extend a locale with translations
addLocale: function addLocale(context, payload) {

@@ -94,2 +122,12 @@ context.commit({

// replace locale information
replaceLocale: function replaceLocale(context, payload) {
context.commit({
type: 'REPLACE_LOCALE',
locale: payload.locale,
translations: payload.translations
});
},
// remove the given locale translations

@@ -493,3 +531,3 @@ removeLocale: function removeLocale(context, payload) {

// add predefined translations to the store
// add predefined translations to the store (keeping existing information)
var addLocale = function addLocale(locale, translations) {

@@ -503,2 +541,11 @@ return store.dispatch({

// replace all locale information in the store
var replaceLocale = function replaceLocale(locale, translations) {
return store.dispatch({
type: 'replaceLocale',
locale: locale,
translations: translations
});
};
// remove the givne locale from the store

@@ -530,2 +577,3 @@ var removeLocale = function removeLocale(locale) {

add: addLocale,
replace: replaceLocale,
remove: removeLocale,

@@ -544,2 +592,3 @@ fallback: setFallbackLocale,

add: addLocale,
replace: replaceLocale,
remove: removeLocale,

@@ -546,0 +595,0 @@ fallback: setFallbackLocale,

@@ -29,4 +29,32 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) {

ADD_LOCALE: function ADD_LOCALE(state, payload) {
// reduce the given translations to a single-depth tree
var translations = flattenTranslations(payload.translations);
if (state.translations.hasOwnProperty(payload.locale)) {
// get the existing translations
var existingTranslations = state.translations[payload.locale];
// merge the translations
state.translations[payload.locale] = Object.assign({}, existingTranslations, translations);
} else {
// just set the locale if it does not yet exist
state.translations[payload.locale] = translations;
}
// make sure to notify vue of changes (this might break with new vue versions)
try {
if (state.translations.__ob__) {
state.translations.__ob__.dep.notify();
}
} catch (ex) {}
},
// replace existing locale information with new translations
REPLACE_LOCALE: function REPLACE_LOCALE(state, payload) {
// reduce the given translations to a single-depth tree
var translations = flattenTranslations(payload.translations);
// replace the translations entirely
state.translations[payload.locale] = translations;

@@ -43,3 +71,3 @@

// remove a new locale
// remove a locale from the store
REMOVE_LOCALE: function REMOVE_LOCALE(state, payload) {

@@ -81,3 +109,3 @@

// add a new locale with translations
// add or extend a locale with translations
addLocale: function addLocale(context, payload) {

@@ -92,2 +120,12 @@ context.commit({

// replace locale information
replaceLocale: function replaceLocale(context, payload) {
context.commit({
type: 'REPLACE_LOCALE',
locale: payload.locale,
translations: payload.translations
});
},
// remove the given locale translations

@@ -491,3 +529,3 @@ removeLocale: function removeLocale(context, payload) {

// add predefined translations to the store
// add predefined translations to the store (keeping existing information)
var addLocale = function addLocale(locale, translations) {

@@ -501,2 +539,11 @@ return store.dispatch({

// replace all locale information in the store
var replaceLocale = function replaceLocale(locale, translations) {
return store.dispatch({
type: 'replaceLocale',
locale: locale,
translations: translations
});
};
// remove the givne locale from the store

@@ -528,2 +575,3 @@ var removeLocale = function removeLocale(locale) {

add: addLocale,
replace: replaceLocale,
remove: removeLocale,

@@ -542,2 +590,3 @@ fallback: setFallbackLocale,

add: addLocale,
replace: replaceLocale,
remove: removeLocale,

@@ -544,0 +593,0 @@ fallback: setFallbackLocale,

@@ -35,4 +35,32 @@ (function (global, factory) {

ADD_LOCALE: function ADD_LOCALE(state, payload) {
// reduce the given translations to a single-depth tree
var translations = flattenTranslations(payload.translations);
if (state.translations.hasOwnProperty(payload.locale)) {
// get the existing translations
var existingTranslations = state.translations[payload.locale];
// merge the translations
state.translations[payload.locale] = Object.assign({}, existingTranslations, translations);
} else {
// just set the locale if it does not yet exist
state.translations[payload.locale] = translations;
}
// make sure to notify vue of changes (this might break with new vue versions)
try {
if (state.translations.__ob__) {
state.translations.__ob__.dep.notify();
}
} catch (ex) {}
},
// replace existing locale information with new translations
REPLACE_LOCALE: function REPLACE_LOCALE(state, payload) {
// reduce the given translations to a single-depth tree
var translations = flattenTranslations(payload.translations);
// replace the translations entirely
state.translations[payload.locale] = translations;

@@ -49,3 +77,3 @@

// remove a new locale
// remove a locale from the store
REMOVE_LOCALE: function REMOVE_LOCALE(state, payload) {

@@ -87,3 +115,3 @@

// add a new locale with translations
// add or extend a locale with translations
addLocale: function addLocale(context, payload) {

@@ -98,2 +126,12 @@ context.commit({

// replace locale information
replaceLocale: function replaceLocale(context, payload) {
context.commit({
type: 'REPLACE_LOCALE',
locale: payload.locale,
translations: payload.translations
});
},
// remove the given locale translations

@@ -497,3 +535,3 @@ removeLocale: function removeLocale(context, payload) {

// add predefined translations to the store
// add predefined translations to the store (keeping existing information)
var addLocale = function addLocale(locale, translations) {

@@ -507,2 +545,11 @@ return store.dispatch({

// replace all locale information in the store
var replaceLocale = function replaceLocale(locale, translations) {
return store.dispatch({
type: 'replaceLocale',
locale: locale,
translations: translations
});
};
// remove the givne locale from the store

@@ -534,2 +581,3 @@ var removeLocale = function removeLocale(locale) {

add: addLocale,
replace: replaceLocale,
remove: removeLocale,

@@ -548,2 +596,3 @@ fallback: setFallbackLocale,

add: addLocale,
replace: replaceLocale,
remove: removeLocale,

@@ -550,0 +599,0 @@ fallback: setFallbackLocale,

2

package.json
{
"name": "vuex-i18n",
"version": "1.6.0",
"version": "1.7.0",
"description": "Easy localization for vue-components using vuex as data store",

@@ -5,0 +5,0 @@ "directories": {

@@ -190,23 +190,27 @@ # vuex-i18n

```javascript
// get the current locale
$i18n.locale(), Vue.i18n.locale()
// get the current locale
// set the current locale (i.e. 'de', 'en')
$i18n.set(locale), Vue.i18n.set(locale)
// set the current locale (i.e. 'de', 'en')
// add locale translation to the storage. this will extend existing information
// (i.e. 'de', {'message': 'Eine Nachricht'})
$i18n.add(locale, translations), Vue.i18n.add(locale, translations)
// add a new locale to the storage
// (i.e. 'de', {'message': 'Eine Nachricht'})
// replace locale translations in the storage. this will remove all previous
// locale information for the specified locale
$i18n.replace(locale, translations), Vue.i18n.replace(locale, translations)
// check if the given locale translations are present in the store
$i18n.localeExists(locale), Vue.i18n.localeExists(locale)
// check if the given locale translations are present in the store
// check if the given key is available in the current or fallback locale
$i18n.keyExists(key), Vue.i18n.keyExists(key)
// check if the given key is available in the current or fallback locale
// remove the given locale from the store
$i18n.remove(locale), Vue.i18n.remove(locale)
// remove the given locale from the store
// set a fallback locale if translation for current locale does not exist
$i18n.fallback(locale), Vue.i18n.fallback(locale)
// set a fallback locale if translation for current locale does not exist
```

@@ -213,0 +217,0 @@

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc