diff --git a/dist/vue-i18n.common.js b/dist/vue-i18n.common.js index c54a7a811..2fec6436c 100644 --- a/dist/vue-i18n.common.js +++ b/dist/vue-i18n.common.js @@ -1,5 +1,5 @@ /*! - * vue-i18n v8.1.1 + * vue-i18n v8.2.0 * (c) 2018 kazuya kawaguchi * Released under the MIT License. */ @@ -756,7 +756,6 @@ function getPathCharType (ch) { case 0x2E: // . case 0x22: // " case 0x27: // ' - case 0x30: // 0 return ch case 0x5F: // _ @@ -775,15 +774,7 @@ function getPathCharType (ch) { return 'ws' } - // a-z, A-Z - if ((code >= 0x61 && code <= 0x7A) || (code >= 0x41 && code <= 0x5A)) { - return 'ident' - } - - // 1-9 - if (code >= 0x31 && code <= 0x39) { return 'number' } - - return 'else' + return 'ident' } /** @@ -976,6 +967,8 @@ var numberFormatKeys = [ 'localeMatcher', 'formatMatcher' ]; +var linkKeyMatcher = /(@:([\w\-_|.]+|\([\w\-_|.]+\)))/g; +var bracketsMatcher = /[()]/g; var VueI18n = function VueI18n (options) { var this$1 = this; @@ -1121,7 +1114,8 @@ VueI18n.prototype._interpolate = function _interpolate ( key, host, interpolateMode, - values + values, + visitedLinkStack ) { if (!message) { return null } @@ -1156,7 +1150,7 @@ VueI18n.prototype._interpolate = function _interpolate ( // Check for the existance of links within the translated string if (ret.indexOf('@:') >= 0) { - ret = this._link(locale, message, ret, host, interpolateMode, values); + ret = this._link(locale, message, ret, host, interpolateMode, values, visitedLinkStack); } return this._render(ret, interpolateMode, values) @@ -1168,7 +1162,8 @@ VueI18n.prototype._link = function _link ( str, host, interpolateMode, - values + values, + visitedLinkStack ) { var this$1 = this; @@ -1177,7 +1172,7 @@ VueI18n.prototype._link = function _link ( // Match all the links within the local // We are going to replace each of // them with its translation - var matches = ret.match(/(@:[\w\-_|.]+)/g); + var matches = ret.match(linkKeyMatcher); for (var idx in matches) { // ie compatible: filter custom array // prototype method @@ -1185,13 +1180,21 @@ VueI18n.prototype._link = function _link ( continue } var link = matches[idx]; - // Remove the leading @: - var linkPlaceholder = link.substr(2); + // Remove the leading @: and the brackets + var linkPlaceholder = link.substr(2).replace(bracketsMatcher, ''); + + if (visitedLinkStack.includes(linkPlaceholder)) { + warn(("Circular reference found. \"" + link + "\" is already visited in the chain of " + (visitedLinkStack.reverse().join(' <- ')))); + return ret + } + visitedLinkStack.push(linkPlaceholder); + // Translate the link var translated = this$1._interpolate( locale, message, linkPlaceholder, host, interpolateMode === 'raw' ? 'string' : interpolateMode, - interpolateMode === 'raw' ? undefined : values + interpolateMode === 'raw' ? undefined : values, + visitedLinkStack ); if (this$1._isFallbackRoot(translated)) { @@ -1211,6 +1214,8 @@ VueI18n.prototype._link = function _link ( Array.isArray(values) ? values : [values] ); + visitedLinkStack.pop(); + // Replace the link with the translated ret = !translated ? ret : ret.replace(link, translated); } @@ -1235,10 +1240,10 @@ VueI18n.prototype._translate = function _translate ( args ) { var res = - this._interpolate(locale, messages[locale], key, host, interpolateMode, args); + this._interpolate(locale, messages[locale], key, host, interpolateMode, args, [key]); if (!isNull(res)) { return res } - res = this._interpolate(fallback, messages[fallback], key, host, interpolateMode, args); + res = this._interpolate(fallback, messages[fallback], key, host, interpolateMode, args, [key]); if (!isNull(res)) { if (process.env.NODE_ENV !== 'production' && !this._silentTranslationWarn) { warn(("Fall back to translate the keypath '" + key + "' with '" + fallback + "' locale.")); @@ -1323,6 +1328,11 @@ VueI18n.prototype._tc = function _tc ( if (choice === undefined) { choice = 1; } + + var predefined = { 'count': choice, 'n': choice }; + var parsedArgs = parseArgs.apply(void 0, values); + parsedArgs.params = Object.assign(predefined, parsedArgs.params); + values = parsedArgs.locale === null ? [parsedArgs.params] : [parsedArgs.locale, parsedArgs.params]; return fetchChoice((ref = this)._t.apply(ref, [ key, _locale, messages, host ].concat( values )), choice) }; @@ -1583,6 +1593,6 @@ VueI18n.availabilities = { numberFormat: canUseNumberFormat }; VueI18n.install = install; -VueI18n.version = '8.1.1'; +VueI18n.version = '8.2.0'; module.exports = VueI18n; diff --git a/dist/vue-i18n.esm.js b/dist/vue-i18n.esm.js index ea81e9c92..839759af0 100644 --- a/dist/vue-i18n.esm.js +++ b/dist/vue-i18n.esm.js @@ -1,5 +1,5 @@ /*! - * vue-i18n v8.1.1 + * vue-i18n v8.2.0 * (c) 2018 kazuya kawaguchi * Released under the MIT License. */ @@ -754,7 +754,6 @@ function getPathCharType (ch) { case 0x2E: // . case 0x22: // " case 0x27: // ' - case 0x30: // 0 return ch case 0x5F: // _ @@ -773,15 +772,7 @@ function getPathCharType (ch) { return 'ws' } - // a-z, A-Z - if ((code >= 0x61 && code <= 0x7A) || (code >= 0x41 && code <= 0x5A)) { - return 'ident' - } - - // 1-9 - if (code >= 0x31 && code <= 0x39) { return 'number' } - - return 'else' + return 'ident' } /** @@ -974,6 +965,8 @@ var numberFormatKeys = [ 'localeMatcher', 'formatMatcher' ]; +var linkKeyMatcher = /(@:([\w\-_|.]+|\([\w\-_|.]+\)))/g; +var bracketsMatcher = /[()]/g; var VueI18n = function VueI18n (options) { var this$1 = this; @@ -1119,7 +1112,8 @@ VueI18n.prototype._interpolate = function _interpolate ( key, host, interpolateMode, - values + values, + visitedLinkStack ) { if (!message) { return null } @@ -1154,7 +1148,7 @@ VueI18n.prototype._interpolate = function _interpolate ( // Check for the existance of links within the translated string if (ret.indexOf('@:') >= 0) { - ret = this._link(locale, message, ret, host, interpolateMode, values); + ret = this._link(locale, message, ret, host, interpolateMode, values, visitedLinkStack); } return this._render(ret, interpolateMode, values) @@ -1166,7 +1160,8 @@ VueI18n.prototype._link = function _link ( str, host, interpolateMode, - values + values, + visitedLinkStack ) { var this$1 = this; @@ -1175,7 +1170,7 @@ VueI18n.prototype._link = function _link ( // Match all the links within the local // We are going to replace each of // them with its translation - var matches = ret.match(/(@:[\w\-_|.]+)/g); + var matches = ret.match(linkKeyMatcher); for (var idx in matches) { // ie compatible: filter custom array // prototype method @@ -1183,13 +1178,21 @@ VueI18n.prototype._link = function _link ( continue } var link = matches[idx]; - // Remove the leading @: - var linkPlaceholder = link.substr(2); + // Remove the leading @: and the brackets + var linkPlaceholder = link.substr(2).replace(bracketsMatcher, ''); + + if (visitedLinkStack.includes(linkPlaceholder)) { + warn(("Circular reference found. \"" + link + "\" is already visited in the chain of " + (visitedLinkStack.reverse().join(' <- ')))); + return ret + } + visitedLinkStack.push(linkPlaceholder); + // Translate the link var translated = this$1._interpolate( locale, message, linkPlaceholder, host, interpolateMode === 'raw' ? 'string' : interpolateMode, - interpolateMode === 'raw' ? undefined : values + interpolateMode === 'raw' ? undefined : values, + visitedLinkStack ); if (this$1._isFallbackRoot(translated)) { @@ -1209,6 +1212,8 @@ VueI18n.prototype._link = function _link ( Array.isArray(values) ? values : [values] ); + visitedLinkStack.pop(); + // Replace the link with the translated ret = !translated ? ret : ret.replace(link, translated); } @@ -1233,10 +1238,10 @@ VueI18n.prototype._translate = function _translate ( args ) { var res = - this._interpolate(locale, messages[locale], key, host, interpolateMode, args); + this._interpolate(locale, messages[locale], key, host, interpolateMode, args, [key]); if (!isNull(res)) { return res } - res = this._interpolate(fallback, messages[fallback], key, host, interpolateMode, args); + res = this._interpolate(fallback, messages[fallback], key, host, interpolateMode, args, [key]); if (!isNull(res)) { if (process.env.NODE_ENV !== 'production' && !this._silentTranslationWarn) { warn(("Fall back to translate the keypath '" + key + "' with '" + fallback + "' locale.")); @@ -1321,6 +1326,11 @@ VueI18n.prototype._tc = function _tc ( if (choice === undefined) { choice = 1; } + + var predefined = { 'count': choice, 'n': choice }; + var parsedArgs = parseArgs.apply(void 0, values); + parsedArgs.params = Object.assign(predefined, parsedArgs.params); + values = parsedArgs.locale === null ? [parsedArgs.params] : [parsedArgs.locale, parsedArgs.params]; return fetchChoice((ref = this)._t.apply(ref, [ key, _locale, messages, host ].concat( values )), choice) }; @@ -1581,6 +1591,6 @@ VueI18n.availabilities = { numberFormat: canUseNumberFormat }; VueI18n.install = install; -VueI18n.version = '8.1.1'; +VueI18n.version = '8.2.0'; export default VueI18n; diff --git a/dist/vue-i18n.js b/dist/vue-i18n.js index e5f470ec4..6bed485ae 100644 --- a/dist/vue-i18n.js +++ b/dist/vue-i18n.js @@ -1,5 +1,5 @@ /*! - * vue-i18n v8.1.1 + * vue-i18n v8.2.0 * (c) 2018 kazuya kawaguchi * Released under the MIT License. */ @@ -760,7 +760,6 @@ case 0x2E: // . case 0x22: // " case 0x27: // ' - case 0x30: // 0 return ch case 0x5F: // _ @@ -779,15 +778,7 @@ return 'ws' } - // a-z, A-Z - if ((code >= 0x61 && code <= 0x7A) || (code >= 0x41 && code <= 0x5A)) { - return 'ident' - } - - // 1-9 - if (code >= 0x31 && code <= 0x39) { return 'number' } - - return 'else' + return 'ident' } /** @@ -980,6 +971,8 @@ 'localeMatcher', 'formatMatcher' ]; + var linkKeyMatcher = /(@:([\w\-_|.]+|\([\w\-_|.]+\)))/g; + var bracketsMatcher = /[()]/g; var VueI18n = function VueI18n (options) { var this$1 = this; @@ -1125,7 +1118,8 @@ key, host, interpolateMode, - values + values, + visitedLinkStack ) { if (!message) { return null } @@ -1160,7 +1154,7 @@ // Check for the existance of links within the translated string if (ret.indexOf('@:') >= 0) { - ret = this._link(locale, message, ret, host, interpolateMode, values); + ret = this._link(locale, message, ret, host, interpolateMode, values, visitedLinkStack); } return this._render(ret, interpolateMode, values) @@ -1172,7 +1166,8 @@ str, host, interpolateMode, - values + values, + visitedLinkStack ) { var this$1 = this; @@ -1181,7 +1176,7 @@ // Match all the links within the local // We are going to replace each of // them with its translation - var matches = ret.match(/(@:[\w\-_|.]+)/g); + var matches = ret.match(linkKeyMatcher); for (var idx in matches) { // ie compatible: filter custom array // prototype method @@ -1189,13 +1184,21 @@ continue } var link = matches[idx]; - // Remove the leading @: - var linkPlaceholder = link.substr(2); + // Remove the leading @: and the brackets + var linkPlaceholder = link.substr(2).replace(bracketsMatcher, ''); + + if (visitedLinkStack.includes(linkPlaceholder)) { + warn(("Circular reference found. \"" + link + "\" is already visited in the chain of " + (visitedLinkStack.reverse().join(' <- ')))); + return ret + } + visitedLinkStack.push(linkPlaceholder); + // Translate the link var translated = this$1._interpolate( locale, message, linkPlaceholder, host, interpolateMode === 'raw' ? 'string' : interpolateMode, - interpolateMode === 'raw' ? undefined : values + interpolateMode === 'raw' ? undefined : values, + visitedLinkStack ); if (this$1._isFallbackRoot(translated)) { @@ -1215,6 +1218,8 @@ Array.isArray(values) ? values : [values] ); + visitedLinkStack.pop(); + // Replace the link with the translated ret = !translated ? ret : ret.replace(link, translated); } @@ -1239,10 +1244,10 @@ args ) { var res = - this._interpolate(locale, messages[locale], key, host, interpolateMode, args); + this._interpolate(locale, messages[locale], key, host, interpolateMode, args, [key]); if (!isNull(res)) { return res } - res = this._interpolate(fallback, messages[fallback], key, host, interpolateMode, args); + res = this._interpolate(fallback, messages[fallback], key, host, interpolateMode, args, [key]); if (!isNull(res)) { if (!this._silentTranslationWarn) { warn(("Fall back to translate the keypath '" + key + "' with '" + fallback + "' locale.")); @@ -1327,6 +1332,11 @@ if (choice === undefined) { choice = 1; } + + var predefined = { 'count': choice, 'n': choice }; + var parsedArgs = parseArgs.apply(void 0, values); + parsedArgs.params = Object.assign(predefined, parsedArgs.params); + values = parsedArgs.locale === null ? [parsedArgs.params] : [parsedArgs.locale, parsedArgs.params]; return fetchChoice((ref = this)._t.apply(ref, [ key, _locale, messages, host ].concat( values )), choice) }; @@ -1587,7 +1597,7 @@ numberFormat: canUseNumberFormat }; VueI18n.install = install; - VueI18n.version = '8.1.1'; + VueI18n.version = '8.2.0'; return VueI18n; diff --git a/dist/vue-i18n.min.js b/dist/vue-i18n.min.js index f3b9739b1..3a25e092c 100644 --- a/dist/vue-i18n.min.js +++ b/dist/vue-i18n.min.js @@ -1,6 +1,6 @@ /*! - * vue-i18n v8.1.1 + * vue-i18n v8.2.0 * (c) 2018 kazuya kawaguchi * Released under the MIT License. */ -!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):t.VueI18n=e()}(this,function(){"use strict";function t(t,e){"undefined"!=typeof console&&(console.warn("[vue-i18n] "+t),e&&console.warn(e.stack))}function e(t){return null!==t&&"object"==typeof t}function n(t){return N.call(t)===M}function r(t){return null===t||void 0===t}function i(){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 o(t,e){return t=Math.abs(t),2===e?a(t):t?Math.min(t,2):0}function s(t,e){if(!t&&"string"!=typeof t)return null;var n=t.split("|");return e=o(e,n.length),n[e]?n[e].trim():t}function c(t){return JSON.parse(JSON.stringify(t))}function l(t,e){if(t.length){var n=t.indexOf(e);if(n>-1)return t.splice(n,1)}}function u(t,e){return W.call(t,e)}function f(t){for(var n=arguments,r=Object(t),i=1;i0;)e[n]=arguments[n+1];var r=this.$i18n;return r._t.apply(r,[t,r.locale,r._getMessages(),this].concat(e))},t.prototype.$tc=function(t,e){for(var n=[],r=arguments.length-2;r-- >0;)n[r]=arguments[r+2];var i=this.$i18n;return i._tc.apply(i,[t,i.locale,i._getMessages(),this,e].concat(n))},t.prototype.$te=function(t,e){var n=this.$i18n;return n._te(t,n.locale,n._getMessages(),e)},t.prototype.$d=function(t){for(var e,n=[],r=arguments.length-1;r-- >0;)n[r]=arguments[r+1];return(e=this.$i18n).d.apply(e,[t].concat(n))},t.prototype.$n=function(t){for(var e,n=[],r=arguments.length-1;r-- >0;)n[r]=arguments[r+1];return(e=this.$i18n).n.apply(e,[t].concat(n))}}function m(t,e,n){v(t,n)&&d(t,e,n)}function _(t,e,n,r){v(t,n)&&(y(t,n)&&h(e.value,e.oldValue)||d(t,e,n))}function g(e,n,r,i){if(!r.context)return void t("Vue instance does not exists in VNode context");e.textContent="",e._vt=void 0,delete e._vt,e._locale=void 0,delete e._locale}function v(e,n){var r=n.context;return r?!!r.$i18n||(t("VueI18n instance does not exists in Vue instance"),!1):(t("Vue instance doest not exists in VNode context"),!1)}function y(t,e){var n=e.context;return t._locale===n.$i18n.locale}function d(e,n,r){var i,a,o=n.value,s=b(o),c=s.path,l=s.locale,u=s.args,f=s.choice;if(!c&&!l&&!u)return void t("value type not supported");if(!c)return void t("`path` is required in v-t directive");var h=r.context;e._vt=e.textContent=f?(i=h.$i18n).tc.apply(i,[c,f].concat($(l,u))):(a=h.$i18n).t.apply(a,[c].concat($(l,u))),e._locale=h.$i18n.locale}function b(t){var e,r,i,a;return"string"==typeof t?e=t:n(t)&&(e=t.path,r=t.locale,i=t.args,a=t.choice),{path:e,locale:r,args:i,choice:a}}function $(t,e){var r=[];return t&&r.push(t),e&&(Array.isArray(e)||n(e))&&r.push(e),r}function F(t){F.installed=!0,j=t;j.version&&Number(j.version.split(".")[0]);p(j),j.mixin(V),j.directive("t",{bind:m,update:_,unbind:g}),j.component(C.name,C),j.config.optionMergeStrategies.i18n=function(t,e){return void 0===e?t:e}}function w(t){for(var e=[],n=0,r="";n=97&&e<=122||e>=65&&e<=90?"ident":e>=49&&e<=57?"number":"else"}function A(t){var e=t.trim();return("0"!==t.charAt(0)||!isNaN(t))&&(T(e)?x(e):"*"+e)}function L(t){var e,n,r,i,a,o,s,c=[],l=-1,u=G,f=0,h=[];for(h[J]=function(){void 0!==n&&(c.push(n),n=void 0)},h[z]=function(){void 0===n?n=r:n+=r},h[U]=function(){h[z](),f++},h[q]=function(){if(f>0)f--,u=B,h[z]();else{if(f=0,!1===(n=A(n)))return!1;h[J]()}};null!==u;)if(l++,"\\"!==(e=t[l])||!function(){var e=t[l+1];if(u===H&&"'"===e||u===K&&'"'===e)return l++,r="\\"+e,h[z](),!0}()){if(i=D(e),s=Y[u],(a=s[i]||s.else||X)===X)return;if(u=a[0],(o=h[a[1]])&&(r=a[2],r=void 0===r?e:r,!1===o()))return;if(u===Q)return c}}function O(t){return!!Array.isArray(t)&&0===t.length}var j,N=Object.prototype.toString,M="[object Object]",W=Object.prototype.hasOwnProperty,I="undefined"!=typeof Intl&&void 0!==Intl.DateTimeFormat,S="undefined"!=typeof Intl&&void 0!==Intl.NumberFormat,V={beforeCreate:function(){var t=this.$options;if(t.i18n=t.i18n||(t.__i18n?{}:null),t.i18n){if(t.i18n instanceof nt){if(t.__i18n)try{var e={};t.__i18n.forEach(function(t){e=f(e,JSON.parse(t))}),Object.keys(e).forEach(function(n){t.i18n.mergeLocaleMessage(n,e[n])})}catch(t){}this._i18n=t.i18n,this._i18nWatcher=this._i18n.watchI18nData(),this._i18n.subscribeDataChanging(this),this._subscribing=!0}else if(n(t.i18n)){if(this.$root&&this.$root.$i18n&&this.$root.$i18n instanceof nt&&(t.i18n.root=this.$root.$i18n,t.i18n.formatter=this.$root.$i18n.formatter,t.i18n.fallbackLocale=this.$root.$i18n.fallbackLocale,t.i18n.silentTranslationWarn=this.$root.$i18n.silentTranslationWarn),t.__i18n)try{var r={};t.__i18n.forEach(function(t){r=f(r,JSON.parse(t))}),t.i18n.messages=r}catch(t){}this._i18n=new nt(t.i18n),this._i18nWatcher=this._i18n.watchI18nData(),this._i18n.subscribeDataChanging(this),this._subscribing=!0,(void 0===t.i18n.sync||t.i18n.sync)&&(this._localeWatcher=this.$i18n.watchLocale())}}else this.$root&&this.$root.$i18n&&this.$root.$i18n instanceof nt?(this._i18n=this.$root.$i18n,this._i18n.subscribeDataChanging(this),this._subscribing=!0):t.parent&&t.parent.$i18n&&t.parent.$i18n instanceof nt&&(this._i18n=t.parent.$i18n,this._i18n.subscribeDataChanging(this),this._subscribing=!0)},beforeDestroy:function(){this._i18n&&(this._subscribing&&(this._i18n.unsubscribeDataChanging(this),delete this._subscribing),this._i18nWatcher&&(this._i18nWatcher(),delete this._i18nWatcher),this._localeWatcher&&(this._localeWatcher(),delete this._localeWatcher),this._i18n=null)}},C={name:"i18n",functional:!0,props:{tag:{type:String,default:"span"},path:{type:String,required:!0},locale:{type:String},places:{type:[Array,Object]}},render:function(e,n){var r=n.props,i=n.data,a=n.children,o=n.parent,s=o.$i18n;if(a=(a||[]).filter(function(t){return t.tag||(t.text=t.text.trim())}),!s)return a;var c=r.path,l=r.locale,u={},f=r.places||{},h=Array.isArray(f)?f.length>0:Object.keys(f).length>0,p=a.every(function(t){if(t.data&&t.data.attrs){var e=t.data.attrs.place;return void 0!==e&&""!==e}});return h&&a.length>0&&!p&&t("If places prop is set, all child elements must have place prop set."),Array.isArray(f)?f.forEach(function(t,e){u[e]=t}):Object.keys(f).forEach(function(t){u[t]=f[t]}),a.forEach(function(t,e){var n=p?""+t.data.attrs.place:""+e;u[n]=t}),e(r.tag,i,s.i(c,l,u))}},E=function(){this._caches=Object.create(null)};E.prototype.interpolate=function(t,e){if(!e)return[t];var n=this._caches[t];return n||(n=w(t),this._caches[t]=n),k(n,e)};var R=/^(\d)+/,P=/^(\w)+/,z=0,J=1,U=2,q=3,G=0,B=4,H=5,K=6,Q=7,X=8,Y=[];Y[G]={ws:[G],ident:[3,z],"[":[B],eof:[Q]},Y[1]={ws:[1],".":[2],"[":[B],eof:[Q]},Y[2]={ws:[2],ident:[3,z],0:[3,z],number:[3,z]},Y[3]={ident:[3,z],0:[3,z],number:[3,z],ws:[1,J],".":[2,J],"[":[B,J],eof:[Q,J]},Y[B]={"'":[H,z],'"':[K,z],"[":[B,U],"]":[1,q],eof:X,else:[B,z]},Y[H]={"'":[B,z],eof:X,else:[H,z]},Y[K]={'"':[B,z],eof:X,else:[K,z]};var Z=/^\s?(true|false|-?[\d.]+|'[^']*'|"[^"]*")\s?$/,tt=function(){this._cache=Object.create(null)};tt.prototype.parsePath=function(t){var e=this._cache[t];return e||(e=L(t))&&(this._cache[t]=e),e||[]},tt.prototype.getPathValue=function(t,n){if(!e(t))return null;var r=this.parsePath(n);if(O(r))return null;for(var i=r.length,a=t,o=0;o=0&&(l=this._link(t,e,l,a,o,s)),this._render(l,o,s)},nt.prototype._link=function(t,e,n,r,i,a){var o=this,s=n,c=s.match(/(@:[\w\-_|.]+)/g);for(var l in c)if(c.hasOwnProperty(l)){var u=c[l],f=u.substr(2),h=o._interpolate(t,e,f,r,"raw"===i?"string":i,"raw"===i?void 0:a);if(o._isFallbackRoot(h)){if(!o._root)throw Error("unexpected error");var p=o._root;h=p._translate(p._getMessages(),p.locale,p.fallbackLocale,f,r,i,a)}h=o._warnDefault(t,f,h,r,Array.isArray(a)?a:[a]),s=h?s.replace(u,h):s}return s},nt.prototype._render=function(t,e,n){var r=this._formatter.interpolate(t,n);return"string"===e?r.join(""):r},nt.prototype._translate=function(t,e,n,i,a,o,s){var c=this._interpolate(e,t[e],i,a,o,s);return r(c)?(c=this._interpolate(n,t[n],i,a,o,s),r(c)?null:c):c},nt.prototype._t=function(t,e,n,r){for(var a,o=[],s=arguments.length-4;s-- >0;)o[s]=arguments[s+4];if(!t)return"";var c=i.apply(void 0,o),l=c.locale||e,u=this._translate(n,l,this.fallbackLocale,t,r,"string",c.params);if(this._isFallbackRoot(u)){if(!this._root)throw Error("unexpected error");return(a=this._root).t.apply(a,[t].concat(o))}return this._warnDefault(l,t,u,r,o)},nt.prototype.t=function(t){for(var e,n=[],r=arguments.length-1;r-- >0;)n[r]=arguments[r+1];return(e=this)._t.apply(e,[t,this.locale,this._getMessages(),null].concat(n))},nt.prototype._i=function(t,e,n,r,i){var a=this._translate(n,e,this.fallbackLocale,t,r,"raw",i);if(this._isFallbackRoot(a)){if(!this._root)throw Error("unexpected error");return this._root.i(t,e,i)}return this._warnDefault(e,t,a,r,[i])},nt.prototype.i=function(t,e,n){return t?("string"!=typeof e&&(e=this.locale),this._i(t,e,this._getMessages(),null,n)):""},nt.prototype._tc=function(t,e,n,r,i){for(var a,o=[],c=arguments.length-5;c-- >0;)o[c]=arguments[c+5];return t?(void 0===i&&(i=1),s((a=this)._t.apply(a,[t,e,n,r].concat(o)),i)):""},nt.prototype.tc=function(t,e){for(var n,r=[],i=arguments.length-2;i-- >0;)r[i]=arguments[i+2];return(n=this)._tc.apply(n,[t,this.locale,this._getMessages(),null,e].concat(r))},nt.prototype._te=function(t,e,n){for(var r=[],a=arguments.length-3;a-- >0;)r[a]=arguments[a+3];var o=i.apply(void 0,r).locale||e;return this._exist(n[o],t)},nt.prototype.te=function(t,e){return this._te(t,this.locale,this._getMessages(),e)},nt.prototype.getLocaleMessage=function(t){return c(this._vm.messages[t]||{})},nt.prototype.setLocaleMessage=function(t,e){this._vm.$set(this._vm.messages,t,e)},nt.prototype.mergeLocaleMessage=function(t,e){this._vm.$set(this._vm.messages,t,j.util.extend(this._vm.messages[t]||{},e))},nt.prototype.getDateTimeFormat=function(t){return c(this._vm.dateTimeFormats[t]||{})},nt.prototype.setDateTimeFormat=function(t,e){this._vm.$set(this._vm.dateTimeFormats,t,e)},nt.prototype.mergeDateTimeFormat=function(t,e){this._vm.$set(this._vm.dateTimeFormats,t,j.util.extend(this._vm.dateTimeFormats[t]||{},e))},nt.prototype._localizeDateTime=function(t,e,n,i,a){var o=e,s=i[o];if((r(s)||r(s[a]))&&(o=n,s=i[o]),r(s)||r(s[a]))return null;var c=s[a],l=o+"__"+a,u=this._dateTimeFormatters[l];return u||(u=this._dateTimeFormatters[l]=new Intl.DateTimeFormat(o,c)),u.format(t)},nt.prototype._d=function(t,e,n){if(!n)return new Intl.DateTimeFormat(e).format(t);var r=this._localizeDateTime(t,e,this.fallbackLocale,this._getDateTimeFormats(),n);if(this._isFallbackRoot(r)){if(!this._root)throw Error("unexpected error");return this._root.d(t,n,e)}return r||""},nt.prototype.d=function(t){for(var n=[],r=arguments.length-1;r-- >0;)n[r]=arguments[r+1];var i=this.locale,a=null;return 1===n.length?"string"==typeof n[0]?a=n[0]:e(n[0])&&(n[0].locale&&(i=n[0].locale),n[0].key&&(a=n[0].key)):2===n.length&&("string"==typeof n[0]&&(a=n[0]),"string"==typeof n[1]&&(i=n[1])),this._d(t,i,a)},nt.prototype.getNumberFormat=function(t){return c(this._vm.numberFormats[t]||{})},nt.prototype.setNumberFormat=function(t,e){this._vm.$set(this._vm.numberFormats,t,e)},nt.prototype.mergeNumberFormat=function(t,e){this._vm.$set(this._vm.numberFormats,t,j.util.extend(this._vm.numberFormats[t]||{},e))},nt.prototype._localizeNumber=function(t,e,n,i,a,o){var s=e,c=i[s];if((r(c)||r(c[a]))&&(s=n,c=i[s]),r(c)||r(c[a]))return null;var l,u=c[a];if(o)l=new Intl.NumberFormat(s,Object.assign({},u,o));else{var f=s+"__"+a;l=this._numberFormatters[f],l||(l=this._numberFormatters[f]=new Intl.NumberFormat(s,u))}return l.format(t)},nt.prototype._n=function(t,e,n,r){if(!n){return(r?new Intl.NumberFormat(e,r):new Intl.NumberFormat(e)).format(t)}var i=this._localizeNumber(t,e,this.fallbackLocale,this._getNumberFormats(),n,r);if(this._isFallbackRoot(i)){if(!this._root)throw Error("unexpected error");return this._root.n(t,Object.assign({},{key:n,locale:e},r))}return i||""},nt.prototype.n=function(t){for(var n=[],r=arguments.length-1;r-- >0;)n[r]=arguments[r+1];var i=this.locale,a=null,o=null;return 1===n.length?"string"==typeof n[0]?a=n[0]:e(n[0])&&(n[0].locale&&(i=n[0].locale),n[0].key&&(a=n[0].key),o=Object.keys(n[0]).reduce(function(t,e){var r;return et.includes(e)?Object.assign({},t,(r={},r[e]=n[0][e],r)):t},null)):2===n.length&&("string"==typeof n[0]&&(a=n[0]),"string"==typeof n[1]&&(i=n[1])),this._n(t,i,a,o)},Object.defineProperties(nt.prototype,rt),nt.availabilities={dateTimeFormat:I,numberFormat:S},nt.install=F,nt.version="8.1.1",nt}); \ No newline at end of file +!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):t.VueI18n=e()}(this,function(){"use strict";function t(t,e){"undefined"!=typeof console&&(console.warn("[vue-i18n] "+t),e&&console.warn(e.stack))}function e(t){return null!==t&&"object"==typeof t}function n(t){return N.call(t)===M}function r(t){return null===t||void 0===t}function i(){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 o(t,e){return t=Math.abs(t),2===e?a(t):t?Math.min(t,2):0}function s(t,e){if(!t&&"string"!=typeof t)return null;var n=t.split("|");return e=o(e,n.length),n[e]?n[e].trim():t}function c(t){return JSON.parse(JSON.stringify(t))}function l(t,e){if(t.length){var n=t.indexOf(e);if(n>-1)return t.splice(n,1)}}function u(t,e){return W.call(t,e)}function f(t){for(var n=arguments,r=Object(t),i=1;i0;)e[n]=arguments[n+1];var r=this.$i18n;return r._t.apply(r,[t,r.locale,r._getMessages(),this].concat(e))},t.prototype.$tc=function(t,e){for(var n=[],r=arguments.length-2;r-- >0;)n[r]=arguments[r+2];var i=this.$i18n;return i._tc.apply(i,[t,i.locale,i._getMessages(),this,e].concat(n))},t.prototype.$te=function(t,e){var n=this.$i18n;return n._te(t,n.locale,n._getMessages(),e)},t.prototype.$d=function(t){for(var e,n=[],r=arguments.length-1;r-- >0;)n[r]=arguments[r+1];return(e=this.$i18n).d.apply(e,[t].concat(n))},t.prototype.$n=function(t){for(var e,n=[],r=arguments.length-1;r-- >0;)n[r]=arguments[r+1];return(e=this.$i18n).n.apply(e,[t].concat(n))}}function m(t,e,n){v(t,n)&&d(t,e,n)}function _(t,e,n,r){v(t,n)&&(y(t,n)&&h(e.value,e.oldValue)||d(t,e,n))}function g(e,n,r,i){if(!r.context)return void t("Vue instance does not exists in VNode context");e.textContent="",e._vt=void 0,delete e._vt,e._locale=void 0,delete e._locale}function v(e,n){var r=n.context;return r?!!r.$i18n||(t("VueI18n instance does not exists in Vue instance"),!1):(t("Vue instance doest not exists in VNode context"),!1)}function y(t,e){var n=e.context;return t._locale===n.$i18n.locale}function d(e,n,r){var i,a,o=n.value,s=b(o),c=s.path,l=s.locale,u=s.args,f=s.choice;if(!c&&!l&&!u)return void t("value type not supported");if(!c)return void t("`path` is required in v-t directive");var h=r.context;e._vt=e.textContent=f?(i=h.$i18n).tc.apply(i,[c,f].concat($(l,u))):(a=h.$i18n).t.apply(a,[c].concat($(l,u))),e._locale=h.$i18n.locale}function b(t){var e,r,i,a;return"string"==typeof t?e=t:n(t)&&(e=t.path,r=t.locale,i=t.args,a=t.choice),{path:e,locale:r,args:i,choice:a}}function $(t,e){var r=[];return t&&r.push(t),e&&(Array.isArray(e)||n(e))&&r.push(e),r}function F(t){F.installed=!0,j=t;j.version&&Number(j.version.split(".")[0]);p(j),j.mixin(V),j.directive("t",{bind:m,update:_,unbind:g}),j.component(C.name,C),j.config.optionMergeStrategies.i18n=function(t,e){return void 0===e?t:e}}function w(t){for(var e=[],n=0,r="";n0)f--,u=B,h[z]();else{if(f=0,!1===(n=A(n)))return!1;h[J]()}};null!==u;)if(l++,"\\"!==(e=t[l])||!function(){var e=t[l+1];if(u===H&&"'"===e||u===K&&'"'===e)return l++,r="\\"+e,h[z](),!0}()){if(i=D(e),s=Y[u],(a=s[i]||s.else||X)===X)return;if(u=a[0],(o=h[a[1]])&&(r=a[2],r=void 0===r?e:r,!1===o()))return;if(u===Q)return c}}function L(t){return!!Array.isArray(t)&&0===t.length}var j,N=Object.prototype.toString,M="[object Object]",W=Object.prototype.hasOwnProperty,I="undefined"!=typeof Intl&&void 0!==Intl.DateTimeFormat,S="undefined"!=typeof Intl&&void 0!==Intl.NumberFormat,V={beforeCreate:function(){var t=this.$options;if(t.i18n=t.i18n||(t.__i18n?{}:null),t.i18n){if(t.i18n instanceof it){if(t.__i18n)try{var e={};t.__i18n.forEach(function(t){e=f(e,JSON.parse(t))}),Object.keys(e).forEach(function(n){t.i18n.mergeLocaleMessage(n,e[n])})}catch(t){}this._i18n=t.i18n,this._i18nWatcher=this._i18n.watchI18nData(),this._i18n.subscribeDataChanging(this),this._subscribing=!0}else if(n(t.i18n)){if(this.$root&&this.$root.$i18n&&this.$root.$i18n instanceof it&&(t.i18n.root=this.$root.$i18n,t.i18n.formatter=this.$root.$i18n.formatter,t.i18n.fallbackLocale=this.$root.$i18n.fallbackLocale,t.i18n.silentTranslationWarn=this.$root.$i18n.silentTranslationWarn),t.__i18n)try{var r={};t.__i18n.forEach(function(t){r=f(r,JSON.parse(t))}),t.i18n.messages=r}catch(t){}this._i18n=new it(t.i18n),this._i18nWatcher=this._i18n.watchI18nData(),this._i18n.subscribeDataChanging(this),this._subscribing=!0,(void 0===t.i18n.sync||t.i18n.sync)&&(this._localeWatcher=this.$i18n.watchLocale())}}else this.$root&&this.$root.$i18n&&this.$root.$i18n instanceof it?(this._i18n=this.$root.$i18n,this._i18n.subscribeDataChanging(this),this._subscribing=!0):t.parent&&t.parent.$i18n&&t.parent.$i18n instanceof it&&(this._i18n=t.parent.$i18n,this._i18n.subscribeDataChanging(this),this._subscribing=!0)},beforeDestroy:function(){this._i18n&&(this._subscribing&&(this._i18n.unsubscribeDataChanging(this),delete this._subscribing),this._i18nWatcher&&(this._i18nWatcher(),delete this._i18nWatcher),this._localeWatcher&&(this._localeWatcher(),delete this._localeWatcher),this._i18n=null)}},C={name:"i18n",functional:!0,props:{tag:{type:String,default:"span"},path:{type:String,required:!0},locale:{type:String},places:{type:[Array,Object]}},render:function(e,n){var r=n.props,i=n.data,a=n.children,o=n.parent,s=o.$i18n;if(a=(a||[]).filter(function(t){return t.tag||(t.text=t.text.trim())}),!s)return a;var c=r.path,l=r.locale,u={},f=r.places||{},h=Array.isArray(f)?f.length>0:Object.keys(f).length>0,p=a.every(function(t){if(t.data&&t.data.attrs){var e=t.data.attrs.place;return void 0!==e&&""!==e}});return h&&a.length>0&&!p&&t("If places prop is set, all child elements must have place prop set."),Array.isArray(f)?f.forEach(function(t,e){u[e]=t}):Object.keys(f).forEach(function(t){u[t]=f[t]}),a.forEach(function(t,e){var n=p?""+t.data.attrs.place:""+e;u[n]=t}),e(r.tag,i,s.i(c,l,u))}},E=function(){this._caches=Object.create(null)};E.prototype.interpolate=function(t,e){if(!e)return[t];var n=this._caches[t];return n||(n=w(t),this._caches[t]=n),k(n,e)};var R=/^(\d)+/,P=/^(\w)+/,z=0,J=1,U=2,q=3,G=0,B=4,H=5,K=6,Q=7,X=8,Y=[];Y[G]={ws:[G],ident:[3,z],"[":[B],eof:[Q]},Y[1]={ws:[1],".":[2],"[":[B],eof:[Q]},Y[2]={ws:[2],ident:[3,z],0:[3,z],number:[3,z]},Y[3]={ident:[3,z],0:[3,z],number:[3,z],ws:[1,J],".":[2,J],"[":[B,J],eof:[Q,J]},Y[B]={"'":[H,z],'"':[K,z],"[":[B,U],"]":[1,q],eof:X,else:[B,z]},Y[H]={"'":[B,z],eof:X,else:[H,z]},Y[K]={'"':[B,z],eof:X,else:[K,z]};var Z=/^\s?(true|false|-?[\d.]+|'[^']*'|"[^"]*")\s?$/,tt=function(){this._cache=Object.create(null)};tt.prototype.parsePath=function(t){var e=this._cache[t];return e||(e=O(t))&&(this._cache[t]=e),e||[]},tt.prototype.getPathValue=function(t,n){if(!e(t))return null;var r=this.parsePath(n);if(L(r))return null;for(var i=r.length,a=t,o=0;o=0&&(u=this._link(t,e,u,a,o,s,c)),this._render(u,o,s)},it.prototype._link=function(e,n,r,i,a,o,s){var c=this,l=r,u=l.match(nt);for(var f in u)if(u.hasOwnProperty(f)){var h=u[f],p=h.substr(2).replace(rt,"");if(s.includes(p))return t('Circular reference found. "'+h+'" is already visited in the chain of '+s.reverse().join(" <- ")),l;s.push(p);var m=c._interpolate(e,n,p,i,"raw"===a?"string":a,"raw"===a?void 0:o,s);if(c._isFallbackRoot(m)){if(!c._root)throw Error("unexpected error");var _=c._root;m=_._translate(_._getMessages(),_.locale,_.fallbackLocale,p,i,a,o)}m=c._warnDefault(e,p,m,i,Array.isArray(o)?o:[o]),s.pop(),l=m?l.replace(h,m):l}return l},it.prototype._render=function(t,e,n){var r=this._formatter.interpolate(t,n);return"string"===e?r.join(""):r},it.prototype._translate=function(t,e,n,i,a,o,s){var c=this._interpolate(e,t[e],i,a,o,s,[i]);return r(c)?(c=this._interpolate(n,t[n],i,a,o,s,[i]),r(c)?null:c):c},it.prototype._t=function(t,e,n,r){for(var a,o=[],s=arguments.length-4;s-- >0;)o[s]=arguments[s+4];if(!t)return"";var c=i.apply(void 0,o),l=c.locale||e,u=this._translate(n,l,this.fallbackLocale,t,r,"string",c.params);if(this._isFallbackRoot(u)){if(!this._root)throw Error("unexpected error");return(a=this._root).t.apply(a,[t].concat(o))}return this._warnDefault(l,t,u,r,o)},it.prototype.t=function(t){for(var e,n=[],r=arguments.length-1;r-- >0;)n[r]=arguments[r+1];return(e=this)._t.apply(e,[t,this.locale,this._getMessages(),null].concat(n))},it.prototype._i=function(t,e,n,r,i){var a=this._translate(n,e,this.fallbackLocale,t,r,"raw",i);if(this._isFallbackRoot(a)){if(!this._root)throw Error("unexpected error");return this._root.i(t,e,i)}return this._warnDefault(e,t,a,r,[i])},it.prototype.i=function(t,e,n){return t?("string"!=typeof e&&(e=this.locale),this._i(t,e,this._getMessages(),null,n)):""},it.prototype._tc=function(t,e,n,r,a){for(var o,c=[],l=arguments.length-5;l-- >0;)c[l]=arguments[l+5];if(!t)return"";void 0===a&&(a=1);var u={count:a,n:a},f=i.apply(void 0,c);return f.params=Object.assign(u,f.params),c=null===f.locale?[f.params]:[f.locale,f.params],s((o=this)._t.apply(o,[t,e,n,r].concat(c)),a)},it.prototype.tc=function(t,e){for(var n,r=[],i=arguments.length-2;i-- >0;)r[i]=arguments[i+2];return(n=this)._tc.apply(n,[t,this.locale,this._getMessages(),null,e].concat(r))},it.prototype._te=function(t,e,n){for(var r=[],a=arguments.length-3;a-- >0;)r[a]=arguments[a+3];var o=i.apply(void 0,r).locale||e;return this._exist(n[o],t)},it.prototype.te=function(t,e){return this._te(t,this.locale,this._getMessages(),e)},it.prototype.getLocaleMessage=function(t){return c(this._vm.messages[t]||{})},it.prototype.setLocaleMessage=function(t,e){this._vm.$set(this._vm.messages,t,e)},it.prototype.mergeLocaleMessage=function(t,e){this._vm.$set(this._vm.messages,t,j.util.extend(this._vm.messages[t]||{},e))},it.prototype.getDateTimeFormat=function(t){return c(this._vm.dateTimeFormats[t]||{})},it.prototype.setDateTimeFormat=function(t,e){this._vm.$set(this._vm.dateTimeFormats,t,e)},it.prototype.mergeDateTimeFormat=function(t,e){this._vm.$set(this._vm.dateTimeFormats,t,j.util.extend(this._vm.dateTimeFormats[t]||{},e))},it.prototype._localizeDateTime=function(t,e,n,i,a){var o=e,s=i[o];if((r(s)||r(s[a]))&&(o=n,s=i[o]),r(s)||r(s[a]))return null;var c=s[a],l=o+"__"+a,u=this._dateTimeFormatters[l];return u||(u=this._dateTimeFormatters[l]=new Intl.DateTimeFormat(o,c)),u.format(t)},it.prototype._d=function(t,e,n){if(!n)return new Intl.DateTimeFormat(e).format(t);var r=this._localizeDateTime(t,e,this.fallbackLocale,this._getDateTimeFormats(),n);if(this._isFallbackRoot(r)){if(!this._root)throw Error("unexpected error");return this._root.d(t,n,e)}return r||""},it.prototype.d=function(t){for(var n=[],r=arguments.length-1;r-- >0;)n[r]=arguments[r+1];var i=this.locale,a=null;return 1===n.length?"string"==typeof n[0]?a=n[0]:e(n[0])&&(n[0].locale&&(i=n[0].locale),n[0].key&&(a=n[0].key)):2===n.length&&("string"==typeof n[0]&&(a=n[0]),"string"==typeof n[1]&&(i=n[1])),this._d(t,i,a)},it.prototype.getNumberFormat=function(t){return c(this._vm.numberFormats[t]||{})},it.prototype.setNumberFormat=function(t,e){this._vm.$set(this._vm.numberFormats,t,e)},it.prototype.mergeNumberFormat=function(t,e){this._vm.$set(this._vm.numberFormats,t,j.util.extend(this._vm.numberFormats[t]||{},e))},it.prototype._localizeNumber=function(t,e,n,i,a,o){var s=e,c=i[s];if((r(c)||r(c[a]))&&(s=n,c=i[s]),r(c)||r(c[a]))return null;var l,u=c[a];if(o)l=new Intl.NumberFormat(s,Object.assign({},u,o));else{var f=s+"__"+a;l=this._numberFormatters[f],l||(l=this._numberFormatters[f]=new Intl.NumberFormat(s,u))}return l.format(t)},it.prototype._n=function(t,e,n,r){if(!n){return(r?new Intl.NumberFormat(e,r):new Intl.NumberFormat(e)).format(t)}var i=this._localizeNumber(t,e,this.fallbackLocale,this._getNumberFormats(),n,r);if(this._isFallbackRoot(i)){if(!this._root)throw Error("unexpected error");return this._root.n(t,Object.assign({},{key:n,locale:e},r))}return i||""},it.prototype.n=function(t){for(var n=[],r=arguments.length-1;r-- >0;)n[r]=arguments[r+1];var i=this.locale,a=null,o=null;return 1===n.length?"string"==typeof n[0]?a=n[0]:e(n[0])&&(n[0].locale&&(i=n[0].locale),n[0].key&&(a=n[0].key),o=Object.keys(n[0]).reduce(function(t,e){var r;return et.includes(e)?Object.assign({},t,(r={},r[e]=n[0][e],r)):t},null)):2===n.length&&("string"==typeof n[0]&&(a=n[0]),"string"==typeof n[1]&&(i=n[1])),this._n(t,i,a,o)},Object.defineProperties(it.prototype,at),it.availabilities={dateTimeFormat:I,numberFormat:S},it.install=F,it.version="8.2.0",it}); \ No newline at end of file