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

vuex-i18n

Package Overview
Dependencies
Maintainers
1
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.2.2 to 1.3.0

73

dist/vuex-i18n.cjs.js

@@ -301,4 +301,19 @@ 'use strict';

if (objType == 'object' && objType !== null) {
// allow unflattened array of strings
if (isArray(translations[i])) {
var count = translations[i].length;
for (var index = 0; index < count; index++) {
var itemType = _typeof(translations[i][index]);
if (itemType !== 'string') {
console.warn('vuex-i18n:', 'currently only arrays of strings are fully supported', translations[i]);
break;
}
}
toReturn[i] = translations[i];
} else if (objType == 'object' && objType !== null) {
var flatObject = flattenTranslations(translations[i]);

@@ -318,2 +333,7 @@

// check if the given object is an array
function isArray(obj) {
return !!obj && Array === obj.constructor;
}
/* vuex-i18n defines the Vuexi18nPlugin to enable localization using a vuex

@@ -433,7 +453,15 @@ ** module to store the translation information. Make sure to also include the

// render the given translation with placeholder replaced
var render = function render(translation) {
var replacements = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
// replace will replace the given replacements in the translation string
var replace = function replace(translation, replacements) {
var warn = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
// check if the object has a replace property
if (!translation.replace) {
console.log('no replace', translation);
return translation;
}
console.log('replace', translation, replacements);
return translation.replace(/\{\w+\}/g, function (placeholder) {

@@ -448,6 +476,8 @@

// warn user that the placeholder has not been found
console.group('Not all placeholder founds');
console.warn('Text:', translation);
console.warn('Placeholder:', placeholder);
console.groupEnd();
if (warn === true) {
console.group('Not all placeholder founds');
console.warn('Text:', translation);
console.warn('Placeholder:', placeholder);
console.groupEnd();
}

@@ -459,2 +489,29 @@ // return the original placeholder

// render will return the given translation object
var render = function render(translation) {
var replacements = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
// get the type of the property
var objType = typeof translation === 'undefined' ? 'undefined' : _typeof(translation);
if (isArray$1(translation)) {
// replace the placeholder elements in all sub-items
return translation.map(function (item) {
return replace(item, replacements, false);
});
} else if (objType === 'string') {
return replace(translation, replacements);
}
// return translation item directly
return translation;
};
// check if the given object is an array
function isArray$1(obj) {
return !!obj && Array === obj.constructor;
}
// import the vuex module for localization

@@ -461,0 +518,0 @@ // import the corresponding plugin for vue

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

if (objType == 'object' && objType !== null) {
// allow unflattened array of strings
if (isArray(translations[i])) {
var count = translations[i].length;
for (var index = 0; index < count; index++) {
var itemType = _typeof(translations[i][index]);
if (itemType !== 'string') {
console.warn('vuex-i18n:', 'currently only arrays of strings are fully supported', translations[i]);
break;
}
}
toReturn[i] = translations[i];
} else if (objType == 'object' && objType !== null) {
var flatObject = flattenTranslations(translations[i]);

@@ -316,2 +331,7 @@

// check if the given object is an array
function isArray(obj) {
return !!obj && Array === obj.constructor;
}
/* vuex-i18n defines the Vuexi18nPlugin to enable localization using a vuex

@@ -431,7 +451,15 @@ ** module to store the translation information. Make sure to also include the

// render the given translation with placeholder replaced
var render = function render(translation) {
var replacements = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
// replace will replace the given replacements in the translation string
var replace = function replace(translation, replacements) {
var warn = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
// check if the object has a replace property
if (!translation.replace) {
console.log('no replace', translation);
return translation;
}
console.log('replace', translation, replacements);
return translation.replace(/\{\w+\}/g, function (placeholder) {

@@ -446,6 +474,8 @@

// warn user that the placeholder has not been found
console.group('Not all placeholder founds');
console.warn('Text:', translation);
console.warn('Placeholder:', placeholder);
console.groupEnd();
if (warn === true) {
console.group('Not all placeholder founds');
console.warn('Text:', translation);
console.warn('Placeholder:', placeholder);
console.groupEnd();
}

@@ -457,2 +487,29 @@ // return the original placeholder

// render will return the given translation object
var render = function render(translation) {
var replacements = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
// get the type of the property
var objType = typeof translation === 'undefined' ? 'undefined' : _typeof(translation);
if (isArray$1(translation)) {
// replace the placeholder elements in all sub-items
return translation.map(function (item) {
return replace(item, replacements, false);
});
} else if (objType === 'string') {
return replace(translation, replacements);
}
// return translation item directly
return translation;
};
// check if the given object is an array
function isArray$1(obj) {
return !!obj && Array === obj.constructor;
}
// import the vuex module for localization

@@ -459,0 +516,0 @@ // import the corresponding plugin for vue

@@ -1,3 +0,6 @@

var vuexI18n = (function () {
'use strict';
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
typeof define === 'function' && define.amd ? define(factory) :
(global.vuexI18n = factory());
}(this, (function () { 'use strict';

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

if (objType == 'object' && objType !== null) {
// allow unflattened array of strings
if (isArray(translations[i])) {
var count = translations[i].length;
for (var index = 0; index < count; index++) {
var itemType = _typeof(translations[i][index]);
if (itemType !== 'string') {
console.warn('vuex-i18n:', 'currently only arrays of strings are fully supported', translations[i]);
break;
}
}
toReturn[i] = translations[i];
} else if (objType == 'object' && objType !== null) {
var flatObject = flattenTranslations(translations[i]);

@@ -319,2 +337,7 @@

// check if the given object is an array
function isArray(obj) {
return !!obj && Array === obj.constructor;
}
/* vuex-i18n defines the Vuexi18nPlugin to enable localization using a vuex

@@ -434,7 +457,15 @@ ** module to store the translation information. Make sure to also include the

// render the given translation with placeholder replaced
var render = function render(translation) {
var replacements = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
// replace will replace the given replacements in the translation string
var replace = function replace(translation, replacements) {
var warn = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
// check if the object has a replace property
if (!translation.replace) {
console.log('no replace', translation);
return translation;
}
console.log('replace', translation, replacements);
return translation.replace(/\{\w+\}/g, function (placeholder) {

@@ -449,6 +480,8 @@

// warn user that the placeholder has not been found
console.group('Not all placeholder founds');
console.warn('Text:', translation);
console.warn('Placeholder:', placeholder);
console.groupEnd();
if (warn === true) {
console.group('Not all placeholder founds');
console.warn('Text:', translation);
console.warn('Placeholder:', placeholder);
console.groupEnd();
}

@@ -460,2 +493,29 @@ // return the original placeholder

// render will return the given translation object
var render = function render(translation) {
var replacements = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
// get the type of the property
var objType = typeof translation === 'undefined' ? 'undefined' : _typeof(translation);
if (isArray$1(translation)) {
// replace the placeholder elements in all sub-items
return translation.map(function (item) {
return replace(item, replacements, false);
});
} else if (objType === 'string') {
return replace(translation, replacements);
}
// return translation item directly
return translation;
};
// check if the given object is an array
function isArray$1(obj) {
return !!obj && Array === obj.constructor;
}
// import the vuex module for localization

@@ -471,2 +531,2 @@ // import the corresponding plugin for vue

}());
})));

4

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

@@ -8,3 +8,3 @@ "directories": {

},
"main": "dist/vuex-i18n.es.js",
"main": "dist/vuex-i18n.min.js",
"files": [

@@ -11,0 +11,0 @@ "dist",

@@ -6,3 +6,7 @@ {

"footer": "Hier steht eine Fusszeile"
}
},
"listing": [
"Dies ist der Block {first}",
"Dies ist der Block {second}"
]
}

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