1 line
20 KiB
JavaScript
1 line
20 KiB
JavaScript
|
const t=["style","currency","currencyDisplay","useGrouping","minimumIntegerDigits","minimumFractionDigits","maximumFractionDigits","minimumSignificantDigits","maximumSignificantDigits","localeMatcher","formatMatcher"];function e(t,e){"undefined"!=typeof console&&(console.warn("[vue-i18n] "+t),e&&console.warn(e.stack))}function n(t){return null!==t&&"object"==typeof t}const s=Object.prototype.toString,r="[object Object]";function i(t){return s.call(t)===r}function a(t){return null==t}function o(...t){let e=null,s=null;return 1===t.length?n(t[0])||Array.isArray(t[0])?s=t[0]:"string"==typeof t[0]&&(e=t[0]):2===t.length&&("string"==typeof t[0]&&(e=t[0]),(n(t[1])||Array.isArray(t[1]))&&(s=t[1])),{locale:e,params:s}}function l(t){return JSON.parse(JSON.stringify(t))}const c=Object.prototype.hasOwnProperty;function u(t,e){return c.call(t,e)}function h(t){const e=Object(t);for(let t=1;t<arguments.length;t++){const s=arguments[t];if(null!=s){let t;for(t in s)u(s,t)&&(n(s[t])?e[t]=h(e[t],s[t]):e[t]=s[t])}}return e}function f(t,e){if(t===e)return!0;const s=n(t),r=n(e);if(!s||!r)return!s&&!r&&String(t)===String(e);try{const n=Array.isArray(t),s=Array.isArray(e);if(n&&s)return t.length===e.length&&t.every((t,n)=>f(t,e[n]));if(n||s)return!1;{const n=Object.keys(t),s=Object.keys(e);return n.length===s.length&&n.every(n=>f(t[n],e[n]))}}catch(t){return!1}}var m={beforeCreate(){const t=this.$options;if(t.i18n=t.i18n||(t.__i18n?{}:null),t.i18n){if(t.i18n instanceof Z){if(t.__i18n)try{let e={};t.__i18n.forEach(t=>{e=h(e,JSON.parse(t))}),Object.keys(e).forEach(n=>{t.i18n.mergeLocaleMessage(n,e[n])})}catch(t){}this._i18n=t.i18n,this._i18nWatcher=this._i18n.watchI18nData()}else if(i(t.i18n)){if(this.$root&&this.$root.$i18n&&this.$root.$i18n instanceof Z&&(t.i18n.root=this.$root,t.i18n.formatter=this.$root.$i18n.formatter,t.i18n.fallbackLocale=this.$root.$i18n.fallbackLocale,t.i18n.formatFallbackMessages=this.$root.$i18n.formatFallbackMessages,t.i18n.silentTranslationWarn=this.$root.$i18n.silentTranslationWarn,t.i18n.silentFallbackWarn=this.$root.$i18n.silentFallbackWarn,t.i18n.pluralizationRules=this.$root.$i18n.pluralizationRules,t.i18n.preserveDirectiveContent=this.$root.$i18n.preserveDirectiveContent),t.__i18n)try{let e={};t.__i18n.forEach(t=>{e=h(e,JSON.parse(t))}),t.i18n.messages=e}catch(t){}const{sharedMessages:e}=t.i18n;e&&i(e)&&(t.i18n.messages=h(t.i18n.messages,e)),this._i18n=new Z(t.i18n),this._i18nWatcher=this._i18n.watchI18nData(),(void 0===t.i18n.sync||t.i18n.sync)&&(this._localeWatcher=this.$i18n.watchLocale())}}else this.$root&&this.$root.$i18n&&this.$root.$i18n instanceof Z?this._i18n=this.$root.$i18n:t.parent&&t.parent.$i18n&&t.parent.$i18n instanceof Z&&(this._i18n=t.parent.$i18n)},beforeMount(){const t=this.$options;t.i18n=t.i18n||(t.__i18n?{}:null),t.i18n?t.i18n instanceof Z?(this._i18n.subscribeDataChanging(this),this._subscribing=!0):i(t.i18n)&&(this._i18n.subscribeDataChanging(this),this._subscribing=!0):this.$root&&this.$root.$i18n&&this.$root.$i18n instanceof Z?(this._i18n.subscribeDataChanging(this),this._subscribing=!0):t.parent&&t.parent.$i18n&&t.parent.$i18n instanceof Z&&(this._i18n.subscribeDataChanging(this),this._subscribing=!0)},beforeDestroy(){if(!this._i18n)return;const t=this;this.$nextTick(()=>{t._subscribing&&(t._i18n.unsubscribeDataChanging(t),delete t._subscribing),t._i18nWatcher&&(t._i18nWatcher(),t._i18n.destroyVM(),delete t._i18nWatcher),t._localeWatcher&&(t._localeWatcher(),delete t._localeWatcher),t._i18n=null})}},_={name:"i18n",functional:!0,props:{tag:{type:String},path:{type:String,required:!0},locale:{type:String},places:{type:[Array,Object]}},render(t,{data:e,parent:n,props:s,slots:r}){const{$i18n:i}=n;if(!i)return;const{path:a,locale:o,places:l}=s,c=r(),u=i.i(a,o,function(t){let e;for(e in t)if("default"!==e)return!1;return Boolean(e)}(c)||l?function(t,e){const n=e?function(t){return Array.isArray(t)?t.reduce(p,{}):Object.assign({},t)}(e):{};if(!t)return n;const s=t.every(b);return t.reduce(s?g:p,n)}(c.default,l):c),h=s.tag||"span";return h?t(h,e,u):u}};function g(t,e){return e.data&&e.data.
|