/*! * vue-i18n v7.8.1 * (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 M.call(t)===N}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;)n[r]=arguments[r+1];var i=t.$i18n;return i._t.apply(i,[e,i.locale,i._getMessages(),t].concat(n))}}}),Object.defineProperty(t.prototype,"$tc",{get:function(){var t=this;return function(e,n){for(var r=[],i=arguments.length-2;i-- >0;)r[i]=arguments[i+2];var a=t.$i18n;return a._tc.apply(a,[e,a.locale,a._getMessages(),t,n].concat(r))}}}),Object.defineProperty(t.prototype,"$te",{get:function(){var t=this;return function(e,n){var r=t.$i18n;return r._te(e,r.locale,r._getMessages(),n)}}}),Object.defineProperty(t.prototype,"$d",{get:function(){var t=this;return function(e){for(var n,r=[],i=arguments.length-1;i-- >0;)r[i]=arguments[i+1];return(n=t.$i18n).d.apply(n,[e].concat(r))}}}),Object.defineProperty(t.prototype,"$n",{get:function(){var t=this;return function(e){for(var n,r=[],i=arguments.length-1;i-- >0;)r[i]=arguments[i+1];return(n=t.$i18n).n.apply(n,[e].concat(r))}}})}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(t,e,n,r){v(t,n)&&(t.textContent="",t._vt=void 0,delete t._vt,t._locale=void 0,delete t._locale)}function v(e,n){var r=n.context;return r?!!r.$i18n||(t("not exist VueI18n instance in Vue instance"),!1):(t("not exist Vue instance 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("not support value type");if(!c)return void t("required `path` 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){L=t;L.version&&Number(L.version.split(".")[0]);F.installed=!0,Object.defineProperty(L.prototype,"$i18n",{get:function(){return this._i18n}}),p(L),L.mixin(P),L.directive("t",{bind:m,update:_,unbind:g}),L.component(C.name,C);var e=L.config.optionMergeStrategies;e.i18n=e.methods}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 O(t){var e=t.trim();return("0"!==t.charAt(0)||!isNaN(t))&&(T(e)?D(e):"*"+e)}function j(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=O(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=x(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 A(t){return!!Array.isArray(t)&&0===t.length}var L,M=Object.prototype.toString,N="[object Object]",W=Object.prototype.hasOwnProperty,I="undefined"!=typeof Intl&&void 0!==Intl.DateTimeFormat,S="undefined"!=typeof Intl&&void 0!==Intl.NumberFormat,P={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))}},V=function(){this._caches=Object.create(null)};V.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 E=/^(\d)+/,R=/^(\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=j(t))&&(this._cache[t]=e),e||[]},tt.prototype.getPathValue=function(t,n){if(!e(t))return null;var r=this.parsePath(n);if(A(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,L.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,L.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,L.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="7.8.1",nt});