@i18n-micro/vue 1.2.1 → 1.3.0
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.
- package/dist/composer.d.ts +0 -2
- package/dist/index.cjs +1 -1
- package/dist/index.mjs +115 -125
- package/dist/use-i18n.d.ts +0 -1
- package/dist/vue-shim.d.ts +1 -1
- package/package.json +3 -3
package/dist/composer.d.ts
CHANGED
|
@@ -29,12 +29,10 @@ export declare class VueI18n extends BaseI18n {
|
|
|
29
29
|
addTranslations(locale: string, translations: Translations, merge?: boolean): void;
|
|
30
30
|
addRouteTranslations(locale: string, routeName: string, translations: Translations, merge?: boolean): void;
|
|
31
31
|
mergeTranslations(locale: string, routeName: string, translations: Translations): void;
|
|
32
|
-
mergeGlobalTranslations(locale: string, translations: Translations): void;
|
|
33
32
|
clearCache(): void;
|
|
34
33
|
subscribeToChanges(cb: () => void): () => void;
|
|
35
34
|
private notifyListeners;
|
|
36
35
|
getAllTranslations(): Record<string, Translations>;
|
|
37
36
|
getStorage(): TranslationStorage;
|
|
38
|
-
getGeneralCache(): Record<string, Translations>;
|
|
39
37
|
getRouteCache(): Record<string, Translations>;
|
|
40
38
|
}
|
package/dist/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("vue"),E=require("@i18n-micro/core"),Z=require("vue-router"),I=Symbol("i18n"),N=Symbol("i18n-locales"),U=Symbol("i18n-default-locale"),$=Symbol("i18n-router-strategy"),F=r.defineComponent({name:"I18nGroup",props:{prefix:{type:String,required:!0},groupClass:{type:String,default:""}},setup(t,{slots:e}){const n=r.inject(I);if(!n)throw new Error("[i18n-micro] I18nGroup: i18n instance not found. Make sure i18n plugin is installed.");const o=(u,l)=>n.t(`${t.prefix}.${u}`,l,void 0,n.getRoute());return()=>r.h("div",{class:["i18n-group",t.groupClass]},e.default?.({prefix:t.prefix,t:o}))}}),G=r.defineComponent({name:"I18nLink",props:{to:{type:[String,Object],required:!0},activeStyle:{type:Object,default:()=>({})},localeRoute:{type:Function,default:void 0}},setup(t,{slots:e}){const n=r.inject(I),o=r.inject($,void 0);if(!n)throw new Error("[i18n-micro] I18nLink: i18n instance not found. Make sure i18n plugin is installed.");const u=r.computed(()=>typeof t.to=="string"?/^(?:https?:\/\/|\/\/|[a-zA-Z0-9-]+\.[a-zA-Z]{2,})|tel:|mailto:/.test(t.to):!1),l=r.computed(()=>{if(u.value)return t.to;if(t.localeRoute){const a=t.localeRoute(t.to);return typeof a=="string"?a:a.path||"/"}if(!o?.resolvePath)return typeof t.to=="string"?t.to:t.to.path||"/";const i=o.resolvePath(t.to,n.locale.value);return typeof i=="string"?i:i.path||"/"}),d=r.computed(()=>{if(u.value||!o)return!1;const i=o.getCurrentPath().replace(/\/$/,""),a=l.value.replace(/\/$/,"");return i===a}),h=r.computed(()=>d.value?t.activeStyle:{});return()=>u.value?r.h("a",{href:l.value,target:"_blank",rel:"noopener noreferrer",style:h.value},e.default?.()):o?.linkComponent?r.h(o.linkComponent,{to:l.value,style:h.value},{default:e.default}):r.h("a",{href:l.value,style:h.value,onClick:i=>{i.preventDefault(),o?o.push({path:l.value}):window.location.href=l.value}},e.default?.())}}),W=r.defineComponent({name:"I18nSwitcher",props:{customLabels:{type:Object,default:()=>({})},customWrapperStyle:{type:Object,default:()=>({})},customButtonStyle:{type:Object,default:()=>({})},customDropdownStyle:{type:Object,default:()=>({})},customItemStyle:{type:Object,default:()=>({})},customLinkStyle:{type:Object,default:()=>({})},customActiveLinkStyle:{type:Object,default:()=>({})},customDisabledLinkStyle:{type:Object,default:()=>({})},customIconStyle:{type:Object,default:()=>({})},locales:{type:Array,default:void 0},currentLocale:{type:[String,Function],default:void 0},getLocaleName:{type:Function,default:void 0},switchLocale:{type:Function,default:void 0},localeRoute:{type:Function,default:void 0}},setup(t,{slots:e}){const n=r.inject(I),o=r.inject($,void 0),u=r.inject(N,void 0);if(!n)throw new Error("[i18n-micro] I18nSwitcher: i18n instance not found. Make sure i18n plugin is installed.");if(!u&&!t.locales)throw new Error("[i18n-micro] I18nSwitcher: locales not provided. Make sure app.provide(I18nLocalesKey, locales) is called or pass locales prop.");const l=r.computed(()=>t.locales||u||[]),d=r.computed(()=>t.currentLocale!==void 0?typeof t.currentLocale=="function"?t.currentLocale():t.currentLocale:n.locale.value),h=r.computed(()=>t.getLocaleName?t.getLocaleName()||null:l.value.find(m=>m.code===n.locale.value)?.displayName||null),i=r.ref(!1),a=r.ref(null),c=s=>{s&&(s.stopPropagation(),s.preventDefault()),i.value=!i.value},f=s=>t.customLabels[s.code]||s.displayName||s.code,p=r.computed(()=>{const s=l.value.find(m=>m.code===d.value);return s?f(s):h.value||d.value}),k=async s=>{if(i.value=!1,await r.nextTick(),t.switchLocale){t.switchLocale(s);return}if(n.locale.value=s,!o)return;const m=o.getCurrentPath(),b=t.localeRoute?(()=>{const g=t.localeRoute(m,s);return typeof g=="string"?g:g.path||"/"})():o?.resolvePath?(()=>{const g=o.resolvePath(m,s);return typeof g=="string"?g:g.path||"/"})():m;o.push({path:b})},S={position:"relative",display:"inline-block",verticalAlign:"middle"},P={padding:"4px 12px",fontSize:"16px",cursor:"pointer",backgroundColor:"#fff",border:"1px solid #333",transition:"background-color 0.3s ease",display:"flex",alignItems:"center",justifyContent:"space-between"},R={position:"absolute",top:"100%",left:"0",zIndex:1e3,backgroundColor:"#fff",border:"1px solid #333",listStyle:"none",padding:"0",margin:"4px 0 0 0",minWidth:"150px",boxShadow:"0 2px 8px rgba(0,0,0,0.15)"},j={margin:"0",padding:"0"},L={display:"block",padding:"8px 12px",color:"#333",textDecoration:"none",transition:"background-color 0.3s ease",cursor:"pointer"},K={fontWeight:"bold",color:"#007bff"},D={marginLeft:"8px",display:"inline-block",transition:"transform 0.3s ease"},M={transform:"rotate(180deg)"},v=s=>s?Array.isArray(s)?s:[s]:[],H=s=>{if(!i.value)return;const m=s.target;if(!m||!a.value)return;const b=a.value.contains(m),g=m.closest(".i18n-switcher-button")!==null;!b&&!g&&(i.value=!1)};return r.onMounted(()=>{document.addEventListener("click",H)}),r.onUnmounted(()=>{document.removeEventListener("click",H)}),()=>{const s=[];e["before-button"]&&s.push(...v(e["before-button"]()));const m=[];if(e["before-selected-locale"]&&m.push(...v(e["before-selected-locale"]())),m.push(r.h("span",p.value)),e["after-selected-locale"]&&m.push(...v(e["after-selected-locale"]())),m.push(r.h("span",{style:{...D,...i.value?M:{},...t.customIconStyle}},"▼")),s.push(r.h("button",{class:"i18n-switcher-button",style:{...P,...t.customButtonStyle},onClick:b=>{b.preventDefault(),b.stopPropagation(),c(b)},type:"button",ariaHaspopup:!0,ariaExpanded:i.value},m)),e["before-dropdown"]&&s.push(...v(e["before-dropdown"]())),i.value){const b=[];e["before-dropdown-items"]&&b.push(...v(e["before-dropdown-items"]())),l.value.forEach(g=>{const C=[];e["before-item"]&&C.push(...v(e["before-item"]({locale:g})));const T=[];e["before-link-content"]&&T.push(...v(e["before-link-content"]({locale:g}))),T.push(f(g)),e["after-link-content"]&&T.push(...v(e["after-link-content"]({locale:g})));const x=typeof window<"u"?window.location.pathname:"/",y=t.localeRoute?t.localeRoute(x,g.code):o?.resolvePath?o.resolvePath(x,g.code):x,_=typeof y=="string"?y:y.path||"#",O=g.code===d.value;C.push(r.h("a",{class:`switcher-locale-${g.code}`,href:typeof _=="string"?_:"#",style:{...L,...O?K:{},...t.customLinkStyle},onClick:w=>{w.preventDefault(),w.stopPropagation(),k(g.code)}},T)),e["after-item"]&&C.push(...v(e["after-item"]({locale:g}))),b.push(r.h("li",{key:g.code,style:{...j,...t.customItemStyle}},C))}),e["after-dropdown-items"]&&b.push(...v(e["after-dropdown-items"]())),s.push(r.h("ul",{class:"i18n-switcher-dropdown",style:{...R,...t.customDropdownStyle}},b))}return e["after-dropdown"]&&s.push(...v(e["after-dropdown"]())),r.h("div",{ref:a,class:"i18n-switcher-wrapper",style:{...S,...t.customWrapperStyle}},s)}}}),q=r.defineComponent({name:"I18nT",props:{keypath:{type:String,required:!0},plural:{type:[Number,String]},tag:{type:String,default:"span"},params:{type:Object,default:()=>({})},defaultValue:{type:String,default:""},html:{type:Boolean,default:!1},hideIfEmpty:{type:Boolean,default:!1},customPluralRule:{type:Function,default:null},number:{type:[Number,String]},date:{type:[Date,String,Number]},relativeDate:{type:[Date,String,Number]}},setup(t,{slots:e,attrs:n}){const o=r.inject(I);if(!o)throw new Error("[i18n-micro] I18nT: i18n instance not found. Make sure i18n plugin is installed.");return()=>{const u={},l=o.getRoute();if(t.number!==void 0){const a=Number(t.number),c=o.tn(a),f=o.t(t.keypath,{number:c,...t.params},void 0,l);return r.h(t.tag,{...n,innerHTML:f})}if(t.date!==void 0){const a=o.td(t.date),c=o.t(t.keypath,{date:a,...t.params},void 0,l);return r.h(t.tag,{...n,innerHTML:c})}if(t.relativeDate!==void 0){const a=o.tdr(t.relativeDate),c=o.t(t.keypath,{relativeDate:a,...t.params},void 0,l);return r.h(t.tag,{...n,innerHTML:c})}if(t.plural!==void 0){const a=Number.parseInt(t.plural.toString(),10);if(t.customPluralRule){const c=t.customPluralRule(t.keypath,a,t.params,o.locale.value,(f,p,k)=>o.t(f,p,k,l));return r.h(t.tag,{...n,innerHTML:c||""})}else{const c=o.tc(t.keypath,{count:a,...t.params});return r.h(t.tag,{...n,innerHTML:c})}}const d=(o.t(t.keypath,{...t.params,...u},void 0,l)??"").toString();if(t.hideIfEmpty&&!d.trim())return t.defaultValue??null;if(t.html)return r.h(t.tag,{...n,innerHTML:d});if(e.default)return r.h(t.tag,n,e.default({translation:d}));const h=[];let i=0;for(const[a,c]of Object.entries(e)){if(a==="default")continue;const f=`{${a}}`,p=d.indexOf(f,i);p!==-1&&(p>i&&h.push(d.slice(i,p)),c&&h.push(r.h(c)),i=p+f.length)}return i<d.length&&h.push(d.slice(i)),e.default?r.h(t.tag,n,e.default({children:h})):h.length>0?r.h(t.tag,n,h):r.h(t.tag,n,d)}}});function B(t){const e=r.inject(I),n=r.inject($,void 0),o=r.inject(N,void 0),u=r.inject(U,void 0);if(!e)throw new Error("[i18n-micro] useI18n() must be called after app.use(i18n). Make sure i18n plugin is installed.");if(!o)throw new Error("[i18n-micro] I18nLocalesKey not provided. Make sure app.provide(I18nLocalesKey, locales) is called.");if(!u)throw new Error("[i18n-micro] I18nDefaultLocaleKey not provided. Make sure app.provide(I18nDefaultLocaleKey, defaultLocale) is called.");const l=t?.locales||o,d=t?.defaultLocale||u,h=(i,a)=>n?.resolvePath?n.resolvePath(i,a||e.locale.value):i;return{instance:e,locale:r.computed({get:()=>e.locale.value,set:i=>{e.locale.value=i}}),getLocales:()=>l,defaultLocale:()=>d,getLocaleName:()=>l.find(a=>a.code===e.locale.value)?.displayName||null,localeRoute:h,localePath:(i,a)=>{const c=h(i,a);return typeof c=="string"?c:c.path||"/"},switchLocale:i=>{if(e.locale.value=i,n){const a=n.getCurrentPath(),c=h(a,i);n.push(typeof c=="string"?{path:c}:{path:c.path||"/"})}},t:e.t.bind(e),ts:e.ts.bind(e),tc:e.tc.bind(e),tn:e.tn.bind(e),td:e.td.bind(e),tdr:e.tdr.bind(e),has:e.has.bind(e),setRoute:e.setRoute.bind(e),getRoute:e.getRoute.bind(e),getLocale:()=>e.locale.value,addTranslations:e.addTranslations.bind(e),addRouteTranslations:e.addRouteTranslations.bind(e),mergeTranslations:e.mergeTranslations.bind(e),mergeGlobalTranslations:e.mergeGlobalTranslations.bind(e),clearCache:e.clearCache.bind(e)}}function J(t={}){const{addDirAttribute:e=!0,identifierAttribute:n="id",addSeoAttributes:o=!0,baseUrl:u="/"}=t,{getLocale:l,getLocales:d,localeRoute:h}=B(),i=r.inject($,void 0),a=r.ref({htmlAttrs:{},link:[],meta:[]});function c(p,k){const S=new URL(p,"http://localhost"),P=new URLSearchParams(S.search),R={};for(const L of k)P.has(L)&&(R[L]=P.get(L));const j=new URLSearchParams(R);return j.toString()?`${S.pathname}?${j.toString()}`:S.pathname}function f(p=[]){if(!i){a.value={htmlAttrs:{},link:[],meta:[]};return}const k=l(),S=d(),P=S.find(y=>y.code===k);if(!P)return;const R=P.iso||k,j=P.dir||"auto";let L=i.getCurrentPath();L.startsWith("/")||(L=`/${L}`);const K=L.split("/").filter(Boolean),D=S.find(y=>K[0]===y.code);let M=L,v;D?(M=L.slice(D.code.length+1)||"/",v=c(M,p)):v=c(L,p);const s=`${typeof u=="function"?u():u}${v.startsWith("/")?"":"/"}${v}`;if(a.value={htmlAttrs:{lang:R,...e?{dir:j}:{}},link:[],meta:[]},!o)return;const m=S,b={[n]:"i18n-og",property:"og:locale",content:R},g={[n]:"i18n-og-url",property:"og:url",content:s},C=m.map(y=>({[n]:`i18n-og-alt-${y.iso||y.code}`,property:"og:locale:alternate",content:y.iso||y.code})),T={[n]:"i18n-can",rel:"canonical",href:s},x=m.flatMap(y=>{if(!h||!i)return[];const _=i.getCurrentPath(),O=h(_,y.code),w=typeof O=="string"?O:O?.path||"/";if(!w)return[];let A;w.startsWith("http://")||w.startsWith("https://")?A=w:A=`${typeof u=="function"?u():u}${w.startsWith("/")?"":"/"}${w}`;const V=[{[n]:`i18n-alternate-${y.code}`,rel:"alternate",href:A,hreflang:y.code}];return y.iso&&y.iso!==y.code&&V.push({[n]:`i18n-alternate-${y.iso}`,rel:"alternate",href:A,hreflang:y.iso}),V});a.value.meta=[b,g,...C],a.value.link=[T,...x]}return{metaObject:a,updateMeta:f}}class z extends E.BaseI18n{constructor(e){const n={translations:new Map};if(super({storage:n,plural:e.plural,missingWarn:e.missingWarn,missingHandler:e.missingHandler}),this.listeners=new Set,this.storage=n,this._locale=r.shallowRef(e.locale),this._fallbackLocale=r.shallowRef(e.fallbackLocale||e.locale),this._currentRoute=r.shallowRef("general"),this._revision=r.shallowRef(0),e.messages)for(const[o,u]of Object.entries(e.messages))this.helper.loadTranslations(o,u)}get locale(){return this._locale}set locale(e){typeof e=="string"?this._locale.value=e:this._locale=e}get fallbackLocale(){return this._fallbackLocale}set fallbackLocale(e){typeof e=="string"?this._fallbackLocale.value=e:this._fallbackLocale=e}get currentRoute(){return this._currentRoute}setRoute(e){this._currentRoute.value=e}getLocale(){return this._locale.value}getFallbackLocale(){return this._fallbackLocale.value}getRoute(){return this._currentRoute.value}addTranslations(e,n,o=!0){super.loadTranslationsCore(e,n,o),this._revision.value++,this.notifyListeners()}addRouteTranslations(e,n,o,u=!0){super.loadRouteTranslationsCore(e,n,o,u),this._revision.value++,this.notifyListeners()}mergeTranslations(e,n,o){this.helper.mergeTranslation(e,n,o,!0),this._revision.value++,this.notifyListeners()}mergeGlobalTranslations(e,n){this.helper.mergeGlobalTranslation(e,n,!0),this._revision.value++,this.notifyListeners()}clearCache(){super.clearCache(),this._revision.value++,this.notifyListeners()}subscribeToChanges(e){return this.listeners.add(e),()=>this.listeners.delete(e)}notifyListeners(){this.listeners.forEach(e=>e())}getAllTranslations(){const e={};for(const[n,o]of this.storage.translations)if(!n.includes(":"))e[n]=o;else{const u=n.split(":")[0];u&&(e[u]||(e[u]={}),Object.assign(e[u],o))}return e}getStorage(){return this.storage}getGeneralCache(){const e={};for(const[n,o]of this.storage.translations)n.includes(":")||(e[n]=o);return e}getRouteCache(){const e={};for(const[n,o]of this.storage.translations)n.includes(":")&&(e[n]=o);return e}}function Q(t){const{routingStrategy:e,locales:n,defaultLocale:o,...u}=t,l=new z(u);let d=null,h=e||null;return{global:l,setRoutingStrategy:a=>{h=a,d&&d.provide($,a)},install(a){d=a,a.provide(I,l),h&&a.provide($,h),n&&a.provide(N,n),o&&a.provide(U,o),a.config.globalProperties.$t=(c,f,p,k)=>l.t(c,f,p,k),a.config.globalProperties.$ts=(c,f,p,k)=>l.ts(c,f,p,k),a.config.globalProperties.$tc=(c,f,p)=>l.tc(c,f,p),a.config.globalProperties.$tn=(c,f)=>l.tn(c,f),a.config.globalProperties.$td=(c,f)=>l.td(c,f),a.config.globalProperties.$tdr=(c,f)=>l.tdr(c,f),a.config.globalProperties.$has=(c,f)=>l.has(c,f),a.config.globalProperties.$i18n=l,a.component("I18nT",q),a.component("I18nLink",G),a.component("I18nGroup",F),a.component("I18nSwitcher",W)}}}function X(t,e,n){const o=e.map(l=>l.code),u=(l,d)=>{const i=(typeof l=="string"?l:l.path||"/").split("/").filter(Boolean),a=i[0];a!==void 0&&o.includes(a)&&i.shift();const c=`/${i.join("/")}`;return d===n?c:`/${d}${c==="/"?"":c}`};return{linkComponent:Z.RouterLink,getCurrentPath:()=>t.currentRoute.value.path,push:l=>{t.push(l.path).catch(()=>{})},replace:l=>{t.replace(l.path).catch(()=>{})},resolvePath:(l,d)=>u(l,d),getRoute:()=>({fullPath:t.currentRoute.value.fullPath,query:t.currentRoute.value.query})}}Object.defineProperty(exports,"FormatService",{enumerable:!0,get:()=>E.FormatService});Object.defineProperty(exports,"defaultPlural",{enumerable:!0,get:()=>E.defaultPlural});Object.defineProperty(exports,"interpolate",{enumerable:!0,get:()=>E.interpolate});exports.I18nDefaultLocaleKey=U;exports.I18nGroup=F;exports.I18nInjectionKey=I;exports.I18nLink=G;exports.I18nLocalesKey=N;exports.I18nSwitcher=W;exports.I18nT=q;exports.VueI18n=z;exports.createI18n=Q;exports.createVueRouterAdapter=X;exports.useI18n=B;exports.useLocaleHead=J;
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("vue"),E=require("@i18n-micro/core"),Z=require("vue-router"),I=Symbol("i18n"),N=Symbol("i18n-locales"),U=Symbol("i18n-default-locale"),$=Symbol("i18n-router-strategy"),F=a.defineComponent({name:"I18nGroup",props:{prefix:{type:String,required:!0},groupClass:{type:String,default:""}},setup(t,{slots:e}){const r=a.inject(I);if(!r)throw new Error("[i18n-micro] I18nGroup: i18n instance not found. Make sure i18n plugin is installed.");const o=(u,l)=>r.t(`${t.prefix}.${u}`,l,void 0,r.getRoute());return()=>a.h("div",{class:["i18n-group",t.groupClass]},e.default?.({prefix:t.prefix,t:o}))}}),W=a.defineComponent({name:"I18nLink",props:{to:{type:[String,Object],required:!0},activeStyle:{type:Object,default:()=>({})},localeRoute:{type:Function,default:void 0}},setup(t,{slots:e}){const r=a.inject(I),o=a.inject($,void 0);if(!r)throw new Error("[i18n-micro] I18nLink: i18n instance not found. Make sure i18n plugin is installed.");const u=a.computed(()=>typeof t.to=="string"?/^(?:https?:\/\/|\/\/|[a-zA-Z0-9-]+\.[a-zA-Z]{2,})|tel:|mailto:/.test(t.to):!1),l=a.computed(()=>{if(u.value)return t.to;if(t.localeRoute){const n=t.localeRoute(t.to);return typeof n=="string"?n:n.path||"/"}if(!o?.resolvePath)return typeof t.to=="string"?t.to:t.to.path||"/";const i=o.resolvePath(t.to,r.locale.value);return typeof i=="string"?i:i.path||"/"}),d=a.computed(()=>{if(u.value||!o)return!1;const i=o.getCurrentPath().replace(/\/$/,""),n=l.value.replace(/\/$/,"");return i===n}),h=a.computed(()=>d.value?t.activeStyle:{});return()=>u.value?a.h("a",{href:l.value,target:"_blank",rel:"noopener noreferrer",style:h.value},e.default?.()):o?.linkComponent?a.h(o.linkComponent,{to:l.value,style:h.value},{default:e.default}):a.h("a",{href:l.value,style:h.value,onClick:i=>{i.preventDefault(),o?o.push({path:l.value}):window.location.href=l.value}},e.default?.())}}),q=a.defineComponent({name:"I18nSwitcher",props:{customLabels:{type:Object,default:()=>({})},customWrapperStyle:{type:Object,default:()=>({})},customButtonStyle:{type:Object,default:()=>({})},customDropdownStyle:{type:Object,default:()=>({})},customItemStyle:{type:Object,default:()=>({})},customLinkStyle:{type:Object,default:()=>({})},customActiveLinkStyle:{type:Object,default:()=>({})},customDisabledLinkStyle:{type:Object,default:()=>({})},customIconStyle:{type:Object,default:()=>({})},locales:{type:Array,default:void 0},currentLocale:{type:[String,Function],default:void 0},getLocaleName:{type:Function,default:void 0},switchLocale:{type:Function,default:void 0},localeRoute:{type:Function,default:void 0}},setup(t,{slots:e}){const r=a.inject(I),o=a.inject($,void 0),u=a.inject(N,void 0);if(!r)throw new Error("[i18n-micro] I18nSwitcher: i18n instance not found. Make sure i18n plugin is installed.");if(!u&&!t.locales)throw new Error("[i18n-micro] I18nSwitcher: locales not provided. Make sure app.provide(I18nLocalesKey, locales) is called or pass locales prop.");const l=a.computed(()=>t.locales||u||[]),d=a.computed(()=>t.currentLocale!==void 0?typeof t.currentLocale=="function"?t.currentLocale():t.currentLocale:r.locale.value),h=a.computed(()=>t.getLocaleName?t.getLocaleName()||null:l.value.find(y=>y.code===r.locale.value)?.displayName||null),i=a.ref(!1),n=a.ref(null),c=s=>{s&&(s.stopPropagation(),s.preventDefault()),i.value=!i.value},f=s=>t.customLabels[s.code]||s.displayName||s.code,m=a.computed(()=>{const s=l.value.find(y=>y.code===d.value);return s?f(s):h.value||d.value}),k=async s=>{if(i.value=!1,await a.nextTick(),t.switchLocale){t.switchLocale(s);return}if(r.locale.value=s,!o)return;const y=o.getCurrentPath(),b=t.localeRoute?(()=>{const g=t.localeRoute(y,s);return typeof g=="string"?g:g.path||"/"})():o?.resolvePath?(()=>{const g=o.resolvePath(y,s);return typeof g=="string"?g:g.path||"/"})():y;o.push({path:b})},S={position:"relative",display:"inline-block",verticalAlign:"middle"},P={padding:"4px 12px",fontSize:"16px",cursor:"pointer",backgroundColor:"#fff",border:"1px solid #333",transition:"background-color 0.3s ease",display:"flex",alignItems:"center",justifyContent:"space-between"},R={position:"absolute",top:"100%",left:"0",zIndex:1e3,backgroundColor:"#fff",border:"1px solid #333",listStyle:"none",padding:"0",margin:"4px 0 0 0",minWidth:"150px",boxShadow:"0 2px 8px rgba(0,0,0,0.15)"},j={margin:"0",padding:"0"},L={display:"block",padding:"8px 12px",color:"#333",textDecoration:"none",transition:"background-color 0.3s ease",cursor:"pointer"},K={fontWeight:"bold",color:"#007bff"},D={marginLeft:"8px",display:"inline-block",transition:"transform 0.3s ease"},M={transform:"rotate(180deg)"},v=s=>s?Array.isArray(s)?s:[s]:[],H=s=>{if(!i.value)return;const y=s.target;if(!y||!n.value)return;const b=n.value.contains(y),g=y.closest(".i18n-switcher-button")!==null;!b&&!g&&(i.value=!1)};return a.onMounted(()=>{document.addEventListener("click",H)}),a.onUnmounted(()=>{document.removeEventListener("click",H)}),()=>{const s=[];e["before-button"]&&s.push(...v(e["before-button"]()));const y=[];if(e["before-selected-locale"]&&y.push(...v(e["before-selected-locale"]())),y.push(a.h("span",m.value)),e["after-selected-locale"]&&y.push(...v(e["after-selected-locale"]())),y.push(a.h("span",{style:{...D,...i.value?M:{},...t.customIconStyle}},"▼")),s.push(a.h("button",{class:"i18n-switcher-button",style:{...P,...t.customButtonStyle},onClick:b=>{b.preventDefault(),b.stopPropagation(),c(b)},type:"button",ariaHaspopup:!0,ariaExpanded:i.value},y)),e["before-dropdown"]&&s.push(...v(e["before-dropdown"]())),i.value){const b=[];e["before-dropdown-items"]&&b.push(...v(e["before-dropdown-items"]())),l.value.forEach(g=>{const C=[];e["before-item"]&&C.push(...v(e["before-item"]({locale:g})));const T=[];e["before-link-content"]&&T.push(...v(e["before-link-content"]({locale:g}))),T.push(f(g)),e["after-link-content"]&&T.push(...v(e["after-link-content"]({locale:g})));const x=typeof window<"u"?window.location.pathname:"/",p=t.localeRoute?t.localeRoute(x,g.code):o?.resolvePath?o.resolvePath(x,g.code):x,_=typeof p=="string"?p:p.path||"#",O=g.code===d.value;C.push(a.h("a",{class:`switcher-locale-${g.code}`,href:typeof _=="string"?_:"#",style:{...L,...O?K:{},...t.customLinkStyle},onClick:w=>{w.preventDefault(),w.stopPropagation(),k(g.code)}},T)),e["after-item"]&&C.push(...v(e["after-item"]({locale:g}))),b.push(a.h("li",{key:g.code,style:{...j,...t.customItemStyle}},C))}),e["after-dropdown-items"]&&b.push(...v(e["after-dropdown-items"]())),s.push(a.h("ul",{class:"i18n-switcher-dropdown",style:{...R,...t.customDropdownStyle}},b))}return e["after-dropdown"]&&s.push(...v(e["after-dropdown"]())),a.h("div",{ref:n,class:"i18n-switcher-wrapper",style:{...S,...t.customWrapperStyle}},s)}}}),B=a.defineComponent({name:"I18nT",props:{keypath:{type:String,required:!0},plural:{type:[Number,String]},tag:{type:String,default:"span"},params:{type:Object,default:()=>({})},defaultValue:{type:String,default:""},html:{type:Boolean,default:!1},hideIfEmpty:{type:Boolean,default:!1},customPluralRule:{type:Function,default:null},number:{type:[Number,String]},date:{type:[Date,String,Number]},relativeDate:{type:[Date,String,Number]}},setup(t,{slots:e,attrs:r}){const o=a.inject(I);if(!o)throw new Error("[i18n-micro] I18nT: i18n instance not found. Make sure i18n plugin is installed.");return()=>{const u={},l=o.getRoute();if(t.number!==void 0){const n=Number(t.number),c=o.tn(n),f=o.t(t.keypath,{number:c,...t.params},void 0,l);return a.h(t.tag,{...r,innerHTML:f})}if(t.date!==void 0){const n=o.td(t.date),c=o.t(t.keypath,{date:n,...t.params},void 0,l);return a.h(t.tag,{...r,innerHTML:c})}if(t.relativeDate!==void 0){const n=o.tdr(t.relativeDate),c=o.t(t.keypath,{relativeDate:n,...t.params},void 0,l);return a.h(t.tag,{...r,innerHTML:c})}if(t.plural!==void 0){const n=Number.parseInt(t.plural.toString(),10);if(t.customPluralRule){const c=t.customPluralRule(t.keypath,n,t.params,o.locale.value,(f,m,k)=>o.t(f,m,k,l));return a.h(t.tag,{...r,innerHTML:c||""})}else{const c=o.tc(t.keypath,{count:n,...t.params});return a.h(t.tag,{...r,innerHTML:c})}}const d=(o.t(t.keypath,{...t.params,...u},void 0,l)??"").toString();if(t.hideIfEmpty&&!d.trim())return t.defaultValue??null;if(t.html)return a.h(t.tag,{...r,innerHTML:d});if(e.default)return a.h(t.tag,r,e.default({translation:d}));const h=[];let i=0;for(const[n,c]of Object.entries(e)){if(n==="default")continue;const f=`{${n}}`,m=d.indexOf(f,i);m!==-1&&(m>i&&h.push(d.slice(i,m)),c&&h.push(a.h(c)),i=m+f.length)}return i<d.length&&h.push(d.slice(i)),e.default?a.h(t.tag,r,e.default({children:h})):h.length>0?a.h(t.tag,r,h):a.h(t.tag,r,d)}}});function z(t){const e=a.inject(I),r=a.inject($,void 0),o=a.inject(N,void 0),u=a.inject(U,void 0);if(!e)throw new Error("[i18n-micro] useI18n() must be called after app.use(i18n). Make sure i18n plugin is installed.");if(!o)throw new Error("[i18n-micro] I18nLocalesKey not provided. Make sure app.provide(I18nLocalesKey, locales) is called.");if(!u)throw new Error("[i18n-micro] I18nDefaultLocaleKey not provided. Make sure app.provide(I18nDefaultLocaleKey, defaultLocale) is called.");const l=t?.locales||o,d=t?.defaultLocale||u,h=(i,n)=>r?.resolvePath?r.resolvePath(i,n||e.locale.value):i;return{instance:e,locale:a.computed({get:()=>e.locale.value,set:i=>{e.locale.value=i}}),getLocales:()=>l,defaultLocale:()=>d,getLocaleName:()=>l.find(n=>n.code===e.locale.value)?.displayName||null,localeRoute:h,localePath:(i,n)=>{const c=h(i,n);return typeof c=="string"?c:c.path||"/"},switchLocale:i=>{if(e.locale.value=i,r){const n=r.getCurrentPath(),c=h(n,i);r.push(typeof c=="string"?{path:c}:{path:c.path||"/"})}},t:e.t.bind(e),ts:e.ts.bind(e),tc:e.tc.bind(e),tn:e.tn.bind(e),td:e.td.bind(e),tdr:e.tdr.bind(e),has:e.has.bind(e),setRoute:e.setRoute.bind(e),getRoute:e.getRoute.bind(e),getLocale:()=>e.locale.value,addTranslations:e.addTranslations.bind(e),addRouteTranslations:e.addRouteTranslations.bind(e),mergeTranslations:e.mergeTranslations.bind(e),clearCache:e.clearCache.bind(e)}}function J(t={}){const{addDirAttribute:e=!0,identifierAttribute:r="id",addSeoAttributes:o=!0,baseUrl:u="/"}=t,{getLocale:l,getLocales:d,localeRoute:h}=z(),i=a.inject($,void 0),n=a.ref({htmlAttrs:{},link:[],meta:[]});function c(m,k){const S=new URL(m,"http://localhost"),P=new URLSearchParams(S.search),R={};for(const L of k)P.has(L)&&(R[L]=P.get(L));const j=new URLSearchParams(R);return j.toString()?`${S.pathname}?${j.toString()}`:S.pathname}function f(m=[]){if(!i){n.value={htmlAttrs:{},link:[],meta:[]};return}const k=l(),S=d(),P=S.find(p=>p.code===k);if(!P)return;const R=P.iso||k,j=P.dir||"auto";let L=i.getCurrentPath();L.startsWith("/")||(L=`/${L}`);const K=L.split("/").filter(Boolean),D=S.find(p=>K[0]===p.code);let M=L,v;D?(M=L.slice(D.code.length+1)||"/",v=c(M,m)):v=c(L,m);const s=`${typeof u=="function"?u():u}${v.startsWith("/")?"":"/"}${v}`;if(n.value={htmlAttrs:{lang:R,...e?{dir:j}:{}},link:[],meta:[]},!o)return;const y=S,b={[r]:"i18n-og",property:"og:locale",content:R},g={[r]:"i18n-og-url",property:"og:url",content:s},C=y.map(p=>({[r]:`i18n-og-alt-${p.iso||p.code}`,property:"og:locale:alternate",content:p.iso||p.code})),T={[r]:"i18n-can",rel:"canonical",href:s},x=y.flatMap(p=>{if(!h||!i)return[];const _=i.getCurrentPath(),O=h(_,p.code),w=typeof O=="string"?O:O?.path||"/";if(!w)return[];let A;w.startsWith("http://")||w.startsWith("https://")?A=w:A=`${typeof u=="function"?u():u}${w.startsWith("/")?"":"/"}${w}`;const V=[{[r]:`i18n-alternate-${p.code}`,rel:"alternate",href:A,hreflang:p.code}];return p.iso&&p.iso!==p.code&&V.push({[r]:`i18n-alternate-${p.iso}`,rel:"alternate",href:A,hreflang:p.iso}),V});n.value.meta=[b,g,...C],n.value.link=[T,...x]}return{metaObject:n,updateMeta:f}}class G extends E.BaseI18n{constructor(e){const r={translations:new Map};if(super({storage:r,plural:e.plural,missingWarn:e.missingWarn,missingHandler:e.missingHandler}),this.listeners=new Set,this.storage=r,this._locale=a.shallowRef(e.locale),this._fallbackLocale=a.shallowRef(e.fallbackLocale||e.locale),this._currentRoute=a.shallowRef("index"),this._revision=a.shallowRef(0),e.messages)for(const[o,u]of Object.entries(e.messages))this.helper.loadTranslations(o,u)}get locale(){return this._locale}set locale(e){typeof e=="string"?this._locale.value=e:this._locale=e}get fallbackLocale(){return this._fallbackLocale}set fallbackLocale(e){typeof e=="string"?this._fallbackLocale.value=e:this._fallbackLocale=e}get currentRoute(){return this._currentRoute}setRoute(e){this._currentRoute.value=e}getLocale(){return this._locale.value}getFallbackLocale(){return this._fallbackLocale.value}getRoute(){return this._currentRoute.value}addTranslations(e,r,o=!0){super.loadTranslationsCore(e,r,o),this._revision.value++,this.notifyListeners()}addRouteTranslations(e,r,o,u=!0){super.loadRouteTranslationsCore(e,r,o,u),this._revision.value++,this.notifyListeners()}mergeTranslations(e,r,o){this.helper.mergeTranslation(e,r,o,!0),this._revision.value++,this.notifyListeners()}clearCache(){super.clearCache(),this._revision.value++,this.notifyListeners()}subscribeToChanges(e){return this.listeners.add(e),()=>this.listeners.delete(e)}notifyListeners(){this.listeners.forEach(e=>e())}getAllTranslations(){const e={};for(const[r,o]of this.storage.translations)if(!r.includes(":"))e[r]=o;else{const u=r.split(":")[0];u&&(e[u]||(e[u]={}),Object.assign(e[u],o))}return e}getStorage(){return this.storage}getRouteCache(){const e={};for(const[r,o]of this.storage.translations)e[r]=o;return e}}function Q(t){const{routingStrategy:e,locales:r,defaultLocale:o,...u}=t,l=new G(u);let d=null,h=e||null;return{global:l,setRoutingStrategy:n=>{h=n,d&&d.provide($,n)},install(n){d=n,n.provide(I,l),h&&n.provide($,h),r&&n.provide(N,r),o&&n.provide(U,o),n.config.globalProperties.$t=(c,f,m,k)=>l.t(c,f,m,k),n.config.globalProperties.$ts=(c,f,m,k)=>l.ts(c,f,m,k),n.config.globalProperties.$tc=(c,f,m)=>l.tc(c,f,m),n.config.globalProperties.$tn=(c,f)=>l.tn(c,f),n.config.globalProperties.$td=(c,f)=>l.td(c,f),n.config.globalProperties.$tdr=(c,f)=>l.tdr(c,f),n.config.globalProperties.$has=(c,f)=>l.has(c,f),n.config.globalProperties.$i18n=l,n.component("I18nT",B),n.component("I18nLink",W),n.component("I18nGroup",F),n.component("I18nSwitcher",q)}}}function X(t,e,r){const o=e.map(l=>l.code),u=(l,d)=>{const i=(typeof l=="string"?l:l.path||"/").split("/").filter(Boolean),n=i[0];n!==void 0&&o.includes(n)&&i.shift();const c=`/${i.join("/")}`;return d===r?c:`/${d}${c==="/"?"":c}`};return{linkComponent:Z.RouterLink,getCurrentPath:()=>t.currentRoute.value.path,push:l=>{t.push(l.path).catch(()=>{})},replace:l=>{t.replace(l.path).catch(()=>{})},resolvePath:(l,d)=>u(l,d),getRoute:()=>({fullPath:t.currentRoute.value.fullPath,query:t.currentRoute.value.query})}}Object.defineProperty(exports,"FormatService",{enumerable:!0,get:()=>E.FormatService});Object.defineProperty(exports,"defaultPlural",{enumerable:!0,get:()=>E.defaultPlural});Object.defineProperty(exports,"interpolate",{enumerable:!0,get:()=>E.interpolate});exports.I18nDefaultLocaleKey=U;exports.I18nGroup=F;exports.I18nInjectionKey=I;exports.I18nLink=W;exports.I18nLocalesKey=N;exports.I18nSwitcher=q;exports.I18nT=B;exports.VueI18n=G;exports.createI18n=Q;exports.createVueRouterAdapter=X;exports.useI18n=z;exports.useLocaleHead=J;
|
package/dist/index.mjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { defineComponent as H, inject as S, h as g, computed as R, ref as
|
|
1
|
+
import { defineComponent as H, inject as S, h as g, computed as R, ref as K, onMounted as q, onUnmounted as G, nextTick as Z, shallowRef as U } from "vue";
|
|
2
2
|
import { BaseI18n as J } from "@i18n-micro/core";
|
|
3
3
|
import { FormatService as he, defaultPlural as ge, interpolate as ye } from "@i18n-micro/core";
|
|
4
4
|
import { RouterLink as Q } from "vue-router";
|
|
5
|
-
const D = /* @__PURE__ */ Symbol("i18n"),
|
|
5
|
+
const D = /* @__PURE__ */ Symbol("i18n"), V = /* @__PURE__ */ Symbol("i18n-locales"), z = /* @__PURE__ */ Symbol("i18n-default-locale"), j = /* @__PURE__ */ Symbol("i18n-router-strategy"), X = H({
|
|
6
6
|
name: "I18nGroup",
|
|
7
7
|
props: {
|
|
8
8
|
prefix: {
|
|
@@ -15,10 +15,10 @@ const D = /* @__PURE__ */ Symbol("i18n"), K = /* @__PURE__ */ Symbol("i18n-local
|
|
|
15
15
|
}
|
|
16
16
|
},
|
|
17
17
|
setup(t, { slots: e }) {
|
|
18
|
-
const
|
|
19
|
-
if (!
|
|
18
|
+
const a = S(D);
|
|
19
|
+
if (!a)
|
|
20
20
|
throw new Error("[i18n-micro] I18nGroup: i18n instance not found. Make sure i18n plugin is installed.");
|
|
21
|
-
const r = (c, o) =>
|
|
21
|
+
const r = (c, o) => a.t(`${t.prefix}.${c}`, o, void 0, a.getRoute());
|
|
22
22
|
return () => g(
|
|
23
23
|
"div",
|
|
24
24
|
{
|
|
@@ -44,25 +44,25 @@ const D = /* @__PURE__ */ Symbol("i18n"), K = /* @__PURE__ */ Symbol("i18n-local
|
|
|
44
44
|
}
|
|
45
45
|
},
|
|
46
46
|
setup(t, { slots: e }) {
|
|
47
|
-
const
|
|
48
|
-
if (!
|
|
47
|
+
const a = S(D), r = S(j, void 0);
|
|
48
|
+
if (!a)
|
|
49
49
|
throw new Error("[i18n-micro] I18nLink: i18n instance not found. Make sure i18n plugin is installed.");
|
|
50
50
|
const c = R(() => typeof t.to == "string" ? /^(?:https?:\/\/|\/\/|[a-zA-Z0-9-]+\.[a-zA-Z]{2,})|tel:|mailto:/.test(t.to) : !1), o = R(() => {
|
|
51
51
|
if (c.value)
|
|
52
52
|
return t.to;
|
|
53
53
|
if (t.localeRoute) {
|
|
54
|
-
const
|
|
55
|
-
return typeof
|
|
54
|
+
const n = t.localeRoute(t.to);
|
|
55
|
+
return typeof n == "string" ? n : n.path || "/";
|
|
56
56
|
}
|
|
57
57
|
if (!r?.resolvePath)
|
|
58
58
|
return typeof t.to == "string" ? t.to : t.to.path || "/";
|
|
59
|
-
const l = r.resolvePath(t.to,
|
|
59
|
+
const l = r.resolvePath(t.to, a.locale.value);
|
|
60
60
|
return typeof l == "string" ? l : l.path || "/";
|
|
61
61
|
}), u = R(() => {
|
|
62
62
|
if (c.value || !r)
|
|
63
63
|
return !1;
|
|
64
|
-
const l = r.getCurrentPath().replace(/\/$/, ""),
|
|
65
|
-
return l ===
|
|
64
|
+
const l = r.getCurrentPath().replace(/\/$/, ""), n = o.value.replace(/\/$/, "");
|
|
65
|
+
return l === n;
|
|
66
66
|
}), f = R(() => u.value ? t.activeStyle : {});
|
|
67
67
|
return () => c.value ? g(
|
|
68
68
|
"a",
|
|
@@ -153,14 +153,14 @@ const D = /* @__PURE__ */ Symbol("i18n"), K = /* @__PURE__ */ Symbol("i18n-local
|
|
|
153
153
|
}
|
|
154
154
|
},
|
|
155
155
|
setup(t, { slots: e }) {
|
|
156
|
-
const
|
|
157
|
-
if (!
|
|
156
|
+
const a = S(D), r = S(j, void 0), c = S(V, void 0);
|
|
157
|
+
if (!a)
|
|
158
158
|
throw new Error("[i18n-micro] I18nSwitcher: i18n instance not found. Make sure i18n plugin is installed.");
|
|
159
159
|
if (!c && !t.locales)
|
|
160
160
|
throw new Error(
|
|
161
161
|
"[i18n-micro] I18nSwitcher: locales not provided. Make sure app.provide(I18nLocalesKey, locales) is called or pass locales prop."
|
|
162
162
|
);
|
|
163
|
-
const o = R(() => t.locales || c || []), u = R(() => t.currentLocale !== void 0 ? typeof t.currentLocale == "function" ? t.currentLocale() : t.currentLocale :
|
|
163
|
+
const o = R(() => t.locales || c || []), u = R(() => t.currentLocale !== void 0 ? typeof t.currentLocale == "function" ? t.currentLocale() : t.currentLocale : a.locale.value), f = R(() => t.getLocaleName ? t.getLocaleName() || null : o.value.find((y) => y.code === a.locale.value)?.displayName || null), l = K(!1), n = K(null), i = (s) => {
|
|
164
164
|
s && (s.stopPropagation(), s.preventDefault()), l.value = !l.value;
|
|
165
165
|
}, d = (s) => t.customLabels[s.code] || s.displayName || s.code, p = R(() => {
|
|
166
166
|
const s = o.value.find((y) => y.code === u.value);
|
|
@@ -170,7 +170,7 @@ const D = /* @__PURE__ */ Symbol("i18n"), K = /* @__PURE__ */ Symbol("i18n-local
|
|
|
170
170
|
t.switchLocale(s);
|
|
171
171
|
return;
|
|
172
172
|
}
|
|
173
|
-
if (
|
|
173
|
+
if (a.locale.value = s, !r)
|
|
174
174
|
return;
|
|
175
175
|
const y = r.getCurrentPath(), b = t.localeRoute ? (() => {
|
|
176
176
|
const h = t.localeRoute(y, s);
|
|
@@ -184,7 +184,7 @@ const D = /* @__PURE__ */ Symbol("i18n"), K = /* @__PURE__ */ Symbol("i18n-local
|
|
|
184
184
|
position: "relative",
|
|
185
185
|
display: "inline-block",
|
|
186
186
|
verticalAlign: "middle"
|
|
187
|
-
},
|
|
187
|
+
}, I = {
|
|
188
188
|
padding: "4px 12px",
|
|
189
189
|
fontSize: "16px",
|
|
190
190
|
cursor: "pointer",
|
|
@@ -194,7 +194,7 @@ const D = /* @__PURE__ */ Symbol("i18n"), K = /* @__PURE__ */ Symbol("i18n-local
|
|
|
194
194
|
display: "flex",
|
|
195
195
|
alignItems: "center",
|
|
196
196
|
justifyContent: "space-between"
|
|
197
|
-
},
|
|
197
|
+
}, C = {
|
|
198
198
|
position: "absolute",
|
|
199
199
|
top: "100%",
|
|
200
200
|
left: "0",
|
|
@@ -206,7 +206,7 @@ const D = /* @__PURE__ */ Symbol("i18n"), K = /* @__PURE__ */ Symbol("i18n-local
|
|
|
206
206
|
margin: "4px 0 0 0",
|
|
207
207
|
minWidth: "150px",
|
|
208
208
|
boxShadow: "0 2px 8px rgba(0,0,0,0.15)"
|
|
209
|
-
},
|
|
209
|
+
}, x = {
|
|
210
210
|
margin: "0",
|
|
211
211
|
padding: "0"
|
|
212
212
|
}, L = {
|
|
@@ -228,13 +228,13 @@ const D = /* @__PURE__ */ Symbol("i18n"), K = /* @__PURE__ */ Symbol("i18n-local
|
|
|
228
228
|
}, v = (s) => s ? Array.isArray(s) ? s : [s] : [], F = (s) => {
|
|
229
229
|
if (!l.value) return;
|
|
230
230
|
const y = s.target;
|
|
231
|
-
if (!y || !
|
|
232
|
-
const b =
|
|
231
|
+
if (!y || !n.value) return;
|
|
232
|
+
const b = n.value.contains(y), h = y.closest(".i18n-switcher-button") !== null;
|
|
233
233
|
!b && !h && (l.value = !1);
|
|
234
234
|
};
|
|
235
|
-
return
|
|
235
|
+
return q(() => {
|
|
236
236
|
document.addEventListener("click", F);
|
|
237
|
-
}),
|
|
237
|
+
}), G(() => {
|
|
238
238
|
document.removeEventListener("click", F);
|
|
239
239
|
}), () => {
|
|
240
240
|
const s = [];
|
|
@@ -257,7 +257,7 @@ const D = /* @__PURE__ */ Symbol("i18n"), K = /* @__PURE__ */ Symbol("i18n-local
|
|
|
257
257
|
"button",
|
|
258
258
|
{
|
|
259
259
|
class: "i18n-switcher-button",
|
|
260
|
-
style: { ...
|
|
260
|
+
style: { ...I, ...t.customButtonStyle },
|
|
261
261
|
onClick: (b) => {
|
|
262
262
|
b.preventDefault(), b.stopPropagation(), i(b);
|
|
263
263
|
},
|
|
@@ -270,12 +270,12 @@ const D = /* @__PURE__ */ Symbol("i18n"), K = /* @__PURE__ */ Symbol("i18n-local
|
|
|
270
270
|
), e["before-dropdown"] && s.push(...v(e["before-dropdown"]())), l.value) {
|
|
271
271
|
const b = [];
|
|
272
272
|
e["before-dropdown-items"] && b.push(...v(e["before-dropdown-items"]())), o.value.forEach((h) => {
|
|
273
|
-
const x = [];
|
|
274
|
-
e["before-item"] && x.push(...v(e["before-item"]({ locale: h })));
|
|
275
273
|
const $ = [];
|
|
276
|
-
e["before-
|
|
274
|
+
e["before-item"] && $.push(...v(e["before-item"]({ locale: h })));
|
|
275
|
+
const T = [];
|
|
276
|
+
e["before-link-content"] && T.push(...v(e["before-link-content"]({ locale: h }))), T.push(d(h)), e["after-link-content"] && T.push(...v(e["after-link-content"]({ locale: h })));
|
|
277
277
|
const O = typeof window < "u" ? window.location.pathname : "/", m = t.localeRoute ? t.localeRoute(O, h.code) : r?.resolvePath ? r.resolvePath(O, h.code) : O, E = typeof m == "string" ? m : m.path || "#", M = h.code === u.value;
|
|
278
|
-
|
|
278
|
+
$.push(
|
|
279
279
|
g(
|
|
280
280
|
"a",
|
|
281
281
|
{
|
|
@@ -286,21 +286,21 @@ const D = /* @__PURE__ */ Symbol("i18n"), K = /* @__PURE__ */ Symbol("i18n-local
|
|
|
286
286
|
...M ? W : {},
|
|
287
287
|
...t.customLinkStyle
|
|
288
288
|
},
|
|
289
|
-
//
|
|
289
|
+
// Prevent default navigation, use only handleSwitchLocale
|
|
290
290
|
onClick: (P) => {
|
|
291
291
|
P.preventDefault(), P.stopPropagation(), k(h.code);
|
|
292
292
|
}
|
|
293
293
|
},
|
|
294
|
-
|
|
294
|
+
T
|
|
295
295
|
)
|
|
296
|
-
), e["after-item"] &&
|
|
296
|
+
), e["after-item"] && $.push(...v(e["after-item"]({ locale: h }))), b.push(
|
|
297
297
|
g(
|
|
298
298
|
"li",
|
|
299
299
|
{
|
|
300
300
|
key: h.code,
|
|
301
|
-
style: { ...
|
|
301
|
+
style: { ...x, ...t.customItemStyle }
|
|
302
302
|
},
|
|
303
|
-
|
|
303
|
+
$
|
|
304
304
|
)
|
|
305
305
|
);
|
|
306
306
|
}), e["after-dropdown-items"] && b.push(...v(e["after-dropdown-items"]())), s.push(
|
|
@@ -308,7 +308,7 @@ const D = /* @__PURE__ */ Symbol("i18n"), K = /* @__PURE__ */ Symbol("i18n-local
|
|
|
308
308
|
"ul",
|
|
309
309
|
{
|
|
310
310
|
class: "i18n-switcher-dropdown",
|
|
311
|
-
style: { ...
|
|
311
|
+
style: { ...C, ...t.customDropdownStyle }
|
|
312
312
|
},
|
|
313
313
|
b
|
|
314
314
|
)
|
|
@@ -317,7 +317,7 @@ const D = /* @__PURE__ */ Symbol("i18n"), K = /* @__PURE__ */ Symbol("i18n-local
|
|
|
317
317
|
return e["after-dropdown"] && s.push(...v(e["after-dropdown"]())), g(
|
|
318
318
|
"div",
|
|
319
319
|
{
|
|
320
|
-
ref:
|
|
320
|
+
ref: n,
|
|
321
321
|
class: "i18n-switcher-wrapper",
|
|
322
322
|
style: { ...w, ...t.customWrapperStyle }
|
|
323
323
|
},
|
|
@@ -369,67 +369,67 @@ const D = /* @__PURE__ */ Symbol("i18n"), K = /* @__PURE__ */ Symbol("i18n-local
|
|
|
369
369
|
type: [Date, String, Number]
|
|
370
370
|
}
|
|
371
371
|
},
|
|
372
|
-
setup(t, { slots: e, attrs:
|
|
372
|
+
setup(t, { slots: e, attrs: a }) {
|
|
373
373
|
const r = S(D);
|
|
374
374
|
if (!r)
|
|
375
375
|
throw new Error("[i18n-micro] I18nT: i18n instance not found. Make sure i18n plugin is installed.");
|
|
376
376
|
return () => {
|
|
377
377
|
const c = {}, o = r.getRoute();
|
|
378
378
|
if (t.number !== void 0) {
|
|
379
|
-
const
|
|
380
|
-
return g(t.tag, { ...
|
|
379
|
+
const n = Number(t.number), i = r.tn(n), d = r.t(t.keypath, { number: i, ...t.params }, void 0, o);
|
|
380
|
+
return g(t.tag, { ...a, innerHTML: d });
|
|
381
381
|
}
|
|
382
382
|
if (t.date !== void 0) {
|
|
383
|
-
const
|
|
384
|
-
return g(t.tag, { ...
|
|
383
|
+
const n = r.td(t.date), i = r.t(t.keypath, { date: n, ...t.params }, void 0, o);
|
|
384
|
+
return g(t.tag, { ...a, innerHTML: i });
|
|
385
385
|
}
|
|
386
386
|
if (t.relativeDate !== void 0) {
|
|
387
|
-
const
|
|
388
|
-
return g(t.tag, { ...
|
|
387
|
+
const n = r.tdr(t.relativeDate), i = r.t(t.keypath, { relativeDate: n, ...t.params }, void 0, o);
|
|
388
|
+
return g(t.tag, { ...a, innerHTML: i });
|
|
389
389
|
}
|
|
390
390
|
if (t.plural !== void 0) {
|
|
391
|
-
const
|
|
391
|
+
const n = Number.parseInt(t.plural.toString(), 10);
|
|
392
392
|
if (t.customPluralRule) {
|
|
393
393
|
const i = t.customPluralRule(
|
|
394
394
|
t.keypath,
|
|
395
|
-
|
|
395
|
+
n,
|
|
396
396
|
t.params,
|
|
397
397
|
r.locale.value,
|
|
398
398
|
(d, p, k) => r.t(d, p, k, o)
|
|
399
399
|
);
|
|
400
|
-
return g(t.tag, { ...
|
|
400
|
+
return g(t.tag, { ...a, innerHTML: i || "" });
|
|
401
401
|
} else {
|
|
402
|
-
const i = r.tc(t.keypath, { count:
|
|
403
|
-
return g(t.tag, { ...
|
|
402
|
+
const i = r.tc(t.keypath, { count: n, ...t.params });
|
|
403
|
+
return g(t.tag, { ...a, innerHTML: i });
|
|
404
404
|
}
|
|
405
405
|
}
|
|
406
406
|
const u = (r.t(t.keypath, { ...t.params, ...c }, void 0, o) ?? "").toString();
|
|
407
407
|
if (t.hideIfEmpty && !u.trim())
|
|
408
408
|
return t.defaultValue ?? null;
|
|
409
409
|
if (t.html)
|
|
410
|
-
return g(t.tag, { ...
|
|
410
|
+
return g(t.tag, { ...a, innerHTML: u });
|
|
411
411
|
if (e.default)
|
|
412
|
-
return g(t.tag,
|
|
412
|
+
return g(t.tag, a, e.default({ translation: u }));
|
|
413
413
|
const f = [];
|
|
414
414
|
let l = 0;
|
|
415
|
-
for (const [
|
|
416
|
-
if (
|
|
417
|
-
const d = `{${
|
|
415
|
+
for (const [n, i] of Object.entries(e)) {
|
|
416
|
+
if (n === "default") continue;
|
|
417
|
+
const d = `{${n}}`, p = u.indexOf(d, l);
|
|
418
418
|
p !== -1 && (p > l && f.push(u.slice(l, p)), i && f.push(g(i)), l = p + d.length);
|
|
419
419
|
}
|
|
420
|
-
return l < u.length && f.push(u.slice(l)), e.default ? g(t.tag,
|
|
420
|
+
return l < u.length && f.push(u.slice(l)), e.default ? g(t.tag, a, e.default({ children: f })) : f.length > 0 ? g(t.tag, a, f) : g(t.tag, a, u);
|
|
421
421
|
};
|
|
422
422
|
}
|
|
423
423
|
});
|
|
424
424
|
function ne(t) {
|
|
425
|
-
const e = S(D),
|
|
425
|
+
const e = S(D), a = S(j, void 0), r = S(V, void 0), c = S(z, void 0);
|
|
426
426
|
if (!e)
|
|
427
427
|
throw new Error("[i18n-micro] useI18n() must be called after app.use(i18n). Make sure i18n plugin is installed.");
|
|
428
428
|
if (!r)
|
|
429
429
|
throw new Error("[i18n-micro] I18nLocalesKey not provided. Make sure app.provide(I18nLocalesKey, locales) is called.");
|
|
430
430
|
if (!c)
|
|
431
431
|
throw new Error("[i18n-micro] I18nDefaultLocaleKey not provided. Make sure app.provide(I18nDefaultLocaleKey, defaultLocale) is called.");
|
|
432
|
-
const o = t?.locales || r, u = t?.defaultLocale || c, f = (l,
|
|
432
|
+
const o = t?.locales || r, u = t?.defaultLocale || c, f = (l, n) => a?.resolvePath ? a.resolvePath(l, n || e.locale.value) : l;
|
|
433
433
|
return {
|
|
434
434
|
// Direct access to instance
|
|
435
435
|
instance: e,
|
|
@@ -443,17 +443,17 @@ function ne(t) {
|
|
|
443
443
|
// Locale helpers
|
|
444
444
|
getLocales: () => o,
|
|
445
445
|
defaultLocale: () => u,
|
|
446
|
-
getLocaleName: () => o.find((
|
|
446
|
+
getLocaleName: () => o.find((n) => n.code === e.locale.value)?.displayName || null,
|
|
447
447
|
// Routing helpers
|
|
448
448
|
localeRoute: f,
|
|
449
|
-
localePath: (l,
|
|
450
|
-
const i = f(l,
|
|
449
|
+
localePath: (l, n) => {
|
|
450
|
+
const i = f(l, n);
|
|
451
451
|
return typeof i == "string" ? i : i.path || "/";
|
|
452
452
|
},
|
|
453
453
|
switchLocale: (l) => {
|
|
454
|
-
if (e.locale.value = l,
|
|
455
|
-
const
|
|
456
|
-
|
|
454
|
+
if (e.locale.value = l, a) {
|
|
455
|
+
const n = a.getCurrentPath(), i = f(n, l);
|
|
456
|
+
a.push(typeof i == "string" ? { path: i } : { path: i.path || "/" });
|
|
457
457
|
}
|
|
458
458
|
},
|
|
459
459
|
// Translation methods (delegate to instance)
|
|
@@ -472,61 +472,60 @@ function ne(t) {
|
|
|
472
472
|
addTranslations: e.addTranslations.bind(e),
|
|
473
473
|
addRouteTranslations: e.addRouteTranslations.bind(e),
|
|
474
474
|
mergeTranslations: e.mergeTranslations.bind(e),
|
|
475
|
-
mergeGlobalTranslations: e.mergeGlobalTranslations.bind(e),
|
|
476
475
|
clearCache: e.clearCache.bind(e)
|
|
477
476
|
};
|
|
478
477
|
}
|
|
479
478
|
function ce(t = {}) {
|
|
480
|
-
const { addDirAttribute: e = !0, identifierAttribute:
|
|
479
|
+
const { addDirAttribute: e = !0, identifierAttribute: a = "id", addSeoAttributes: r = !0, baseUrl: c = "/" } = t, { getLocale: o, getLocales: u, localeRoute: f } = ne(), l = S(j, void 0), n = K({
|
|
481
480
|
htmlAttrs: {},
|
|
482
481
|
link: [],
|
|
483
482
|
meta: []
|
|
484
483
|
});
|
|
485
484
|
function i(p, k) {
|
|
486
|
-
const w = new URL(p, "http://localhost"),
|
|
485
|
+
const w = new URL(p, "http://localhost"), I = new URLSearchParams(w.search), C = {};
|
|
487
486
|
for (const L of k)
|
|
488
|
-
|
|
489
|
-
const
|
|
490
|
-
return
|
|
487
|
+
I.has(L) && (C[L] = I.get(L));
|
|
488
|
+
const x = new URLSearchParams(C);
|
|
489
|
+
return x.toString() ? `${w.pathname}?${x.toString()}` : w.pathname;
|
|
491
490
|
}
|
|
492
491
|
function d(p = []) {
|
|
493
492
|
if (!l) {
|
|
494
|
-
|
|
493
|
+
n.value = { htmlAttrs: {}, link: [], meta: [] };
|
|
495
494
|
return;
|
|
496
495
|
}
|
|
497
|
-
const k = o(), w = u(),
|
|
498
|
-
if (!
|
|
496
|
+
const k = o(), w = u(), I = w.find((m) => m.code === k);
|
|
497
|
+
if (!I)
|
|
499
498
|
return;
|
|
500
|
-
const
|
|
499
|
+
const C = I.iso || k, x = I.dir || "auto";
|
|
501
500
|
let L = l.getCurrentPath();
|
|
502
501
|
L.startsWith("/") || (L = `/${L}`);
|
|
503
502
|
const W = L.split("/").filter(Boolean), _ = w.find((m) => W[0] === m.code);
|
|
504
503
|
let A = L, v;
|
|
505
504
|
_ ? (A = L.slice(_.code.length + 1) || "/", v = i(A, p)) : v = i(L, p);
|
|
506
505
|
const s = `${typeof c == "function" ? c() : c}${v.startsWith("/") ? "" : "/"}${v}`;
|
|
507
|
-
if (
|
|
506
|
+
if (n.value = {
|
|
508
507
|
htmlAttrs: {
|
|
509
|
-
lang:
|
|
510
|
-
...e ? { dir:
|
|
508
|
+
lang: C,
|
|
509
|
+
...e ? { dir: x } : {}
|
|
511
510
|
},
|
|
512
511
|
link: [],
|
|
513
512
|
meta: []
|
|
514
513
|
}, !r)
|
|
515
514
|
return;
|
|
516
515
|
const y = w, b = {
|
|
517
|
-
[
|
|
516
|
+
[a]: "i18n-og",
|
|
518
517
|
property: "og:locale",
|
|
519
|
-
content:
|
|
518
|
+
content: C
|
|
520
519
|
}, h = {
|
|
521
|
-
[
|
|
520
|
+
[a]: "i18n-og-url",
|
|
522
521
|
property: "og:url",
|
|
523
522
|
content: s
|
|
524
|
-
},
|
|
525
|
-
[
|
|
523
|
+
}, $ = y.map((m) => ({
|
|
524
|
+
[a]: `i18n-og-alt-${m.iso || m.code}`,
|
|
526
525
|
property: "og:locale:alternate",
|
|
527
526
|
content: m.iso || m.code
|
|
528
|
-
})),
|
|
529
|
-
[
|
|
527
|
+
})), T = {
|
|
528
|
+
[a]: "i18n-can",
|
|
530
529
|
rel: "canonical",
|
|
531
530
|
href: s
|
|
532
531
|
}, O = y.flatMap((m) => {
|
|
@@ -537,39 +536,39 @@ function ce(t = {}) {
|
|
|
537
536
|
return [];
|
|
538
537
|
let N;
|
|
539
538
|
P.startsWith("http://") || P.startsWith("https://") ? N = P : N = `${typeof c == "function" ? c() : c}${P.startsWith("/") ? "" : "/"}${P}`;
|
|
540
|
-
const
|
|
539
|
+
const B = [
|
|
541
540
|
{
|
|
542
|
-
[
|
|
541
|
+
[a]: `i18n-alternate-${m.code}`,
|
|
543
542
|
rel: "alternate",
|
|
544
543
|
href: N,
|
|
545
544
|
hreflang: m.code
|
|
546
545
|
}
|
|
547
546
|
];
|
|
548
|
-
return m.iso && m.iso !== m.code &&
|
|
549
|
-
[
|
|
547
|
+
return m.iso && m.iso !== m.code && B.push({
|
|
548
|
+
[a]: `i18n-alternate-${m.iso}`,
|
|
550
549
|
rel: "alternate",
|
|
551
550
|
href: N,
|
|
552
551
|
hreflang: m.iso
|
|
553
|
-
}),
|
|
552
|
+
}), B;
|
|
554
553
|
});
|
|
555
|
-
|
|
554
|
+
n.value.meta = [b, h, ...$], n.value.link = [T, ...O];
|
|
556
555
|
}
|
|
557
556
|
return {
|
|
558
|
-
metaObject:
|
|
557
|
+
metaObject: n,
|
|
559
558
|
updateMeta: d
|
|
560
559
|
};
|
|
561
560
|
}
|
|
562
561
|
class ae extends J {
|
|
563
562
|
constructor(e) {
|
|
564
|
-
const
|
|
563
|
+
const a = {
|
|
565
564
|
translations: /* @__PURE__ */ new Map()
|
|
566
565
|
};
|
|
567
566
|
if (super({
|
|
568
|
-
storage:
|
|
567
|
+
storage: a,
|
|
569
568
|
plural: e.plural,
|
|
570
569
|
missingWarn: e.missingWarn,
|
|
571
570
|
missingHandler: e.missingHandler
|
|
572
|
-
}), this.listeners = /* @__PURE__ */ new Set(), this.storage =
|
|
571
|
+
}), this.listeners = /* @__PURE__ */ new Set(), this.storage = a, this._locale = U(e.locale), this._fallbackLocale = U(e.fallbackLocale || e.locale), this._currentRoute = U("index"), this._revision = U(0), e.messages)
|
|
573
572
|
for (const [r, c] of Object.entries(e.messages))
|
|
574
573
|
this.helper.loadTranslations(r, c);
|
|
575
574
|
}
|
|
@@ -600,17 +599,14 @@ class ae extends J {
|
|
|
600
599
|
getRoute() {
|
|
601
600
|
return this._currentRoute.value;
|
|
602
601
|
}
|
|
603
|
-
addTranslations(e,
|
|
604
|
-
super.loadTranslationsCore(e,
|
|
605
|
-
}
|
|
606
|
-
addRouteTranslations(e, n, r, c = !0) {
|
|
607
|
-
super.loadRouteTranslationsCore(e, n, r, c), this._revision.value++, this.notifyListeners();
|
|
602
|
+
addTranslations(e, a, r = !0) {
|
|
603
|
+
super.loadTranslationsCore(e, a, r), this._revision.value++, this.notifyListeners();
|
|
608
604
|
}
|
|
609
|
-
|
|
610
|
-
|
|
605
|
+
addRouteTranslations(e, a, r, c = !0) {
|
|
606
|
+
super.loadRouteTranslationsCore(e, a, r, c), this._revision.value++, this.notifyListeners();
|
|
611
607
|
}
|
|
612
|
-
|
|
613
|
-
this.helper.
|
|
608
|
+
mergeTranslations(e, a, r) {
|
|
609
|
+
this.helper.mergeTranslation(e, a, r, !0), this._revision.value++, this.notifyListeners();
|
|
614
610
|
}
|
|
615
611
|
clearCache() {
|
|
616
612
|
super.clearCache(), this._revision.value++, this.notifyListeners();
|
|
@@ -623,11 +619,11 @@ class ae extends J {
|
|
|
623
619
|
}
|
|
624
620
|
getAllTranslations() {
|
|
625
621
|
const e = {};
|
|
626
|
-
for (const [
|
|
627
|
-
if (!
|
|
628
|
-
e[
|
|
622
|
+
for (const [a, r] of this.storage.translations)
|
|
623
|
+
if (!a.includes(":"))
|
|
624
|
+
e[a] = r;
|
|
629
625
|
else {
|
|
630
|
-
const c =
|
|
626
|
+
const c = a.split(":")[0];
|
|
631
627
|
c && (e[c] || (e[c] = {}), Object.assign(e[c], r));
|
|
632
628
|
}
|
|
633
629
|
return e;
|
|
@@ -635,40 +631,34 @@ class ae extends J {
|
|
|
635
631
|
getStorage() {
|
|
636
632
|
return this.storage;
|
|
637
633
|
}
|
|
638
|
-
getGeneralCache() {
|
|
639
|
-
const e = {};
|
|
640
|
-
for (const [n, r] of this.storage.translations)
|
|
641
|
-
n.includes(":") || (e[n] = r);
|
|
642
|
-
return e;
|
|
643
|
-
}
|
|
644
634
|
getRouteCache() {
|
|
645
635
|
const e = {};
|
|
646
|
-
for (const [
|
|
647
|
-
|
|
636
|
+
for (const [a, r] of this.storage.translations)
|
|
637
|
+
e[a] = r;
|
|
648
638
|
return e;
|
|
649
639
|
}
|
|
650
640
|
}
|
|
651
641
|
function se(t) {
|
|
652
|
-
const { routingStrategy: e, locales:
|
|
642
|
+
const { routingStrategy: e, locales: a, defaultLocale: r, ...c } = t, o = new ae(c);
|
|
653
643
|
let u = null, f = e || null;
|
|
654
644
|
return {
|
|
655
645
|
global: o,
|
|
656
|
-
//
|
|
657
|
-
setRoutingStrategy: (
|
|
658
|
-
f =
|
|
646
|
+
// Access to instance outside components
|
|
647
|
+
setRoutingStrategy: (n) => {
|
|
648
|
+
f = n, u && u.provide(j, n);
|
|
659
649
|
},
|
|
660
|
-
//
|
|
661
|
-
install(
|
|
662
|
-
u =
|
|
650
|
+
// Method for setting adapter after creation
|
|
651
|
+
install(n) {
|
|
652
|
+
u = n, n.provide(D, o), f && n.provide(j, f), a && n.provide(V, a), r && n.provide(z, r), n.config.globalProperties.$t = (i, d, p, k) => o.t(i, d, p, k), n.config.globalProperties.$ts = (i, d, p, k) => o.ts(i, d, p, k), n.config.globalProperties.$tc = (i, d, p) => o.tc(i, d, p), n.config.globalProperties.$tn = (i, d) => o.tn(i, d), n.config.globalProperties.$td = (i, d) => o.td(i, d), n.config.globalProperties.$tdr = (i, d) => o.tdr(i, d), n.config.globalProperties.$has = (i, d) => o.has(i, d), n.config.globalProperties.$i18n = o, n.component("I18nT", te), n.component("I18nLink", Y), n.component("I18nGroup", X), n.component("I18nSwitcher", ee);
|
|
663
653
|
}
|
|
664
654
|
};
|
|
665
655
|
}
|
|
666
|
-
function ue(t, e,
|
|
656
|
+
function ue(t, e, a) {
|
|
667
657
|
const r = e.map((o) => o.code), c = (o, u) => {
|
|
668
|
-
const l = (typeof o == "string" ? o : o.path || "/").split("/").filter(Boolean),
|
|
669
|
-
|
|
658
|
+
const l = (typeof o == "string" ? o : o.path || "/").split("/").filter(Boolean), n = l[0];
|
|
659
|
+
n !== void 0 && r.includes(n) && l.shift();
|
|
670
660
|
const i = `/${l.join("/")}`;
|
|
671
|
-
return u ===
|
|
661
|
+
return u === a ? i : `/${u}${i === "/" ? "" : i}`;
|
|
672
662
|
};
|
|
673
663
|
return {
|
|
674
664
|
linkComponent: Q,
|
|
@@ -690,11 +680,11 @@ function ue(t, e, n) {
|
|
|
690
680
|
}
|
|
691
681
|
export {
|
|
692
682
|
he as FormatService,
|
|
693
|
-
|
|
683
|
+
z as I18nDefaultLocaleKey,
|
|
694
684
|
X as I18nGroup,
|
|
695
685
|
D as I18nInjectionKey,
|
|
696
686
|
Y as I18nLink,
|
|
697
|
-
|
|
687
|
+
V as I18nLocalesKey,
|
|
698
688
|
ee as I18nSwitcher,
|
|
699
689
|
te as I18nT,
|
|
700
690
|
ae as VueI18n,
|
package/dist/use-i18n.d.ts
CHANGED
|
@@ -36,6 +36,5 @@ export declare function useI18n(options?: UseI18nOptions): {
|
|
|
36
36
|
addTranslations: (locale: string, translations: import('@i18n-micro/types').Translations, merge?: boolean) => void;
|
|
37
37
|
addRouteTranslations: (locale: string, routeName: string, translations: import('@i18n-micro/types').Translations, merge?: boolean) => void;
|
|
38
38
|
mergeTranslations: (locale: string, routeName: string, translations: import('@i18n-micro/types').Translations) => void;
|
|
39
|
-
mergeGlobalTranslations: (locale: string, translations: import('@i18n-micro/types').Translations) => void;
|
|
40
39
|
clearCache: () => void;
|
|
41
40
|
};
|
package/dist/vue-shim.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Params, CleanTranslation, TranslationKey } from '@i18n-micro/types';
|
|
2
|
-
//
|
|
2
|
+
// Extend '@vue/runtime-core' module so types work correctly in all environments
|
|
3
3
|
declare module '@vue/runtime-core' {
|
|
4
4
|
interface ComponentCustomProperties {
|
|
5
5
|
$t: (key: TranslationKey, params?: Params, defaultValue?: string | null, routeName?: string) => CleanTranslation
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@i18n-micro/vue",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.3.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./dist/index.cjs",
|
|
6
6
|
"module": "./dist/index.mjs",
|
|
@@ -19,8 +19,8 @@
|
|
|
19
19
|
"access": "public"
|
|
20
20
|
},
|
|
21
21
|
"dependencies": {
|
|
22
|
-
"@i18n-micro/core": "1.
|
|
23
|
-
"@i18n-micro/types": "1.1.
|
|
22
|
+
"@i18n-micro/core": "1.2.0",
|
|
23
|
+
"@i18n-micro/types": "1.1.5"
|
|
24
24
|
},
|
|
25
25
|
"peerDependencies": {
|
|
26
26
|
"vue": "^3.5.25",
|