Comparing version 4.7.1 to 4.7.2
@@ -0,1 +1,16 @@ | ||
<a name="4.7.2"></a> | ||
## [4.7.2](https://github.com/kazupon/vue-i18n/compare/v4.7.1...v4.7.2) (2016-11-19) | ||
### :bug: Bug Fixes | ||
* **observer:** fix dep undefined error ([#88](https://github.com/kazupon/vue-i18n/issues/88)) by [@fandaa](https://github.com/fandaa) ([724974e](https://github.com/kazupon/vue-i18n/commit/724974e)), closes [#88](https://github.com/kazupon/vue-i18n/issues/88) | ||
### :zap: Improvements | ||
* **extend:** support translate empty string ([#86](https://github.com/kazupon/vue-i18n/issues/86)) by [@QingWei](https://github.com/QingWei)-Li ([8e6d154](https://github.com/kazupon/vue-i18n/commit/8e6d154)) | ||
<a name="4.7.1"></a> | ||
@@ -2,0 +17,0 @@ ## [4.7.1](https://github.com/kazupon/vue-i18n/compare/v4.7.0...v4.7.1) (2016-10-29) |
/*! | ||
* vue-i18n v4.7.1 | ||
* vue-i18n v4.7.2 | ||
* (c) 2016 kazuya kawaguchi | ||
@@ -196,3 +196,3 @@ * Released under the MIT License. | ||
function getDep(vm) { | ||
if (!Dep) { | ||
if (!Dep && vm && vm._data && vm._data.__ob__ && vm._data.__ob__.dep) { | ||
Dep = vm._data.__ob__.dep.constructor; | ||
@@ -220,3 +220,3 @@ } | ||
watcher.dirty && watcher.evaluate(); | ||
Dep.target && watcher.depend(); | ||
Dep && Dep.target && watcher.depend(); | ||
return watcher.value; | ||
@@ -277,4 +277,18 @@ }; | ||
/** | ||
* utilites | ||
*/ | ||
/** | ||
* isNil | ||
* | ||
* @param {*} val | ||
* @return Boolean | ||
*/ | ||
function isNil(val) { | ||
return val === null || val === undefined; | ||
} | ||
/** | ||
* String format template | ||
* - Inspired: | ||
* - Inspired: | ||
* https://github.com/Matt-Esch/string-template/index.js | ||
@@ -290,3 +304,3 @@ */ | ||
* template | ||
* | ||
* | ||
* @param {String} string | ||
@@ -319,3 +333,3 @@ * @param {Array} ...args | ||
result = hasOwn(args, i) ? args[i] : match; | ||
if (result === null || result === undefined) { | ||
if (isNil(result)) { | ||
return ''; | ||
@@ -745,4 +759,7 @@ } | ||
var val = getValue(locale, key) || locale[key]; | ||
if (!val) { | ||
var val = getValue(locale, key); | ||
if (isNil(val)) { | ||
val = locale[key]; | ||
} | ||
if (isNil(val)) { | ||
return null; | ||
@@ -774,3 +791,3 @@ } | ||
res = interpolate(getter(lang), key, params); | ||
if (res) { | ||
if (!isNil(res)) { | ||
return res; | ||
@@ -780,3 +797,3 @@ } | ||
res = interpolate(getter(fallback), key, params); | ||
if (res) { | ||
if (!isNil(res)) { | ||
if (process.env.NODE_ENV !== 'production') { | ||
@@ -791,3 +808,6 @@ warn('Fall back to translate the keypath "' + key + '" with "' + fallback + '" language.'); | ||
function warnDefault(lang, key, vm) { | ||
function warnDefault(lang, key, vm, result) { | ||
if (!isNil(result)) { | ||
return result; | ||
} | ||
if (process.env.NODE_ENV !== 'production') { | ||
@@ -858,3 +878,3 @@ warn('Cannot translate the value of keypath "' + key + '". ' + 'Use the value of keypath as default'); | ||
return translate(getAssetLocale, lang, fallback, key, params) || warnDefault(lang, key, null); | ||
return warnDefault(lang, key, null, translate(getAssetLocale, lang, fallback, key, params)); | ||
}; | ||
@@ -909,3 +929,3 @@ | ||
} | ||
return translate(getAssetLocale, lang, fallback, key, params) || warnDefault(lang, key, this); | ||
return warnDefault(lang, key, this, translate(getAssetLocale, lang, fallback, key, params)); | ||
}; | ||
@@ -979,3 +999,3 @@ | ||
plugin.version = '4.7.1'; | ||
plugin.version = '4.7.2'; | ||
@@ -982,0 +1002,0 @@ if (typeof window !== 'undefined' && window.Vue) { |
/*! | ||
* vue-i18n v4.7.1 | ||
* vue-i18n v4.7.2 | ||
* (c) 2016 kazuya kawaguchi | ||
@@ -200,3 +200,3 @@ * Released under the MIT License. | ||
function getDep(vm) { | ||
if (!Dep) { | ||
if (!Dep && vm && vm._data && vm._data.__ob__ && vm._data.__ob__.dep) { | ||
Dep = vm._data.__ob__.dep.constructor; | ||
@@ -224,3 +224,3 @@ } | ||
watcher.dirty && watcher.evaluate(); | ||
Dep.target && watcher.depend(); | ||
Dep && Dep.target && watcher.depend(); | ||
return watcher.value; | ||
@@ -281,4 +281,18 @@ }; | ||
/** | ||
* utilites | ||
*/ | ||
/** | ||
* isNil | ||
* | ||
* @param {*} val | ||
* @return Boolean | ||
*/ | ||
function isNil(val) { | ||
return val === null || val === undefined; | ||
} | ||
/** | ||
* String format template | ||
* - Inspired: | ||
* - Inspired: | ||
* https://github.com/Matt-Esch/string-template/index.js | ||
@@ -294,3 +308,3 @@ */ | ||
* template | ||
* | ||
* | ||
* @param {String} string | ||
@@ -323,3 +337,3 @@ * @param {Array} ...args | ||
result = hasOwn(args, i) ? args[i] : match; | ||
if (result === null || result === undefined) { | ||
if (isNil(result)) { | ||
return ''; | ||
@@ -749,4 +763,7 @@ } | ||
var val = getValue(locale, key) || locale[key]; | ||
if (!val) { | ||
var val = getValue(locale, key); | ||
if (isNil(val)) { | ||
val = locale[key]; | ||
} | ||
if (isNil(val)) { | ||
return null; | ||
@@ -778,3 +795,3 @@ } | ||
res = interpolate(getter(lang), key, params); | ||
if (res) { | ||
if (!isNil(res)) { | ||
return res; | ||
@@ -784,3 +801,3 @@ } | ||
res = interpolate(getter(fallback), key, params); | ||
if (res) { | ||
if (!isNil(res)) { | ||
if ('development' !== 'production') { | ||
@@ -795,3 +812,6 @@ warn('Fall back to translate the keypath "' + key + '" with "' + fallback + '" language.'); | ||
function warnDefault(lang, key, vm) { | ||
function warnDefault(lang, key, vm, result) { | ||
if (!isNil(result)) { | ||
return result; | ||
} | ||
if ('development' !== 'production') { | ||
@@ -862,3 +882,3 @@ warn('Cannot translate the value of keypath "' + key + '". ' + 'Use the value of keypath as default'); | ||
return translate(getAssetLocale, lang, fallback, key, params) || warnDefault(lang, key, null); | ||
return warnDefault(lang, key, null, translate(getAssetLocale, lang, fallback, key, params)); | ||
}; | ||
@@ -913,3 +933,3 @@ | ||
} | ||
return translate(getAssetLocale, lang, fallback, key, params) || warnDefault(lang, key, this); | ||
return warnDefault(lang, key, this, translate(getAssetLocale, lang, fallback, key, params)); | ||
}; | ||
@@ -983,3 +1003,3 @@ | ||
plugin.version = '4.7.1'; | ||
plugin.version = '4.7.2'; | ||
@@ -986,0 +1006,0 @@ if (typeof window !== 'undefined' && window.Vue) { |
/*! | ||
* vue-i18n v4.7.1 | ||
* vue-i18n v4.7.2 | ||
* (c) 2016 kazuya kawaguchi | ||
* Released under the MIT License. | ||
*/ | ||
!function(n,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):n.VueI18n=t()}(this,function(){"use strict";function n(n,t){window.console&&(console.warn("[vue-i18n] "+n),t&&console.warn(t.stack))}function t(t,r){t.locale=function(t,o,i){return void 0===o?r.locales[t]:void(null===o?(r.locales[t]=void 0,delete r.locales[t]):e(t,o,function(e){e?r.locales[t]=e:n("failed set `"+t+"` locale"),i&&i()}))}}function e(n,t,e){var o=this;"object"===("undefined"==typeof t?"undefined":w["typeof"](t))?e(t):!function(){var n=t.call(o);"function"==typeof n?n.resolved?e(n.resolved):n.requested?n.pendingCallbacks.push(e):!function(){n.requested=!0;var t=n.pendingCallbacks=[e];n(function(e){n.resolved=e;for(var r=0,o=t.length;o>r;r++)t[r](e)},function(){e()})}():r(n)&&n.then(function(n){e(n)},function(){e()})["catch"](function(n){console.error(n),e()})}()}function r(n){return n&&"function"==typeof n.then}function o(n,t,e){function r(n){if(e>1)n.$forceUpdate();else for(var t=n._watchers.length;t--;)n._watchers[t].update(!0)}var o=n.prototype._init;n.prototype._init=function(n){var e=this;o.call(this,n),this.$parent||(this.$lang=t,this._langUnwatch=this.$lang.$watch("$data",function(n,t){r(e)},{deep:!0}))};var i=n.prototype._destroy;n.prototype._destroy=function(){!this.$parent&&this._langUnwatch&&(this._langUnwatch(),this._langUnwatch=null,this.$lang=null),i.apply(this,arguments)}}function i(n){if(!m){var t=n.$watch("__watcher__",function(n){});m=n._watchers[0].constructor,t()}return m}function a(n){return _||(_=n._data.__ob__.dep.constructor),_}function u(n,t,e){function r(n,t){var e=new u(t,n,null,{lazy:!0});return function(){return e.dirty&&e.evaluate(),c.target&&e.depend(),e.value}}var o=n.util.bind,u=i(t),c=a(t);Object.defineProperty(n.config,"lang",{enumerable:!0,configurable:!0,get:r(function(){return t.lang},t),set:o(function(n){t.lang=n},t)}),A=e,Object.defineProperty(n.config,"fallbackLang",{enumerable:!0,configurable:!0,get:function(){return A},set:function(n){A=n}}),Object.defineProperty(n.config,"missingHandler",{enumerable:!0,configurable:!0,get:function(){return $},set:function(n){$=n}}),Object.defineProperty(n.config,"i18nFormatter",{enumerable:!0,configurable:!0,get:function(){return O},set:function(n){O=n}})}function c(n){function t(n){for(var t=arguments.length,r=Array(t>1?t-1:0),o=1;t>o;o++)r[o-1]=arguments[o];return r=1===r.length&&"object"===w["typeof"](r[0])?r[0]:{},r&&r.hasOwnProperty||(r={}),n.replace(j,function(t,o,i,a){var u=void 0;return"{"===n[a-1]&&"}"===n[a+t.length]?i:(u=e(r,i)?r[i]:t,null===u||void 0===u?"":u)})}var e=n.util.hasOwn;return t}function l(n){return Z.test(n)}function f(n){var t=n.charCodeAt(0),e=n.charCodeAt(n.length-1);return t!==e||34!==t&&39!==t?n:n.slice(1,-1)}function s(n){if(void 0===n)return"eof";var t=n.charCodeAt(0);switch(t){case 91:case 93:case 46:case 34:case 39:case 48:return n;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 t>=97&&122>=t||t>=65&&90>=t?"ident":t>=49&&57>=t?"number":"else"}function d(n){var t=n.trim();return"0"===n.charAt(0)&&isNaN(n)?!1:l(t)?f(t):"*"+t}function v(n){function t(){var t=n[r+1];return o===q&&"'"===t||o===z&&'"'===t?(r++,u="\\"+t,g[P](),!0):void 0}var e=[],r=-1,o=x,i=0,a=void 0,u=void 0,c=void 0,l=void 0,f=void 0,v=void 0,p=void 0,g=[];for(g[C]=function(){void 0!==c&&(e.push(c),c=void 0)},g[P]=function(){void 0===c?c=u:c+=u},g[U]=function(){g[P](),i++},g[S]=function(){if(i>0)i--,o=V,g[P]();else{if(i=0,c=d(c),c===!1)return!1;g[C]()}};null!=o;)if(r++,a=n[r],"\\"!==a||!t()){if(l=s(a),p=I[o],f=p[l]||p["else"]||M,f===M)return;if(o=f[0],v=g[f[1]],v&&(u=f[2],u=void 0===u?a:u,v()===!1))return;if(o===L)return e.raw=n,e}}function p(n){var t=k[n];return t||(t=v(n),t&&(k[n]=t)),t}function g(n){function t(n){if(null===n||void 0===n)return!0;if(Array.isArray(n)){if(n.length>0)return!1;if(0===n.length)return!0}else if(i(n))for(var t in n)if(a(n,t))return!1;return!0}function e(n,e){if(!o(n))return null;var r=p(e);if(t(r))return null;for(var i=r.length,a=null,u=n,c=0;i>c;){var l=u[r[c]];if(void 0===l){u=null;break}u=l,c++}return a=u}var r=n.util,o=r.isObject,i=r.isPlainObject,a=r.hasOwn;return e}function h(n){function t(){for(var t=arguments.length,e=Array(t),r=0;t>r;r++)e[r]=arguments[r];var o=n.config.lang,i=n.config.fallbackLang;return 1===e.length?d(e[0])||Array.isArray(e[0])?e=e[0]:"string"==typeof e[0]&&(o=e[0]):2===e.length&&("string"==typeof e[0]&&(o=e[0]),(d(e[1])||Array.isArray(e[1]))&&(e=e[1])),{lang:o,fallback:i,params:e}}function e(t,r,o){if(!t)return null;var i=h(t,r)||t[r];if(!i)return null;if(i.indexOf("@:")>=0){var a=i.match(/(@:[\w|.]+)/g);for(var u in a){var c=a[u],l=c.substr(2),f=e(t,l,o);i=i.replace(c,f)}}return o?n.config.i18nFormatter?n.config.i18nFormatter.apply(null,[i].concat(o)):p(i,o):i}function r(n,t,r,o,i){var a=null;return(a=e(n(t),o,i))?a:(a=e(n(r),o,i),a?a:null)}function o(t,e,r){return n.config.missingHandler&&n.config.missingHandler.apply(null,[t,e,r]),e}function i(t){return n.locale(t)}function a(n){return this.$options.locales[n]}function u(n){return n?n>1?1:0:1}function l(n,t){return n=Math.abs(n),2===t?u(n):n?Math.min(n,2):0}function f(n,t){if(!n&&"string"!=typeof n)return null;var e=n.split("|");return t=l(t,e.length),e[t]?e[t].trim():n}var s=n.util,d=s.isObject,v=s.bind,p=c(n),h=g(n);return n.t=function(n){for(var e=arguments.length,a=Array(e>1?e-1:0),u=1;e>u;u++)a[u-1]=arguments[u];if(!n)return"";var c=t.apply(void 0,a),l=c.lang,f=c.fallback,s=c.params;return r(i,l,f,n,s)||o(l,n,null)},n.tc=function(t,e){for(var r=arguments.length,o=Array(r>2?r-2:0),i=2;r>i;i++)o[i-2]=arguments[i];return f(n.t.apply(n,[t].concat(o)),e)},n.prototype.$t=function(n){if(!n)return"";for(var e=arguments.length,u=Array(e>1?e-1:0),c=1;e>c;c++)u[c-1]=arguments[c];var l=t.apply(void 0,u),f=l.lang,s=l.fallback,d=l.params,p=null;return this.$options.locales&&(p=r(v(a,this),f,s,n,d))?p:r(i,f,s,n,d)||o(f,n,this)},n.prototype.$tc=function(n,t){if("number"!=typeof t&&"undefined"!=typeof t)return n;for(var e=arguments.length,r=Array(e>2?e-2:0),o=2;e>o;o++)r[o-2]=arguments[o];return f(this.$t.apply(this,[n].concat(r)),t)},n}function y(n){var e=(arguments.length<=1||void 0===arguments[1]?{}:arguments[1],n.version&&Number(n.version.split(".")[0])||-1),r="en";b(n,r),t(n,B),o(n,B,e),u(n,B,r),h(n)}function b(n,t){var e=n.config.silent;n.config.silent=!0,B||(B=new n({data:{lang:t,locales:{}}})),n.config.silent=e}var w={};w["typeof"]="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(n){return typeof n}:function(n){return n&&"function"==typeof Symbol&&n.constructor===Symbol?"symbol":typeof n};var m=void 0,_=void 0,A=void 0,$=null,O=null,j=/(%|)\{([0-9a-zA-Z_]+)\}/g,k=Object.create(null),P=0,C=1,U=2,S=3,x=0,F=1,H=2,N=3,V=4,q=5,z=6,L=7,M=8,I=[];I[x]={ws:[x],ident:[N,P],"[":[V],eof:[L]},I[F]={ws:[F],".":[H],"[":[V],eof:[L]},I[H]={ws:[H],ident:[N,P]},I[N]={ident:[N,P],0:[N,P],number:[N,P],ws:[F,C],".":[H,C],"[":[V,C],eof:[L,C]},I[V]={"'":[q,P],'"':[z,P],"[":[V,U],"]":[F,S],eof:M,"else":[V,P]},I[q]={"'":[V,P],eof:M,"else":[q,P]},I[z]={'"':[V,P],eof:M,"else":[z,P]};var Z=/^\s?(true|false|-?[\d.]+|'[^']*'|"[^"]*")\s?$/,B=void 0;return y.version="4.7.1","undefined"!=typeof window&&window.Vue&&window.Vue.use(y),y}); | ||
!function(n,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):n.VueI18n=t()}(this,function(){"use strict";function n(n,t){window.console&&(console.warn("[vue-i18n] "+n),t&&console.warn(t.stack))}function t(t,r){t.locale=function(t,o,i){return void 0===o?r.locales[t]:void(null===o?(r.locales[t]=void 0,delete r.locales[t]):e(t,o,function(e){e?r.locales[t]=e:n("failed set `"+t+"` locale"),i&&i()}))}}function e(n,t,e){var o=this;"object"===("undefined"==typeof t?"undefined":_["typeof"](t))?e(t):!function(){var n=t.call(o);"function"==typeof n?n.resolved?e(n.resolved):n.requested?n.pendingCallbacks.push(e):!function(){n.requested=!0;var t=n.pendingCallbacks=[e];n(function(e){n.resolved=e;for(var r=0,o=t.length;o>r;r++)t[r](e)},function(){e()})}():r(n)&&n.then(function(n){e(n)},function(){e()})["catch"](function(n){console.error(n),e()})}()}function r(n){return n&&"function"==typeof n.then}function o(n,t,e){function r(n){if(e>1)n.$forceUpdate();else for(var t=n._watchers.length;t--;)n._watchers[t].update(!0)}var o=n.prototype._init;n.prototype._init=function(n){var e=this;o.call(this,n),this.$parent||(this.$lang=t,this._langUnwatch=this.$lang.$watch("$data",function(n,t){r(e)},{deep:!0}))};var i=n.prototype._destroy;n.prototype._destroy=function(){!this.$parent&&this._langUnwatch&&(this._langUnwatch(),this._langUnwatch=null,this.$lang=null),i.apply(this,arguments)}}function i(n){if(!m){var t=n.$watch("__watcher__",function(n){});m=n._watchers[0].constructor,t()}return m}function a(n){return!A&&n&&n._data&&n._data.__ob__&&n._data.__ob__.dep&&(A=n._data.__ob__.dep.constructor),A}function u(n,t,e){function r(n,t){var e=new u(t,n,null,{lazy:!0});return function(){return e.dirty&&e.evaluate(),c&&c.target&&e.depend(),e.value}}var o=n.util.bind,u=i(t),c=a(t);Object.defineProperty(n.config,"lang",{enumerable:!0,configurable:!0,get:r(function(){return t.lang},t),set:o(function(n){t.lang=n},t)}),$=e,Object.defineProperty(n.config,"fallbackLang",{enumerable:!0,configurable:!0,get:function(){return $},set:function(n){$=n}}),Object.defineProperty(n.config,"missingHandler",{enumerable:!0,configurable:!0,get:function(){return O},set:function(n){O=n}}),Object.defineProperty(n.config,"i18nFormatter",{enumerable:!0,configurable:!0,get:function(){return j},set:function(n){j=n}})}function c(n){return null===n||void 0===n}function f(n){function t(n){for(var t=arguments.length,r=Array(t>1?t-1:0),o=1;t>o;o++)r[o-1]=arguments[o];return r=1===r.length&&"object"===_["typeof"](r[0])?r[0]:{},r&&r.hasOwnProperty||(r={}),n.replace(k,function(t,o,i,a){var u=void 0;return"{"===n[a-1]&&"}"===n[a+t.length]?i:(u=e(r,i)?r[i]:t,c(u)?"":u)})}var e=n.util.hasOwn;return t}function l(n){return B.test(n)}function s(n){var t=n.charCodeAt(0),e=n.charCodeAt(n.length-1);return t!==e||34!==t&&39!==t?n:n.slice(1,-1)}function d(n){if(void 0===n)return"eof";var t=n.charCodeAt(0);switch(t){case 91:case 93:case 46:case 34:case 39:case 48:return n;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 t>=97&&122>=t||t>=65&&90>=t?"ident":t>=49&&57>=t?"number":"else"}function v(n){var t=n.trim();return"0"===n.charAt(0)&&isNaN(n)?!1:l(t)?s(t):"*"+t}function p(n){function t(){var t=n[r+1];return o===z&&"'"===t||o===L&&'"'===t?(r++,u="\\"+t,g[C](),!0):void 0}var e=[],r=-1,o=F,i=0,a=void 0,u=void 0,c=void 0,f=void 0,l=void 0,s=void 0,p=void 0,g=[];for(g[U]=function(){void 0!==c&&(e.push(c),c=void 0)},g[C]=function(){void 0===c?c=u:c+=u},g[S]=function(){g[C](),i++},g[x]=function(){if(i>0)i--,o=q,g[C]();else{if(i=0,c=v(c),c===!1)return!1;g[U]()}};null!=o;)if(r++,a=n[r],"\\"!==a||!t()){if(f=d(a),p=Z[o],l=p[f]||p["else"]||I,l===I)return;if(o=l[0],s=g[l[1]],s&&(u=l[2],u=void 0===u?a:u,s()===!1))return;if(o===M)return e.raw=n,e}}function g(n){var t=P[n];return t||(t=p(n),t&&(P[n]=t)),t}function h(n){function t(n){if(null===n||void 0===n)return!0;if(Array.isArray(n)){if(n.length>0)return!1;if(0===n.length)return!0}else if(i(n))for(var t in n)if(a(n,t))return!1;return!0}function e(n,e){if(!o(n))return null;var r=g(e);if(t(r))return null;for(var i=r.length,a=null,u=n,c=0;i>c;){var f=u[r[c]];if(void 0===f){u=null;break}u=f,c++}return a=u}var r=n.util,o=r.isObject,i=r.isPlainObject,a=r.hasOwn;return e}function y(n){function t(){for(var t=arguments.length,e=Array(t),r=0;t>r;r++)e[r]=arguments[r];var o=n.config.lang,i=n.config.fallbackLang;return 1===e.length?v(e[0])||Array.isArray(e[0])?e=e[0]:"string"==typeof e[0]&&(o=e[0]):2===e.length&&("string"==typeof e[0]&&(o=e[0]),(v(e[1])||Array.isArray(e[1]))&&(e=e[1])),{lang:o,fallback:i,params:e}}function e(t,r,o){if(!t)return null;var i=y(t,r);if(c(i)&&(i=t[r]),c(i))return null;if(i.indexOf("@:")>=0){var a=i.match(/(@:[\w|.]+)/g);for(var u in a){var f=a[u],l=f.substr(2),s=e(t,l,o);i=i.replace(f,s)}}return o?n.config.i18nFormatter?n.config.i18nFormatter.apply(null,[i].concat(o)):g(i,o):i}function r(n,t,r,o,i){var a=null;return a=e(n(t),o,i),c(a)?(a=e(n(r),o,i),c(a)?null:a):a}function o(t,e,r,o){return c(o)?(n.config.missingHandler&&n.config.missingHandler.apply(null,[t,e,r]),e):o}function i(t){return n.locale(t)}function a(n){return this.$options.locales[n]}function u(n){return n?n>1?1:0:1}function l(n,t){return n=Math.abs(n),2===t?u(n):n?Math.min(n,2):0}function s(n,t){if(!n&&"string"!=typeof n)return null;var e=n.split("|");return t=l(t,e.length),e[t]?e[t].trim():n}var d=n.util,v=d.isObject,p=d.bind,g=f(n),y=h(n);return n.t=function(n){for(var e=arguments.length,a=Array(e>1?e-1:0),u=1;e>u;u++)a[u-1]=arguments[u];if(!n)return"";var c=t.apply(void 0,a),f=c.lang,l=c.fallback,s=c.params;return o(f,n,null,r(i,f,l,n,s))},n.tc=function(t,e){for(var r=arguments.length,o=Array(r>2?r-2:0),i=2;r>i;i++)o[i-2]=arguments[i];return s(n.t.apply(n,[t].concat(o)),e)},n.prototype.$t=function(n){if(!n)return"";for(var e=arguments.length,u=Array(e>1?e-1:0),c=1;e>c;c++)u[c-1]=arguments[c];var f=t.apply(void 0,u),l=f.lang,s=f.fallback,d=f.params,v=null;return this.$options.locales&&(v=r(p(a,this),l,s,n,d))?v:o(l,n,this,r(i,l,s,n,d))},n.prototype.$tc=function(n,t){if("number"!=typeof t&&"undefined"!=typeof t)return n;for(var e=arguments.length,r=Array(e>2?e-2:0),o=2;e>o;o++)r[o-2]=arguments[o];return s(this.$t.apply(this,[n].concat(r)),t)},n}function b(n){var e=(arguments.length<=1||void 0===arguments[1]?{}:arguments[1],n.version&&Number(n.version.split(".")[0])||-1),r="en";w(n,r),t(n,D),o(n,D,e),u(n,D,r),y(n)}function w(n,t){var e=n.config.silent;n.config.silent=!0,D||(D=new n({data:{lang:t,locales:{}}})),n.config.silent=e}var _={};_["typeof"]="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(n){return typeof n}:function(n){return n&&"function"==typeof Symbol&&n.constructor===Symbol?"symbol":typeof n};var m=void 0,A=void 0,$=void 0,O=null,j=null,k=/(%|)\{([0-9a-zA-Z_]+)\}/g,P=Object.create(null),C=0,U=1,S=2,x=3,F=0,H=1,N=2,V=3,q=4,z=5,L=6,M=7,I=8,Z=[];Z[F]={ws:[F],ident:[V,C],"[":[q],eof:[M]},Z[H]={ws:[H],".":[N],"[":[q],eof:[M]},Z[N]={ws:[N],ident:[V,C]},Z[V]={ident:[V,C],0:[V,C],number:[V,C],ws:[H,U],".":[N,U],"[":[q,U],eof:[M,U]},Z[q]={"'":[z,C],'"':[L,C],"[":[q,S],"]":[H,x],eof:I,"else":[q,C]},Z[z]={"'":[q,C],eof:I,"else":[z,C]},Z[L]={'"':[q,C],eof:I,"else":[L,C]};var B=/^\s?(true|false|-?[\d.]+|'[^']*'|"[^"]*")\s?$/,D=void 0;return b.version="4.7.2","undefined"!=typeof window&&window.Vue&&window.Vue.use(b),b}); |
{ | ||
"name": "vue-i18n", | ||
"description": "Internationalization plugin for Vue.js", | ||
"version": "4.7.1", | ||
"version": "4.7.2", | ||
"author": { | ||
@@ -6,0 +6,0 @@ "name": "kazuya kawaguchi", |
@@ -11,3 +11,3 @@ import warn from './warn' | ||
*/ | ||
Vue.locale = (id, definition, cb) => { | ||
@@ -14,0 +14,0 @@ if (definition === undefined) { // gettter |
@@ -19,3 +19,3 @@ import { getWatcher, getDep } from './observer' | ||
watcher.dirty && watcher.evaluate() | ||
Dep.target && watcher.depend() | ||
Dep && Dep.target && watcher.depend() | ||
return watcher.value | ||
@@ -22,0 +22,0 @@ } |
import warn from './warn' | ||
import Format from './format' | ||
import Path from './path' | ||
import { isNil } from './util' | ||
/** | ||
@@ -43,4 +43,5 @@ * extend | ||
let val = getValue(locale, key) || locale[key] | ||
if (!val) { return null } | ||
let val = getValue(locale, key) | ||
if (isNil(val)) { val = locale[key] } | ||
if (isNil(val)) { return null } | ||
@@ -74,6 +75,6 @@ // Check for the existance of links within the translated string | ||
res = interpolate(getter(lang), key, params) | ||
if (res) { return res } | ||
if (!isNil(res)) { return res } | ||
res = interpolate(getter(fallback), key, params) | ||
if (res) { | ||
if (!isNil(res)) { | ||
if (process.env.NODE_ENV !== 'production') { | ||
@@ -90,3 +91,4 @@ warn('Fall back to translate the keypath "' + key + '" with "' | ||
function warnDefault (lang, key, vm) { | ||
function warnDefault (lang, key, vm, result) { | ||
if (!isNil(result)) { return result } | ||
if (process.env.NODE_ENV !== 'production') { | ||
@@ -140,4 +142,3 @@ warn('Cannot translate the value of keypath "' + key + '". ' | ||
const { lang, fallback, params } = parseArgs(...args) | ||
return translate(getAssetLocale, lang, fallback, key, params) | ||
|| warnDefault(lang, key, null) | ||
return warnDefault(lang, key, null, translate(getAssetLocale, lang, fallback, key, params)) | ||
} | ||
@@ -176,4 +177,3 @@ | ||
} | ||
return translate(getAssetLocale, lang, fallback, key, params) | ||
|| warnDefault(lang, key, this) | ||
return warnDefault(lang, key, this, translate(getAssetLocale, lang, fallback, key, params)) | ||
} | ||
@@ -180,0 +180,0 @@ |
@@ -0,4 +1,6 @@ | ||
import { isNil } from './util' | ||
/** | ||
* String format template | ||
* - Inspired: | ||
* - Inspired: | ||
* https://github.com/Matt-Esch/string-template/index.js | ||
@@ -15,3 +17,3 @@ */ | ||
* template | ||
* | ||
* | ||
* @param {String} string | ||
@@ -41,3 +43,3 @@ * @param {Array} ...args | ||
result = hasOwn(args, i) ? args[i] : match | ||
if (result === null || result === undefined) { | ||
if (isNil(result)) { | ||
return '' | ||
@@ -44,0 +46,0 @@ } |
@@ -50,3 +50,3 @@ import warn from './warn' | ||
plugin.version = '4.7.1' | ||
plugin.version = '4.7.2' | ||
@@ -53,0 +53,0 @@ export default plugin |
@@ -31,3 +31,3 @@ /** | ||
export function getDep (vm) { | ||
if (!Dep) { | ||
if (!Dep && vm && vm._data && vm._data.__ob__ && vm._data.__ob__.dep) { | ||
Dep = vm._data.__ob__.dep.constructor | ||
@@ -34,0 +34,0 @@ } |
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
85950
17
2441