gc_i18n 1.0.4 → 1.0.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -21,4 +21,4 @@ ${g}`:f)}else throw i},onCacheKey:i=>br(t,n,i)}}function ca(e){if(A(e))return e;
21
21
  * Released under the MIT License.
22
22
  */const ba="11.1.1";function ya(){typeof __VUE_I18N_FULL_INSTALL__!="boolean"&&(Ce().__VUE_I18N_FULL_INSTALL__=!0),typeof __VUE_I18N_LEGACY_API__!="boolean"&&(Ce().__VUE_I18N_LEGACY_API__=!0),typeof __INTLIFY_DROP_MESSAGE_COMPILER__!="boolean"&&(Ce().__INTLIFY_DROP_MESSAGE_COMPILER__=!1),typeof __INTLIFY_PROD_DEVTOOLS__!="boolean"&&(Ce().__INTLIFY_PROD_DEVTOOLS__=!1)}const B={UNEXPECTED_RETURN_TYPE:Is,INVALID_ARGUMENT:25,MUST_BE_CALL_SETUP_TOP:26,NOT_INSTALLED:27,REQUIRED_VALUE:28,INVALID_VALUE:29,CANNOT_SETUP_VUE_DEVTOOLS_PLUGIN:30,NOT_INSTALLED_WITH_PROVIDE:31,UNEXPECTED_ERROR:32,NOT_COMPATIBLE_LEGACY_VUE_I18N:33,NOT_AVAILABLE_COMPOSITION_IN_LEGACY:34};function re(e,...t){return Re(e,null,process.env.NODE_ENV!=="production"?{messages:Na,args:t}:void 0)}const Na={[B.UNEXPECTED_RETURN_TYPE]:"Unexpected return type in composer",[B.INVALID_ARGUMENT]:"Invalid argument",[B.MUST_BE_CALL_SETUP_TOP]:"Must be called at the top of a `setup` function",[B.NOT_INSTALLED]:"Need to install with `app.use` function",[B.UNEXPECTED_ERROR]:"Unexpected error",[B.REQUIRED_VALUE]:"Required in value: {0}",[B.INVALID_VALUE]:"Invalid value",[B.CANNOT_SETUP_VUE_DEVTOOLS_PLUGIN]:"Cannot setup vue-devtools plugin",[B.NOT_INSTALLED_WITH_PROVIDE]:"Need to install with `provide` function",[B.NOT_COMPATIBLE_LEGACY_VUE_I18N]:"Not compatible legacy VueI18n.",[B.NOT_AVAILABLE_COMPOSITION_IN_LEGACY]:"Not available Compostion API in Legacy API mode. Please make sure that the legacy API mode is working properly"},kt=ce("__translateVNode"),St=ce("__datetimeParts"),Dt=ce("__numberParts"),Ie=ce("__enableEmitter"),Ge=ce("__disableEmitter"),xn=ce("__setPluralRules"),$n=ce("__injectWithOption"),Pt=ce("__dispose"),fe={FALLBACK_TO_ROOT:xs,NOT_FOUND_PARENT_SCOPE:9,IGNORE_OBJ_FLATTEN:10,DEPRECATE_LEGACY_MODE:11,DEPRECATE_TRANSLATE_CUSTOME_DIRECTIVE:12},va={[fe.FALLBACK_TO_ROOT]:"Fall back to {type} '{key}' with root locale.",[fe.NOT_FOUND_PARENT_SCOPE]:"Not found parent scope. use the global scope.",[fe.IGNORE_OBJ_FLATTEN]:"Ignore object flatten: '{key}' key has an string value",[fe.DEPRECATE_LEGACY_MODE]:`Legacy API mode has been deprecated in v11. Use Composition API mode instead.
