Comparing version 4.2.3 to 4.3.0
@@ -0,1 +1,11 @@ | ||
<a name="4.3.0"></a> | ||
# [4.3.0](https://github.com/kazupon/vue-i18n/compare/v4.2.3...v4.3.0) (2016-08-26) | ||
### :star: New Features | ||
* add pluralization ([#44](https://github.com/kazupon/vue-i18n/issues/44)) by [@mmochetti](https://github.com/mmochetti) ([b5b84d8](https://github.com/kazupon/vue-i18n/commit/b5b84d8)) | ||
<a name="4.2.3"></a> | ||
@@ -2,0 +12,0 @@ ## [4.2.3](https://github.com/kazupon/vue-i18n/compare/v4.2.2...v4.2.3) (2016-08-23) |
/*! | ||
* vue-i18n v4.2.3 | ||
* vue-i18n v4.3.0 | ||
* (c) 2016 kazuya kawaguchi | ||
@@ -754,2 +754,14 @@ * Released under the MIT License. | ||
function fetchChoice(locale, choice) { | ||
if (!locale && typeof locale !== 'string') { | ||
return null; | ||
} | ||
var choices = locale.split('|'); | ||
choice = choice - 1; | ||
if (!choices[choice]) { | ||
return locale; | ||
} | ||
return choices[choice].trim(); | ||
} | ||
/** | ||
@@ -782,2 +794,22 @@ * Vue.t | ||
/** | ||
* Vue.tc | ||
* | ||
* @param {String} key | ||
* @param {number|undefined} choice | ||
* @param {Array} ...args | ||
* @return {String} | ||
*/ | ||
Vue.tc = function (key, choice) { | ||
for (var _len3 = arguments.length, args = Array(_len3 > 2 ? _len3 - 2 : 0), _key3 = 2; _key3 < _len3; _key3++) { | ||
args[_key3 - 2] = arguments[_key3]; | ||
} | ||
if (!choice) { | ||
choice = 1; | ||
} | ||
return fetchChoice(Vue.t.apply(Vue, [key].concat(args)), choice); | ||
}; | ||
/** | ||
* $t | ||
@@ -795,4 +827,4 @@ * | ||
for (var _len3 = arguments.length, args = Array(_len3 > 1 ? _len3 - 1 : 0), _key3 = 1; _key3 < _len3; _key3++) { | ||
args[_key3 - 1] = arguments[_key3]; | ||
for (var _len4 = arguments.length, args = Array(_len4 > 1 ? _len4 - 1 : 0), _key4 = 1; _key4 < _len4; _key4++) { | ||
args[_key4 - 1] = arguments[_key4]; | ||
} | ||
@@ -816,2 +848,26 @@ | ||
/** | ||
* $tc | ||
* | ||
* @param {String} key | ||
* @param {number|undefined} choice | ||
* @param {Array} ...args | ||
* @return {String} | ||
*/ | ||
Vue.prototype.$tc = function (key, choice) { | ||
if (typeof choice !== 'number' && typeof choice !== 'undefined') { | ||
return key; | ||
} | ||
if (!choice) { | ||
choice = 1; | ||
} | ||
for (var _len5 = arguments.length, args = Array(_len5 > 2 ? _len5 - 2 : 0), _key5 = 2; _key5 < _len5; _key5++) { | ||
args[_key5 - 2] = arguments[_key5]; | ||
} | ||
return fetchChoice(this.$t.apply(this, [key].concat(args)), choice); | ||
}; | ||
return Vue; | ||
@@ -862,3 +918,3 @@ } | ||
plugin.version = '4.2.3'; | ||
plugin.version = '4.3.0'; | ||
@@ -865,0 +921,0 @@ if (typeof window !== 'undefined' && window.Vue) { |
/*! | ||
* vue-i18n v4.2.3 | ||
* vue-i18n v4.3.0 | ||
* (c) 2016 kazuya kawaguchi | ||
@@ -758,2 +758,14 @@ * Released under the MIT License. | ||
function fetchChoice(locale, choice) { | ||
if (!locale && typeof locale !== 'string') { | ||
return null; | ||
} | ||
var choices = locale.split('|'); | ||
choice = choice - 1; | ||
if (!choices[choice]) { | ||
return locale; | ||
} | ||
return choices[choice].trim(); | ||
} | ||
/** | ||
@@ -786,2 +798,22 @@ * Vue.t | ||
/** | ||
* Vue.tc | ||
* | ||
* @param {String} key | ||
* @param {number|undefined} choice | ||
* @param {Array} ...args | ||
* @return {String} | ||
*/ | ||
Vue.tc = function (key, choice) { | ||
for (var _len3 = arguments.length, args = Array(_len3 > 2 ? _len3 - 2 : 0), _key3 = 2; _key3 < _len3; _key3++) { | ||
args[_key3 - 2] = arguments[_key3]; | ||
} | ||
if (!choice) { | ||
choice = 1; | ||
} | ||
return fetchChoice(Vue.t.apply(Vue, [key].concat(args)), choice); | ||
}; | ||
/** | ||
* $t | ||
@@ -799,4 +831,4 @@ * | ||
for (var _len3 = arguments.length, args = Array(_len3 > 1 ? _len3 - 1 : 0), _key3 = 1; _key3 < _len3; _key3++) { | ||
args[_key3 - 1] = arguments[_key3]; | ||
for (var _len4 = arguments.length, args = Array(_len4 > 1 ? _len4 - 1 : 0), _key4 = 1; _key4 < _len4; _key4++) { | ||
args[_key4 - 1] = arguments[_key4]; | ||
} | ||
@@ -820,2 +852,26 @@ | ||
/** | ||
* $tc | ||
* | ||
* @param {String} key | ||
* @param {number|undefined} choice | ||
* @param {Array} ...args | ||
* @return {String} | ||
*/ | ||
Vue.prototype.$tc = function (key, choice) { | ||
if (typeof choice !== 'number' && typeof choice !== 'undefined') { | ||
return key; | ||
} | ||
if (!choice) { | ||
choice = 1; | ||
} | ||
for (var _len5 = arguments.length, args = Array(_len5 > 2 ? _len5 - 2 : 0), _key5 = 2; _key5 < _len5; _key5++) { | ||
args[_key5 - 2] = arguments[_key5]; | ||
} | ||
return fetchChoice(this.$t.apply(this, [key].concat(args)), choice); | ||
}; | ||
return Vue; | ||
@@ -866,3 +922,3 @@ } | ||
plugin.version = '4.2.3'; | ||
plugin.version = '4.3.0'; | ||
@@ -869,0 +925,0 @@ if (typeof window !== 'undefined' && window.Vue) { |
/*! | ||
* vue-i18n v4.2.3 | ||
* vue-i18n v4.3.0 | ||
* (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){t.locale=function(t,r,o){return void 0===r?_[t]:void(null===r?(_[t]=void 0,delete _[t]):e(t,r,function(e){e?(_[t]=e,o&&o()):n("failed set `"+t+"` locale")}))}}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("lang",function(n,t){r(e)}))};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 u(n){return A||(A=n._data.__ob__.dep.constructor),A}function a(n,t,e){function r(n,t){var e=new a(t,n,null,{lazy:!0});return function(){return e.dirty&&e.evaluate(),c.target&&e.depend(),e.value}}var o=n.util.bind,a=i(t),c=u(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}})}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 1===r.length&&"object"===w["typeof"](r[0])&&(r=r[0]),r&&r.hasOwnProperty||(r={}),n.replace(j,function(t,o,i,u){var a=void 0;return"{"===n[u-1]&&"}"===n[u+t.length]?i:(a=e(r,i)?r[i]:null,null===a||void 0===a?"":a)})}var e=n.util.hasOwn;return t}function f(n){return D.test(n)}function l(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: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:f(t)?l(t):"*"+t}function v(n){function t(){var t=n[r+1];return o===z&&"'"===t||o===L&&'"'===t?(r++,a="\\"+t,p[k](),!0):void 0}var e=[],r=-1,o=S,i=0,u=void 0,a=void 0,c=void 0,f=void 0,l=void 0,v=void 0,h=void 0,p=[];for(p[C]=function(){void 0!==c&&(e.push(c),c=void 0)},p[k]=function(){void 0===c?c=a:c+=a},p[U]=function(){p[k](),i++},p[P]=function(){if(i>0)i--,o=x,p[k]();else{if(i=0,c=d(c),c===!1)return!1;p[C]()}};null!=o;)if(r++,u=n[r],"\\"!==u||!t()){if(f=s(u),h=B[o],l=h[f]||h["else"]||Z,l===Z)return;if(o=l[0],v=p[l[1]],v&&(a=l[2],a=void 0===a?u:a,v()===!1))return;if(o===I)return e.raw=n,e}}function h(n){var t=O[n];return t||(t=v(n),t&&(O[n]=t)),t}function p(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(u(n,t))return!1;return!0}function e(n,e){if(!o(n))return null;var r=h(e);if(t(r))return null;for(var i=r.length,u=null,a=n,c=0;i>c;){var f=a[r[c]];if(void 0===f){a=null;break}a=f,c++}return u=a}var r=n.util,o=r.isObject,i=r.isPlainObject,u=r.hasOwn;return e}function g(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?f(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]),(f(e[1])||Array.isArray(e[1]))&&(e=e[1])),{lang:o,fallback:i,params:e}}function e(n,t,e){if(!n)return null;var r=d(n,t)||n[t];return r?e?s(r,e):r:null}function r(n,t,r,o,i){var u=null;return(u=e(n(t),o,i))?u:(u=e(n(r),o,i),u?u:null)}function o(n){return n}function i(t){return n.locale(t)}function u(n){return this.$options.locales[n]}var a=n.util,f=a.isObject,l=a.bind,s=c(n),d=p(n);return n.t=function(n){for(var e=arguments.length,u=Array(e>1?e-1:0),a=1;e>a;a++)u[a-1]=arguments[a];if(!n)return"";var c=t.apply(void 0,u),f=c.lang,l=c.fallback,s=c.params;return r(i,f,l,n,s)||o(n)},n.prototype.$t=function(n){if(!n)return"";for(var e=arguments.length,a=Array(e>1?e-1:0),c=1;e>c;c++)a[c-1]=arguments[c];var f=t.apply(void 0,a),s=f.lang,d=f.fallback,v=f.params,h=null;return this.$options.locales&&(h=r(l(u,this),s,d,n,v))?h:r(i,s,d,n,v)||o(n)},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),o(n,E,e),a(n,E,r),g(n)}function b(n,t){var e=n.config.silent;n.config.silent=!0,E||(E=new n({data:{lang:t}})),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 _=Object.create(null),m=void 0,A=void 0,$=void 0,j=/(%|)\{([0-9a-zA-Z_]+)\}/g,O=Object.create(null),k=0,C=1,U=2,P=3,S=0,N=1,V=2,q=3,x=4,z=5,L=6,I=7,Z=8,B=[];B[S]={ws:[S],ident:[q,k],"[":[x],eof:[I]},B[N]={ws:[N],".":[V],"[":[x],eof:[I]},B[V]={ws:[V],ident:[q,k]},B[q]={ident:[q,k],0:[q,k],number:[q,k],ws:[N,C],".":[V,C],"[":[x,C],eof:[I,C]},B[x]={"'":[z,k],'"':[L,k],"[":[x,U],"]":[N,P],eof:Z,"else":[x,k]},B[z]={"'":[x,k],eof:Z,"else":[z,k]},B[L]={'"':[x,k],eof:Z,"else":[L,k]};var D=/^\s?(true|false|-?[\d\.]+|'[^']*'|"[^"]*")\s?$/,E=void 0;return y.version="4.2.3","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){t.locale=function(t,r,o){return void 0===r?_[t]:void(null===r?(_[t]=void 0,delete _[t]):e(t,r,function(e){e?(_[t]=e,o&&o()):n("failed set `"+t+"` locale")}))}}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("lang",function(n,t){r(e)}))};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 u(n){return A||(A=n._data.__ob__.dep.constructor),A}function a(n,t,e){function r(n,t){var e=new a(t,n,null,{lazy:!0});return function(){return e.dirty&&e.evaluate(),c.target&&e.depend(),e.value}}var o=n.util.bind,a=i(t),c=u(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}})}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 1===r.length&&"object"===w["typeof"](r[0])&&(r=r[0]),r&&r.hasOwnProperty||(r={}),n.replace(j,function(t,o,i,u){var a=void 0;return"{"===n[u-1]&&"}"===n[u+t.length]?i:(a=e(r,i)?r[i]:null,null===a||void 0===a?"":a)})}var e=n.util.hasOwn;return t}function f(n){return D.test(n)}function l(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: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:f(t)?l(t):"*"+t}function v(n){function t(){var t=n[r+1];return o===z&&"'"===t||o===L&&'"'===t?(r++,a="\\"+t,h[k](),!0):void 0}var e=[],r=-1,o=S,i=0,u=void 0,a=void 0,c=void 0,f=void 0,l=void 0,v=void 0,p=void 0,h=[];for(h[C]=function(){void 0!==c&&(e.push(c),c=void 0)},h[k]=function(){void 0===c?c=a:c+=a},h[U]=function(){h[k](),i++},h[P]=function(){if(i>0)i--,o=x,h[k]();else{if(i=0,c=d(c),c===!1)return!1;h[C]()}};null!=o;)if(r++,u=n[r],"\\"!==u||!t()){if(f=s(u),p=B[o],l=p[f]||p["else"]||Z,l===Z)return;if(o=l[0],v=h[l[1]],v&&(a=l[2],a=void 0===a?u:a,v()===!1))return;if(o===I)return e.raw=n,e}}function p(n){var t=O[n];return t||(t=v(n),t&&(O[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(u(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,u=null,a=n,c=0;i>c;){var f=a[r[c]];if(void 0===f){a=null;break}a=f,c++}return u=a}var r=n.util,o=r.isObject,i=r.isPlainObject,u=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?l(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]),(l(e[1])||Array.isArray(e[1]))&&(e=e[1])),{lang:o,fallback:i,params:e}}function e(n,t,e){if(!n)return null;var r=v(n,t)||n[t];return r?e?d(r,e):r:null}function r(n,t,r,o,i){var u=null;return(u=e(n(t),o,i))?u:(u=e(n(r),o,i),u?u:null)}function o(n){return n}function i(t){return n.locale(t)}function u(n){return this.$options.locales[n]}function a(n,t){if(!n&&"string"!=typeof n)return null;var e=n.split("|");return t-=1,e[t]?e[t].trim():n}var f=n.util,l=f.isObject,s=f.bind,d=c(n),v=h(n);return n.t=function(n){for(var e=arguments.length,u=Array(e>1?e-1:0),a=1;e>a;a++)u[a-1]=arguments[a];if(!n)return"";var c=t.apply(void 0,u),f=c.lang,l=c.fallback,s=c.params;return r(i,f,l,n,s)||o(n)},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 e||(e=1),a(n.t.apply(n,[t].concat(o)),e)},n.prototype.$t=function(n){if(!n)return"";for(var e=arguments.length,a=Array(e>1?e-1:0),c=1;e>c;c++)a[c-1]=arguments[c];var f=t.apply(void 0,a),l=f.lang,d=f.fallback,v=f.params,p=null;return this.$options.locales&&(p=r(s(u,this),l,d,n,v))?p:r(i,l,d,n,v)||o(n)},n.prototype.$tc=function(n,t){if("number"!=typeof t&&"undefined"!=typeof t)return n;t||(t=1);for(var e=arguments.length,r=Array(e>2?e-2:0),o=2;e>o;o++)r[o-2]=arguments[o];return a(this.$t.apply(this,[n].concat(r)),t)},n}function g(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),o(n,E,e),a(n,E,r),y(n)}function b(n,t){var e=n.config.silent;n.config.silent=!0,E||(E=new n({data:{lang:t}})),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 _=Object.create(null),m=void 0,A=void 0,$=void 0,j=/(%|)\{([0-9a-zA-Z_]+)\}/g,O=Object.create(null),k=0,C=1,U=2,P=3,S=0,N=1,V=2,q=3,x=4,z=5,L=6,I=7,Z=8,B=[];B[S]={ws:[S],ident:[q,k],"[":[x],eof:[I]},B[N]={ws:[N],".":[V],"[":[x],eof:[I]},B[V]={ws:[V],ident:[q,k]},B[q]={ident:[q,k],0:[q,k],number:[q,k],ws:[N,C],".":[V,C],"[":[x,C],eof:[I,C]},B[x]={"'":[z,k],'"':[L,k],"[":[x,U],"]":[N,P],eof:Z,"else":[x,k]},B[z]={"'":[x,k],eof:Z,"else":[z,k]},B[L]={'"':[x,k],eof:Z,"else":[L,k]};var D=/^\s?(true|false|-?[\d\.]+|'[^']*'|"[^"]*")\s?$/,E=void 0;return g.version="4.3.0","undefined"!=typeof window&&window.Vue&&window.Vue.use(g),g}); |
{ | ||
"name": "vue-i18n", | ||
"description": "Internationalization plugin for Vue.js", | ||
"version": "4.2.3", | ||
"version": "4.3.0", | ||
"author": { | ||
@@ -26,2 +26,3 @@ "name": "kazuya kawaguchi", | ||
"git-commit-message-convention": "git://github.com/kazupon/git-commit-message-convention.git", | ||
"gitbook-cli": "^2.3.0", | ||
"istanbul-instrumenter-loader": "^0.2.0", | ||
@@ -78,3 +79,3 @@ "json-loader": "^0.5.4", | ||
"browser": "VUE_I18N_TYPE=browser karma start config/karma.conf.js", | ||
"build": "node config/build.js", | ||
"build": "node config/build.js && npm run docs:build", | ||
"changelog": "conventional-changelog -i CHANGELOG.md -s -n ./node_modules/git-commit-message-convention/convention.js", | ||
@@ -87,2 +88,4 @@ "ci": "npm run lint && npm run coverage && npm run coveralls && npm run sauce", | ||
"dev": "webpack-dev-server --quiet --config config/webpack.test.conf.js", | ||
"docs": "gitbook serve ./gitbook ./docs", | ||
"docs:build": "gitbook build ./gitbook ./docs", | ||
"e2e": "webpack-dev-server --quiet --config config/webpack.e2e.conf.js & mocha --opts test/e2e/mocha.opts --harmony test/e2e/test.js && kill $! || (kill $! && exit 1)", | ||
@@ -92,2 +95,3 @@ "ie": "VUE_I18N_TYPE=sauce SAUCE=batch2 karma start config/karma.conf.js", | ||
"mobile": "VUE_I18N_TYPE=sauce SAUCE=batch3 karma start config/karma.conf.js", | ||
"postinstall": "gitbook install ./gitbook", | ||
"proto": "webpack-dev-server --quite --config config/webpack.dev.conf.js --host 0.0.0.0", | ||
@@ -94,0 +98,0 @@ "release": "conventional-github-releaser -n ./node_modules/git-commit-message-convention/convention.js", |
@@ -57,3 +57,4 @@ import warn from './warn' | ||
if (process.env.NODE_ENV !== 'production') { | ||
warn('Fall back to translate the keypath "' + key + '" with "' + fallback + '" language.') | ||
warn('Fall back to translate the keypath "' + key + '" with "' | ||
+ fallback + '" language.') | ||
} | ||
@@ -83,2 +84,10 @@ return res | ||
function fetchChoice (locale, choice) { | ||
if (!locale && typeof locale !== 'string') { return null } | ||
const choices = locale.split('|') | ||
choice = choice - 1 | ||
if (!choices[choice]) { return locale } | ||
return choices[choice].trim() | ||
} | ||
/** | ||
@@ -99,3 +108,16 @@ * Vue.t | ||
/** | ||
* Vue.tc | ||
* | ||
* @param {String} key | ||
* @param {number|undefined} choice | ||
* @param {Array} ...args | ||
* @return {String} | ||
*/ | ||
Vue.tc = (key, choice, ...args) => { | ||
if (!choice) { choice = 1 } | ||
return fetchChoice(Vue.t(key, ...args), choice) | ||
} | ||
/** | ||
@@ -114,3 +136,5 @@ * $t | ||
if (this.$options.locales) { | ||
res = translate(bind(getComponentLocale, this), lang, fallback, key, params) | ||
res = translate( | ||
bind(getComponentLocale, this), lang, fallback, key, params | ||
) | ||
if (res) { return res } | ||
@@ -122,3 +146,19 @@ } | ||
/** | ||
* $tc | ||
* | ||
* @param {String} key | ||
* @param {number|undefined} choice | ||
* @param {Array} ...args | ||
* @return {String} | ||
*/ | ||
Vue.prototype.$tc = function (key, choice, ...args) { | ||
if (typeof choice !== 'number' | ||
&& typeof choice !== 'undefined') { return key } | ||
if (!choice) { choice = 1 } | ||
return fetchChoice(this.$t(key, ...args), choice) | ||
} | ||
return Vue | ||
} |
@@ -50,3 +50,3 @@ import warn from './warn' | ||
plugin.version = '4.2.3' | ||
plugin.version = '4.3.0' | ||
@@ -53,0 +53,0 @@ export default plugin |
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
Install scripts
Supply chain riskInstall scripts are run when the package is installed. The majority of malware in npm is hidden in install scripts.
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
75666
17
2252
53
41
1