1 line
22 KiB
JavaScript
1 line
22 KiB
JavaScript
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var shared=require("@intlify/shared"),coreBase=require("@intlify/core-base"),vue=require("vue");const VERSION="9.1.7",warnMessages={[6]:"Fall back to {type} '{key}' with root locale.",7:"Not supported 'preserve'.",8:"Not supported 'formatter'.",9:"Not supported 'preserveDirectiveContent'.",10:"Not supported 'getChoiceIndex'.",11:"Component name legacy compatible: '{name}' -> 'i18n'",12:"Not found parent scope. use the global scope."};function getWarnMessage(e,...a){return shared.format(warnMessages[e],...a)}function createI18nError(e,...a){return coreBase.createCompileError(e,null,{messages:errorMessages,args:a})}const errorMessages={[14]:"Unexpected return type in composer",15:"Invalid argument",16:"Must be called at the top of a `setup` function",17:"Need to install with `app.use` function",22:"Unexpected error",18:"Not available in legacy mode",19:"Required in value: {0}",20:"Invalid value",21:"Cannot setup vue-devtools plugin"},DEVTOOLS_META="__INTLIFY_META__",TransrateVNodeSymbol=shared.makeSymbol("__transrateVNode"),DatetimePartsSymbol=shared.makeSymbol("__datetimeParts"),NumberPartsSymbol=shared.makeSymbol("__numberParts"),EnableEmitter=shared.makeSymbol("__enableEmitter"),DisableEmitter=shared.makeSymbol("__disableEmitter"),SetPluralRulesSymbol=shared.makeSymbol("__setPluralRules");shared.makeSymbol("__intlifyMeta");let composerID=0;function defineCoreMissingHandler(s){return(e,a,r,t)=>s(a,r,vue.getCurrentInstance()||void 0,t)}function getLocaleMessages(e,a){const{messages:r,__i18n:t}=a,s=shared.isPlainObject(r)?r:shared.isArray(t)?{}:{[e]:{}};if(shared.isArray(t)&&t.forEach(({locale:e,resource:a})=>{e?(s[e]=s[e]||{},deepCopy(a,s[e])):deepCopy(a,s)}),a.flatJson)for(const n in s)shared.hasOwn(s,n)&&coreBase.handleFlatJson(s[n]);return s}const isNotObjectOrIsArray=e=>!shared.isObject(e)||shared.isArray(e);function deepCopy(e,a){if(isNotObjectOrIsArray(e)||isNotObjectOrIsArray(a))throw createI18nError(20);for(const r in e)shared.hasOwn(e,r)&&(isNotObjectOrIsArray(e[r])||isNotObjectOrIsArray(a[r])?a[r]=e[r]:deepCopy(e[r],a[r]))}const getMetaInfo=()=>{var e=vue.getCurrentInstance();return e&&e.type[DEVTOOLS_META]?{[DEVTOOLS_META]:e.type[DEVTOOLS_META]}:null};function createComposer(e={}){const{__root:i}=e,a=void 0===i;let r=!shared.isBoolean(e.inheritLocale)||e.inheritLocale;const c=vue.ref(i&&r?i.locale.value:shared.isString(e.locale)?e.locale:"en-US"),u=vue.ref(i&&r?i.fallbackLocale.value:shared.isString(e.fallbackLocale)||shared.isArray(e.fallbackLocale)||shared.isPlainObject(e.fallbackLocale)||!1===e.fallbackLocale?e.fallbackLocale:c.value),m=vue.ref(getLocaleMessages(c.value,e)),g=vue.ref(shared.isPlainObject(e.datetimeFormats)?e.datetimeFormats:{[c.value]:{}}),d=vue.ref(shared.isPlainObject(e.numberFormats)?e.numberFormats:{[c.value]:{}});let b=i?i.missingWarn:!shared.isBoolean(e.missingWarn)&&!shared.isRegExp(e.missingWarn)||e.missingWarn,p=i?i.fallbackWarn:!shared.isBoolean(e.fallbackWarn)&&!shared.isRegExp(e.fallbackWarn)||e.fallbackWarn,h=i?i.fallbackRoot:!shared.isBoolean(e.fallbackRoot)||e.fallbackRoot,t=!!e.fallbackFormat,s=shared.isFunction(e.missing)?e.missing:null,n=shared.isFunction(e.missing)?defineCoreMissingHandler(e.missing):null,o=shared.isFunction(e.postTranslation)?e.postTranslation:null,l=!shared.isBoolean(e.warnHtmlMessage)||e.warnHtmlMessage,f=!!e.escapeParameter;const v=i?i.modifiers:shared.isPlainObject(e.modifiers)?e.modifiers:{};let _=e.pluralRules||i&&i.pluralRules,y;y=coreBase.createCoreContext({version:VERSION,locale:c.value,fallbackLocale:u.value,messages:m.value,datetimeFormats:g.value,numberFormats:d.value,modifiers:v,pluralRules:_,missing:null===n?void 0:n,missingWarn:b,fallbackWarn:p,fallbackFormat:t,unresolving:!0,postTranslation:null===o?void 0:o,warnHtmlMessage:l,escapeParameter:f,__datetimeFormatters:shared.isPlainObject(y)?y.__datetimeFormatters:void 0,__numberFormatters:shared.isPlainObject(y)?y.__numberFormatters:void 0,__v_emitter:shared.isPlainObject(y)?y.__v_emitter:void 0,__meta:{framework:"vue"}}),coreBase.updateFallbackLocale(y,c.value,u.value);var F=vue.computed({get:()=>c.value,set:e=>{c.value=e,y.locale=c.value}}),k=vue.computed({get:()=>u.value,set:e=>{u.value=e,y.fallbackLocale=u.value,coreBase.updateFallbackLocale(y,c.value,e)}}),M=vue.computed(()=>m.value),I=vue.computed(()=>g.value),e=vue.computed(()=>d.value);function S(e,a,r,t,s,n){c.value,u.value,m.value,g.value,d.value;let o;try{coreBase.setAdditionalMeta(getMetaInfo()),o=e(y)}finally{coreBase.setAdditionalMeta(null)}if(shared.isNumber(o)&&o===coreBase.NOT_REOSLVED){var[e,a]=a();if(i&&shared.isString(e)&&(a=a,"translate"!==r||!1==!!a.resolvedMessage)){h&&(coreBase.isTranslateFallbackWarn(p,e)||coreBase.isTranslateMissingWarn(b,e))&&shared.warn(getWarnMessage(6,{key:e,type:r}));{const{__v_emitter:l}=y;l&&h&&l.emit("fallback",{type:r,key:e,to:"global",groupId:`${r}:${e}`})}}return i&&h?t(i):s(e)}if(n(o))return o;throw createI18nError(14)}function O(...a){return S(e=>coreBase.translate(e,...a),()=>coreBase.parseTranslateArgs(...a),"translate",e=>e.t(...a),e=>e,e=>shared.isString(e))}const E={normalize:function(e){return e.map(e=>shared.isString(e)?vue.createVNode(vue.Text,null,e,0):e)},interpolate:e=>e,type:"vnode"};function T(e){return m.value[e]||{}}composerID++,i&&(vue.watch(i.locale,e=>{r&&(c.value=e,y.locale=e,coreBase.updateFallbackLocale(y,c.value,u.value))}),vue.watch(i.fallbackLocale,e=>{r&&(u.value=e,y.fallbackLocale=e,coreBase.updateFallbackLocale(y,c.value,u.value))}));const L={id:composerID,locale:F,fallbackLocale:k,get inheritLocale(){return r},set inheritLocale(e){(r=e)&&i&&(c.value=i.locale.value,u.value=i.fallbackLocale.value,coreBase.updateFallbackLocale(y,c.value,u.value))},get availableLocales(){return Object.keys(m.value).sort()},messages:M,datetimeFormats:I,numberFormats:e,get modifiers(){return v},get pluralRules(){return _||{}},get isGlobal(){return a},get missingWarn(){return b},set missingWarn(e){b=e,y.missingWarn=b},get fallbackWarn(){return p},set fallbackWarn(e){p=e,y.fallbackWarn=p},get fallbackRoot(){return h},set fallbackRoot(e){h=e},get fallbackFormat(){return t},set fallbackFormat(e){t=e,y.fallbackFormat=t},get warnHtmlMessage(){return l},set warnHtmlMessage(e){l=e,y.warnHtmlMessage=e},get escapeParameter(){return f},set escapeParameter(e){f=e,y.escapeParameter=e},t:O,rt:function(...e){var[a,r,e]=e;if(e&&!shared.isObject(e))throw createI18nError(15);return O(a,r,shared.assign({resolvedMessage:!0},e||{}))},d:function(...a){return S(e=>coreBase.datetime(e,...a),()=>coreBase.parseDateTimeArgs(...a),"datetime format",e=>e.d(...a),()=>coreBase.MISSING_RESOLVE_VALUE,e=>shared.isString(e))},n:function(...a){return S(e=>coreBase.number(e,...a),()=>coreBase.parseNumberArgs(...a),"number format",e=>e.n(...a),()=>coreBase.MISSING_RESOLVE_VALUE,e=>shared.isString(e))},te:function(e,a){return a=T(shared.isString(a)?a:c.value),null!==coreBase.resolveValue(a,e)},tm:function(e){var a=function(a){let r=null;var t=coreBase.getLocaleChain(y,u.value,c.value);for(let e=0;e<t.length;e++){var s=m.value[t[e]]||{},s=coreBase.resolveValue(s,a);if(null!=s){r=s;break}}return r}(e);return null!=a?a:i&&i.tm(e)||{}},getLocaleMessage:T,setLocaleMessage:function(e,a){m.value[e]=a,y.messages=m.value},mergeLocaleMessage:function(e,a){m.value[e]=m.value[e]||{},deepCopy(a,m.value[e]),y.messages=m.value},getDateTimeFormat:function(e){return g.value[e]||{}},setDateTimeFormat:function(e,a){g.value[e]=a,y.datetimeFormats=g.value,coreBase.clearDateTimeFormat(y,e,a)},mergeDateTimeFormat:function(e,a){g.value[e]=shared.assign(g.value[e]||{},a),y.datetimeFormats=g.value,coreBase.clearDateTimeFormat(y,e,a)},getNumberFormat:function(e){return d.value[e]||{}},setNumberFormat:function(e,a){d.value[e]=a,y.numberFormats=d.value,coreBase.clearNumberFormat(y,e,a)},mergeNumberFormat:function(e,a){d.value[e]=shared.assign(d.value[e]||{},a),y.numberFormats=d.value,coreBase.clearNumberFormat(y,e,a)},getPostTranslationHandler:function(){return shared.isFunction(o)?o:null},setPostTranslationHandler:function(e){o=e,y.postTranslation=e},getMissingHandler:function(){return s},setMissingHandler:function(e){null!==e&&(n=defineCoreMissingHandler(e)),s=e,y.missing=n},[TransrateVNodeSymbol]:function(...t){return S(e=>{let a;const r=e;try{r.processor=E,a=coreBase.translate(r,...t)}finally{r.processor=null}return a},()=>coreBase.parseTranslateArgs(...t),"translate",e=>e[TransrateVNodeSymbol](...t),e=>[vue.createVNode(vue.Text,null,e,0)],e=>shared.isArray(e))},[NumberPartsSymbol]:function(...a){return S(e=>coreBase.number(e,...a),()=>coreBase.parseNumberArgs(...a),"number format",e=>e[NumberPartsSymbol](...a),()=>[],e=>shared.isString(e)||shared.isArray(e))},[DatetimePartsSymbol]:function(...a){return S(e=>coreBase.datetime(e,...a),()=>coreBase.parseDateTimeArgs(...a),"datetime format",e=>e[DatetimePartsSymbol](...a),()=>[],e=>shared.isString(e)||shared.isArray(e))},[SetPluralRulesSymbol]:function(e){_=e,y.pluralRules=_}};return L[EnableEmitter]=e=>{y.__v_emitter=e},L[DisableEmitter]=()=>{y.__v_emitter=void 0},L}function convertComposerOptions(e){var a=shared.isString(e.locale)?e.locale:"en-US",r=shared.isString(e.fallbackLocale)||shared.isArray(e.fallbackLocale)||shared.isPlainObject(e.fallbackLocale)||!1===e.fallbackLocale?e.fallbackLocale:a,t=shared.isFunction(e.missing)?e.missing:void 0,s=!shared.isBoolean(e.silentTranslationWarn)&&!shared.isRegExp(e.silentTranslationWarn)||!e.silentTranslationWarn,n=!shared.isBoolean(e.silentFallbackWarn)&&!shared.isRegExp(e.silentFallbackWarn)||!e.silentFallbackWarn,o=!shared.isBoolean(e.fallbackRoot)||e.fallbackRoot,l=!!e.formatFallbackMessages,i=shared.isPlainObject(e.modifiers)?e.modifiers:{},c=e.pluralizationRules,u=shared.isFunction(e.postTranslation)?e.postTranslation:void 0,m=!shared.isString(e.warnHtmlInMessage)||"off"!==e.warnHtmlInMessage,g=!!e.escapeParameterHtml,d=!shared.isBoolean(e.sync)||e.sync;e.formatter&&shared.warn(getWarnMessage(8)),e.preserveDirectiveContent&&shared.warn(getWarnMessage(9));let b=e.messages;if(shared.isPlainObject(e.sharedMessages)){const _=e.sharedMessages,y=Object.keys(_);b=y.reduce((e,a)=>{var r=e[a]||(e[a]={});return shared.assign(r,_[a]),e},b||{})}var{__i18n:p,__root:h}=e,f=e.datetimeFormats,v=e.numberFormats,e=e.flatJson;return{locale:a,fallbackLocale:r,messages:b,flatJson:e,datetimeFormats:f,numberFormats:v,missing:t,missingWarn:s,fallbackWarn:n,fallbackRoot:o,fallbackFormat:l,modifiers:i,pluralRules:c,postTranslation:u,warnHtmlMessage:m,escapeParameter:g,inheritLocale:d,__i18n:p,__root:h}}function createVueI18n(r={}){const o=createComposer(convertComposerOptions(r)),t={id:o.id,get locale(){return o.locale.value},set locale(e){o.locale.value=e},get fallbackLocale(){return o.fallbackLocale.value},set fallbackLocale(e){o.fallbackLocale.value=e},get messages(){return o.messages.value},get datetimeFormats(){return o.datetimeFormats.value},get numberFormats(){return o.numberFormats.value},get availableLocales(){return o.availableLocales},get formatter(){return shared.warn(getWarnMessage(8)),{interpolate(){return[]}}},set formatter(e){shared.warn(getWarnMessage(8))},get missing(){return o.getMissingHandler()},set missing(e){o.setMissingHandler(e)},get silentTranslationWarn(){return shared.isBoolean(o.missingWarn)?!o.missingWarn:o.missingWarn},set silentTranslationWarn(e){o.missingWarn=shared.isBoolean(e)?!e:e},get silentFallbackWarn(){return shared.isBoolean(o.fallbackWarn)?!o.fallbackWarn:o.fallbackWarn},set silentFallbackWarn(e){o.fallbackWarn=shared.isBoolean(e)?!e:e},get modifiers(){return o.modifiers},get formatFallbackMessages(){return o.fallbackFormat},set formatFallbackMessages(e){o.fallbackFormat=e},get postTranslation(){return o.getPostTranslationHandler()},set postTranslation(e){o.setPostTranslationHandler(e)},get sync(){return o.inheritLocale},set sync(e){o.inheritLocale=e},get warnHtmlInMessage(){return o.warnHtmlMessage?"warn":"off"},set warnHtmlInMessage(e){o.warnHtmlMessage="off"!==e},get escapeParameterHtml(){return o.escapeParameter},set escapeParameterHtml(e){o.escapeParameter=e},get preserveDirectiveContent(){return shared.warn(getWarnMessage(9)),!0},set preserveDirectiveContent(e){shared.warn(getWarnMessage(9))},get pluralizationRules(){return o.pluralRules||{}},__composer:o,t(...e){var[a,r,e]=e;const t={};let s=null,n=null;if(!shared.isString(a))throw createI18nError(15);return shared.isString(r)?t.locale=r:shared.isArray(r)?s=r:shared.isPlainObject(r)&&(n=r),shared.isArray(e)?s=e:shared.isPlainObject(e)&&(n=e),o.t(a,s||n||{},t)},rt(...e){return o.rt(...e)},tc(...e){var[a,r,e]=e;const t={plural:1};let s=null,n=null;if(!shared.isString(a))throw createI18nError(15);return shared.isString(r)?t.locale=r:shared.isNumber(r)?t.plural=r:shared.isArray(r)?s=r:shared.isPlainObject(r)&&(n=r),shared.isString(e)?t.locale=e:shared.isArray(e)?s=e:shared.isPlainObject(e)&&(n=e),o.t(a,s||n||{},t)},te(e,a){return o.te(e,a)},tm(e){return o.tm(e)},getLocaleMessage(e){return o.getLocaleMessage(e)},setLocaleMessage(e,a){o.setLocaleMessage(e,a)},mergeLocaleMessage(e,a){o.mergeLocaleMessage(e,a)},d(...e){return o.d(...e)},getDateTimeFormat(e){return o.getDateTimeFormat(e)},setDateTimeFormat(e,a){o.setDateTimeFormat(e,a)},mergeDateTimeFormat(e,a){o.mergeDateTimeFormat(e,a)},n(...e){return o.n(...e)},getNumberFormat(e){return o.getNumberFormat(e)},setNumberFormat(e,a){o.setNumberFormat(e,a)},mergeNumberFormat(e,a){o.mergeNumberFormat(e,a)},getChoiceIndex(e,a){return shared.warn(getWarnMessage(10)),-1},__onComponentInstanceCreated(e){const{componentInstanceCreatedListener:a}=r;a&&a(e,t)},__enableEmitter:e=>{const a=o;a[EnableEmitter]&&a[EnableEmitter](e)},__disableEmitter:()=>{const e=o;e[DisableEmitter]&&e[DisableEmitter]()}};return t}const baseFormatProps={tag:{type:[String,Object]},locale:{type:String},scope:{type:String,validator:e=>"parent"===e||"global"===e,default:"parent"},i18n:{type:Object}},Translation={name:"i18n-t",props:shared.assign({keypath:{type:String,required:!0},plural:{type:[Number,String],validator:e=>shared.isNumber(e)||!isNaN(e)}},baseFormatProps),setup(t,s){const{slots:e,attrs:n}=s,o=t.i18n||useI18n({useScope:t.scope}),l=Object.keys(e).filter(e=>"_"!==e);return()=>{const e={};t.locale&&(e.locale=t.locale),void 0!==t.plural&&(e.plural=shared.isString(t.plural)?+t.plural:t.plural);var a=getInterpolateArg(s,l),r=o[TransrateVNodeSymbol](t.keypath,a,e),a=shared.assign({},n);return shared.isString(t.tag)||shared.isObject(t.tag)?vue.h(t.tag,a,r):vue.h(vue.Fragment,a,r)}}};function getInterpolateArg({slots:t},e){return 1===e.length&&"default"===e[0]?t.default?t.default():[]:e.reduce((e,a)=>{const r=t[a];return r&&(e[a]=r()),e},{})}function renderFormatter(n,e,o,l){const{slots:i,attrs:c}=e;return()=>{const e={part:!0};let a={};n.locale&&(e.locale=n.locale),shared.isString(n.format)?e.key=n.format:shared.isObject(n.format)&&(shared.isString(n.format.key)&&(e.key=n.format.key),a=Object.keys(n.format).reduce((e,a)=>o.includes(a)?shared.assign({},e,{[a]:n.format[a]}):e,{}));const t=l(n.value,e,a);let r=[e.key];shared.isArray(t)?r=t.map((e,a)=>{const r=i[e.type];return r?r({[e.type]:e.value,index:a,parts:t}):[e.value]}):shared.isString(t)&&(r=[t]);var s=shared.assign({},c);return shared.isString(n.tag)||shared.isObject(n.tag)?vue.h(n.tag,s,r):vue.h(vue.Fragment,s,r)}}const NUMBER_FORMAT_KEYS=["localeMatcher","style","unit","unitDisplay","currency","currencyDisplay","useGrouping","numberingSystem","minimumIntegerDigits","minimumFractionDigits","maximumFractionDigits","minimumSignificantDigits","maximumSignificantDigits","notation","formatMatcher"],NumberFormat={name:"i18n-n",props:shared.assign({value:{type:Number,required:!0},format:{type:[String,Object]}},baseFormatProps),setup(e,a){const r=e.i18n||useI18n({useScope:"parent"});return renderFormatter(e,a,NUMBER_FORMAT_KEYS,(...e)=>r[NumberPartsSymbol](...e))}},DATETIME_FORMAT_KEYS=["dateStyle","timeStyle","fractionalSecondDigits","calendar","dayPeriod","numberingSystem","localeMatcher","timeZone","hour12","hourCycle","formatMatcher","weekday","era","year","month","day","hour","minute","second","timeZoneName"],DatetimeFormat={name:"i18n-d",props:shared.assign({value:{type:[Number,Date],required:!0},format:{type:[String,Object]}},baseFormatProps),setup(e,a){const r=e.i18n||useI18n({useScope:"parent"});return renderFormatter(e,a,DATETIME_FORMAT_KEYS,(...e)=>r[DatetimePartsSymbol](...e))}};function getComposer$1(e,a){const r=e;if("composition"===e.mode)return r.__getInstance(a)||e.global;a=r.__getInstance(a);return(null!=a?a:e.global).__composer}function vTDirective(n){var e=(e,{instance:a,value:r,modifiers:t})=>{if(!a||!a.$)throw createI18nError(22);const s=getComposer$1(n,a.$);t.preserve&&shared.warn(getWarnMessage(7));r=parseValue(r);e.textContent=s.t(...makeParams(r))};return{beforeMount:e,beforeUpdate:e}}function parseValue(e){if(shared.isString(e))return{path:e};if(shared.isPlainObject(e)){if(!("path"in e))throw createI18nError(19,"path");return e}throw createI18nError(20)}function makeParams(e){var{path:a,locale:r,args:t,choice:s,plural:e}=e;const n={};t=t||{};return shared.isString(r)&&(n.locale=r),shared.isNumber(s)&&(n.plural=s),shared.isNumber(e)&&(n.plural=e),[a,t,n]}function apply(e,a,...r){var t=shared.isPlainObject(r[0])?r[0]:{},r=!!t.useI18nComponentName,t=!shared.isBoolean(t.globalInstall)||t.globalInstall;t&&r&&shared.warn(getWarnMessage(11,{name:Translation.name})),t&&(e.component(r?"i18n":Translation.name,Translation),e.component(NumberFormat.name,NumberFormat),e.component(DatetimeFormat.name,DatetimeFormat)),e.directive("t",vTDirective(a))}function defineMixin(t,s,n){return{beforeCreate(){var e=vue.getCurrentInstance();if(!e)throw createI18nError(22);var a=this.$options;if(a.i18n){const r=a.i18n;a.__i18n&&(r.__i18n=a.__i18n),r.__root=s,this===this.$root?this.$i18n=mergeToRoot(t,r):this.$i18n=createVueI18n(r)}else a.__i18n?this===this.$root?this.$i18n=mergeToRoot(t,a):this.$i18n=createVueI18n({__i18n:a.__i18n,__root:s}):this.$i18n=t;t.__onComponentInstanceCreated(this.$i18n),n.__setInstance(e,this.$i18n),this.$t=(...e)=>this.$i18n.t(...e),this.$rt=(...e)=>this.$i18n.rt(...e),this.$tc=(...e)=>this.$i18n.tc(...e),this.$te=(e,a)=>this.$i18n.te(e,a),this.$d=(...e)=>this.$i18n.d(...e),this.$n=(...e)=>this.$i18n.n(...e),this.$tm=e=>this.$i18n.tm(e)},mounted(){},beforeUnmount(){var e=vue.getCurrentInstance();if(!e)throw createI18nError(22);delete this.$t,delete this.$rt,delete this.$tc,delete this.$te,delete this.$d,delete this.$n,delete this.$tm,n.__deleteInstance(e),delete this.$i18n}}}function mergeToRoot(a,r){a.locale=r.locale||a.locale,a.fallbackLocale=r.fallbackLocale||a.fallbackLocale,a.missing=r.missing||a.missing,a.silentTranslationWarn=r.silentTranslationWarn||a.silentFallbackWarn,a.silentFallbackWarn=r.silentFallbackWarn||a.silentFallbackWarn,a.formatFallbackMessages=r.formatFallbackMessages||a.formatFallbackMessages,a.postTranslation=r.postTranslation||a.postTranslation,a.warnHtmlInMessage=r.warnHtmlInMessage||a.warnHtmlInMessage,a.escapeParameterHtml=r.escapeParameterHtml||a.escapeParameterHtml,a.sync=r.sync||a.sync,a.__composer[SetPluralRulesSymbol](r.pluralizationRules||a.pluralizationRules);const t=getLocaleMessages(a.locale,{messages:r.messages,__i18n:r.__i18n});return Object.keys(t).forEach(e=>a.mergeLocaleMessage(e,t[e])),r.datetimeFormats&&Object.keys(r.datetimeFormats).forEach(e=>a.mergeDateTimeFormat(e,r.datetimeFormats[e])),r.numberFormats&&Object.keys(r.numberFormats).forEach(e=>a.mergeNumberFormat(e,r.numberFormats[e])),a}function createI18n(e={}){const r=!shared.isBoolean(e.legacy)||e.legacy,t=!!e.globalInjection,s=new Map,n=(r?createVueI18n:createComposer)(e),o=shared.makeSymbol("vue-i18n"),l={get mode(){return r?"legacy":"composition"},async install(e,...a){e.__VUE_I18N_SYMBOL__=o,e.provide(e.__VUE_I18N_SYMBOL__,l),!r&&t&&injectGlobalFields(e,l.global),apply(e,l,...a),r&&e.mixin(defineMixin(n,n.__composer,l))},get global(){return n},__instances:s,__getInstance(e){return s.get(e)||null},__setInstance(e,a){s.set(e,a)},__deleteInstance(e){s.delete(e)}};return l}function useI18n(r={}){var t=vue.getCurrentInstance();if(null==t)throw createI18nError(16);if(!t.appContext.app.__VUE_I18N_SYMBOL__)throw createI18nError(17);var a=vue.inject(t.appContext.app.__VUE_I18N_SYMBOL__);if(!a)throw createI18nError(22);const s="composition"===a.mode?a.global:a.global.__composer;var e=shared.isEmptyObject(r)?"__i18n"in t.type?"local":"global":r.useScope||"local";if("global"===e){let a=shared.isObject(r.messages)?r.messages:{};"__i18nGlobal"in t.type&&(a=getLocaleMessages(s.locale.value,{messages:a,__i18n:t.type.__i18nGlobal}));const l=Object.keys(a);if(l.length&&l.forEach(e=>{s.mergeLocaleMessage(e,a[e])}),shared.isObject(r.datetimeFormats)){const i=Object.keys(r.datetimeFormats);i.length&&i.forEach(e=>{s.mergeDateTimeFormat(e,r.datetimeFormats[e])})}if(shared.isObject(r.numberFormats)){const c=Object.keys(r.numberFormats);c.length&&c.forEach(e=>{s.mergeNumberFormat(e,r.numberFormats[e])})}return s}if("parent"===e){let e=getComposer(a,t);return null==e&&(shared.warn(getWarnMessage(12)),e=s),e}if("legacy"===a.mode)throw createI18nError(18);const n=a;let o=n.__getInstance(t);if(null==o){a=t.type;const u=shared.assign({},r);a.__i18n&&(u.__i18n=a.__i18n),s&&(u.__root=s),o=createComposer(u),setupLifeCycle(n,t),n.__setInstance(t,o)}return o}function getComposer(e,a){let r=null;var t,s=a.root;let n=a.parent;for(;null!=n;){const o=e;if("composition"===e.mode?r=o.__getInstance(n):null!=(t=o.__getInstance(n))&&(r=t.__composer),null!=r)break;if(s===n)break;n=n.parent}return r}function setupLifeCycle(e,a,r){vue.onMounted(()=>{},a),vue.onUnmounted(()=>{e.__deleteInstance(a)},a)}const globalExportProps=["locale","fallbackLocale","availableLocales"],globalExportMethods=["t","rt","d","n","tm"];function injectGlobalFields(r,t){const s=Object.create(null);globalExportProps.forEach(e=>{const a=Object.getOwnPropertyDescriptor(t,e);if(!a)throw createI18nError(22);var r=vue.isRef(a.value)?{get(){return a.value.value},set(e){a.value.value=e}}:{get(){return a.get&&a.get()}};Object.defineProperty(s,e,r)}),r.config.globalProperties.$i18n=s,globalExportMethods.forEach(e=>{var a=Object.getOwnPropertyDescriptor(t,e);if(!a||!a.value)throw createI18nError(22);Object.defineProperty(r.config.globalProperties,`$${e}`,a)})}coreBase.registerMessageCompiler(coreBase.compileToFunction);{const od=shared.getGlobalThis();od.__INTLIFY__=!0,coreBase.setDevToolsHook(od.__INTLIFY_DEVTOOLS_GLOBAL_HOOK__)}exports.DatetimeFormat=DatetimeFormat,exports.NumberFormat=NumberFormat,exports.Translation=Translation,exports.VERSION=VERSION,exports.createI18n=createI18n,exports.useI18n=useI18n,exports.vTDirective=vTDirective; |