23
23
  About how to use the Composition API mode, see https://vue-i18n.intlify.dev/guide/advanced/composition.html`,[fe.DEPRECATE_TRANSLATE_CUSTOME_DIRECTIVE]:"'v-t' has been deprecated in v11. Use translate APIs ('t' or '$t') instead."};function Be(e,...t){return ze(va[e],...t)}function Ye(e){if(!K(e))return e;for(const t in e)if(le(e,t))if(!t.includes("."))K(e[t])&&Ye(e[t]);else{const n=t.split("."),r=n.length-1;let a=e,s=!1;for(let i=0;i<r;i++){if(n[i]in a||(a[n[i]]=W()),!K(a[n[i]])){process.env.NODE_ENV!=="production"&&ge(Be(fe.IGNORE_OBJ_FLATTEN,{key:n[i]})),s=!0;break}a=a[n[i]]}s||(a[n[r]]=e[t],delete e[t]),K(a[n[r]])&&Ye(a[n[r]])}return e}function Rt(e,t){const{messages:n,__i18n:r,messageResolver:a,flatJson:s}=t,i=F(n)?n:j(r)?W():{[e]:W()};if(j(r)&&r.forEach(c=>{if("locale"in c&&"resource"in c){const{locale:f,resource:g}=c;f?(i[f]=i[f]||W(),nt(g,i[f])):nt(g,i)}else A(c)&&nt(JSON.parse(c),i)}),a==null&&s)for(const c in i)le(i,c)&&Ye(i[c]);return i}function Wn(e){return e.type}function Gn(e,t,n){let r=K(t.messages)?t.messages:W();"__i18nGlobal"in n&&(r=Rt(e.locale.value,{messages:r,__i18n:n.__i18nGlobal}));const a=Object.keys(r);a.length&&a.forEach(s=>{e.mergeLocaleMessage(s,r[s])});{if(K(t.datetimeFormats)){const s=Object.keys(t.datetimeFormats);s.length&&s.forEach(i=>{e.mergeDateTimeFormat(i,t.datetimeFormats[i])})}if(K(t.numberFormats)){const s=Object.keys(t.numberFormats);s.length&&s.forEach(i=>{e.mergeNumberFormat(i,t.numberFormats[i])})}}}function Bn(e){return C.createVNode(C.Text,null,e,0)}const Yn="__INTLIFY_META__",Hn=()=>[],Ta=()=>!1;let jn=0;function Xn(e){return(t,n,r,a)=>e(n,r,C.getCurrentInstance()||void 0,a)}const La=()=>{const e=C.getCurrentInstance();let t=null;return e&&(t=Wn(e)[Yn])?{[Yn]:t}:null};function Mt(e={}){const{__root:t,__injectWithOption:n}=e,r=t===void 0,a=e.flatJson,s=oe?C.ref:C.shallowRef;let i=U(e.inheritLocale)?e.inheritLocale:!0;const c=s(t&&i?t.locale.value:A(e.locale)?e.locale:$e),f=s(t&&i?t.fallbackLocale.value:A(e.fallbackLocale)||j(e.fallbackLocale)||F(e.fallbackLocale)||e.fallbackLocale===!1?e.fallbackLocale:c.value),g=s(Rt(c.value,e)),N=s(F(e.datetimeFormats)?e.datetimeFormats:{[c.value]:{}}),v=s(F(e.numberFormats)?e.numberFormats:{[c.value]:{}});let y=t?t.missingWarn:U(e.missingWarn)||Pe(e.missingWarn)?e.missingWarn:!0,I=t?t.fallbackWarn:U(e.fallbackWarn)||Pe(e.fallbackWarn)?e.fallbackWarn:!0,P=t?t.fallbackRoot:U(e.fallbackRoot)?e.fallbackRoot:!0,k=!!e.fallbackFormat,S=G(e.missing)?e.missing:null,o=G(e.missing)?Xn(e.missing):null,m=G(e.postTranslation)?e.postTranslation:null,l=t?t.warnHtmlMessage:U(e.warnHtmlMessage)?e.warnHtmlMessage:!0,u=!!e.escapeParameter;const _=t?t.modifiers:F(e.modifiers)?e.modifiers:{};let E=e.pluralRules||t&&t.pluralRules,p;p=(()=>{r&&vn(null);const b={version:ba,locale:c.value,fallbackLocale:f.value,messages:g.value,modifiers:_,pluralRules:E,missing:o===null?void 0:o,missingWarn:y,fallbackWarn:I,fallbackFormat:k,unresolving:!0,postTranslation:m===null?void 0:m,warnHtmlMessage:l,escapeParameter:u,messageResolver:e.messageResolver,messageCompiler:e.messageCompiler,__meta:{framework:"vue"}};b.datetimeFormats=N.value,b.numberFormats=v.value,b.__datetimeFormatters=F(p)?p.__datetimeFormatters:void 0,b.__numberFormatters=F(p)?p.__numberFormatters:void 0,process.env.NODE_ENV!=="production"&&(b.__v_emitter=F(p)?p.__v_emitter:void 0);const L=Js(b);return r&&vn(L),L})(),We(p,c.value,f.value);function R(){return[c.value,f.value,g.value,N.value,v.value]}const w=C.computed({get:()=>c.value,set:b=>{p.locale=b,c.value=b}}),Y=C.computed({get:()=>f.value,set:b=>{p.fallbackLocale=b,f.value=b,We(p,c.value,b)}}),$=C.computed(()=>g.value),de=C.computed(()=>N.value),_e=C.computed(()=>v.value);function Ae(){return G(m)?m:null}function se(b){m=b,p.postTranslation=b}function ve(){return S}function Ke(b){b!==null&&(o=Xn(b)),S=b,p.missing=o}function je(b,L){return b!=="translate"||!L.resolvedMessage}const pe=(b,L,x,J,Se,ft)=>{R();let Ue;try{process.env.NODE_ENV!=="production"||__INTLIFY_PROD_DEVTOOLS__,r||(p.fallbackContext=t?qs():void 0),Ue=b(p)}finally{process.env.NODE_ENV!=="production"||__INTLIFY_PROD_DEVTOOLS__,r||(p.fallbackContext=void 0)}if(x!=="translate exists"&&Z(Ue)&&Ue===at||x==="translate exists"&&!Ue){const[De,yi]=L();if(process.env.NODE_ENV!=="production"&&t&&A(De)&&je(x,yi)&&(P&&(ot(I,De)||Ln(y,De))&&ge(Be(fe.FALLBACK_TO_ROOT,{key:De,type:x})),process.env.NODE_ENV!=="production")){const{__v_emitter:_r}=p;_r&&P&&_r.emit("fallback",{type:x,key:De,to:"global",groupId:`${x}:${De}`})}return t&&P?J(t):Se(De)}else{if(ft(Ue))return Ue;throw re(B.UNEXPECTED_RETURN_TYPE)}};function Xe(...b){return pe(L=>Reflect.apply(Fn,null,[L,...b]),()=>It(...b),"translate",L=>Reflect.apply(L.t,L,[...b]),L=>L,L=>A(L))}function Gt(...b){const[L,x,J]=b;if(J&&!K(J))throw re(B.INVALID_ARGUMENT);return Xe(L,x,z({resolvedMessage:!0},J||{}))}function Bt(...b){return pe(L=>Reflect.apply(An,null,[L,...b]),()=>Ct(...b),"datetime format",L=>Reflect.apply(L.d,L,[...b]),()=>it,L=>A(L))}function Yt(...b){return pe(L=>Reflect.apply(Dn,null,[L,...b]),()=>Ot(...b),"number format",L=>Reflect.apply(L.n,L,[...b]),()=>it,L=>A(L))}function Ht(b){return b.map(L=>A(L)||Z(L)||U(L)?Bn(String(L)):L)}const jt={normalize:Ht,interpolate:b=>b,type:"vnode"};function ut(...b){return pe(L=>{let x;const J=L;try{J.processor=jt,x=Reflect.apply(Fn,null,[J,...b])}finally{J.processor=null}return x},()=>It(...b),"translate",L=>L[kt](...b),L=>[Bn(L)],L=>j(L))}function Xt(...b){return pe(L=>Reflect.apply(Dn,null,[L,...b]),()=>Ot(...b),"number format",L=>L[Dt](...b),Hn,L=>A(L)||j(L))}function qt(...b){return pe(L=>Reflect.apply(An,null,[L,...b]),()=>Ct(...b),"datetime format",L=>L[St](...b),Hn,L=>A(L)||j(L))}function Jt(b){E=b,p.pluralRules=E}function Qt(b,L){return pe(()=>{if(!b)return!1;const x=A(L)?L:c.value,J=ke(x),Se=p.messageResolver(J,b);return ye(Se)||ie(Se)||A(Se)},()=>[b],"translate exists",x=>Reflect.apply(x.te,x,[b,L]),Ta,x=>U(x))}function qe(b){let L=null;const x=_n(p,f.value,c.value);for(let J=0;J<x.length;J++){const Se=g.value[x[J]]||{},ft=p.messageResolver(Se,b);if(ft!=null){L=ft;break}}return L}function Je(b){const L=qe(b);return L??(t?t.tm(b)||{}:{})}function ke(b){return g.value[b]||{}}function Qe(b,L){if(a){const x={[b]:L};for(const J in x)le(x,J)&&Ye(x[J]);L=x[b]}g.value[b]=L,p.messages=g.value}function Zt(b,L){g.value[b]=g.value[b]||{};const x={[b]:L};if(a)for(const J in x)le(x,J)&&Ye(x[J]);L=x[b],nt(L,g.value[b]),p.messages=g.value}function d(b){return N.value[b]||{}}function h(b,L){N.value[b]=L,p.datetimeFormats=N.value,Sn(p,b,L)}function T(b,L){N.value[b]=z(N.value[b]||{},L),p.datetimeFormats=N.value,Sn(p,b,L)}function D(b){return v.value[b]||{}}function X(b,L){v.value[b]=L,p.numberFormats=v.value,Rn(p,b,L)}function q(b,L){v.value[b]=z(v.value[b]||{},L),p.numberFormats=v.value,Rn(p,b,L)}jn++,t&&oe&&(C.watch(t.locale,b=>{i&&(c.value=b,p.locale=b,We(p,c.value,f.value))}),C.watch(t.fallbackLocale,b=>{i&&(f.value=b,p.fallbackLocale=b,We(p,c.value,f.value))}));const V={id:jn,locale:w,fallbackLocale:Y,get inheritLocale(){return i},set inheritLocale(b){i=b,b&&t&&(c.value=t.locale.value,f.value=t.fallbackLocale.value,We(p,c.value,f.value))},get availableLocales(){return Object.keys(g.value).sort()},messages:$,get modifiers(){return _},get pluralRules(){return E||{}},get isGlobal(){return r},get missingWarn(){return y},set missingWarn(b){y=b,p.missingWarn=y},get fallbackWarn(){return I},set fallbackWarn(b){I=b,p.fallbackWarn=I},get fallbackRoot(){return P},set fallbackRoot(b){P=b},get fallbackFormat(){return k},set fallbackFormat(b){k=b,p.fallbackFormat=k},get warnHtmlMessage(){return l},set warnHtmlMessage(b){l=b,p.warnHtmlMessage=b},get escapeParameter(){return u},set escapeParameter(b){u=b,p.escapeParameter=b},t:Xe,getLocaleMessage:ke,setLocaleMessage:Qe,mergeLocaleMessage:Zt,getPostTranslationHandler:Ae,setPostTranslationHandler:se,getMissingHandler:ve,setMissingHandler:Ke,[xn]:Jt};return V.datetimeFormats=de,V.numberFormats=_e,V.rt=Gt,V.te=Qt,V.tm=Je,V.d=Bt,V.n=Yt,V.getDateTimeFormat=d,V.setDateTimeFormat=h,V.mergeDateTimeFormat=T,V.getNumberFormat=D,V.setNumberFormat=X,V.mergeNumberFormat=q,V[$n]=n,V[kt]=ut,V[St]=qt,V[Dt]=Xt,process.env.NODE_ENV!=="production"&&(V[Ie]=b=>{p.__v_emitter=b},V[Ge]=()=>{p.__v_emitter=void 0}),V}const qn="vue-i18n: composer properties",wt={"vue-devtools-plugin-vue-i18n":"Vue I18n DevTools","vue-i18n-resource-inspector":"Vue I18n DevTools","vue-i18n-timeline":"Vue I18n"},Ca={"vue-i18n-resource-inspector":"Search for scopes ..."},Oa={"vue-i18n-timeline":16764185};let Ft;async function Ia(e,t){return new Promise((n,r)=>{try{Ea({id:"vue-devtools-plugin-vue-i18n",label:wt["vue-devtools-plugin-vue-i18n"],packageName:"vue-i18n",homepage:"https://vue-i18n.intlify.dev",logo:"https://vue-i18n.intlify.dev/vue-i18n-devtools-logo.png",componentStateTypes:[qn],app:e},a=>{Ft=a,a.on.visitComponentTree(({componentInstance:i,treeNode:c})=>{Aa(i,c,t)}),a.on.inspectComponent(({componentInstance:i,instanceData:c})=>{i.vnode.el&&i.vnode.el.__VUE_I18N__&&c&&(t.mode==="legacy"?i.vnode.el.__VUE_I18N__!==t.global.__composer&&Qn(c,i.vnode.el.__VUE_I18N__):Qn(c,i.vnode.el.__VUE_I18N__))}),a.addInspector({id:"vue-i18n-resource-inspector",label:wt["vue-i18n-resource-inspector"],icon:"language",treeFilterPlaceholder:Ca["vue-i18n-resource-inspector"]}),a.on.getInspectorTree(i=>{i.app===e&&i.inspectorId==="vue-i18n-resource-inspector"&&Ra(i,t)});const s=new Map;a.on.getInspectorState(async i=>{if(i.app===e&&i.inspectorId==="vue-i18n-resource-inspector")if(a.unhighlightElement(),wa(i,t),i.nodeId==="global"){if(!s.has(i.app)){const[c]=await a.getComponentInstances(i.app);s.set(i.app,c)}a.highlightElement(s.get(i.app))}else{const c=Ma(i.nodeId,t);c&&a.highlightElement(c)}}),a.on.editInspectorState(i=>{i.app===e&&i.inspectorId==="vue-i18n-resource-inspector"&&Ka(i,t)}),a.addTimelineLayer({id:"vue-i18n-timeline",label:wt["vue-i18n-timeline"],color:Oa["vue-i18n-timeline"]}),n(!0)})}catch(a){console.error(a),r(!1)}})}function Jn(e){return e.type.name||e.type.displayName||e.type.__file||"Anonymous"}function Aa(e,t,n){const r=n.mode==="composition"?n.global:n.global.__composer;if(e&&e.vnode.el&&e.vnode.el.__VUE_I18N__&&e.vnode.el.__VUE_I18N__!==r){const a={label:`i18n (${Jn(e)} Scope)`,textColor:0,backgroundColor:16764185};t.tags.push(a)}}function Qn(e,t){const n=qn;e.state.push({type:n,key:"locale",editable:!0,value:t.locale.value}),e.state.push({type:n,key:"availableLocales",editable:!1,value:t.availableLocales}),e.state.push({type:n,key:"fallbackLocale",editable:!0,value:t.fallbackLocale.value}),e.state.push({type:n,key:"inheritLocale",editable:!0,value:t.inheritLocale}),e.state.push({type:n,key:"messages",editable:!1,value:Kt(t.messages.value)}),e.state.push({type:n,key:"datetimeFormats",editable:!1,value:t.datetimeFormats.value}),e.state.push({type:n,key:"numberFormats",editable:!1,value:t.numberFormats.value})}function Kt(e){const t={};return Object.keys(e).forEach(n=>{const r=e[n];G(r)&&"source"in r?t[n]=Pa(r):ye(r)&&r.loc&&r.loc.source?t[n]=r.loc.source:K(r)?t[n]=Kt(r):t[n]=r}),t}const ka={"<":"&lt;",">":"&gt;",'"':"&quot;","&":"&amp;"};function Sa(e){return e.replace(/[<>"&]/g,Da)}function Da(e){return ka[e]||e}function Pa(e){return{_custom:{type:"function",display:`<span>ƒ</span> ${e.source?`("${Sa(e.source)}")`:"(?)"}`}}}function Ra(e,t){e.rootNodes.push({id:"global",label:"Global Scope"});const n=t.mode==="composition"?t.global:t.global.__composer;for(const[r,a]of t.__instances){const s=t.mode==="composition"?a:a.__composer;n!==s&&e.rootNodes.push({id:s.id.toString(),label:`${Jn(r)} Scope`})}}function Ma(e,t){let n=null;if(e!=="global"){for(const[r,a]of t.__instances.entries())if(a.id.toString()===e){n=r;break}}return n}function Zn(e,t){if(e==="global")return t.mode==="composition"?t.global:t.global.__composer;{const n=Array.from(t.__instances.values()).find(r=>r.id.toString()===e);return n?t.mode==="composition"?n:n.__composer:null}}function wa(e,t){const n=Zn(e.nodeId,t);return n&&(e.state=Fa(n)),null}function Fa(e){const t={},n="Locale related info",r=[{type:n,key:"locale",editable:!0,value:e.locale.value},{type:n,key:"fallbackLocale",editable:!0,value:e.fallbackLocale.value},{type:n,key:"availableLocales",editable:!1,value:e.availableLocales},{type:n,key:"inheritLocale",editable:!0,value:e.inheritLocale}];t[n]=r;const a="Locale messages info",s=[{type:a,key:"messages",editable:!1,value:Kt(e.messages.value)}];t[a]=s;{const i="Datetime formats info",c=[{type:i,key:"datetimeFormats",editable:!1,value:e.datetimeFormats.value}];t[i]=c;const f="Datetime formats info",g=[{type:f,key:"numberFormats",editable:!1,value:e.numberFormats.value}];t[f]=g}return t}function He(e,t){if(Ft){let n;t&&"groupId"in t&&(n=t.groupId,delete t.groupId),Ft.addTimelineEvent({layerId:"vue-i18n-timeline",event:{title:e,groupId:n,time:Date.now(),meta:{},data:t||{},logType:e==="compile-error"?"error":e==="fallback"||e==="missing"?"warning":"default"}})}}function Ka(e,t){const n=Zn(e.nodeId,t);if(n){const[r]=e.path;r==="locale"&&A(e.state.value)?n.locale.value=e.state.value:r==="fallbackLocale"&&(A(e.state.value)||j(e.state.value)||K(e.state.value))?n.fallbackLocale.value=e.state.value:r==="inheritLocale"&&U(e.state.value)&&(n.inheritLocale=e.state.value)}}function Ua(e){const t=A(e.locale)?e.locale:$e,n=A(e.fallbackLocale)||j(e.fallbackLocale)||F(e.fallbackLocale)||e.fallbackLocale===!1?e.fallbackLocale:t,r=G(e.missing)?e.missing:void 0,a=U(e.silentTranslationWarn)||Pe(e.silentTranslationWarn)?!e.silentTranslationWarn:!0,s=U(e.silentFallbackWarn)||Pe(e.silentFallbackWarn)?!e.silentFallbackWarn:!0,i=U(e.fallbackRoot)?e.fallbackRoot:!0,c=!!e.formatFallbackMessages,f=F(e.modifiers)?e.modifiers:{},g=e.pluralizationRules,N=G(e.postTranslation)?e.postTranslation:void 0,v=A(e.warnHtmlInMessage)?e.warnHtmlInMessage!=="off":!0,y=!!e.escapeParameterHtml,I=U(e.sync)?e.sync:!0;let P=e.messages;if(F(e.sharedMessages)){const _=e.sharedMessages;P=Object.keys(_).reduce((p,O)=>{const R=p[O]||(p[O]={});return z(R,_[O]),p},P||{})}const{__i18n:k,__root:S,__injectWithOption:o}=e,m=e.datetimeFormats,l=e.numberFormats,u=e.flatJson;return{locale:t,fallbackLocale:n,messages:P,flatJson:u,datetimeFormats:m,numberFormats:l,missing:r,missingWarn:a,fallbackWarn:s,fallbackRoot:i,fallbackFormat:c,modifiers:f,pluralRules:g,postTranslation:N,warnHtmlMessage:v,escapeParameter:y,messageResolver:e.messageResolver,inheritLocale:I,__i18n:k,__root:S,__injectWithOption:o}}function Ut(e={}){const t=Mt(Ua(e)),{__extender:n}=e,r={id:t.id,get locale(){return t.locale.value},set locale(a){t.locale.value=a},get fallbackLocale(){return t.fallbackLocale.value},set fallbackLocale(a){t.fallbackLocale.value=a},get messages(){return t.messages.value},get datetimeFormats(){return t.datetimeFormats.value},get numberFormats(){return t.numberFormats.value},get availableLocales(){return t.availableLocales},get missing(){return t.getMissingHandler()},set missing(a){t.setMissingHandler(a)},get silentTranslationWarn(){return U(t.missingWarn)?!t.missingWarn:t.missingWarn},set silentTranslationWarn(a){t.missingWarn=U(a)?!a:a},get silentFallbackWarn(){return U(t.fallbackWarn)?!t.fallbackWarn:t.fallbackWarn},set silentFallbackWarn(a){t.fallbackWarn=U(a)?!a:a},get modifiers(){return t.modifiers},get formatFallbackMessages(){return t.fallbackFormat},set formatFallbackMessages(a){t.fallbackFormat=a},get postTranslation(){return t.getPostTranslationHandler()},set postTranslation(a){t.setPostTranslationHandler(a)},get sync(){return t.inheritLocale},set sync(a){t.inheritLocale=a},get warnHtmlInMessage(){return t.warnHtmlMessage?"warn":"off"},set warnHtmlInMessage(a){t.warnHtmlMessage=a!=="off"},get escapeParameterHtml(){return t.escapeParameter},set escapeParameterHtml(a){t.escapeParameter=a},get pluralizationRules(){return t.pluralRules||{}},__composer:t,t(...a){return Reflect.apply(t.t,t,[...a])},rt(...a){return Reflect.apply(t.rt,t,[...a])},te(a,s){return t.te(a,s)},tm(a){return t.tm(a)},getLocaleMessage(a){return t.getLocaleMessage(a)},setLocaleMessage(a,s){t.setLocaleMessage(a,s)},mergeLocaleMessage(a,s){t.mergeLocaleMessage(a,s)},d(...a){return Reflect.apply(t.d,t,[...a])},getDateTimeFormat(a){return t.getDateTimeFormat(a)},setDateTimeFormat(a,s){t.setDateTimeFormat(a,s)},mergeDateTimeFormat(a,s){t.mergeDateTimeFormat(a,s)},n(...a){return Reflect.apply(t.n,t,[...a])},getNumberFormat(a){return t.getNumberFormat(a)},setNumberFormat(a,s){t.setNumberFormat(a,s)},mergeNumberFormat(a,s){t.mergeNumberFormat(a,s)}};return r.__extender=n,process.env.NODE_ENV!=="production"&&(r.__enableEmitter=a=>{const s=t;s[Ie]&&s[Ie](a)},r.__disableEmitter=()=>{const a=t;a[Ge]&&a[Ge]()}),r}function Va(e,t,n){return{beforeCreate(){const r=C.getCurrentInstance();if(!r)throw re(B.UNEXPECTED_ERROR);const a=this.$options;if(a.i18n){const s=a.i18n;if(a.__i18n&&(s.__i18n=a.__i18n),s.__root=t,this===this.$root)this.$i18n=zn(e,s);else{s.__injectWithOption=!0,s.__extender=n.__vueI18nExtend,this.$i18n=Ut(s);const i=this.$i18n;i.__extender&&(i.__disposer=i.__extender(this.$i18n))}}else if(a.__i18n)if(this===this.$root)this.$i18n=zn(e,a);else{this.$i18n=Ut({__i18n:a.__i18n,__injectWithOption:!0,__extender:n.__vueI18nExtend,__root:t});const s=this.$i18n;s.__extender&&(s.__disposer=s.__extender(this.$i18n))}else this.$i18n=e;a.__i18nGlobal&&Gn(t,a,a),this.$t=(...s)=>this.$i18n.t(...s),this.$rt=(...s)=>this.$i18n.rt(...s),this.$te=(s,i)=>this.$i18n.te(s,i),this.$d=(...s)=>this.$i18n.d(...s),this.$n=(...s)=>this.$i18n.n(...s),this.$tm=s=>this.$i18n.tm(s),n.__setInstance(r,this.$i18n)},mounted(){if(process.env.NODE_ENV!=="production"&&this.$el&&this.$i18n){const r=this.$i18n;this.$el.__VUE_I18N__=r.__composer;const a=this.__v_emitter=ht();r.__enableEmitter&&r.__enableEmitter(a),a.on("*",He)}},unmounted(){const r=C.getCurrentInstance();if(!r)throw re(B.UNEXPECTED_ERROR);const a=this.$i18n;process.env.NODE_ENV!=="production"&&this.$el&&this.$el.__VUE_I18N__&&(this.__v_emitter&&(this.__v_emitter.off("*",He),delete this.__v_emitter),this.$i18n&&(a.__disableEmitter&&a.__disableEmitter(),delete this.$el.__VUE_I18N__)),delete this.$t,delete this.$rt,delete this.$te,delete this.$d,delete this.$n,delete this.$tm,a.__disposer&&(a.__disposer(),delete a.__disposer,delete a.__extender),n.__deleteInstance(r),delete this.$i18n}}}function zn(e,t){e.locale=t.locale||e.locale,e.fallbackLocale=t.fallbackLocale||e.fallbackLocale,e.missing=t.missing||e.missing,e.silentTranslationWarn=t.silentTranslationWarn||e.silentFallbackWarn,e.silentFallbackWarn=t.silentFallbackWarn||e.silentFallbackWarn,e.formatFallbackMessages=t.formatFallbackMessages||e.formatFallbackMessages,e.postTranslation=t.postTranslation||e.postTranslation,e.warnHtmlInMessage=t.warnHtmlInMessage||e.warnHtmlInMessage,e.escapeParameterHtml=t.escapeParameterHtml||e.escapeParameterHtml,e.sync=t.sync||e.sync,e.__composer[xn](t.pluralizationRules||e.pluralizationRules);const n=Rt(e.locale,{messages:t.messages,__i18n:t.__i18n});return Object.keys(n).forEach(r=>e.mergeLocaleMessage(r,n[r])),t.datetimeFormats&&Object.keys(t.datetimeFormats).forEach(r=>e.mergeDateTimeFormat(r,t.datetimeFormats[r])),t.numberFormats&&Object.keys(t.numberFormats).forEach(r=>e.mergeNumberFormat(r,t.numberFormats[r])),e}const Vt={tag:{type:[String,Object]},locale:{type:String},scope:{type:String,validator:e=>e==="parent"||e==="global",default:"parent"},i18n:{type:Object}};function xa({slots:e},t){return t.length===1&&t[0]==="default"?(e.default?e.default():[]).reduce((r,a)=>[...r,...a.type===C.Fragment?a.children:[a]],[]):t.reduce((n,r)=>{const a=e[r];return a&&(n[r]=a()),n},W())}function er(){return C.Fragment}const tr=C.defineComponent({name:"i18n-t",props:z({keypath:{type:String,required:!0},plural:{type:[Number,String],validator:e=>Z(e)||!isNaN(e)}},Vt),setup(e,t){const{slots:n,attrs:r}=t,a=e.i18n||xt({useScope:e.scope,__useComponent:!0});return()=>{const s=Object.keys(n).filter(v=>v!=="_"),i=W();e.locale&&(i.locale=e.locale),e.plural!==void 0&&(i.plural=A(e.plural)?+e.plural:e.plural);const c=xa(t,s),f=a[kt](e.keypath,c,i),g=z(W(),r),N=A(e.tag)||K(e.tag)?e.tag:er();return C.h(N,g,f)}}});function $a(e){return j(e)&&!A(e[0])}function nr(e,t,n,r){const{slots:a,attrs:s}=t;return()=>{const i={part:!0};let c=W();e.locale&&(i.locale=e.locale),A(e.format)?i.key=e.format:K(e.format)&&(A(e.format.key)&&(i.key=e.format.key),c=Object.keys(e.format).reduce((y,I)=>n.includes(I)?z(W(),y,{[I]:e.format[I]}):y,W()));const f=r(e.value,i,c);let g=[i.key];j(f)?g=f.map((y,I)=>{const P=a[y.type],k=P?P({[y.type]:y.value,index:I,parts:f}):[y.value];return $a(k)&&(k[0].key=`${y.type}-${I}`),k}):A(f)&&(g=[f]);const N=z(W(),s),v=A(e.tag)||K(e.tag)?e.tag:er();return C.h(v,N,g)}}const rr=C.defineComponent({name:"i18n-n",props:z({value:{type:Number,required:!0},format:{type:[String,Object]}},Vt),setup(e,t){const n=e.i18n||xt({useScope:e.scope,__useComponent:!0});return nr(e,t,Pn,(...r)=>n[Dt](...r))}});function Wa(e,t){const n=e;if(e.mode==="composition")return n.__getInstance(t)||e.global;{const r=n.__getInstance(t);return r!=null?r.__composer:e.global.__composer}}function Ga(e){const t=i=>{process.env.NODE_ENV!=="production"&&mt(Be(fe.DEPRECATE_TRANSLATE_CUSTOME_DIRECTIVE));const{instance:c,value:f}=i;if(!c||!c.$)throw re(B.UNEXPECTED_ERROR);const g=Wa(e,c.$),N=sr(f);return[Reflect.apply(g.t,g,[...ar(N)]),g]};return{created:(i,c)=>{const[f,g]=t(c);oe&&e.global===g&&(i.__i18nWatcher=C.watch(g.locale,()=>{c.instance&&c.instance.$forceUpdate()})),i.__composer=g,i.textContent=f},unmounted:i=>{oe&&i.__i18nWatcher&&(i.__i18nWatcher(),i.__i18nWatcher=void 0,delete i.__i18nWatcher),i.__composer&&(i.__composer=void 0,delete i.__composer)},beforeUpdate:(i,{value:c})=>{if(i.__composer){const f=i.__composer,g=sr(c);i.textContent=Reflect.apply(f.t,f,[...ar(g)])}},getSSRProps:i=>{const[c]=t(i);return{textContent:c}}}}function sr(e){if(A(e))return{path:e};if(F(e)){if(!("path"in e))throw re(B.REQUIRED_VALUE,"path");return e}else throw re(B.INVALID_VALUE)}function ar(e){const{path:t,locale:n,args:r,choice:a,plural:s}=e,i={},c=r||{};return A(n)&&(i.locale=n),Z(a)&&(i.plural=a),Z(s)&&(i.plural=s),[t,c,i]}function Ba(e,t,...n){const r=F(n[0])?n[0]:{};(U(r.globalInstall)?r.globalInstall:!0)&&([tr.name,"I18nT"].forEach(s=>e.component(s,tr)),[rr.name,"I18nN"].forEach(s=>e.component(s,rr)),[or.name,"I18nD"].forEach(s=>e.component(s,or))),e.directive("t",Ga(t))}const Ya=ce("global-vue-i18n");function Ha(e={}){const t=__VUE_I18N_LEGACY_API__&&U(e.legacy)?e.legacy:__VUE_I18N_LEGACY_API__;process.env.NODE_ENV!=="production"&&t&&mt(Be(fe.DEPRECATE_LEGACY_MODE));const n=U(e.globalInjection)?e.globalInjection:!0,r=new Map,[a,s]=ja(e,t),i=ce(process.env.NODE_ENV!=="production"?"vue-i18n":"");function c(v){return r.get(v)||null}function f(v,y){r.set(v,y)}function g(v){r.delete(v)}const N={get mode(){return __VUE_I18N_LEGACY_API__&&t?"legacy":"composition"},async install(v,...y){if(process.env.NODE_ENV!=="production"&&(v.__VUE_I18N__=N),v.__VUE_I18N_SYMBOL__=i,v.provide(v.__VUE_I18N_SYMBOL__,N),F(y[0])){const k=y[0];N.__composerExtend=k.__composerExtend,N.__vueI18nExtend=k.__vueI18nExtend}let I=null;!t&&n&&(I=ti(v,N.global)),__VUE_I18N_FULL_INSTALL__&&Ba(v,N,...y),__VUE_I18N_LEGACY_API__&&t&&v.mixin(Va(s,s.__composer,N));const P=v.unmount;if(v.unmount=()=>{I&&I(),N.dispose(),P()},process.env.NODE_ENV!=="production"){if(!await Ia(v,N))throw re(B.CANNOT_SETUP_VUE_DEVTOOLS_PLUGIN);const S=ht();if(t){const o=s;o.__enableEmitter&&o.__enableEmitter(S)}else{const o=s;o[Ie]&&o[Ie](S)}S.on("*",He)}},get global(){return s},dispose(){a.stop()},__instances:r,__getInstance:c,__setInstance:f,__deleteInstance:g};return N}function xt(e={}){const t=C.getCurrentInstance();if(t==null)throw re(B.MUST_BE_CALL_SETUP_TOP);if(!t.isCE&&t.appContext.app!=null&&!t.appContext.app.__VUE_I18N_SYMBOL__)throw re(B.NOT_INSTALLED);const n=Xa(t),r=Ja(n),a=Wn(t),s=qa(e,a);if(s==="global")return Gn(r,e,a),r;if(s==="parent"){let f=Qa(n,t,e.__useComponent);return f==null&&(process.env.NODE_ENV!=="production"&&ge(Be(fe.NOT_FOUND_PARENT_SCOPE)),f=r),f}const i=n;let c=i.__getInstance(t);if(c==null){const f=z({},e);"__i18n"in a&&(f.__i18n=a.__i18n),r&&(f.__root=r),c=Mt(f),i.__composerExtend&&(c[Pt]=i.__composerExtend(c)),za(i,t,c),i.__setInstance(t,c)}return c}function ja(e,t){const n=C.effectScope(),r=__VUE_I18N_LEGACY_API__&&t?n.run(()=>Ut(e)):n.run(()=>Mt(e));if(r==null)throw re(B.UNEXPECTED_ERROR);return[n,r]}function Xa(e){const t=C.inject(e.isCE?Ya:e.appContext.app.__VUE_I18N_SYMBOL__);if(!t)throw re(e.isCE?B.NOT_INSTALLED_WITH_PROVIDE:B.UNEXPECTED_ERROR);return t}function qa(e,t){return et(e)?"__i18n"in t?"local":"global":e.useScope?e.useScope:"local"}function Ja(e){return e.mode==="composition"?e.global:e.global.__composer}function Qa(e,t,n=!1){let r=null;const a=t.root;let s=Za(t,n);for(;s!=null;){const i=e;if(e.mode==="composition")r=i.__getInstance(s);else if(__VUE_I18N_LEGACY_API__){const c=i.__getInstance(s);c!=null&&(r=c.__composer,n&&r&&!r[$n]&&(r=null))}if(r!=null||a===s)break;s=s.parent}return r}function Za(e,t=!1){return e==null?null:t&&e.vnode.ctx||e.parent}function za(e,t,n){let r=null;C.onMounted(()=>{if(process.env.NODE_ENV!=="production"&&t.vnode.el){t.vnode.el.__VUE_I18N__=n,r=ht();const a=n;a[Ie]&&a[Ie](r),r.on("*",He)}},t),C.onUnmounted(()=>{const a=n;process.env.NODE_ENV!=="production"&&t.vnode.el&&t.vnode.el.__VUE_I18N__&&(r&&r.off("*",He),a[Ge]&&a[Ge](),delete t.vnode.el.__VUE_I18N__),e.__deleteInstance(t);const s=a[Pt];s&&(s(),delete a[Pt])},t)}const ei=["locale","fallbackLocale","availableLocales"],ir=["t","rt","d","n","tm","te"];function ti(e,t){const n=Object.create(null);return ei.forEach(a=>{const s=Object.getOwnPropertyDescriptor(t,a);if(!s)throw re(B.UNEXPECTED_ERROR);const i=C.isRef(s.value)?{get(){return s.value.value},set(c){s.value.value=c}}:{get(){return s.get&&s.get()}};Object.defineProperty(n,a,i)}),e.config.globalProperties.$i18n=n,ir.forEach(a=>{const s=Object.getOwnPropertyDescriptor(t,a);if(!s||!s.value)throw re(B.UNEXPECTED_ERROR);Object.defineProperty(e.config.globalProperties,`$${a}`,s)}),()=>{delete e.config.globalProperties.$i18n,ir.forEach(a=>{delete e.config.globalProperties[`$${a}`]})}}const or=C.defineComponent({name:"i18n-d",props:z({value:{type:[Number,Date],required:!0},format:{type:[String,Object]}},Vt),setup(e,t){const n=e.i18n||xt({useScope:e.scope,__useComponent:!0});return nr(e,t,kn,(...r)=>n[St](...r))}});if(ya(),Bs(vs),Ys(Vs),Hs(_n),process.env.NODE_ENV!=="production"||__INTLIFY_PROD_DEVTOOLS__){const e=Ce();e.__INTLIFY__=!0,Ts(e.__INTLIFY_DEVTOOLS_GLOBAL_HOOK__)}process.env.NODE_ENV;var lt={exports:{}};/*! store2 - v2.14.4 - 2024-12-26
