mirror of
https://codeberg.org/nobody/LocalCDN.git
synced 2024-12-22 16:12:13 +01:00
1 line
23 KiB
JavaScript
1 line
23 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.10",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"),InejctWithOption=(shared.makeSymbol("__intlifyMeta"),shared.makeSymbol("__injectWithOption"));let composerID=0;function defineCoreMissingHandler(s){return(e,a,t,r)=>s(a,t,vue.getCurrentInstance()||void 0,r)}function getLocaleMessages(e,a){const{messages:t,__i18n:r}=a,s=shared.isPlainObject(t)?t:shared.isArray(r)?{}:{[e]:{}};if(shared.isArray(r)&&r.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 t in e)shared.hasOwn(e,t)&&(isNotObjectOrIsArray(e[t])||isNotObjectOrIsArray(a[t])?a[t]=e[t]:deepCopy(e[t],a[t]))}const getMetaInfo=()=>{var e=vue.getCurrentInstance();return e&&e.type[DEVTOOLS_META]?{[DEVTOOLS_META]:e.type[DEVTOOLS_META]}:null};function createComposer(e={}){const i=e["__root"],a=void 0===i;let t=!shared.isBoolean(e.inheritLocale)||e.inheritLocale;const c=vue.ref(i&&t?i.locale.value:shared.isString(e.locale)?e.locale:"en-US"),u=vue.ref(i&&t?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,r=!!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 _=i?i.modifiers:shared.isPlainObject(e.modifiers)?e.modifiers:{};let v=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:_,pluralRules:v,missing:null===n?void 0:n,missingWarn:b,fallbackWarn:p,fallbackFormat:r,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),O=vue.computed(()=>d.value);function S(e,a,t,r,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"!==t||!1==!!a.resolvedMessage)){h&&(coreBase.isTranslateFallbackWarn(p,e)||coreBase.isTranslateMissingWarn(b,e))&&shared.warn(getWarnMessage(6,{key:e,type:t}));{const l=y["__v_emitter"];l&&h&&l.emit("fallback",{type:t,key:e,to:"global",groupId:t+":"+e})}}return i&&h?r(i):s(e)}if(n(o))return o;throw createI18nError(14)}function E(...a){return S(e=>coreBase.translate(e,...a),()=>coreBase.parseTranslateArgs(...a),"translate",e=>e.t(...a),e=>e,e=>shared.isString(e))}const T={normalize:function(e){return e.map(e=>shared.isString(e)?vue.createVNode(vue.Text,null,e,0):e)},interpolate:e=>e,type:"vnode"};function L(e){return m.value[e]||{}}composerID++,i&&(vue.watch(i.locale,e=>{t&&(c.value=e,y.locale=e,coreBase.updateFallbackLocale(y,c.value,u.value))}),vue.watch(i.fallbackLocale,e=>{t&&(u.value=e,y.fallbackLocale=e,coreBase.updateFallbackLocale(y,c.value,u.value))}));const N={id:composerID,locale:F,fallbackLocale:k,get inheritLocale(){return t},set inheritLocale(e){(t=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:O,get modifiers(){return _},get pluralRules(){return v||{}},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 r},set fallbackFormat(e){r=e,y.fallbackFormat=r},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:E,rt:function(...e){var[e,a,t]=e;if(t&&!shared.isObject(t))throw createI18nError(15);return E(e,a,shared.assign({resolvedMessage:!0},t||{}))},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=L(shared.isString(a)?a:c.value),null!==coreBase.resolveValue(a,e)},tm:function(e){var a=function(a){let t=null;var r=coreBase.getLocaleChain(y,u.value,c.value);for(let e=0;e<r.length;e++){var s=m.value[r[e]]||{},s=coreBase.resolveValue(s,a);if(null!=s){t=s;break}}return t}(e);return null!=a?a:i&&i.tm(e)||{}},getLocaleMessage:L,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(...r){return S(e=>{let a;const t=e;try{t.processor=T,a=coreBase.translate(t,...r)}finally{t.processor=null}return a},()=>coreBase.parseTranslateArgs(...r),"translate",e=>e[TransrateVNodeSymbol](...r),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){v=e,y.pluralRules=v},[InejctWithOption]:e.__injectWithOption};return N[EnableEmitter]=e=>{y.__v_emitter=e},N[DisableEmitter]=()=>{y.__v_emitter=void 0},N}function convertComposerOptions(e){var a=shared.isString(e.locale)?e.locale:"en-US",t=shared.isString(e.fallbackLocale)||shared.isArray(e.fallbackLocale)||shared.isPlainObject(e.fallbackLocale)||!1===e.fallbackLocale?e.fallbackLocale:a,r=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 y=e.sharedMessages,F=Object.keys(y);b=F.reduce((e,a)=>{var t=e[a]||(e[a]={});return shared.assign(t,y[a]),e},b||{})}var{__i18n:p,__root:h,__injectWithOption:f}=e,_=e.datetimeFormats,v=e.numberFormats,e=e.flatJson;return{locale:a,fallbackLocale:t,messages:b,flatJson:e,datetimeFormats:_,numberFormats:v,missing:r,missingWarn:s,fallbackWarn:n,fallbackRoot:o,fallbackFormat:l,modifiers:i,pluralRules:c,postTranslation:u,warnHtmlMessage:m,escapeParameter:g,inheritLocale:d,__i18n:p,__root:h,__injectWithOption:f}}function createVueI18n(t={}){const o=createComposer(convertComposerOptions(t)),r={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[e,a,t]=e;const r={};let s=null,n=null;if(!shared.isString(e))throw createI18nError(15);return shared.isString(a)?r.locale=a:shared.isArray(a)?s=a:shared.isPlainObject(a)&&(n=a),shared.isArray(t)?s=t:shared.isPlainObject(t)&&(n=t),o.t(e,s||n||{},r)},rt(...e){return o.rt(...e)},tc(...e){var[e,a,t]=e;const r={plural:1};let s=null,n=null;if(!shared.isString(e))throw createI18nError(15);return shared.isString(a)?r.locale=a:shared.isNumber(a)?r.plural=a:shared.isArray(a)?s=a:shared.isPlainObject(a)&&(n=a),shared.isString(t)?r.locale=t:shared.isArray(t)?s=t:shared.isPlainObject(t)&&(n=t),o.t(e,s||n||{},r)},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 a=t["componentInstanceCreatedListener"];a&&a(e,r)},__enableEmitter:e=>{const a=o;a[EnableEmitter]&&a[EnableEmitter](e)},__disableEmitter:()=>{const e=o;e[DisableEmitter]&&e[DisableEmitter]()}};return r}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(r,s){const{slots:e,attrs:n}=s,o=r.i18n||useI18n({useScope:r.scope,__useComponent:!0}),l=Object.keys(e).filter(e=>"_"!==e);return()=>{const e={};r.locale&&(e.locale=r.locale),void 0!==r.plural&&(e.plural=shared.isString(r.plural)?+r.plural:r.plural);var a=getInterpolateArg(s,l),a=o[TransrateVNodeSymbol](r.keypath,a,e),t=shared.assign({},n);return shared.isString(r.tag)||shared.isObject(r.tag)?vue.h(r.tag,t,a):vue.h(vue.Fragment,t,a)}}};function getInterpolateArg({slots:r},e){return 1===e.length&&"default"===e[0]?r.default?r.default():[]:e.reduce((e,a)=>{const t=r[a];return t&&(e[a]=t()),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 r=l(n.value,e,a);let t=[e.key];shared.isArray(r)?t=r.map((e,a)=>{const t=i[e.type];return t?t({[e.type]:e.value,index:a,parts:r}):[e.value]}):shared.isString(r)&&(t=[r]);var s=shared.assign({},c);return shared.isString(n.tag)||shared.isObject(n.tag)?vue.h(n.tag,s,t):vue.h(vue.Fragment,s,t)}}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 t=e.i18n||useI18n({useScope:"parent",__useComponent:!0});return renderFormatter(e,a,NUMBER_FORMAT_KEYS,(...e)=>t[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 t=e.i18n||useI18n({useScope:"parent",__useComponent:!0});return renderFormatter(e,a,DATETIME_FORMAT_KEYS,(...e)=>t[DatetimePartsSymbol](...e))}};function getComposer$1(e,a){const t=e;return"composition"===e.mode?t.__getInstance(a)||e.global:(null!=(a=t.__getInstance(a))?a:e.global).__composer}function vTDirective(n){var e=(e,{instance:a,value:t,modifiers:r})=>{if(!a||!a.$)throw createI18nError(22);const s=getComposer$1(n,a.$);r.preserve&&shared.warn(getWarnMessage(7));a=parseValue(t);e.textContent=s.t(...makeParams(a))};return{beforeMount:e,beforeUpdate:e}}function parseValue(e){if(shared.isString(e))return{path:e};if(shared.isPlainObject(e)){if("path"in e)return e;throw createI18nError(19,"path")}throw createI18nError(20)}function makeParams(e){var{path:e,locale:a,args:t,choice:r,plural:s}=e;const n={};t=t||{};return shared.isString(a)&&(n.locale=a),shared.isNumber(r)&&(n.plural=r),shared.isNumber(s)&&(n.plural=s),[e,t,n]}function apply(e,a,...t){var t=shared.isPlainObject(t[0])?t[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(r,s,n){return{beforeCreate(){var e=vue.getCurrentInstance();if(!e)throw createI18nError(22);var a=this.$options;if(a.i18n){const t=a.i18n;a.__i18n&&(t.__i18n=a.__i18n),t.__root=s,this===this.$root?this.$i18n=mergeToRoot(r,t):(t.__injectWithOption=!0,this.$i18n=createVueI18n(t))}else a.__i18n?this===this.$root?this.$i18n=mergeToRoot(r,a):this.$i18n=createVueI18n({__i18n:a.__i18n,__injectWithOption:!0,__root:s}):this.$i18n=r;r.__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,t){a.locale=t.locale||a.locale,a.fallbackLocale=t.fallbackLocale||a.fallbackLocale,a.missing=t.missing||a.missing,a.silentTranslationWarn=t.silentTranslationWarn||a.silentFallbackWarn,a.silentFallbackWarn=t.silentFallbackWarn||a.silentFallbackWarn,a.formatFallbackMessages=t.formatFallbackMessages||a.formatFallbackMessages,a.postTranslation=t.postTranslation||a.postTranslation,a.warnHtmlInMessage=t.warnHtmlInMessage||a.warnHtmlInMessage,a.escapeParameterHtml=t.escapeParameterHtml||a.escapeParameterHtml,a.sync=t.sync||a.sync,a.__composer[SetPluralRulesSymbol](t.pluralizationRules||a.pluralizationRules);const r=getLocaleMessages(a.locale,{messages:t.messages,__i18n:t.__i18n});return Object.keys(r).forEach(e=>a.mergeLocaleMessage(e,r[e])),t.datetimeFormats&&Object.keys(t.datetimeFormats).forEach(e=>a.mergeDateTimeFormat(e,t.datetimeFormats[e])),t.numberFormats&&Object.keys(t.numberFormats).forEach(e=>a.mergeNumberFormat(e,t.numberFormats[e])),a}function createI18n(e={}){const t=!shared.isBoolean(e.legacy)||e.legacy,r=!!e.globalInjection,s=new Map,n=(t?createVueI18n:createComposer)(e),o=shared.makeSymbol("vue-i18n"),l={get mode(){return t?"legacy":"composition"},async install(e,...a){e.__VUE_I18N_SYMBOL__=o,e.provide(e.__VUE_I18N_SYMBOL__,l),!t&&r&&injectGlobalFields(e,l.global),apply(e,l,...a),t&&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(t={}){var r=vue.getCurrentInstance();if(null==r)throw createI18nError(16);if(!r.appContext.app.__VUE_I18N_SYMBOL__)throw createI18nError(17);var a=vue.inject(r.appContext.app.__VUE_I18N_SYMBOL__);if(!a)throw createI18nError(22);const s="composition"===a.mode?a.global:a.global.__composer;var e=shared.isEmptyObject(t)?"__i18n"in r.type?"local":"global":t.useScope||"local";if("global"===e){let a=shared.isObject(t.messages)?t.messages:{};"__i18nGlobal"in r.type&&(a=getLocaleMessages(s.locale.value,{messages:a,__i18n:r.type.__i18nGlobal}));const l=Object.keys(a);if(l.length&&l.forEach(e=>{s.mergeLocaleMessage(e,a[e])}),shared.isObject(t.datetimeFormats)){const i=Object.keys(t.datetimeFormats);i.length&&i.forEach(e=>{s.mergeDateTimeFormat(e,t.datetimeFormats[e])})}if(shared.isObject(t.numberFormats)){const c=Object.keys(t.numberFormats);c.length&&c.forEach(e=>{s.mergeNumberFormat(e,t.numberFormats[e])})}return s}if("parent"===e){let e=getComposer(a,r,t.__useComponent);return null==e&&(shared.warn(getWarnMessage(12)),e=s),e}if("legacy"===a.mode)throw createI18nError(18);const n=a;let o=n.__getInstance(r);if(null==o){e=r.type;const u=shared.assign({},t);e.__i18n&&(u.__i18n=e.__i18n),s&&(u.__root=s),o=createComposer(u),setupLifeCycle(n,r),n.__setInstance(r,o)}return o}function getComposer(e,a,t=!1){let r=null;var s,n=a.root;let o=a.parent;for(;null!=o;){const l=e;if("composition"===e.mode?r=l.__getInstance(o):(null!=(s=l.__getInstance(o))&&(r=s.__composer),t&&r&&!r[InejctWithOption]&&(r=null)),null!=r)break;if(n===o)break;o=o.parent}return r}function setupLifeCycle(e,a,t){vue.onMounted(()=>{},a),vue.onUnmounted(()=>{e.__deleteInstance(a)},a)}const globalExportProps=["locale","fallbackLocale","availableLocales"],globalExportMethods=["t","rt","d","n","tm"];function injectGlobalFields(t,r){const s=Object.create(null);globalExportProps.forEach(e=>{const a=Object.getOwnPropertyDescriptor(r,e);if(!a)throw createI18nError(22);var t=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,t)}),t.config.globalProperties.$i18n=s,globalExportMethods.forEach(e=>{var a=Object.getOwnPropertyDescriptor(r,e);if(!a||!a.value)throw createI18nError(22);Object.defineProperty(t.config.globalProperties,"$"+e,a)})}coreBase.registerMessageCompiler(coreBase.compileToFunction);{const qd=shared.getGlobalThis();qd.__INTLIFY__=!0,coreBase.setDevToolsHook(qd.__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; |