Socket
Socket
Sign inDemoInstall

vue-i18n

Package Overview
Dependencies
Maintainers
1
Versions
353
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

vue-i18n - npm Package Compare versions

Comparing version 6.0.0-alpha.1 to 6.0.0-alpha.2

decls/i18n.js

11

CHANGELOG.md

@@ -0,1 +1,12 @@

<a name="6.0.0-alpha.2"></a>
# [6.0.0-alpha.2](https://github.com/kazupon/vue-i18n/compare/v6.0.0-alpha.1...v6.0.0-alpha.2) (2017-02-27)
### :zap: Improvements
* **mixin:** release i18n instance ([cc362a3](https://github.com/kazupon/vue-i18n/commit/cc362a3))
* **vue:** support vue 2.2 ([5e7bf5e](https://github.com/kazupon/vue-i18n/commit/5e7bf5e))
<a name="6.0.0-alpha.1"></a>

@@ -2,0 +13,0 @@ # [6.0.0-alpha.1](https://github.com/kazupon/vue-i18n/compare/v5.0.2...v6.0.0-alpha.1) (2017-02-23)

255

dist/vue-i18n.common.js
/*!
* vue-i18n v6.0.0-alpha.1
* vue-i18n v6.0.0-alpha.2
* (c) 2017 kazuya kawaguchi

@@ -10,2 +10,6 @@ * Released under the MIT License.

/**
* utilites
*/
function warn (msg, err) {

@@ -20,2 +24,72 @@ if (typeof console !== 'undefined') {

var hasOwnProperty = Object.prototype.hasOwnProperty;
function hasOwn (obj, key) {
return hasOwnProperty.call(obj, key)
}
function isObject (obj) {
return obj !== null && typeof obj === 'object'
}
var toString = Object.prototype.toString;
var OBJECT_STRING = '[object Object]';
function isPlainObject (obj) {
return toString.call(obj) === OBJECT_STRING
}
function isNull (val) {
return val === null || val === undefined
}
function parseArgs () {
var args = [], len = arguments.length;
while ( len-- ) args[ len ] = arguments[ len ];
var locale = null;
var params = null;
if (args.length === 1) {
if (isObject(args[0]) || Array.isArray(args[0])) {
params = args[0];
} else if (typeof args[0] === 'string') {
locale = args[0];
}
} else if (args.length === 2) {
if (typeof args[0] === 'string') {
locale = args[0];
}
if (isObject(args[1]) || Array.isArray(args[1])) {
params = args[1];
}
}
return { locale: locale, params: params }
}
function getOldChoiceIndexFixed (choice) {
return choice
? choice > 1
? 1
: 0
: 1
}
function getChoiceIndex (choice, choicesLength) {
choice = Math.abs(choice);
if (choicesLength === 2) { return getOldChoiceIndexFixed(choice) }
return choice ? Math.min(choice, 2) : 0
}
function fetchChoice (message, choice) {
if (!message && typeof message !== 'string') { return null }
var choices = message.split('|');
choice = getChoiceIndex(choice, choices.length);
if (!choices[choice]) { return message }
return choices[choice].trim()
}
/* */

@@ -87,2 +161,6 @@

}
},
beforeDestroy: function beforeDestroy () {
this.$i18n = null;
}

@@ -95,2 +173,3 @@ };

strats.i18n = function (parent, child) {
var ret = Object.create(null);
if (!child) { return parent }

@@ -100,6 +179,5 @@ if (!parent) { return child }

// TODO: should be warn
return {}
return ret
}
var ret = Object.create(null);
Vue.extend(ret, parent);
Vue.util.extend(ret, parent);
for (var key in child) {

@@ -137,60 +215,2 @@ ret[key] = child[key];

/**
* utilites
*/
function isNil (val) {
return val === null || val === undefined
}
function parseArgs () {
var args = [], len = arguments.length;
while ( len-- ) args[ len ] = arguments[ len ];
var locale = null;
if (args.length === 1) {
if (Vue.util.isObject(args[0]) || Array.isArray(args[0])) {
args = args[0];
} else if (typeof args[0] === 'string') {
locale = args[0];
}
} else if (args.length === 2) {
if (typeof args[0] === 'string') {
locale = args[0];
}
if (Vue.util.isObject(args[1]) || Array.isArray(args[1])) {
args = args[1];
}
}
return { locale: locale, params: args }
}
function getOldChoiceIndexFixed (choice) {
return choice
? choice > 1
? 1
: 0
: 1
}
function getChoiceIndex (choice, choicesLength) {
choice = Math.abs(choice);
if (choicesLength === 2) { return getOldChoiceIndexFixed(choice) }
return choice ? Math.min(choice, 2) : 0
}
function fetchChoice (message, choice) {
if (!message && typeof message !== 'string') { return null }
var choices = message.split('|');
choice = getChoiceIndex(choice, choices.length);
if (!choices[choice]) { return message }
return choices[choice].trim()
}
/* */
var BaseFormatter = function BaseFormatter (options) {

@@ -205,3 +225,2 @@ if ( options === void 0 ) options = {};

prototypeAccessors$1.options.get = function () { return this._options };
prototypeAccessors$1.options.set = function (options) { this._options = options; };

@@ -254,4 +273,4 @@ BaseFormatter.prototype.format = function format (message) {

} else {
result = Vue.util.hasOwn(args, i) ? args[i] : match;
if (isNil(result)) {
result = hasOwn(args, i) ? args[i] : match;
if (isNull(result)) {
return ''

@@ -545,58 +564,48 @@ }

var Path = function (Vue) {
var ref = Vue.util;
var isObject = ref.isObject;
var isPlainObject = ref.isPlainObject;
var hasOwn = ref.hasOwn;
function empty (target) {
if (target === null || target === undefined) { return true }
function empty (target) {
if (target === null || target === undefined) { return true }
if (Array.isArray(target)) {
if (target.length > 0) { return false }
if (target.length === 0) { return true }
} else if (isPlainObject(target)) {
/* eslint-disable prefer-const */
for (var key in target) {
if (hasOwn(target, key)) { return false }
}
/* eslint-enable prefer-const */
if (Array.isArray(target)) {
if (target.length > 0) { return false }
if (target.length === 0) { return true }
} else if (isPlainObject(target)) {
/* eslint-disable prefer-const */
for (var key in target) {
if (hasOwn(target, key)) { return false }
}
return true
/* eslint-enable prefer-const */
}
/**
* Get path value from path string
*/
return true
}
function getPathValue (obj, path) {
if (!isObject(obj)) { return null }
/**
* Get path value from path string
*/
function getPathValue (obj, path) {
if (!isObject(obj)) { return null }
var paths = parsePath(path);
if (empty(paths)) {
return null
} else {
var length = paths.length;
var ret = null;
var last = obj;
var i = 0;
while (i < length) {
var value = last[paths[i]];
if (value === undefined) {
last = null;
break
}
last = value;
i++;
var paths = parsePath(path);
if (empty(paths)) {
return null
} else {
var length = paths.length;
var ret = null;
var last = obj;
var i = 0;
while (i < length) {
var value = last[paths[i]];
if (value === undefined) {
last = null;
break
}
last = value;
i++;
}
ret = last;
return ret
}
ret = last;
return ret
}
}
return getPathValue
};
/* */

@@ -616,7 +625,5 @@

var getPathValue = Path(Vue);
this._getPathValue = getPathValue;
this._exist = function (message, key) {
if (!message || !key) { return false }
return !isNil(getPathValue(message, key))
return !isNull(getPathValue(message, key))
};

@@ -652,3 +659,3 @@

VueI18n.prototype._warnDefault = function _warnDefault (locale, key, result, vm) {
if (!isNil(result)) { return result }
if (!isNull(result)) { return result }
if (this.missing) {

@@ -668,3 +675,3 @@ this.missing.apply(null, [locale, key, vm]);

VueI18n.prototype._isFallbackRoot = function _isFallbackRoot (val) {
return !val && !isNil(this._root) && this._fallbackRoot
return !val && !isNull(this._root) && this._fallbackRoot
};

@@ -677,6 +684,6 @@

var val = this._getPathValue(message, key);
var val = getPathValue(message, key);
if (Array.isArray(val)) { return val }
if (isNil(val)) { val = message[key]; }
if (isNil(val)) { return null }
if (isNull(val)) { val = message[key]; }
if (isNull(val)) { return null }
if (typeof val !== 'string') {

@@ -718,6 +725,6 @@ warn(("Value of key '" + key + "' is not a string!"));

res = this._interpolate(messages[locale], key, args);
if (!isNil(res)) { return res }
if (!isNull(res)) { return res }
res = this._interpolate(messages[fallback], key, args);
if (!isNil(res)) {
if (!isNull(res)) {
if (process.env.NODE_ENV !== 'production') {

@@ -743,3 +750,3 @@ warn(("Fall back to translate the keypath '" + key + "' with '" + fallback + "' locale."));

if (this._isFallbackRoot(ret)) {
if (process.env.NODE_ENV !== 'production') {
if (process.env.NODE_ENV !== 'production') {
warn(("Fall back to translate the keypath '" + key + "' with root locale."));

@@ -797,5 +804,5 @@ }

return (ref = this)._te.apply(ref, [ key, this.locale, this.messages ].concat( args ))
return (ref = this)._te.apply(ref, [ key, this.locale, this.messages ].concat( args ))
var ref;
};
};

@@ -802,0 +809,0 @@ Object.defineProperties( VueI18n.prototype, prototypeAccessors );

/*!
* vue-i18n v6.0.0-alpha.1
* vue-i18n v6.0.0-alpha.2
* (c) 2017 kazuya kawaguchi

@@ -14,2 +14,6 @@ * Released under the MIT License.

/**
* utilites
*/
function warn (msg, err) {

@@ -24,2 +28,72 @@ if (typeof console !== 'undefined') {

var hasOwnProperty = Object.prototype.hasOwnProperty;
function hasOwn (obj, key) {
return hasOwnProperty.call(obj, key)
}
function isObject (obj) {
return obj !== null && typeof obj === 'object'
}
var toString = Object.prototype.toString;
var OBJECT_STRING = '[object Object]';
function isPlainObject (obj) {
return toString.call(obj) === OBJECT_STRING
}
function isNull (val) {
return val === null || val === undefined
}
function parseArgs () {
var args = [], len = arguments.length;
while ( len-- ) args[ len ] = arguments[ len ];
var locale = null;
var params = null;
if (args.length === 1) {
if (isObject(args[0]) || Array.isArray(args[0])) {
params = args[0];
} else if (typeof args[0] === 'string') {
locale = args[0];
}
} else if (args.length === 2) {
if (typeof args[0] === 'string') {
locale = args[0];
}
if (isObject(args[1]) || Array.isArray(args[1])) {
params = args[1];
}
}
return { locale: locale, params: params }
}
function getOldChoiceIndexFixed (choice) {
return choice
? choice > 1
? 1
: 0
: 1
}
function getChoiceIndex (choice, choicesLength) {
choice = Math.abs(choice);
if (choicesLength === 2) { return getOldChoiceIndexFixed(choice) }
return choice ? Math.min(choice, 2) : 0
}
function fetchChoice (message, choice) {
if (!message && typeof message !== 'string') { return null }
var choices = message.split('|');
choice = getChoiceIndex(choice, choices.length);
if (!choices[choice]) { return message }
return choices[choice].trim()
}
/* */

@@ -91,2 +165,6 @@

}
},
beforeDestroy: function beforeDestroy () {
this.$i18n = null;
}

@@ -99,2 +177,3 @@ };

strats.i18n = function (parent, child) {
var ret = Object.create(null);
if (!child) { return parent }

@@ -104,6 +183,5 @@ if (!parent) { return child }

// TODO: should be warn
return {}
return ret
}
var ret = Object.create(null);
Vue.extend(ret, parent);
Vue.util.extend(ret, parent);
for (var key in child) {

@@ -141,60 +219,2 @@ ret[key] = child[key];

/**
* utilites
*/
function isNil (val) {
return val === null || val === undefined
}
function parseArgs () {
var args = [], len = arguments.length;
while ( len-- ) args[ len ] = arguments[ len ];
var locale = null;
if (args.length === 1) {
if (Vue.util.isObject(args[0]) || Array.isArray(args[0])) {
args = args[0];
} else if (typeof args[0] === 'string') {
locale = args[0];
}
} else if (args.length === 2) {
if (typeof args[0] === 'string') {
locale = args[0];
}
if (Vue.util.isObject(args[1]) || Array.isArray(args[1])) {
args = args[1];
}
}
return { locale: locale, params: args }
}
function getOldChoiceIndexFixed (choice) {
return choice
? choice > 1
? 1
: 0
: 1
}
function getChoiceIndex (choice, choicesLength) {
choice = Math.abs(choice);
if (choicesLength === 2) { return getOldChoiceIndexFixed(choice) }
return choice ? Math.min(choice, 2) : 0
}
function fetchChoice (message, choice) {
if (!message && typeof message !== 'string') { return null }
var choices = message.split('|');
choice = getChoiceIndex(choice, choices.length);
if (!choices[choice]) { return message }
return choices[choice].trim()
}
/* */
var BaseFormatter = function BaseFormatter (options) {

@@ -209,3 +229,2 @@ if ( options === void 0 ) options = {};

prototypeAccessors$1.options.get = function () { return this._options };
prototypeAccessors$1.options.set = function (options) { this._options = options; };

@@ -258,4 +277,4 @@ BaseFormatter.prototype.format = function format (message) {

} else {
result = Vue.util.hasOwn(args, i) ? args[i] : match;
if (isNil(result)) {
result = hasOwn(args, i) ? args[i] : match;
if (isNull(result)) {
return ''

@@ -549,58 +568,48 @@ }

var Path = function (Vue) {
var ref = Vue.util;
var isObject = ref.isObject;
var isPlainObject = ref.isPlainObject;
var hasOwn = ref.hasOwn;
function empty (target) {
if (target === null || target === undefined) { return true }
function empty (target) {
if (target === null || target === undefined) { return true }
if (Array.isArray(target)) {
if (target.length > 0) { return false }
if (target.length === 0) { return true }
} else if (isPlainObject(target)) {
/* eslint-disable prefer-const */
for (var key in target) {
if (hasOwn(target, key)) { return false }
}
/* eslint-enable prefer-const */
if (Array.isArray(target)) {
if (target.length > 0) { return false }
if (target.length === 0) { return true }
} else if (isPlainObject(target)) {
/* eslint-disable prefer-const */
for (var key in target) {
if (hasOwn(target, key)) { return false }
}
return true
/* eslint-enable prefer-const */
}
/**
* Get path value from path string
*/
return true
}
function getPathValue (obj, path) {
if (!isObject(obj)) { return null }
/**
* Get path value from path string
*/
function getPathValue (obj, path) {
if (!isObject(obj)) { return null }
var paths = parsePath(path);
if (empty(paths)) {
return null
} else {
var length = paths.length;
var ret = null;
var last = obj;
var i = 0;
while (i < length) {
var value = last[paths[i]];
if (value === undefined) {
last = null;
break
}
last = value;
i++;
var paths = parsePath(path);
if (empty(paths)) {
return null
} else {
var length = paths.length;
var ret = null;
var last = obj;
var i = 0;
while (i < length) {
var value = last[paths[i]];
if (value === undefined) {
last = null;
break
}
last = value;
i++;
}
ret = last;
return ret
}
ret = last;
return ret
}
}
return getPathValue
};
/* */

@@ -620,7 +629,5 @@

var getPathValue = Path(Vue);
this._getPathValue = getPathValue;
this._exist = function (message, key) {
if (!message || !key) { return false }
return !isNil(getPathValue(message, key))
return !isNull(getPathValue(message, key))
};

@@ -656,3 +663,3 @@

VueI18n.prototype._warnDefault = function _warnDefault (locale, key, result, vm) {
if (!isNil(result)) { return result }
if (!isNull(result)) { return result }
if (this.missing) {

@@ -672,3 +679,3 @@ this.missing.apply(null, [locale, key, vm]);

VueI18n.prototype._isFallbackRoot = function _isFallbackRoot (val) {
return !val && !isNil(this._root) && this._fallbackRoot
return !val && !isNull(this._root) && this._fallbackRoot
};

@@ -681,6 +688,6 @@

var val = this._getPathValue(message, key);
var val = getPathValue(message, key);
if (Array.isArray(val)) { return val }
if (isNil(val)) { val = message[key]; }
if (isNil(val)) { return null }
if (isNull(val)) { val = message[key]; }
if (isNull(val)) { return null }
if (typeof val !== 'string') {

@@ -722,6 +729,6 @@ warn(("Value of key '" + key + "' is not a string!"));

res = this._interpolate(messages[locale], key, args);
if (!isNil(res)) { return res }
if (!isNull(res)) { return res }
res = this._interpolate(messages[fallback], key, args);
if (!isNil(res)) {
if (!isNull(res)) {
{

@@ -747,3 +754,3 @@ warn(("Fall back to translate the keypath '" + key + "' with '" + fallback + "' locale."));

if (this._isFallbackRoot(ret)) {
{
{
warn(("Fall back to translate the keypath '" + key + "' with root locale."));

@@ -801,5 +808,5 @@ }

return (ref = this)._te.apply(ref, [ key, this.locale, this.messages ].concat( args ))
return (ref = this)._te.apply(ref, [ key, this.locale, this.messages ].concat( args ))
var ref;
};
};

@@ -809,3 +816,3 @@ Object.defineProperties( VueI18n.prototype, prototypeAccessors );

VueI18n.install = install;
VueI18n.version = '6.0.0-alpha.1';
VueI18n.version = '6.0.0-alpha.2';

@@ -812,0 +819,0 @@ if (typeof window !== 'undefined' && window.Vue) {

/*!
* vue-i18n v6.0.0-alpha.1
* vue-i18n v6.0.0-alpha.2
* (c) 2017 kazuya kawaguchi
* Released under the MIT License.
*/
!function(t,n){"object"==typeof exports&&"undefined"!=typeof module?module.exports=n():"function"==typeof define&&define.amd?define(n):t.VueI18n=n()}(this,function(){"use strict";function t(t,n){"undefined"!=typeof console&&(console.warn("[vue-i18n] "+t),n&&console.warn(n.stack))}function n(t){v=t;v.version&&Number(v.version.split(".")[0])||-1;n.installed=!0,v.mixin(g),m(v)}function e(t){return null===t||void 0===t}function r(){for(var t=[],n=arguments.length;n--;)t[n]=arguments[n];var e=null;return 1===t.length?v.util.isObject(t[0])||Array.isArray(t[0])?t=t[0]:"string"==typeof t[0]&&(e=t[0]):2===t.length&&("string"==typeof t[0]&&(e=t[0]),(v.util.isObject(t[1])||Array.isArray(t[1]))&&(t=t[1])),{locale:e,params:t}}function i(t){return t?t>1?1:0:1}function o(t,n){return t=Math.abs(t),2===n?i(t):t?Math.min(t,2):0}function a(t,n){if(!t&&"string"!=typeof t)return null;var e=t.split("|");return n=o(n,e.length),e[n]?e[n].trim():t}function s(t){for(var n=[],r=arguments.length-1;r-- >0;)n[r]=arguments[r+1];return n=1===n.length&&"object"==typeof n[0]?n[0]:{},n&&n.hasOwnProperty||(n={}),t.replace(d,function(r,i,o,a){var s;return"{"===t[a-1]&&"}"===t[a+r.length]?o:(s=v.util.hasOwn(n,o)?n[o]:r,e(s)?"":s)})}function l(t){return S.test(t)}function u(t){var n=t.charCodeAt(0),e=t.charCodeAt(t.length-1);return n!==e||34!==n&&39!==n?t:t.slice(1,-1)}function c(t){if(void 0===t||null===t)return"eof";var n=t.charCodeAt(0);switch(n){case 91:case 93:case 46:case 34:case 39:case 48:return t;case 95:case 36:case 45:return"ident";case 32:case 9:case 10:case 13:case 160:case 65279:case 8232:case 8233:return"ws"}return n>=97&&n<=122||n>=65&&n<=90?"ident":n>=49&&n<=57?"number":"else"}function f(t){var n=t.trim();return("0"!==t.charAt(0)||!isNaN(t))&&(l(n)?u(n):"*"+n)}function h(t){function n(){var n=t[h+1];if(p===P&&"'"===n||p===M&&'"'===n)return h++,i="\\"+n,g[b](),!0}var e,r,i,o,a,s,l,u=[],h=-1,p=O,v=0,g=[];for(g[w]=function(){void 0!==r&&(u.push(r),r=void 0)},g[b]=function(){void 0===r?r=i:r+=i},g[k]=function(){g[b](),v++},g[A]=function(){if(v>0)v--,p=V,g[b]();else{if(v=0,r=f(r),r===!1)return!1;g[w]()}};null!==p;)if(h++,e=t[h],"\\"!==e||!n()){if(o=c(e),l=N[p],a=l[o]||l.else||C,a===C)return;if(p=a[0],s=g[a[1]],s&&(i=a[2],i=void 0===i?e:i,s()===!1))return;if(p===R)return u}}function p(t){var n=$[t];return n||(n=h(t),n&&($[t]=n)),n||[]}var v,g={computed:{$t:function(){var t=this,n=this.$i18n.locale,e=this.$i18n.messages;return function(r){for(var i=[],o=arguments.length-1;o-- >0;)i[o]=arguments[o+1];return(a=t.$i18n)._t.apply(a,[r,n,e,t].concat(i));var a}},$tc:function(){var t=this,n=this.$i18n.locale,e=this.$i18n.messages;return function(r,i){for(var o=[],a=arguments.length-2;a-- >0;)o[a]=arguments[a+2];return(s=t.$i18n)._tc.apply(s,[r,n,e,t,i].concat(o));var s}},$te:function(){var t=this,n=this.$i18n.locale,e=this.$i18n.messages;return function(r){for(var i=[],o=arguments.length-1;o-- >0;)i[o]=arguments[o+1];return(a=t.$i18n)._te.apply(a,[r,n,e].concat(i));var a}}},beforeCreate:function(){var t=this.$options;t.i18n?t.i18n instanceof F?this.$i18n=t.i18n:(this.$root&&this.$root.$i18n&&this.$root.$i18n instanceof F&&(t.i18n.root=this.$root.$i18n),this.$i18n=new F(t.i18n)):this.$root&&this.$root.$i18n&&this.$root.$i18n instanceof F&&(this.$i18n=this.$root.$i18n)}},m=function(t){var n=t.config.optionMergeStrategies;n&&(n.i18n=function(n,e){if(!e)return n;if(!n)return e;if(!e&!n)return{};var r=Object.create(null);t.extend(r,n);for(var i in e)r[i]=e[i];return r})},_=function(t){void 0===t&&(t={}),this._options=t},y={options:{}};y.options.get=function(){return this._options},y.options.set=function(t){this._options=t},_.prototype.format=function(t){for(var n=[],e=arguments.length-1;e-- >0;)n[e]=arguments[e+1];return s.apply(void 0,[t].concat(n))},Object.defineProperties(_.prototype,y);var d=/(%|)\{([0-9a-zA-Z_]+)\}/g,$=Object.create(null),b=0,w=1,k=2,A=3,O=0,j=1,x=2,L=3,V=4,P=5,M=6,R=7,C=8,N=[];N[O]={ws:[O],ident:[L,b],"[":[V],eof:[R]},N[j]={ws:[j],".":[x],"[":[V],eof:[R]},N[x]={ws:[x],ident:[L,b],0:[L,b],number:[L,b]},N[L]={ident:[L,b],0:[L,b],number:[L,b],ws:[j,w],".":[x,w],"[":[V,w],eof:[R,w]},N[V]={"'":[P,b],'"':[M,b],"[":[V,k],"]":[j,A],eof:C,else:[V,b]},N[P]={"'":[V,b],eof:C,else:[P,b]},N[M]={'"':[V,b],eof:C,else:[M,b]};var S=/^\s?(true|false|-?[\d.]+|'[^']*'|"[^"]*")\s?$/,D=function(t){function n(t){if(null===t||void 0===t)return!0;if(Array.isArray(t)){if(t.length>0)return!1;if(0===t.length)return!0}else if(o(t))for(var n in t)if(a(t,n))return!1;return!0}function e(t,e){if(!i(t))return null;var r=p(e);if(n(r))return null;for(var o=r.length,a=null,s=t,l=0;l<o;){var u=s[r[l]];if(void 0===u){s=null;break}s=u,l++}return a=s}var r=t.util,i=r.isObject,o=r.isPlainObject,a=r.hasOwn;return e},F=function(t){void 0===t&&(t={});var n=t.locale||"en-US",r=t.messages||{};this._vm=null,this._fallbackLocale=t.fallbackLocale||"en-US",this._formatter=t.formatter||new _,this._missing=t.missing,this._root=t.root||null,this._fallbackRoot=t.fallbackRoot||!1;var i=D(v);this._getPathValue=i,this._exist=function(t,n){return!(!t||!n)&&!e(i(t,n))},this._resetVM({locale:n,messages:r})},U={messages:{},locale:{},fallbackLocale:{},missing:{},formatter:{}};return F.prototype._resetVM=function(t){var n=v.config.silent;v.config.silent=!0,this._vm=new v({data:t}),v.config.silent=n},U.messages.get=function(){return this._vm.$data.messages},U.messages.set=function(t){this._vm.$set(this._vm,"messages",t)},U.locale.get=function(){return this._vm.$data.locale},U.locale.set=function(t){this._vm.$set(this._vm,"locale",t)},U.fallbackLocale.get=function(){return this._fallbackLocale},U.fallbackLocale.set=function(t){this._fallbackLocale=t},U.missing.get=function(){return this._missing},U.missing.set=function(t){this._missing=t},U.formatter.get=function(){return this._formatter},U.formatter.set=function(t){this._formatter=t},F.prototype._warnDefault=function(t,n,r,i){return e(r)?(this.missing&&this.missing.apply(null,[t,n,i]),n):r},F.prototype._isFallbackRoot=function(t){return!t&&!e(this._root)&&this._fallbackRoot},F.prototype._interpolate=function(n,r,i){var o=this;if(!n)return null;var a=this._getPathValue(n,r);if(Array.isArray(a))return a;if(e(a)&&(a=n[r]),e(a))return null;if("string"!=typeof a)return t("Value of key '"+r+"' is not a string!"),null;if(a.indexOf("@:")>=0){var s=a.match(/(@:[\w|.]+)/g);for(var l in s){var u=s[l],c=u.substr(2),f=o._interpolate(n,c,i);a=a.replace(u,f)}}return i?this._format(a,i):a},F.prototype._format=function(t){for(var n=[],e=arguments.length-1;e-- >0;)n[e]=arguments[e+1];return(r=this._formatter).format.apply(r,[t].concat(n));var r},F.prototype._translate=function(t,n,r,i,o){var a=null;return a=this._interpolate(t[n],i,o),e(a)?(a=this._interpolate(t[r],i,o),e(a)?null:a):a},F.prototype._t=function(t,n,e,i){for(var o=[],a=arguments.length-4;a-- >0;)o[a]=arguments[a+4];if(!t)return"";var s=r.apply(void 0,o),l=s.locale||n,u=this._translate(e,l,this.fallbackLocale,t,s.params);if(this._isFallbackRoot(u)){if(!this._root)throw Error("unexpected error");return(c=this._root).t.apply(c,[t].concat(o))}return this._warnDefault(l,t,u,i);var c},F.prototype.t=function(t){for(var n=[],e=arguments.length-1;e-- >0;)n[e]=arguments[e+1];return(r=this)._t.apply(r,[t,this.locale,this.messages,null].concat(n));var r},F.prototype._tc=function(t,n,e,r,i){for(var o=[],s=arguments.length-5;s-- >0;)o[s]=arguments[s+5];return t?void 0!==i?a((l=this)._t.apply(l,[t,n,e,r].concat(o)),i):(u=this)._t.apply(u,[t,n,e,r].concat(o)):"";var l,u},F.prototype.tc=function(t,n){for(var e=[],r=arguments.length-2;r-- >0;)e[r]=arguments[r+2];return(i=this)._tc.apply(i,[t,this.locale,this.messages,null,n].concat(e));var i},F.prototype._te=function(t,n,e){for(var i=[],o=arguments.length-3;o-- >0;)i[o]=arguments[o+3];var a=r.apply(void 0,i).locale||n;return this._exist(e[a],t)},F.prototype.te=function(t){for(var n=[],e=arguments.length-1;e-- >0;)n[e]=arguments[e+1];return(r=this)._te.apply(r,[t,this.locale,this.messages].concat(n));var r},Object.defineProperties(F.prototype,U),F.install=n,F.version="6.0.0-alpha.1","undefined"!=typeof window&&window.Vue&&window.Vue.use(F),F});
!function(t,n){"object"==typeof exports&&"undefined"!=typeof module?module.exports=n():"function"==typeof define&&define.amd?define(n):t.VueI18n=n()}(this,function(){"use strict";function t(t,n){"undefined"!=typeof console&&(console.warn("[vue-i18n] "+t),n&&console.warn(n.stack))}function n(t,n){return $.call(t,n)}function e(t){return null!==t&&"object"==typeof t}function r(t){return b.call(t)===w}function i(t){return null===t||void 0===t}function o(){for(var t=[],n=arguments.length;n--;)t[n]=arguments[n];var r=null,i=null;return 1===t.length?e(t[0])||Array.isArray(t[0])?i=t[0]:"string"==typeof t[0]&&(r=t[0]):2===t.length&&("string"==typeof t[0]&&(r=t[0]),(e(t[1])||Array.isArray(t[1]))&&(i=t[1])),{locale:r,params:i}}function a(t){return t?t>1?1:0:1}function s(t,n){return t=Math.abs(t),2===n?a(t):t?Math.min(t,2):0}function l(t,n){if(!t&&"string"!=typeof t)return null;var e=t.split("|");return n=s(n,e.length),e[n]?e[n].trim():t}function c(t){d=t;d.version&&Number(d.version.split(".")[0])||-1;c.installed=!0,d.mixin(k),A(d)}function u(t){for(var e=[],r=arguments.length-1;r-- >0;)e[r]=arguments[r+1];return e=1===e.length&&"object"==typeof e[0]?e[0]:{},e&&e.hasOwnProperty||(e={}),t.replace(x,function(r,o,a,s){var l;return"{"===t[s-1]&&"}"===t[s+r.length]?a:(l=n(e,a)?e[a]:r,i(l)?"":l)})}function f(t){return q.test(t)}function h(t){var n=t.charCodeAt(0),e=t.charCodeAt(t.length-1);return n!==e||34!==n&&39!==n?t:t.slice(1,-1)}function p(t){if(void 0===t||null===t)return"eof";var n=t.charCodeAt(0);switch(n){case 91:case 93:case 46:case 34:case 39:case 48:return t;case 95:case 36:case 45:return"ident";case 32:case 9:case 10:case 13:case 160:case 65279:case 8232:case 8233:return"ws"}return n>=97&&n<=122||n>=65&&n<=90?"ident":n>=49&&n<=57?"number":"else"}function v(t){var n=t.trim();return("0"!==t.charAt(0)||!isNaN(t))&&(f(n)?h(n):"*"+n)}function g(t){function n(){var n=t[u+1];if(f===U&&"'"===n||f===z&&'"'===n)return u++,i="\\"+n,g[V](),!0}var e,r,i,o,a,s,l,c=[],u=-1,f=P,h=0,g=[];for(g[M]=function(){void 0!==r&&(c.push(r),r=void 0)},g[V]=function(){void 0===r?r=i:r+=i},g[R]=function(){g[V](),h++},g[C]=function(){if(h>0)h--,f=F,g[V]();else{if(h=0,r=v(r),r===!1)return!1;g[M]()}};null!==f;)if(u++,e=t[u],"\\"!==e||!n()){if(o=p(e),l=Z[f],a=l[o]||l.else||I,a===I)return;if(f=a[0],s=g[a[1]],s&&(i=a[2],i=void 0===i?e:i,s()===!1))return;if(f===E)return c}}function m(t){var n=L[t];return n||(n=g(t),n&&(L[t]=n)),n||[]}function y(t){if(null===t||void 0===t)return!0;if(Array.isArray(t)){if(t.length>0)return!1;if(0===t.length)return!0}else if(r(t))for(var e in t)if(n(t,e))return!1;return!0}function _(t,n){if(!e(t))return null;var r=m(n);if(y(r))return null;for(var i=r.length,o=null,a=t,s=0;s<i;){var l=a[r[s]];if(void 0===l){a=null;break}a=l,s++}return o=a}var d,$=Object.prototype.hasOwnProperty,b=Object.prototype.toString,w="[object Object]",k={computed:{$t:function(){var t=this,n=this.$i18n.locale,e=this.$i18n.messages;return function(r){for(var i=[],o=arguments.length-1;o-- >0;)i[o]=arguments[o+1];return(a=t.$i18n)._t.apply(a,[r,n,e,t].concat(i));var a}},$tc:function(){var t=this,n=this.$i18n.locale,e=this.$i18n.messages;return function(r,i){for(var o=[],a=arguments.length-2;a-- >0;)o[a]=arguments[a+2];return(s=t.$i18n)._tc.apply(s,[r,n,e,t,i].concat(o));var s}},$te:function(){var t=this,n=this.$i18n.locale,e=this.$i18n.messages;return function(r){for(var i=[],o=arguments.length-1;o-- >0;)i[o]=arguments[o+1];return(a=t.$i18n)._te.apply(a,[r,n,e].concat(i));var a}}},beforeCreate:function(){var t=this.$options;t.i18n?t.i18n instanceof B?this.$i18n=t.i18n:(this.$root&&this.$root.$i18n&&this.$root.$i18n instanceof B&&(t.i18n.root=this.$root.$i18n),this.$i18n=new B(t.i18n)):this.$root&&this.$root.$i18n&&this.$root.$i18n instanceof B&&(this.$i18n=this.$root.$i18n)},beforeDestroy:function(){this.$i18n=null}},A=function(t){var n=t.config.optionMergeStrategies;n&&(n.i18n=function(n,e){var r=Object.create(null);if(!e)return n;if(!n)return e;if(!e&!n)return r;t.util.extend(r,n);for(var i in e)r[i]=e[i];return r})},j=function(t){void 0===t&&(t={}),this._options=t},O={options:{}};O.options.get=function(){return this._options},j.prototype.format=function(t){for(var n=[],e=arguments.length-1;e-- >0;)n[e]=arguments[e+1];return u.apply(void 0,[t].concat(n))},Object.defineProperties(j.prototype,O);var x=/(%|)\{([0-9a-zA-Z_]+)\}/g,L=Object.create(null),V=0,M=1,R=2,C=3,P=0,S=1,D=2,N=3,F=4,U=5,z=6,E=7,I=8,Z=[];Z[P]={ws:[P],ident:[N,V],"[":[F],eof:[E]},Z[S]={ws:[S],".":[D],"[":[F],eof:[E]},Z[D]={ws:[D],ident:[N,V],0:[N,V],number:[N,V]},Z[N]={ident:[N,V],0:[N,V],number:[N,V],ws:[S,M],".":[D,M],"[":[F,M],eof:[E,M]},Z[F]={"'":[U,V],'"':[z,V],"[":[F,R],"]":[S,C],eof:I,else:[F,V]},Z[U]={"'":[F,V],eof:I,else:[U,V]},Z[z]={'"':[F,V],eof:I,else:[z,V]};var q=/^\s?(true|false|-?[\d.]+|'[^']*'|"[^"]*")\s?$/,B=function(t){void 0===t&&(t={});var n=t.locale||"en-US",e=t.messages||{};this._vm=null,this._fallbackLocale=t.fallbackLocale||"en-US",this._formatter=t.formatter||new j,this._missing=t.missing,this._root=t.root||null,this._fallbackRoot=t.fallbackRoot||!1,this._exist=function(t,n){return!(!t||!n)&&!i(_(t,n))},this._resetVM({locale:n,messages:e})},G={messages:{},locale:{},fallbackLocale:{},missing:{},formatter:{}};return B.prototype._resetVM=function(t){var n=d.config.silent;d.config.silent=!0,this._vm=new d({data:t}),d.config.silent=n},G.messages.get=function(){return this._vm.$data.messages},G.messages.set=function(t){this._vm.$set(this._vm,"messages",t)},G.locale.get=function(){return this._vm.$data.locale},G.locale.set=function(t){this._vm.$set(this._vm,"locale",t)},G.fallbackLocale.get=function(){return this._fallbackLocale},G.fallbackLocale.set=function(t){this._fallbackLocale=t},G.missing.get=function(){return this._missing},G.missing.set=function(t){this._missing=t},G.formatter.get=function(){return this._formatter},G.formatter.set=function(t){this._formatter=t},B.prototype._warnDefault=function(t,n,e,r){return i(e)?(this.missing&&this.missing.apply(null,[t,n,r]),n):e},B.prototype._isFallbackRoot=function(t){return!t&&!i(this._root)&&this._fallbackRoot},B.prototype._interpolate=function(n,e,r){var o=this;if(!n)return null;var a=_(n,e);if(Array.isArray(a))return a;if(i(a)&&(a=n[e]),i(a))return null;if("string"!=typeof a)return t("Value of key '"+e+"' is not a string!"),null;if(a.indexOf("@:")>=0){var s=a.match(/(@:[\w|.]+)/g);for(var l in s){var c=s[l],u=c.substr(2),f=o._interpolate(n,u,r);a=a.replace(c,f)}}return r?this._format(a,r):a},B.prototype._format=function(t){for(var n=[],e=arguments.length-1;e-- >0;)n[e]=arguments[e+1];return(r=this._formatter).format.apply(r,[t].concat(n));var r},B.prototype._translate=function(t,n,e,r,o){var a=null;return a=this._interpolate(t[n],r,o),i(a)?(a=this._interpolate(t[e],r,o),i(a)?null:a):a},B.prototype._t=function(t,n,e,r){for(var i=[],a=arguments.length-4;a-- >0;)i[a]=arguments[a+4];if(!t)return"";var s=o.apply(void 0,i),l=s.locale||n,c=this._translate(e,l,this.fallbackLocale,t,s.params);if(this._isFallbackRoot(c)){if(!this._root)throw Error("unexpected error");return(u=this._root).t.apply(u,[t].concat(i))}return this._warnDefault(l,t,c,r);var u},B.prototype.t=function(t){for(var n=[],e=arguments.length-1;e-- >0;)n[e]=arguments[e+1];return(r=this)._t.apply(r,[t,this.locale,this.messages,null].concat(n));var r},B.prototype._tc=function(t,n,e,r,i){for(var o=[],a=arguments.length-5;a-- >0;)o[a]=arguments[a+5];return t?void 0!==i?l((s=this)._t.apply(s,[t,n,e,r].concat(o)),i):(c=this)._t.apply(c,[t,n,e,r].concat(o)):"";var s,c},B.prototype.tc=function(t,n){for(var e=[],r=arguments.length-2;r-- >0;)e[r]=arguments[r+2];return(i=this)._tc.apply(i,[t,this.locale,this.messages,null,n].concat(e));var i},B.prototype._te=function(t,n,e){for(var r=[],i=arguments.length-3;i-- >0;)r[i]=arguments[i+3];var a=o.apply(void 0,r).locale||n;return this._exist(e[a],t)},B.prototype.te=function(t){for(var n=[],e=arguments.length-1;e-- >0;)n[e]=arguments[e+1];return(r=this)._te.apply(r,[t,this.locale,this.messages].concat(n));var r},Object.defineProperties(B.prototype,G),B.install=c,B.version="6.0.0-alpha.2","undefined"!=typeof window&&window.Vue&&window.Vue.use(B),B});
{
"name": "vue-i18n",
"description": "Internationalization plugin for Vue.js",
"version": "6.0.0-alpha.1",
"version": "6.0.0-alpha.2",
"author": {

@@ -60,3 +60,3 @@ "name": "kazuya kawaguchi",

"uglify-js": "^2.7.5",
"vue": "2.0.0",
"vue": "^2.2.0",
"webpack": "^2.2.0",

@@ -69,3 +69,4 @@ "webpack-dev-server": "^2.2.1"

"dist/vue-i18n.common.js",
"src"
"src",
"decls"
],

@@ -72,0 +73,0 @@ "homepage": "https://github.com/kazupon/vue-i18n#readme",

@@ -5,2 +5,3 @@ export default function (Vue) {

strats.i18n = (parent, child) => {
const ret = Object.create(null)
if (!child) { return parent }

@@ -10,6 +11,5 @@ if (!parent) { return child }

// TODO: should be warn
return {}
return ret
}
const ret = Object.create(null)
Vue.extend(ret, parent)
Vue.util.extend(ret, parent)
for (const key in child) {

@@ -16,0 +16,0 @@ ret[key] = child[key]

/* @flow */
import { isNil } from './util'
import { Vue } from './install'
import { isNull, hasOwn } from './util'

@@ -14,3 +13,2 @@ export default class BaseFormatter {

get options (): FormatterOptions { return this._options }
set options (options: FormatterOptions): void { this._options = options }

@@ -56,4 +54,4 @@ format (message: string, ...args: any): any {

} else {
result = Vue.util.hasOwn(args, i) ? args[i] : match
if (isNil(result)) {
result = hasOwn(args, i) ? args[i] : match
if (isNull(result)) {
return ''

@@ -60,0 +58,0 @@ }

/* @flow */
import { install, Vue } from './install'
import { isNil, parseArgs, fetchChoice } from './util'
import warn from './warn'
import { warn, isNull, parseArgs, fetchChoice } from './util'
import BaseFormatter from './format'
import Path from './path'
import getPathValue from './path'
import type { PathValue } from './path'

@@ -20,3 +20,2 @@

_missing: ?MissingHandler
_getPathValue: Function
_exist: Function

@@ -34,7 +33,5 @@

const getPathValue: Function = Path(Vue)
this._getPathValue = getPathValue
this._exist = (message: Object, key: string): boolean => {
if (!message || !key) { return false }
return !isNil(getPathValue(message, key))
return !isNull(getPathValue(message, key))
}

@@ -68,3 +65,3 @@

_warnDefault (locale: string, key: string, result: ?any, vm: ?any): ?string {
if (!isNil(result)) { return result }
if (!isNull(result)) { return result }
if (this.missing) {

@@ -84,3 +81,3 @@ this.missing.apply(null, [locale, key, vm])

_isFallbackRoot (val: any): boolean {
return !val && !isNil(this._root) && this._fallbackRoot
return !val && !isNull(this._root) && this._fallbackRoot
}

@@ -91,6 +88,6 @@

let val: PathValue = this._getPathValue(message, key)
let val: PathValue = getPathValue(message, key)
if (Array.isArray(val)) { return val }
if (isNil(val)) { val = message[key] }
if (isNil(val)) { return null }
if (isNull(val)) { val = message[key] }
if (isNull(val)) { return null }
if (typeof val !== 'string') {

@@ -128,6 +125,6 @@ warn(`Value of key '${key}' is not a string!`)

res = this._interpolate(messages[locale], key, args)
if (!isNil(res)) { return res }
if (!isNull(res)) { return res }
res = this._interpolate(messages[fallback], key, args)
if (!isNil(res)) {
if (!isNull(res)) {
if (process.env.NODE_ENV !== 'production') {

@@ -134,0 +131,0 @@ warn(`Fall back to translate the keypath '${key}' with '${fallback}' locale.`)

@@ -1,2 +0,2 @@

import warn from './warn'
import { warn } from './util'
import mixin from './mixin'

@@ -3,0 +3,0 @@ import Asset from './asset'

@@ -51,3 +51,7 @@ /* @flow */

}
},
beforeDestroy () {
this.$i18n = null
}
}
/* @flow */
import { isObject, isPlainObject, hasOwn } from './util'
/**

@@ -281,54 +283,46 @@ * Path paerser

export default function (Vue: any): Function {
const { isObject, isPlainObject, hasOwn } = Vue.util
function empty (target: any): boolean {
if (target === null || target === undefined) { return true }
function empty (target: any): boolean {
if (target === null || target === undefined) { return true }
if (Array.isArray(target)) {
if (target.length > 0) { return false }
if (target.length === 0) { return true }
} else if (isPlainObject(target)) {
/* eslint-disable prefer-const */
for (let key in target) {
if (hasOwn(target, key)) { return false }
}
/* eslint-enable prefer-const */
if (Array.isArray(target)) {
if (target.length > 0) { return false }
if (target.length === 0) { return true }
} else if (isPlainObject(target)) {
/* eslint-disable prefer-const */
for (let key in target) {
if (hasOwn(target, key)) { return false }
}
return true
/* eslint-enable prefer-const */
}
/**
* Get path value from path string
*/
return true
}
function getPathValue (obj: Object, path: string): PathValue {
if (!isObject(obj)) { return null }
/**
* Get path value from path string
*/
export default function getPathValue (obj: Object, path: string): PathValue {
if (!isObject(obj)) { return null }
const paths: Array<string> = parsePath(path)
if (empty(paths)) {
return null
} else {
const length = paths.length
let ret: any = null
let last: any = obj
let i = 0
while (i < length) {
const value: any = last[paths[i]]
if (value === undefined) {
last = null
break
}
last = value
i++
const paths: Array<string> = parsePath(path)
if (empty(paths)) {
return null
} else {
const length = paths.length
let ret: any = null
let last: any = obj
let i = 0
while (i < length) {
const value: any = last[paths[i]]
if (value === undefined) {
last = null
break
}
last = value
i++
}
ret = last
return ret
}
ret = last
return ret
}
return getPathValue
}
/* @flow */
import { Vue } from './install'
/**

@@ -9,11 +7,50 @@ * utilites

export function isNil (val: mixed): boolean {
export function warn (msg: string, err: ?Error): void {
if (typeof console !== 'undefined') {
console.warn('[vue-i18n] ' + msg)
if (err) {
console.warn(err.stack)
}
}
}
const hasOwnProperty = Object.prototype.hasOwnProperty
export function hasOwn (obj: Object, key: string): boolean {
return hasOwnProperty.call(obj, key)
}
export function bind (fn: Function, ctx: Object): Function {
function boundFn (a) {
const l: number = arguments.length
return l
? l > 1
? fn.apply(ctx, arguments)
: fn.call(ctx, a)
: fn.call(ctx)
}
// record original fn length
boundFn._length = fn.length
return boundFn
}
export function isObject (obj: mixed): boolean {
return obj !== null && typeof obj === 'object'
}
const toString = Object.prototype.toString
const OBJECT_STRING = '[object Object]'
export function isPlainObject (obj: any): boolean {
return toString.call(obj) === OBJECT_STRING
}
export function isNull (val: mixed): boolean {
return val === null || val === undefined
}
export function parseArgs (...args: any): Object {
let locale = null
export function parseArgs (...args: Array<mixed>): Object {
let locale: ?string = null
let params: mixed = null
if (args.length === 1) {
if (Vue.util.isObject(args[0]) || Array.isArray(args[0])) {
args = args[0]
if (isObject(args[0]) || Array.isArray(args[0])) {
params = args[0]
} else if (typeof args[0] === 'string') {

@@ -26,8 +63,8 @@ locale = args[0]

}
if (Vue.util.isObject(args[1]) || Array.isArray(args[1])) {
args = args[1]
if (isObject(args[1]) || Array.isArray(args[1])) {
params = args[1]
}
}
return { locale, params: args }
return { locale, params }
}

@@ -51,3 +88,3 @@

export function fetchChoice (message: any, choice: number): ?string {
export function fetchChoice (message: string, choice: number): ?string {
if (!message && typeof message !== 'string') { return null }

@@ -54,0 +91,0 @@ const choices: Array<string> = message.split('|')

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