24
- * Copyright (c) 2024 Nathan Bubna; Licensed MIT */var $t=lt.exports,lr;function ni(){return lr||(lr=1,function(e){(function(t,n){var r={version:"2.14.4",areas:{},apis:{},nsdelim:".",inherit:function(s,i){for(var c in s)i.hasOwnProperty(c)||Object.defineProperty(i,c,Object.getOwnPropertyDescriptor(s,c));return i},stringify:function(s,i){return s===void 0||typeof s=="function"?s+"":JSON.stringify(s,i||r.replace)},parse:function(s,i){try{return JSON.parse(s,i||r.revive)}catch{return s}},fn:function(s,i){r.storeAPI[s]=i;for(var c in r.apis)r.apis[c][s]=i},get:function(s,i){return s.getItem(i)},set:function(s,i,c){s.setItem(i,c)},remove:function(s,i){s.removeItem(i)},key:function(s,i){return s.key(i)},length:function(s){return s.length},clear:function(s){s.clear()},Store:function(s,i,c){var f=r.inherit(r.storeAPI,function(N,v,y){return arguments.length===0?f.getAll():typeof v=="function"?f.transact(N,v,y):v!==void 0?f.set(N,v,y):typeof N=="string"||typeof N=="number"?f.get(N):typeof N=="function"?f.each(N):N?f.setAll(N,v):f.clear()});f._id=s;try{var g="__store2_test";i.setItem(g,"ok"),f._area=i,i.removeItem(g)}catch{f._area=r.storage("fake")}return f._ns=c||"",r.areas[s]||(r.areas[s]=f._area),r.apis[f._ns+f._id]||(r.apis[f._ns+f._id]=f),f},storeAPI:{area:function(s,i){var c=this[s];return(!c||!c.area)&&(c=r.Store(s,i,this._ns),this[s]||(this[s]=c)),c},namespace:function(s,i,c){if(c=c||this._delim||r.nsdelim,!s)return this._ns?this._ns.substring(0,this._ns.length-c.length):"";var f=s,g=this[f];if((!g||!g.namespace)&&(g=r.Store(this._id,this._area,this._ns+f+c),g._delim=c,this[f]||(this[f]=g),!i))for(var N in r.areas)g.area(N,r.areas[N]);return g},isFake:function(s){return s?(this._real=this._area,this._area=r.storage("fake")):s===!1&&(this._area=this._real||this._area),this._area.name==="fake"},toString:function(){return"store"+(this._ns?"."+this.namespace():"")+"["+this._id+"]"},has:function(s){return this._area.has?this._area.has(this._in(s)):this._in(s)in this._area},size:function(){return this.keys().length},each:function(s,i){for(var c=0,f=r.length(this._area);c<f;c++){var g=this._out(r.key(this._area,c));if(g!==void 0&&s.call(this,g,this.get(g),i)===!1)break;f>r.length(this._area)&&(f--,c--)}return i||this},keys:function(s){return this.each(function(i,c,f){f.push(i)},s||[])},get:function(s,i){var c=r.get(this._area,this._in(s)),f;return typeof i=="function"&&(f=i,i=null),c!==null?r.parse(c,f):i??c},getAll:function(s){return this.each(function(i,c,f){f[i]=c},s||{})},transact:function(s,i,c){var f=this.get(s,c),g=i(f);return this.set(s,g===void 0?f:g),this},set:function(s,i,c){var f=this.get(s),g;return f!=null&&c===!1?i:(typeof c=="function"&&(g=c,c=void 0),r.set(this._area,this._in(s),r.stringify(i,g),c)||f)},setAll:function(s,i){var c,f;for(var g in s)f=s[g],this.set(g,f,i)!==f&&(c=!0);return c},add:function(s,i,c){var f=this.get(s);if(f instanceof Array)i=f.concat(i);else if(f!==null){var g=typeof f;if(g===typeof i&&g==="object"){for(var N in i)f[N]=i[N];i=f}else i=f+i}return r.set(this._area,this._in(s),r.stringify(i,c)),i},remove:function(s,i){var c=this.get(s,i);return r.remove(this._area,this._in(s)),c},clear:function(){return this._ns?this.each(function(s){r.remove(this._area,this._in(s))},1):r.clear(this._area),this},clearAll:function(){var s=this._area;for(var i in r.areas)r.areas.hasOwnProperty(i)&&(this._area=r.areas[i],this.clear());return this._area=s,this},_in:function(s){return typeof s!="string"&&(s=r.stringify(s)),this._ns?this._ns+s:s},_out:function(s){return this._ns?s&&s.indexOf(this._ns)===0?s.substring(this._ns.length):void 0:s}},storage:function(s){return r.inherit(r.storageAPI,{items:{},name:s})},storageAPI:{length:0,has:function(s){return this.items.hasOwnProperty(s)},key:function(s){var i=0;for(var c in this.items)if(this.has(c)&&s===i++)return c},setItem:function(s,i){this.has(s)||this.length++,this.items[s]=i},removeItem:function(s){this.has(s)&&(delete this.items[s],this.length--)},getItem:function(s){return this.has(s)?this.items[s]:null},clear:function(){for(var s in this.items)this.removeItem(s)}}},a=r.Store("local",function(){try{return localStorage}catch{}}());a.local=a,a._=r,a.area("session",function(){try{return sessionStorage}catch{}}()),a.area("page",r.storage("page")),typeof n=="function"&&n.amd!==void 0?n("store2",[],function(){return a}):e.exports?e.exports=a:(t.store&&(r.conflict=t.store),t.store=a)})($t,$t&&$t.define)}(lt)),lt.exports}var ri=ni();const Wt=en(ri),si=e=>{const t={};for(const n of e)t[n.key]=n.value;return t},ai=(e,t)=>(t.forEach(n=>{const r=H.find(e,{key:n.key});r?H.merge(r,n):e.push(n)}),e),ct="https://test.ihotel.cn",cr=async e=>Te.get(ct+"/i18n-web/sysoption/getsupportedlangs",{headers:{Authorization:e}}),ur=async({appCode:e,language:t="zh-CN",page:n,lastPullDate:r,token:a})=>new Promise(async(s,i)=>{const c=ct+"/i18n-web/kv_translate/kv_translates",f=r?c+"?lastPullDate="+r:c,g=await Te({url:f,method:"GET",headers:{appCode:e,page:n,language:t,Authorization:a}});g&&g.result==0?s(g.retVal):s(g)}),ii=async(e,t)=>Te({url:ct+"/i18n-web/kv_translate/kv_translates",method:"POST",data:e,headers:{token:t}}),oi=async(e,t)=>Te({url:ct+"/i18n-web/kv_translate/batch",method:"POST",data:e,headers:{token:t}}),li=async({appCode:e,language:t="zh-CN",token:n})=>new Promise(async(r,a)=>{const s=Wt.namespace(`i18n_${e}`),i={appCode:e,language:t,token:n},c=s.get(t);if(!c||!c.lastPullDate){const f=await ur(i);f&&(s.set(t,f),r(f.translatesDTOs))}else{const{lastPullDate:f}=c,g=await ur({...i,lastPullDate:f});if(g){const N=H.get(c,"translatesDTOs");if(H.isEmpty(g.translatesDTOs))r(N);else{const v=ai(N,g.translatesDTOs),y={lastPullDate:g.lastPullDate,translatesDTOs:v};Wt.namespace(`i18n_${e}`).set(t,y,":"),r(v)}}}}),ci={data(){return{isModalVisible:!1,searchText:"",languages:[],data:[]}},computed:{firstResult(){return this.data.firstResult/this.data.pageSize+1},columns(){let e=[{title:"关键字",fixed:"left",width:200,key:"dictKey"}];return H.map(this.languages,t=>{const n=t.code;return e.push({title:t.name,key:n,width:200,render:(r,{row:a,index:s})=>{const i=a[n];return C.createVNode(C.resolveComponent("Input"),{modelValue:i,onOnChange:c=>{this.data.datas[s][n]=c.target.value}},null)}})}),e}},props:{appCode:String,name:String,setLanguage:Function,token:String},methods:{closeModal(){this.searchText="",this.isModalVisible=!1},openModal(){this.isModalVisible||(this.isModalVisible=!0,this.init())},findShallowStringDiff(e,t){const{appCode:n,dictKey:r,page:a,unitCode:s}=e,i=[];return H.forIn(e,(c,f)=>{H.isEqual(c,t[f])||i.push({appCode:n,key:r,page:a,unitCode:s,lang:f,value:c})}),i},async saveData({msg:e=""}){const t=H.differenceWith(this.data.datas,this.initialData.datas,H.isEqual);let n=[];for(let a=0;a<t.length;a++){const s=t[a],i=H.find(this.initialData.datas,{dictKey:s.dictKey}),c=this.findShallowStringDiff(s,i);n=H.concat(n,c)}const r=await oi({appCode:this.appCode,language:this.language,data:n},this.token);r&&r.result===0&&(Q.Message.success(e||r.msg),this.setLanguage(),this.initialData.datas=H.cloneDeep(this.data.datas))},async saveNoEqual(){H.isEqual(this.initialData,this.data)||this.saveData({msg:"已为您自动保存"})},changePage(e){this.saveNoEqual(),this.search({firstResult:(e-1)*this.data.pageSize})},async search(e){const t={appCode:this.appCode,searchBlur:this.searchText,page:this.name?H.toUpper(this.name):"HOME",commaSeparatedLangs:H.map(this.languages,"code").toString(),firstResult:0,pageSize:10,...e},n=await ii(t,this.token);n&&(this.initialData=H.cloneDeep(n.retVal),this.data=n.retVal)},async init(){const e=await cr(this.token);e&&e.result==0?(this.languages=e.retVal,this.search()):Q.Message.error("获取语言失败,出错了")}}},fr=(e,t)=>{const n=e.__vccOpts||e;for(const[r,a]of t)n[r]=a;return n},ui={class:"extra"},fi={class:"gc_i18n_page"},di={style:{display:"flex"}};function _i(e,t,n,r,a,s){const i=C.resolveComponent("Table"),c=C.resolveComponent("TabPane"),f=C.resolveComponent("Input"),g=C.resolveComponent("Tabs"),N=C.resolveComponent("Page"),v=C.resolveComponent("Button"),y=C.resolveComponent("Modal");return C.openBlock(),C.createBlock(y,{modelValue:a.isModalVisible,"onUpdate:modelValue":t[2]||(t[2]=I=>a.isModalVisible=I),"mask-closable":!1,width:70,title:"多语言管理中心","footer-hide":""},{default:C.withCtx(()=>[C.createVNode(g,{type:"card",class:"gc_i18n_tabs"},{extra:C.withCtx(()=>[C.createElementVNode("div",ui,[C.createVNode(f,{prefix:"ios-search",placeholder:"请输入搜索内容",modelValue:a.searchText,"onUpdate:modelValue":t[0]||(t[0]=I=>a.searchText=I),clearable:"",onOnEnter:s.search,onOnClear:s.search},null,8,["modelValue","onOnEnter","onOnClear"])])]),default:C.withCtx(()=>[C.createVNode(c,{label:"当前页面"},{default:C.withCtx(()=>[C.createVNode(i,{border:"",height:550,columns:s.columns,data:a.data.datas},null,8,["columns","data"])]),_:1})]),_:1}),C.createElementVNode("div",fi,[C.createElementVNode("div",di,[C.createVNode(N,{modelValue:s.firstResult,"onUpdate:modelValue":t[1]||(t[1]=I=>s.firstResult=I),total:a.data.totalRows,"page-size":10,simple:"","show-total":"",onOnChange:s.changePage},null,8,["modelValue","total","onOnChange"]),C.createElementVNode("div",null,"共 "+C.toDisplayString(a.data.totalRows)+" 项数据",1)]),C.createElementVNode("div",null,[C.createVNode(v,{style:{"margin-right":"10px"},onClick:s.closeModal},{default:C.withCtx(()=>t[3]||(t[3]=[C.createTextVNode("关闭")])),_:1},8,["onClick"]),C.createVNode(v,{type:"primary",onClick:s.saveData},{default:C.withCtx(()=>t[4]||(t[4]=[C.createTextVNode("保存")])),_:1},8,["onClick"])])])]),_:1},8,["modelValue"])}const mi=fr(ci,[["render",_i]]),hi={name:"LangChange",data(){return{languages:[],language:""}},props:{more:{type:Boolean,default:!1}},async mounted(){this.language=navigator.language||"zh-CN";const e=await cr();e&&e.result===0&&(this.languages=e.retVal)}},pi={key:0};function gi(e,t,n,r,a,s){const i=C.resolveComponent("Option"),c=C.resolveComponent("Select");return C.openBlock(),C.createElementBlock("div",null,[n.more?(C.openBlock(),C.createElementBlock("div",pi,t[1]||(t[1]=[C.createElementVNode("span",null,"切换语种",-1)]))):(C.openBlock(),C.createBlock(c,{key:1,modelValue:a.language,"onUpdate:modelValue":t[0]||(t[0]=f=>a.language=f)},{default:C.withCtx(()=>[C.createVNode(i,{value:"zh-CN"},{default:C.withCtx(()=>t[2]||(t[2]=[C.createTextVNode("中文")])),_:1})]),_:1},8,["modelValue"]))])}const Ei=fr(hi,[["render",gi]]);Q.Message.config({duration:3}),Te.defaults.timeout=6e4,Te.interceptors.request.use(e=>(e.headers["Content-Type"]="application/json",e),e=>(Q.Message.error({content:"请求超时!"}),Promise.resolve(e))),Te.interceptors.response.use(e=>{const{nomsg:t}=e.config.headers;return e.status&&e.status!=200?t||Q.Message.error({content:e.data.message||"未知错误"}):e.data.success=!0,e.data},e=>(e.response?e.response.status==504||e.response.status==404?Q.Message.error({content:"服务器被吃了⊙﹏⊙∥"}):e.response.status==403?Q.Message.error({content:"权限不足,请联系管理员!"}):Q.Message.error({content:`${e.response.status}:${e.response.statusText||e.response.error}`}):e.code==="ECONNABORTED"&&e.message.indexOf("timeout")!==-1?Q.Message.error({content:"请求超时!"}):Q.Message.error({content:e.message||"未知错误!"}),Promise.resolve(e)));class bi{constructor(t={}){const{router:n,appCode:r,messages:a,token:s}=t;this.token=s||Wt.get("token"),this.appCode=r,this.router=n,this.locale=navigator.language||"zh-CN",this.modalLoad=!1,this.messages=a||{},this.i18n=Ha({locale:"zh-CN",globalInjection:!0,legacy:!1,silentTranslationWarn:!0,silentFallbackWarn:!0,missingWarn:!1,fallbackWarn:!1,...t});const i=this.i18n.global.t;this.i18n.global.t=(c,f)=>{var v,y;const g=H.toUpper((y=(v=n==null?void 0:n.currentRoute)==null?void 0:v.value)==null?void 0:y.name),N=i(c);if(N===c&&g){const I=`${g}.${c}`,P=i(I);return P!==I?P:f&&H.has(f,"comment")?H.get(f,"comment"):c}return N},this.i18n.global.changeLocal=c=>{this.setLanguage(c||this.locale)},n.beforeEach((c,f,g)=>{const{language:N,token:v}=c.query;v&&this.setToken(v),this.setLanguage(N),g()}),n.afterEach((c,f)=>{C.nextTick(()=>{this.configInstance?this.configInstance.closeModal():this.createModal(c.name)})})}setToken(t){this.token=t}async setLanguage(t="zh-CN"){const n=await li({appCode:this.appCode,language:t,token:this.token});if(n){const r=si(n);this.i18n.global.setLocaleMessage(t,H.assign({},H.get(this.messages,t),r))}this.locale=t,this.i18n.global.locale.value=t}createModal(t){this.modalLoad=!0,this.configInstance=C.createApp(mi,{appCode:this.appCode,token:this.token,setLanguage:this.setLanguage.bind(this,this.locale),name:t}).use(Q).mount(document.createElement("div")),gr.bind("shift > t",n=>{this.configInstance.openModal()})}install(t,{router:n}){t.use(this.i18n),t.use(Q),t.component("LangChange",Ei)}}return bi});
24
+ * Copyright (c) 2024 Nathan Bubna; Licensed MIT */var $t=lt.exports,lr;function ni(){return lr||(lr=1,function(e){(function(t,n){var r={version:"2.14.4",areas:{},apis:{},nsdelim:".",inherit:function(s,i){for(var c in s)i.hasOwnProperty(c)||Object.defineProperty(i,c,Object.getOwnPropertyDescriptor(s,c));return i},stringify:function(s,i){return s===void 0||typeof s=="function"?s+"":JSON.stringify(s,i||r.replace)},parse:function(s,i){try{return JSON.parse(s,i||r.revive)}catch{return s}},fn:function(s,i){r.storeAPI[s]=i;for(var c in r.apis)r.apis[c][s]=i},get:function(s,i){return s.getItem(i)},set:function(s,i,c){s.setItem(i,c)},remove:function(s,i){s.removeItem(i)},key:function(s,i){return s.key(i)},length:function(s){return s.length},clear:function(s){s.clear()},Store:function(s,i,c){var f=r.inherit(r.storeAPI,function(N,v,y){return arguments.length===0?f.getAll():typeof v=="function"?f.transact(N,v,y):v!==void 0?f.set(N,v,y):typeof N=="string"||typeof N=="number"?f.get(N):typeof N=="function"?f.each(N):N?f.setAll(N,v):f.clear()});f._id=s;try{var g="__store2_test";i.setItem(g,"ok"),f._area=i,i.removeItem(g)}catch{f._area=r.storage("fake")}return f._ns=c||"",r.areas[s]||(r.areas[s]=f._area),r.apis[f._ns+f._id]||(r.apis[f._ns+f._id]=f),f},storeAPI:{area:function(s,i){var c=this[s];return(!c||!c.area)&&(c=r.Store(s,i,this._ns),this[s]||(this[s]=c)),c},namespace:function(s,i,c){if(c=c||this._delim||r.nsdelim,!s)return this._ns?this._ns.substring(0,this._ns.length-c.length):"";var f=s,g=this[f];if((!g||!g.namespace)&&(g=r.Store(this._id,this._area,this._ns+f+c),g._delim=c,this[f]||(this[f]=g),!i))for(var N in r.areas)g.area(N,r.areas[N]);return g},isFake:function(s){return s?(this._real=this._area,this._area=r.storage("fake")):s===!1&&(this._area=this._real||this._area),this._area.name==="fake"},toString:function(){return"store"+(this._ns?"."+this.namespace():"")+"["+this._id+"]"},has:function(s){return this._area.has?this._area.has(this._in(s)):this._in(s)in this._area},size:function(){return this.keys().length},each:function(s,i){for(var c=0,f=r.length(this._area);c<f;c++){var g=this._out(r.key(this._area,c));if(g!==void 0&&s.call(this,g,this.get(g),i)===!1)break;f>r.length(this._area)&&(f--,c--)}return i||this},keys:function(s){return this.each(function(i,c,f){f.push(i)},s||[])},get:function(s,i){var c=r.get(this._area,this._in(s)),f;return typeof i=="function"&&(f=i,i=null),c!==null?r.parse(c,f):i??c},getAll:function(s){return this.each(function(i,c,f){f[i]=c},s||{})},transact:function(s,i,c){var f=this.get(s,c),g=i(f);return this.set(s,g===void 0?f:g),this},set:function(s,i,c){var f=this.get(s),g;return f!=null&&c===!1?i:(typeof c=="function"&&(g=c,c=void 0),r.set(this._area,this._in(s),r.stringify(i,g),c)||f)},setAll:function(s,i){var c,f;for(var g in s)f=s[g],this.set(g,f,i)!==f&&(c=!0);return c},add:function(s,i,c){var f=this.get(s);if(f instanceof Array)i=f.concat(i);else if(f!==null){var g=typeof f;if(g===typeof i&&g==="object"){for(var N in i)f[N]=i[N];i=f}else i=f+i}return r.set(this._area,this._in(s),r.stringify(i,c)),i},remove:function(s,i){var c=this.get(s,i);return r.remove(this._area,this._in(s)),c},clear:function(){return this._ns?this.each(function(s){r.remove(this._area,this._in(s))},1):r.clear(this._area),this},clearAll:function(){var s=this._area;for(var i in r.areas)r.areas.hasOwnProperty(i)&&(this._area=r.areas[i],this.clear());return this._area=s,this},_in:function(s){return typeof s!="string"&&(s=r.stringify(s)),this._ns?this._ns+s:s},_out:function(s){return this._ns?s&&s.indexOf(this._ns)===0?s.substring(this._ns.length):void 0:s}},storage:function(s){return r.inherit(r.storageAPI,{items:{},name:s})},storageAPI:{length:0,has:function(s){return this.items.hasOwnProperty(s)},key:function(s){var i=0;for(var c in this.items)if(this.has(c)&&s===i++)return c},setItem:function(s,i){this.has(s)||this.length++,this.items[s]=i},removeItem:function(s){this.has(s)&&(delete this.items[s],this.length--)},getItem:function(s){return this.has(s)?this.items[s]:null},clear:function(){for(var s in this.items)this.removeItem(s)}}},a=r.Store("local",function(){try{return localStorage}catch{}}());a.local=a,a._=r,a.area("session",function(){try{return sessionStorage}catch{}}()),a.area("page",r.storage("page")),typeof n=="function"&&n.amd!==void 0?n("store2",[],function(){return a}):e.exports?e.exports=a:(t.store&&(r.conflict=t.store),t.store=a)})($t,$t&&$t.define)}(lt)),lt.exports}var ri=ni();const Wt=en(ri),si=e=>{const t={};for(const n of e)t[n.key]=n.value;return t},ai=(e,t)=>(t.forEach(n=>{const r=H.find(e,{key:n.key});r?H.merge(r,n):e.push(n)}),e),ct="https://test.ihotel.cn",cr=async e=>Te.get(ct+"/i18n-web/sysoption/getsupportedlangs",{headers:{Authorization:e}}),ur=async({appCode:e,language:t="zh-CN",page:n,lastPullDate:r,token:a})=>new Promise(async(s,i)=>{const c=ct+"/i18n-web/kv_translate/kv_translates",f=r?c+"?lastPullDate="+r:c,g=await Te({url:f,method:"GET",headers:{appCode:e,page:n,language:t,Authorization:a}});g&&g.result==0?s(g.retVal):s(g)}),ii=async(e,t)=>Te({url:ct+"/i18n-web/kv_translate/kv_translates",method:"POST",data:e,headers:{Authorization:t}}),oi=async(e,t)=>Te({url:ct+"/i18n-web/kv_translate/batch",method:"POST",data:e,headers:{Authorization:t}}),li=async({appCode:e,language:t="zh-CN",token:n})=>new Promise(async(r,a)=>{const s=Wt.namespace(`i18n_${e}`),i={appCode:e,language:t,token:n},c=s.get(t);if(!c||!c.lastPullDate){const f=await ur(i);f&&(s.set(t,f),r(f.translatesDTOs))}else{const{lastPullDate:f}=c,g=await ur({...i,lastPullDate:f});if(g){const N=H.get(c,"translatesDTOs");if(H.isEmpty(g.translatesDTOs))r(N);else{const v=ai(N,g.translatesDTOs),y={lastPullDate:g.lastPullDate,translatesDTOs:v};Wt.namespace(`i18n_${e}`).set(t,y,":"),r(v)}}}}),ci={data(){return{isModalVisible:!1,searchText:"",name:"",languages:[],data:[]}},computed:{firstResult(){return this.data.firstResult/this.data.pageSize+1},columns(){let e=[{title:"关键字",fixed:"left",width:200,key:"dictKey"}];return H.map(this.languages,t=>{const n=t.code;return e.push({title:t.name,key:n,width:200,render:(r,{row:a,index:s})=>{const i=a[n];return C.createVNode(C.resolveComponent("Input"),{modelValue:i,onOnChange:c=>{this.data.datas[s][n]=c.target.value}},null)}})}),e}},props:{appCode:String,setLanguage:Function,token:String},methods:{closeModal(){this.searchText="",this.isModalVisible=!1},openModal({name:e}){this.isModalVisible||(this.isModalVisible=!0,this.name=e,this.init())},findShallowStringDiff(e,t){const{appCode:n,dictKey:r,page:a,unitCode:s}=e,i=[];return H.forIn(e,(c,f)=>{H.isEqual(c,t[f])||i.push({appCode:n,key:r,page:a,unitCode:s,lang:f,value:c})}),i},async saveData({msg:e=""}){const t=H.differenceWith(this.data.datas,this.initialData.datas,H.isEqual);let n=[];for(let a=0;a<t.length;a++){const s=t[a],i=H.find(this.initialData.datas,{dictKey:s.dictKey}),c=this.findShallowStringDiff(s,i);n=H.concat(n,c)}const r=await oi({appCode:this.appCode,language:this.language,data:n},this.token);r&&r.result===0&&(Q.Message.success(e||r.msg),this.setLanguage(),this.initialData.datas=H.cloneDeep(this.data.datas))},async saveNoEqual(){H.isEqual(this.initialData,this.data)||this.saveData({msg:"已为您自动保存"})},changePage(e){this.saveNoEqual(),this.search({firstResult:(e-1)*this.data.pageSize})},async search(e){const t={appCode:this.appCode,searchBlur:this.searchText,page:this.name?H.toUpper(this.name):"HOME",commaSeparatedLangs:H.map(this.languages,"code").toString(),firstResult:0,pageSize:10,...e},n=await ii(t,this.token);n&&(this.initialData=H.cloneDeep(n.retVal),this.data=n.retVal)},async init(){const e=await cr(this.token);e&&e.result==0?(this.languages=e.retVal,this.search()):Q.Message.error("获取语言失败,出错了")}}},fr=(e,t)=>{const n=e.__vccOpts||e;for(const[r,a]of t)n[r]=a;return n},ui={class:"extra"},fi={class:"gc_i18n_page"},di={style:{display:"flex"}};function _i(e,t,n,r,a,s){const i=C.resolveComponent("Table"),c=C.resolveComponent("TabPane"),f=C.resolveComponent("Input"),g=C.resolveComponent("Tabs"),N=C.resolveComponent("Page"),v=C.resolveComponent("Button"),y=C.resolveComponent("Modal");return C.openBlock(),C.createBlock(y,{modelValue:a.isModalVisible,"onUpdate:modelValue":t[2]||(t[2]=I=>a.isModalVisible=I),"mask-closable":!1,width:70,title:"多语言管理中心","footer-hide":""},{default:C.withCtx(()=>[C.createVNode(g,{type:"card",class:"gc_i18n_tabs"},{extra:C.withCtx(()=>[C.createElementVNode("div",ui,[C.createVNode(f,{prefix:"ios-search",placeholder:"请输入搜索内容",modelValue:a.searchText,"onUpdate:modelValue":t[0]||(t[0]=I=>a.searchText=I),clearable:"",onOnEnter:s.search,onOnClear:s.search},null,8,["modelValue","onOnEnter","onOnClear"])])]),default:C.withCtx(()=>[C.createVNode(c,{label:"当前页面"},{default:C.withCtx(()=>[C.createVNode(i,{border:"",height:550,columns:s.columns,data:a.data.datas},null,8,["columns","data"])]),_:1})]),_:1}),C.createElementVNode("div",fi,[C.createElementVNode("div",di,[C.createVNode(N,{modelValue:s.firstResult,"onUpdate:modelValue":t[1]||(t[1]=I=>s.firstResult=I),total:a.data.totalRows,"page-size":10,simple:"","show-total":"",onOnChange:s.changePage},null,8,["modelValue","total","onOnChange"]),C.createElementVNode("div",null,"共 "+C.toDisplayString(a.data.totalRows)+" 项数据",1)]),C.createElementVNode("div",null,[C.createVNode(v,{style:{"margin-right":"10px"},onClick:s.closeModal},{default:C.withCtx(()=>t[3]||(t[3]=[C.createTextVNode("关闭")])),_:1},8,["onClick"]),C.createVNode(v,{type:"primary",onClick:s.saveData},{default:C.withCtx(()=>t[4]||(t[4]=[C.createTextVNode("保存")])),_:1},8,["onClick"])])])]),_:1},8,["modelValue"])}const mi=fr(ci,[["render",_i]]),hi={name:"LangChange",data(){return{languages:[],language:""}},props:{more:{type:Boolean,default:!1}},async mounted(){this.language=navigator.language||"zh-CN";const e=await cr();e&&e.result===0&&(this.languages=e.retVal)}},pi={key:0};function gi(e,t,n,r,a,s){const i=C.resolveComponent("Option"),c=C.resolveComponent("Select");return C.openBlock(),C.createElementBlock("div",null,[n.more?(C.openBlock(),C.createElementBlock("div",pi,t[1]||(t[1]=[C.createElementVNode("span",null,"切换语种",-1)]))):(C.openBlock(),C.createBlock(c,{key:1,modelValue:a.language,"onUpdate:modelValue":t[0]||(t[0]=f=>a.language=f)},{default:C.withCtx(()=>[C.createVNode(i,{value:"zh-CN"},{default:C.withCtx(()=>t[2]||(t[2]=[C.createTextVNode("中文")])),_:1})]),_:1},8,["modelValue"]))])}const Ei=fr(hi,[["render",gi]]);Q.Message.config({duration:3}),Te.defaults.timeout=6e4,Te.interceptors.request.use(e=>(e.headers["Content-Type"]="application/json",e),e=>(Q.Message.error({content:"请求超时!"}),Promise.resolve(e))),Te.interceptors.response.use(e=>{const{nomsg:t}=e.config.headers;return e.status&&e.status!=200?t||Q.Message.error({content:e.data.message||"未知错误"}):e.data.success=!0,e.data},e=>(e.response?e.response.status==504||e.response.status==404?Q.Message.error({content:"服务器被吃了⊙﹏⊙∥"}):e.response.status==403?Q.Message.error({content:"权限不足,请联系管理员!"}):Q.Message.error({content:`${e.response.status}:${e.response.statusText||e.response.error}`}):e.code==="ECONNABORTED"&&e.message.indexOf("timeout")!==-1?Q.Message.error({content:"请求超时!"}):Q.Message.error({content:e.message||"未知错误!"}),Promise.resolve(e)));class bi{constructor(t={}){const{router:n,appCode:r,messages:a,token:s}=t;this.token=s||Wt.get("token"),this.appCode=r,this.router=n,this.locale=navigator.language||"zh-CN",this.modalLoad=!1,this.name="",this.messages=a||{},this.i18n=Ha({locale:"zh-CN",globalInjection:!0,legacy:!1,silentTranslationWarn:!0,silentFallbackWarn:!0,missingWarn:!1,fallbackWarn:!1,...t});const i=this.i18n.global.t;this.i18n.global.t=(c,f)=>{var v,y;const g=H.toUpper((y=(v=n==null?void 0:n.currentRoute)==null?void 0:v.value)==null?void 0:y.name),N=i(c);if(N===c&&g){const I=`${g}.${c}`,P=i(I);return P!==I?P:f&&H.has(f,"comment")?H.get(f,"comment"):c}return N},this.i18n.global.changeLocal=c=>{this.setLanguage(c||this.locale)},this.createModal(),n.beforeEach(async(c,f,g)=>{const{language:N,token:v}=c.query;this.configInstance&&this.configInstance.closeModal(),this.name=c.name,v&&this.setToken(v),await this.setLanguage(N),g()}),gr.bind("shift > t",c=>{this.configInstance.openModal({name:this.name})})}setToken(t){this.token=t}async setLanguage(t="zh-CN"){return new Promise(async(n,r)=>{const a=await li({appCode:this.appCode,language:t,token:this.token});if(a){const s=si(a);this.i18n.global.setLocaleMessage(t,H.assign({},H.get(this.messages,t),s))}this.locale=t,this.i18n.global.locale.value=t,n(!0)})}createModal(t){this.modalLoad=!0,this.configInstance=C.createApp(mi,{appCode:this.appCode,token:this.token,setLanguage:this.setLanguage.bind(this,this.locale),name:this.name}).use(Q).mount(document.createElement("div"))}install(t,{router:n}){t.use(this.i18n),t.use(Q,{i18n:this.i18n}),t.component("LangChange",Ei)}}return bi});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gc_i18n",
3
- "version": "1.0.4",
3
+ "version": "1.0.6",
4
4
  "gc_i18n": {
5
5
  "appCode": "TEST"
6
6
  },
@@ -8,6 +8,7 @@ export default {
8
8
  return {
9
9
  isModalVisible: false,
10
10
  searchText: "",
11
+ name: "",
11
12
  languages: [],
12
13
  data: []
13
14
  };
@@ -49,7 +50,6 @@ export default {
49
50
  },
50
51
  props: {
51
52
  appCode: String,
52
- name: String,
53
53
  setLanguage: Function,
54
54
  token: String
55
55
  },
@@ -58,9 +58,10 @@ export default {
58
58
  this.searchText = "";
59
59
  this.isModalVisible = false;
60
60
  },
61
- openModal() {
61
+ openModal({ name }) {
62
62
  if (!this.isModalVisible) {
63
63
  this.isModalVisible = true; // 打开弹窗
64
+ this.name = name;
64
65
  this.init();
65
66
  }
66
67
  },
package/packages/index.js CHANGED
@@ -18,6 +18,7 @@ export default class I18n {
18
18
  this.router = router;
19
19
  this.locale = navigator.language || "zh-CN";
20
20
  this.modalLoad = false;
21
+ this.name = "";
21
22
  this.messages = messages || {};
22
23
  this.i18n = createI18n({
23
24
  locale: "zh-CN",
@@ -60,40 +61,54 @@ export default class I18n {
60
61
  this.i18n.global.changeLocal = (newLocale) => {
61
62
  this.setLanguage(newLocale || this.locale);
62
63
  };
63
- router.beforeEach((to, from, next) => {
64
+ this.createModal();
65
+ router.beforeEach(async (to, from, next) => {
64
66
  const { language, token } = to.query;
67
+ this.configInstance && this.configInstance.closeModal();
68
+ this.name = to.name;
65
69
  token && this.setToken(token);
66
- this.setLanguage(language);
70
+ await this.setLanguage(language);
67
71
  next();
68
72
  });
69
- router.afterEach((to, from) => {
70
- nextTick(() => {
71
- if (!this.configInstance) {
72
- this.createModal(to.name);
73
- } else {
74
- this.configInstance.closeModal();
75
- }
76
- });
73
+ // router.afterEach((to, from) => {
74
+ // nextTick(() => {
75
+ // console.log("this.configInstance", this.configInstance);
76
+
77
+ // if (!this.configInstance) {
78
+ // console.log("to", to, to.name);
79
+ // this.name = to.name;
80
+ // } else {
81
+ // this.configInstance.closeModal();
82
+ // this.configInstance = null;
83
+ // }
84
+ // });
85
+ // });
86
+ keyboardJS.bind("shift > t", (e) => {
87
+ // 打开弹窗
88
+ this.configInstance.openModal({ name: this.name }); // 调用 openModal 方法
77
89
  });
78
90
  }
79
91
  setToken(token) {
80
92
  this.token = token;
81
93
  }
82
94
  async setLanguage(language = "zh-CN") {
83
- const res = await getTranslate({
84
- appCode: this.appCode,
85
- language,
86
- token: this.token
87
- });
88
- if (res) {
89
- const messages = convertArrayToObject(res);
90
- this.i18n.global.setLocaleMessage(
95
+ return new Promise(async (resolve, reject) => {
96
+ const res = await getTranslate({
97
+ appCode: this.appCode,
91
98
  language,
92
- _.assign({}, _.get(this.messages, language), messages)
93
- );
94
- }
95
- this.locale = language;
96
- this.i18n.global.locale.value = language;
99
+ token: this.token
100
+ });
101
+ if (res) {
102
+ const messages = convertArrayToObject(res);
103
+ this.i18n.global.setLocaleMessage(
104
+ language,
105
+ _.assign({}, _.get(this.messages, language), messages)
106
+ );
107
+ }
108
+ this.locale = language;
109
+ this.i18n.global.locale.value = language;
110
+ resolve(true);
111
+ });
97
112
  }
98
113
  createModal(name) {
99
114
  this.modalLoad = true;
@@ -102,18 +117,16 @@ export default class I18n {
102
117
  appCode: this.appCode,
103
118
  token: this.token,
104
119
  setLanguage: this.setLanguage.bind(this, this.locale),
105
- name
120
+ name: this.name
106
121
  })
107
122
  .use(iview)
108
123
  .mount(document.createElement("div")); // 挂载到一个临时的 div
109
- keyboardJS.bind("shift > t", (e) => {
110
- // 打开弹窗
111
- this.configInstance.openModal(); // 调用 openModal 方法
112
- });
113
124
  }
114
125
  install(app, { router }) {
115
126
  app.use(this.i18n);
116
- app.use(iview);
127
+ app.use(iview, {
128
+ i18n: this.i18n
129
+ });
117
130
  app.component("LangChange", LangChange);
118
131
  }
119
132
  }
@@ -46,7 +46,7 @@ export const getAllTranslate = async (data, token) => {
46
46
  url: service + "/i18n-web/kv_translate/kv_translates",
47
47
  method: "POST",
48
48
  data,
49
- headers: { token }
49
+ headers: { Authorization: token }
50
50
  });
51
51
  };
52
52
  export const saveTranslate = async (data, token) => {
@@ -54,7 +54,9 @@ export const saveTranslate = async (data, token) => {
54
54
  url: service + "/i18n-web/kv_translate/batch",
55
55
  method: "POST",
56
56
  data,
57
- headers: { token }
57
+ headers: {
58
+ Authorization: token
59
+ }
58
60
  });
59
61
  };
60
62
  export const getTranslate = async ({ appCode, language = "zh-CN", token }) => {
@@ -2,9 +2,14 @@ import { createRouter, createWebHashHistory } from "vue-router";
2
2
 
3
3
  const routes = [
4
4
  {
5
- path: "/book",
6
- name: "book",
5
+ path: "/",
6
+ name: "Home",
7
7
  component: () => import("../view/Home.vue")
8
+ },
9
+ {
10
+ path: "/BOOK",
11
+ name: "BOOK",
12
+ component: () => import("../view/book.vue")
8
13
  }
9
14
  ];
10
15
  const router = createRouter({
package/src/view/Home.vue CHANGED
@@ -2,54 +2,11 @@
2
2
  import { useI18n } from "vue-i18n";
3
3
  const { locale, changeLocal } = useI18n();
4
4
 
5
- defineProps({
6
- msg: String
7
- });
8
- const langs = [
9
- {
10
- label: "中文",
11
- code: "zh-CN"
12
- },
13
- {
14
- label: "English",
15
- code: "en-US"
16
- },
17
- {
18
- label: "繁体",
19
- code: "zh-TW"
20
- }
21
- ];
22
5
  const change = (lang) => {
23
6
  changeLocal(lang);
24
7
  };
25
8
  </script>
26
9
 
27
10
  <template>
28
- <div>
29
- <Button
30
- v-for="item in langs"
31
- :type="item.code === locale ? 'primary' : 'default'"
32
- @click="change(item.code)"
33
- >{{ item.label }}</Button
34
- >
35
- <div>
36
- <div>带路由前缀:</div>
37
- <div>{{ $t("BOOK.ZHENGJIANLEIXING", { comment: "姓名xxx" }) }}</div>
38
- </div>
39
- <div>
40
- <div>不带前缀:</div>
41
- <div>{{ $t("ZHENGJIANLEIXING", { comment: "姓名xxx" }) }}</div>
42
- </div>
43
- <div>
44
- <div>完全找不到的数据:</div>
45
- <div>{{ $t("BOOK.abc", { comment: "找不到" }) }}</div>
46
- </div>
47
- <Page
48
- :total="40"
49
- size="small"
50
- show-total
51
- />
52
-
53
- <!-- <LangChange></LangChange> -->
54
- </div>
11
+ {{ locale }}
55
12
  </template>
@@ -0,0 +1,57 @@
1
+ <script setup>
2
+ import { useI18n } from "vue-i18n";
3
+ const { locale, changeLocal } = useI18n();
4
+
5
+ defineProps({
6
+ msg: String
7
+ });
8
+ const langs = [
9
+ {
10
+ label: "中文",
11
+ code: "zh-CN"
12
+ },
13
+ {
14
+ label: "English",
15
+ code: "en-US"
16
+ },
17
+ {
18
+ label: "繁体",
19
+ code: "zh-TW"
20
+ }
21
+ ];
22
+ const change = (lang) => {
23
+ changeLocal(lang);
24
+ };
25
+ </script>
26
+
27
+ <template>
28
+ <div>
29
+ {{ locale }}
30
+ <Button
31
+ v-for="item in langs"
32
+ :type="item.code === locale ? 'primary' : 'default'"
33
+ @click="change(item.code)"
34
+ >{{ item.label }}</Button
35
+ >
36
+ <!-- <div>
37
+ <div>带路由前缀:</div>
38
+ <div>{{ $t("BOOK.KAIHANGSHIJIAN", { comment: "找不到" }) }}</div>
39
+ </div> -->
40
+ <div>
41
+ <div>不带前缀:</div>
42
+ <div>{{ $t("KAIHANGSHIJIAN", { comment: "找不到" }) }}</div>
43
+ <!-- <div>{{ $t("中文{0}", [{ comment: "找不到" }]) }}</div> -->
44
+ </div>
45
+ <div>
46
+ <div>完全找不到的数据:</div>
47
+ <div>{{ $t("BOOK.KAIHANGSHIJIAN", { comment: "找不到" }) }}</div>
48
+ </div>
49
+ <Page
50
+ :total="40"
51
+ size="small"
52
+ show-total
53
+ />
54
+
55
+ <!-- <LangChange></LangChange> -->
56
+ </div>
57
+ </template>