@i18n-micro/vue 1.2.0 → 1.2.1

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.
@@ -1,4 +1,4 @@
1
- import { PropType, CSSProperties } from 'vue';
1
+ import { CSSProperties, PropType } from 'vue';
2
2
  export declare const I18nLink: import('vue').DefineComponent<import('vue').ExtractPropTypes<{
3
3
  to: {
4
4
  type: PropType<string | {
@@ -1,5 +1,5 @@
1
- import { PropType, CSSProperties, VNode } from 'vue';
2
1
  import { Locale } from '@i18n-micro/types';
2
+ import { CSSProperties, PropType, VNode } from 'vue';
3
3
  export declare const I18nSwitcher: import('vue').DefineComponent<import('vue').ExtractPropTypes<{
4
4
  customLabels: {
5
5
  type: PropType<Record<string, string>>;
@@ -1,5 +1,5 @@
1
- import { PropType, VNode } from 'vue';
2
1
  import { PluralFunc, TranslationKey } from '@i18n-micro/types';
2
+ import { PropType, VNode } from 'vue';
3
3
  export declare const I18nT: import('vue').DefineComponent<import('vue').ExtractPropTypes<{
4
4
  keypath: {
5
5
  type: PropType<TranslationKey>;
@@ -85,10 +85,10 @@ export declare const I18nT: import('vue').DefineComponent<import('vue').ExtractP
85
85
  type: PropType<Date | string | number>;
86
86
  };
87
87
  }>> & Readonly<{}>, {
88
+ html: boolean;
88
89
  tag: string;
89
90
  params: Record<string, string | number | boolean>;
90
91
  defaultValue: string;
91
- html: boolean;
92
92
  hideIfEmpty: boolean;
93
93
  customPluralRule: PluralFunc;
94
94
  }, {}, {}, {}, string, import('vue').ComponentProvideOptions, true, {}, any>;
@@ -1,6 +1,6 @@
1
- import { Ref } from 'vue';
2
1
  import { BaseI18n, TranslationStorage } from '@i18n-micro/core';
3
- import { Translations, PluralFunc } from '@i18n-micro/types';
2
+ import { PluralFunc, Translations } from '@i18n-micro/types';
3
+ import { Ref } from 'vue';
4
4
  export interface VueI18nOptions {
5
5
  locale: string;
6
6
  fallbackLocale?: string;
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");class F 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}}const I=Symbol("i18n"),N=Symbol("i18n-locales"),U=Symbol("i18n-default-locale"),$=Symbol("i18n-router-strategy"),G=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());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)}}}),W=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?.())}}),q=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}))}}),B=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)}}});function J(t){const{routingStrategy:e,locales:n,defaultLocale:o,...u}=t,l=new F(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",G),a.component("I18nLink",W),a.component("I18nGroup",q),a.component("I18nSwitcher",B)}}}function z(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 Q(t={}){const{addDirAttribute:e=!0,identifierAttribute:n="id",addSeoAttributes:o=!0,baseUrl:u="/"}=t,{getLocale:l,getLocales:d,localeRoute:h}=z(),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}}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=q;exports.I18nInjectionKey=I;exports.I18nLink=W;exports.I18nLocalesKey=N;exports.I18nSwitcher=B;exports.I18nT=G;exports.VueI18n=F;exports.createI18n=J;exports.createVueRouterAdapter=X;exports.useI18n=z;exports.useLocaleHead=Q;
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;
package/dist/index.d.ts CHANGED
@@ -1,15 +1,15 @@
1
- export { createI18n } from './plugin';
2
- export type { I18nPlugin } from './plugin';
3
- export { useI18n, type UseI18nOptions } from './use-i18n';
4
- export { VueI18n, type VueI18nOptions } from './composer';
5
- export { I18nT } from './components/i18n-t';
6
- export { I18nLink } from './components/i18n-link';
7
1
  export { I18nGroup } from './components/i18n-group';
2
+ export { I18nLink } from './components/i18n-link';
8
3
  export { I18nSwitcher } from './components/i18n-switcher';
9
- export { I18nInjectionKey, I18nLocalesKey, I18nDefaultLocaleKey } from './injection';
10
- export { useLocaleHead } from './composables/use-locale-head';
4
+ export { I18nT } from './components/i18n-t';
11
5
  export type { UseLocaleHeadOptions } from './composables/use-locale-head';
12
- export type { I18nRoutingStrategy } from './router/types';
6
+ export { useLocaleHead } from './composables/use-locale-head';
7
+ export { VueI18n, type VueI18nOptions } from './composer';
8
+ export { I18nDefaultLocaleKey, I18nInjectionKey, I18nLocalesKey } from './injection';
9
+ export type { I18nPlugin } from './plugin';
10
+ export { createI18n } from './plugin';
11
+ export { type UseI18nOptions, useI18n } from './use-i18n';
12
+ export { defaultPlural, FormatService, interpolate } from '@i18n-micro/core';
13
+ export type { CleanTranslation, Getter, Locale, LocaleCode, Params, PluralFunc, Translations, } from '@i18n-micro/types';
13
14
  export { createVueRouterAdapter } from './router/adapter';
14
- export type { Translations, Params, PluralFunc, Getter, Locale, LocaleCode, CleanTranslation, } from '@i18n-micro/types';
15
- export { interpolate, FormatService, defaultPlural } from '@i18n-micro/core';
15
+ export type { I18nRoutingStrategy } from './router/types';
package/dist/index.mjs CHANGED
@@ -1,200 +1,33 @@
1
- import { shallowRef as U, defineComponent as H, inject as S, h as g, computed as R, ref as G, onMounted as z, onUnmounted as q, nextTick as Z } from "vue";
1
+ import { defineComponent as H, inject as S, h as g, computed as R, ref as G, onMounted as z, onUnmounted as q, 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
- class X extends J {
6
- constructor(e) {
7
- const n = {
8
- translations: /* @__PURE__ */ new Map()
9
- };
10
- if (super({
11
- storage: n,
12
- plural: e.plural,
13
- missingWarn: e.missingWarn,
14
- missingHandler: e.missingHandler
15
- }), this.listeners = /* @__PURE__ */ new Set(), this.storage = n, this._locale = U(e.locale), this._fallbackLocale = U(e.fallbackLocale || e.locale), this._currentRoute = U("general"), this._revision = U(0), e.messages)
16
- for (const [r, c] of Object.entries(e.messages))
17
- this.helper.loadTranslations(r, c);
18
- }
19
- get locale() {
20
- return this._locale;
21
- }
22
- set locale(e) {
23
- typeof e == "string" ? this._locale.value = e : this._locale = e;
24
- }
25
- get fallbackLocale() {
26
- return this._fallbackLocale;
27
- }
28
- set fallbackLocale(e) {
29
- typeof e == "string" ? this._fallbackLocale.value = e : this._fallbackLocale = e;
30
- }
31
- get currentRoute() {
32
- return this._currentRoute;
33
- }
34
- setRoute(e) {
35
- this._currentRoute.value = e;
36
- }
37
- getLocale() {
38
- return this._locale.value;
39
- }
40
- getFallbackLocale() {
41
- return this._fallbackLocale.value;
42
- }
43
- getRoute() {
44
- return this._currentRoute.value;
45
- }
46
- addTranslations(e, n, r = !0) {
47
- super.loadTranslationsCore(e, n, r), this._revision.value++, this.notifyListeners();
48
- }
49
- addRouteTranslations(e, n, r, c = !0) {
50
- super.loadRouteTranslationsCore(e, n, r, c), this._revision.value++, this.notifyListeners();
51
- }
52
- mergeTranslations(e, n, r) {
53
- this.helper.mergeTranslation(e, n, r, !0), this._revision.value++, this.notifyListeners();
54
- }
55
- mergeGlobalTranslations(e, n) {
56
- this.helper.mergeGlobalTranslation(e, n, !0), this._revision.value++, this.notifyListeners();
57
- }
58
- clearCache() {
59
- super.clearCache(), this._revision.value++, this.notifyListeners();
60
- }
61
- subscribeToChanges(e) {
62
- return this.listeners.add(e), () => this.listeners.delete(e);
63
- }
64
- notifyListeners() {
65
- this.listeners.forEach((e) => e());
66
- }
67
- getAllTranslations() {
68
- const e = {};
69
- for (const [n, r] of this.storage.translations)
70
- if (!n.includes(":"))
71
- e[n] = r;
72
- else {
73
- const c = n.split(":")[0];
74
- c && (e[c] || (e[c] = {}), Object.assign(e[c], r));
75
- }
76
- return e;
77
- }
78
- getStorage() {
79
- return this.storage;
80
- }
81
- getGeneralCache() {
82
- const e = {};
83
- for (const [n, r] of this.storage.translations)
84
- n.includes(":") || (e[n] = r);
85
- return e;
86
- }
87
- getRouteCache() {
88
- const e = {};
89
- for (const [n, r] of this.storage.translations)
90
- n.includes(":") && (e[n] = r);
91
- return e;
92
- }
93
- }
94
- const D = /* @__PURE__ */ Symbol("i18n"), K = /* @__PURE__ */ Symbol("i18n-locales"), B = /* @__PURE__ */ Symbol("i18n-default-locale"), j = /* @__PURE__ */ Symbol("i18n-router-strategy"), Y = H({
95
- name: "I18nT",
5
+ const D = /* @__PURE__ */ Symbol("i18n"), K = /* @__PURE__ */ Symbol("i18n-locales"), B = /* @__PURE__ */ Symbol("i18n-default-locale"), j = /* @__PURE__ */ Symbol("i18n-router-strategy"), X = H({
6
+ name: "I18nGroup",
96
7
  props: {
97
- keypath: {
8
+ prefix: {
98
9
  type: String,
99
10
  required: !0
100
11
  },
101
- plural: {
102
- type: [Number, String]
103
- },
104
- tag: {
105
- type: String,
106
- default: "span"
107
- },
108
- params: {
109
- type: Object,
110
- default: () => ({})
111
- },
112
- defaultValue: {
12
+ groupClass: {
113
13
  type: String,
114
14
  default: ""
115
- },
116
- html: {
117
- type: Boolean,
118
- default: !1
119
- },
120
- hideIfEmpty: {
121
- type: Boolean,
122
- default: !1
123
- },
124
- customPluralRule: {
125
- type: Function,
126
- default: null
127
- },
128
- number: {
129
- type: [Number, String]
130
- },
131
- date: {
132
- type: [Date, String, Number]
133
- },
134
- relativeDate: {
135
- type: [Date, String, Number]
136
15
  }
137
16
  },
138
- setup(t, { slots: e, attrs: n }) {
139
- const r = S(D);
140
- if (!r)
141
- throw new Error("[i18n-micro] I18nT: i18n instance not found. Make sure i18n plugin is installed.");
142
- return () => {
143
- const c = {}, o = r.getRoute();
144
- if (t.number !== void 0) {
145
- const a = Number(t.number), i = r.tn(a), d = r.t(t.keypath, { number: i, ...t.params }, void 0, o);
146
- return g(t.tag, { ...n, innerHTML: d });
147
- }
148
- if (t.date !== void 0) {
149
- const a = r.td(t.date), i = r.t(t.keypath, { date: a, ...t.params }, void 0, o);
150
- return g(t.tag, { ...n, innerHTML: i });
151
- }
152
- if (t.relativeDate !== void 0) {
153
- const a = r.tdr(t.relativeDate), i = r.t(t.keypath, { relativeDate: a, ...t.params }, void 0, o);
154
- return g(t.tag, { ...n, innerHTML: i });
155
- }
156
- if (t.plural !== void 0) {
157
- const a = Number.parseInt(t.plural.toString());
158
- if (t.customPluralRule) {
159
- const i = t.customPluralRule(
160
- t.keypath,
161
- a,
162
- t.params,
163
- r.locale.value,
164
- (d, p, k) => r.t(d, p, k, o)
165
- );
166
- return g(t.tag, { ...n, innerHTML: i || "" });
167
- } else {
168
- const i = r.tc(t.keypath, { count: a, ...t.params });
169
- return g(t.tag, { ...n, innerHTML: i });
170
- }
171
- }
172
- const u = (r.t(t.keypath, { ...t.params, ...c }, void 0, o) ?? "").toString();
173
- if (t.hideIfEmpty && !u.trim())
174
- return t.defaultValue ?? null;
175
- if (t.html)
176
- return g(t.tag, { ...n, innerHTML: u });
177
- if (e.default)
178
- return g(
179
- t.tag,
180
- n,
181
- e.default({ translation: u })
182
- );
183
- const f = [];
184
- let l = 0;
185
- for (const [a, i] of Object.entries(e)) {
186
- if (a === "default") continue;
187
- const d = `{${a}}`, p = u.indexOf(d, l);
188
- p !== -1 && (p > l && f.push(u.slice(l, p)), i && f.push(g(i)), l = p + d.length);
189
- }
190
- return l < u.length && f.push(u.slice(l)), e.default ? g(
191
- t.tag,
192
- n,
193
- e.default({ children: f })
194
- ) : f.length > 0 ? g(t.tag, n, f) : g(t.tag, n, u);
195
- };
17
+ setup(t, { slots: e }) {
18
+ const n = S(D);
19
+ if (!n)
20
+ throw new Error("[i18n-micro] I18nGroup: i18n instance not found. Make sure i18n plugin is installed.");
21
+ const r = (c, o) => n.t(`${t.prefix}.${c}`, o, void 0, n.getRoute());
22
+ return () => g(
23
+ "div",
24
+ {
25
+ class: ["i18n-group", t.groupClass]
26
+ },
27
+ e.default?.({ prefix: t.prefix, t: r })
28
+ );
196
29
  }
197
- }), ee = H({
30
+ }), Y = H({
198
31
  name: "I18nLink",
199
32
  props: {
200
33
  to: {
@@ -231,44 +64,35 @@ const D = /* @__PURE__ */ Symbol("i18n"), K = /* @__PURE__ */ Symbol("i18n-local
231
64
  const l = r.getCurrentPath().replace(/\/$/, ""), a = o.value.replace(/\/$/, "");
232
65
  return l === a;
233
66
  }), f = R(() => u.value ? t.activeStyle : {});
234
- return () => c.value ? g("a", {
235
- href: o.value,
236
- target: "_blank",
237
- rel: "noopener noreferrer",
238
- style: f.value
239
- }, e.default?.()) : r?.linkComponent ? g(r.linkComponent, {
240
- to: o.value,
241
- style: f.value
242
- }, { default: e.default }) : g("a", {
243
- href: o.value,
244
- style: f.value,
245
- onClick: (l) => {
246
- l.preventDefault(), r ? r.push({ path: o.value }) : window.location.href = o.value;
247
- }
248
- }, e.default?.());
249
- }
250
- }), te = H({
251
- name: "I18nGroup",
252
- props: {
253
- prefix: {
254
- type: String,
255
- required: !0
256
- },
257
- groupClass: {
258
- type: String,
259
- default: ""
260
- }
261
- },
262
- setup(t, { slots: e }) {
263
- const n = S(D);
264
- if (!n)
265
- throw new Error("[i18n-micro] I18nGroup: i18n instance not found. Make sure i18n plugin is installed.");
266
- const r = (c, o) => n.t(`${t.prefix}.${c}`, o, void 0, n.getRoute());
267
- return () => g("div", {
268
- class: ["i18n-group", t.groupClass]
269
- }, e.default?.({ prefix: t.prefix, t: r }));
67
+ return () => c.value ? g(
68
+ "a",
69
+ {
70
+ href: o.value,
71
+ target: "_blank",
72
+ rel: "noopener noreferrer",
73
+ style: f.value
74
+ },
75
+ e.default?.()
76
+ ) : r?.linkComponent ? g(
77
+ r.linkComponent,
78
+ {
79
+ to: o.value,
80
+ style: f.value
81
+ },
82
+ { default: e.default }
83
+ ) : g(
84
+ "a",
85
+ {
86
+ href: o.value,
87
+ style: f.value,
88
+ onClick: (l) => {
89
+ l.preventDefault(), r ? r.push({ path: o.value }) : window.location.href = o.value;
90
+ }
91
+ },
92
+ e.default?.()
93
+ );
270
94
  }
271
- }), ne = H({
95
+ }), ee = H({
272
96
  name: "I18nSwitcher",
273
97
  props: {
274
98
  customLabels: {
@@ -333,7 +157,9 @@ const D = /* @__PURE__ */ Symbol("i18n"), K = /* @__PURE__ */ Symbol("i18n-local
333
157
  if (!n)
334
158
  throw new Error("[i18n-micro] I18nSwitcher: i18n instance not found. Make sure i18n plugin is installed.");
335
159
  if (!c && !t.locales)
336
- throw new Error("[i18n-micro] I18nSwitcher: locales not provided. Make sure app.provide(I18nLocalesKey, locales) is called or pass locales prop.");
160
+ throw new Error(
161
+ "[i18n-micro] I18nSwitcher: locales not provided. Make sure app.provide(I18nLocalesKey, locales) is called or pass locales prop."
162
+ );
337
163
  const o = R(() => t.locales || c || []), u = R(() => t.currentLocale !== void 0 ? typeof t.currentLocale == "function" ? t.currentLocale() : t.currentLocale : n.locale.value), f = R(() => t.getLocaleName ? t.getLocaleName() || null : o.value.find((y) => y.code === n.locale.value)?.displayName || null), l = G(!1), a = G(null), i = (s) => {
338
164
  s && (s.stopPropagation(), s.preventDefault()), l.value = !l.value;
339
165
  }, d = (s) => t.customLabels[s.code] || s.displayName || s.code, p = R(() => {
@@ -415,24 +241,32 @@ const D = /* @__PURE__ */ Symbol("i18n"), K = /* @__PURE__ */ Symbol("i18n-local
415
241
  e["before-button"] && s.push(...v(e["before-button"]()));
416
242
  const y = [];
417
243
  if (e["before-selected-locale"] && y.push(...v(e["before-selected-locale"]())), y.push(g("span", p.value)), e["after-selected-locale"] && y.push(...v(e["after-selected-locale"]())), y.push(
418
- g("span", {
419
- style: {
420
- ..._,
421
- ...l.value ? A : {},
422
- ...t.customIconStyle
423
- }
424
- }, "▼")
244
+ g(
245
+ "span",
246
+ {
247
+ style: {
248
+ ..._,
249
+ ...l.value ? A : {},
250
+ ...t.customIconStyle
251
+ }
252
+ },
253
+ "▼"
254
+ )
425
255
  ), s.push(
426
- g("button", {
427
- class: "i18n-switcher-button",
428
- style: { ...C, ...t.customButtonStyle },
429
- onClick: (b) => {
430
- b.preventDefault(), b.stopPropagation(), i(b);
256
+ g(
257
+ "button",
258
+ {
259
+ class: "i18n-switcher-button",
260
+ style: { ...C, ...t.customButtonStyle },
261
+ onClick: (b) => {
262
+ b.preventDefault(), b.stopPropagation(), i(b);
263
+ },
264
+ type: "button",
265
+ ariaHaspopup: !0,
266
+ ariaExpanded: l.value
431
267
  },
432
- type: "button",
433
- ariaHaspopup: !0,
434
- ariaExpanded: l.value
435
- }, y)
268
+ y
269
+ )
436
270
  ), e["before-dropdown"] && s.push(...v(e["before-dropdown"]())), l.value) {
437
271
  const b = [];
438
272
  e["before-dropdown-items"] && b.push(...v(e["before-dropdown-items"]())), o.value.forEach((h) => {
@@ -442,56 +276,152 @@ const D = /* @__PURE__ */ Symbol("i18n"), K = /* @__PURE__ */ Symbol("i18n-local
442
276
  e["before-link-content"] && $.push(...v(e["before-link-content"]({ locale: h }))), $.push(d(h)), e["after-link-content"] && $.push(...v(e["after-link-content"]({ locale: h })));
443
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;
444
278
  x.push(
445
- g("a", {
446
- class: `switcher-locale-${h.code}`,
447
- href: typeof E == "string" ? E : "#",
448
- style: {
449
- ...L,
450
- ...M ? W : {},
451
- ...t.customLinkStyle
279
+ g(
280
+ "a",
281
+ {
282
+ class: `switcher-locale-${h.code}`,
283
+ href: typeof E == "string" ? E : "#",
284
+ style: {
285
+ ...L,
286
+ ...M ? W : {},
287
+ ...t.customLinkStyle
288
+ },
289
+ // Предотвращаем стандартную навигацию, используем только handleSwitchLocale
290
+ onClick: (P) => {
291
+ P.preventDefault(), P.stopPropagation(), k(h.code);
292
+ }
452
293
  },
453
- // Предотвращаем стандартную навигацию, используем только handleSwitchLocale
454
- onClick: (P) => {
455
- P.preventDefault(), P.stopPropagation(), k(h.code);
456
- }
457
- }, $)
294
+ $
295
+ )
458
296
  ), e["after-item"] && x.push(...v(e["after-item"]({ locale: h }))), b.push(
459
- g("li", {
460
- key: h.code,
461
- style: { ...T, ...t.customItemStyle }
462
- }, x)
297
+ g(
298
+ "li",
299
+ {
300
+ key: h.code,
301
+ style: { ...T, ...t.customItemStyle }
302
+ },
303
+ x
304
+ )
463
305
  );
464
306
  }), e["after-dropdown-items"] && b.push(...v(e["after-dropdown-items"]())), s.push(
465
- g("ul", {
466
- class: "i18n-switcher-dropdown",
467
- style: { ...I, ...t.customDropdownStyle }
468
- }, b)
307
+ g(
308
+ "ul",
309
+ {
310
+ class: "i18n-switcher-dropdown",
311
+ style: { ...I, ...t.customDropdownStyle }
312
+ },
313
+ b
314
+ )
469
315
  );
470
316
  }
471
- return e["after-dropdown"] && s.push(...v(e["after-dropdown"]())), g("div", {
472
- ref: a,
473
- class: "i18n-switcher-wrapper",
474
- style: { ...w, ...t.customWrapperStyle }
475
- }, s);
317
+ return e["after-dropdown"] && s.push(...v(e["after-dropdown"]())), g(
318
+ "div",
319
+ {
320
+ ref: a,
321
+ class: "i18n-switcher-wrapper",
322
+ style: { ...w, ...t.customWrapperStyle }
323
+ },
324
+ s
325
+ );
476
326
  };
477
327
  }
478
- });
479
- function ce(t) {
480
- const { routingStrategy: e, locales: n, defaultLocale: r, ...c } = t, o = new X(c);
481
- let u = null, f = e || null;
482
- return {
483
- global: o,
484
- // Доступ к инстансу вне компонентов
485
- setRoutingStrategy: (a) => {
486
- f = a, u && u.provide(j, a);
328
+ }), te = H({
329
+ name: "I18nT",
330
+ props: {
331
+ keypath: {
332
+ type: String,
333
+ required: !0
487
334
  },
488
- // Метод для установки адаптера после создания
489
- install(a) {
490
- u = a, a.provide(D, o), f && a.provide(j, f), n && a.provide(K, n), r && a.provide(B, r), a.config.globalProperties.$t = (i, d, p, k) => o.t(i, d, p, k), a.config.globalProperties.$ts = (i, d, p, k) => o.ts(i, d, p, k), a.config.globalProperties.$tc = (i, d, p) => o.tc(i, d, p), a.config.globalProperties.$tn = (i, d) => o.tn(i, d), a.config.globalProperties.$td = (i, d) => o.td(i, d), a.config.globalProperties.$tdr = (i, d) => o.tdr(i, d), a.config.globalProperties.$has = (i, d) => o.has(i, d), a.config.globalProperties.$i18n = o, a.component("I18nT", Y), a.component("I18nLink", ee), a.component("I18nGroup", te), a.component("I18nSwitcher", ne);
335
+ plural: {
336
+ type: [Number, String]
337
+ },
338
+ tag: {
339
+ type: String,
340
+ default: "span"
341
+ },
342
+ params: {
343
+ type: Object,
344
+ default: () => ({})
345
+ },
346
+ defaultValue: {
347
+ type: String,
348
+ default: ""
349
+ },
350
+ html: {
351
+ type: Boolean,
352
+ default: !1
353
+ },
354
+ hideIfEmpty: {
355
+ type: Boolean,
356
+ default: !1
357
+ },
358
+ customPluralRule: {
359
+ type: Function,
360
+ default: null
361
+ },
362
+ number: {
363
+ type: [Number, String]
364
+ },
365
+ date: {
366
+ type: [Date, String, Number]
367
+ },
368
+ relativeDate: {
369
+ type: [Date, String, Number]
491
370
  }
492
- };
493
- }
494
- function ae(t) {
371
+ },
372
+ setup(t, { slots: e, attrs: n }) {
373
+ const r = S(D);
374
+ if (!r)
375
+ throw new Error("[i18n-micro] I18nT: i18n instance not found. Make sure i18n plugin is installed.");
376
+ return () => {
377
+ const c = {}, o = r.getRoute();
378
+ if (t.number !== void 0) {
379
+ const a = Number(t.number), i = r.tn(a), d = r.t(t.keypath, { number: i, ...t.params }, void 0, o);
380
+ return g(t.tag, { ...n, innerHTML: d });
381
+ }
382
+ if (t.date !== void 0) {
383
+ const a = r.td(t.date), i = r.t(t.keypath, { date: a, ...t.params }, void 0, o);
384
+ return g(t.tag, { ...n, innerHTML: i });
385
+ }
386
+ if (t.relativeDate !== void 0) {
387
+ const a = r.tdr(t.relativeDate), i = r.t(t.keypath, { relativeDate: a, ...t.params }, void 0, o);
388
+ return g(t.tag, { ...n, innerHTML: i });
389
+ }
390
+ if (t.plural !== void 0) {
391
+ const a = Number.parseInt(t.plural.toString(), 10);
392
+ if (t.customPluralRule) {
393
+ const i = t.customPluralRule(
394
+ t.keypath,
395
+ a,
396
+ t.params,
397
+ r.locale.value,
398
+ (d, p, k) => r.t(d, p, k, o)
399
+ );
400
+ return g(t.tag, { ...n, innerHTML: i || "" });
401
+ } else {
402
+ const i = r.tc(t.keypath, { count: a, ...t.params });
403
+ return g(t.tag, { ...n, innerHTML: i });
404
+ }
405
+ }
406
+ const u = (r.t(t.keypath, { ...t.params, ...c }, void 0, o) ?? "").toString();
407
+ if (t.hideIfEmpty && !u.trim())
408
+ return t.defaultValue ?? null;
409
+ if (t.html)
410
+ return g(t.tag, { ...n, innerHTML: u });
411
+ if (e.default)
412
+ return g(t.tag, n, e.default({ translation: u }));
413
+ const f = [];
414
+ let l = 0;
415
+ for (const [a, i] of Object.entries(e)) {
416
+ if (a === "default") continue;
417
+ const d = `{${a}}`, p = u.indexOf(d, l);
418
+ p !== -1 && (p > l && f.push(u.slice(l, p)), i && f.push(g(i)), l = p + d.length);
419
+ }
420
+ return l < u.length && f.push(u.slice(l)), e.default ? g(t.tag, n, e.default({ children: f })) : f.length > 0 ? g(t.tag, n, f) : g(t.tag, n, u);
421
+ };
422
+ }
423
+ });
424
+ function ne(t) {
495
425
  const e = S(D), n = S(j, void 0), r = S(K, void 0), c = S(B, void 0);
496
426
  if (!e)
497
427
  throw new Error("[i18n-micro] useI18n() must be called after app.use(i18n). Make sure i18n plugin is installed.");
@@ -546,13 +476,8 @@ function ae(t) {
546
476
  clearCache: e.clearCache.bind(e)
547
477
  };
548
478
  }
549
- function se(t = {}) {
550
- const {
551
- addDirAttribute: e = !0,
552
- identifierAttribute: n = "id",
553
- addSeoAttributes: r = !0,
554
- baseUrl: c = "/"
555
- } = t, { getLocale: o, getLocales: u, localeRoute: f } = ae(), l = S(j, void 0), a = G({
479
+ function ce(t = {}) {
480
+ const { addDirAttribute: e = !0, identifierAttribute: n = "id", addSeoAttributes: r = !0, baseUrl: c = "/" } = t, { getLocale: o, getLocales: u, localeRoute: f } = ne(), l = S(j, void 0), a = G({
556
481
  htmlAttrs: {},
557
482
  link: [],
558
483
  meta: []
@@ -612,12 +537,14 @@ function se(t = {}) {
612
537
  return [];
613
538
  let N;
614
539
  P.startsWith("http://") || P.startsWith("https://") ? N = P : N = `${typeof c == "function" ? c() : c}${P.startsWith("/") ? "" : "/"}${P}`;
615
- const V = [{
616
- [n]: `i18n-alternate-${m.code}`,
617
- rel: "alternate",
618
- href: N,
619
- hreflang: m.code
620
- }];
540
+ const V = [
541
+ {
542
+ [n]: `i18n-alternate-${m.code}`,
543
+ rel: "alternate",
544
+ href: N,
545
+ hreflang: m.code
546
+ }
547
+ ];
621
548
  return m.iso && m.iso !== m.code && V.push({
622
549
  [n]: `i18n-alternate-${m.iso}`,
623
550
  rel: "alternate",
@@ -632,11 +559,115 @@ function se(t = {}) {
632
559
  updateMeta: d
633
560
  };
634
561
  }
562
+ class ae extends J {
563
+ constructor(e) {
564
+ const n = {
565
+ translations: /* @__PURE__ */ new Map()
566
+ };
567
+ if (super({
568
+ storage: n,
569
+ plural: e.plural,
570
+ missingWarn: e.missingWarn,
571
+ missingHandler: e.missingHandler
572
+ }), this.listeners = /* @__PURE__ */ new Set(), this.storage = n, this._locale = U(e.locale), this._fallbackLocale = U(e.fallbackLocale || e.locale), this._currentRoute = U("general"), this._revision = U(0), e.messages)
573
+ for (const [r, c] of Object.entries(e.messages))
574
+ this.helper.loadTranslations(r, c);
575
+ }
576
+ get locale() {
577
+ return this._locale;
578
+ }
579
+ set locale(e) {
580
+ typeof e == "string" ? this._locale.value = e : this._locale = e;
581
+ }
582
+ get fallbackLocale() {
583
+ return this._fallbackLocale;
584
+ }
585
+ set fallbackLocale(e) {
586
+ typeof e == "string" ? this._fallbackLocale.value = e : this._fallbackLocale = e;
587
+ }
588
+ get currentRoute() {
589
+ return this._currentRoute;
590
+ }
591
+ setRoute(e) {
592
+ this._currentRoute.value = e;
593
+ }
594
+ getLocale() {
595
+ return this._locale.value;
596
+ }
597
+ getFallbackLocale() {
598
+ return this._fallbackLocale.value;
599
+ }
600
+ getRoute() {
601
+ return this._currentRoute.value;
602
+ }
603
+ addTranslations(e, n, r = !0) {
604
+ super.loadTranslationsCore(e, n, r), this._revision.value++, this.notifyListeners();
605
+ }
606
+ addRouteTranslations(e, n, r, c = !0) {
607
+ super.loadRouteTranslationsCore(e, n, r, c), this._revision.value++, this.notifyListeners();
608
+ }
609
+ mergeTranslations(e, n, r) {
610
+ this.helper.mergeTranslation(e, n, r, !0), this._revision.value++, this.notifyListeners();
611
+ }
612
+ mergeGlobalTranslations(e, n) {
613
+ this.helper.mergeGlobalTranslation(e, n, !0), this._revision.value++, this.notifyListeners();
614
+ }
615
+ clearCache() {
616
+ super.clearCache(), this._revision.value++, this.notifyListeners();
617
+ }
618
+ subscribeToChanges(e) {
619
+ return this.listeners.add(e), () => this.listeners.delete(e);
620
+ }
621
+ notifyListeners() {
622
+ this.listeners.forEach((e) => e());
623
+ }
624
+ getAllTranslations() {
625
+ const e = {};
626
+ for (const [n, r] of this.storage.translations)
627
+ if (!n.includes(":"))
628
+ e[n] = r;
629
+ else {
630
+ const c = n.split(":")[0];
631
+ c && (e[c] || (e[c] = {}), Object.assign(e[c], r));
632
+ }
633
+ return e;
634
+ }
635
+ getStorage() {
636
+ return this.storage;
637
+ }
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
+ getRouteCache() {
645
+ const e = {};
646
+ for (const [n, r] of this.storage.translations)
647
+ n.includes(":") && (e[n] = r);
648
+ return e;
649
+ }
650
+ }
651
+ function se(t) {
652
+ const { routingStrategy: e, locales: n, defaultLocale: r, ...c } = t, o = new ae(c);
653
+ let u = null, f = e || null;
654
+ return {
655
+ global: o,
656
+ // Доступ к инстансу вне компонентов
657
+ setRoutingStrategy: (a) => {
658
+ f = a, u && u.provide(j, a);
659
+ },
660
+ // Метод для установки адаптера после создания
661
+ install(a) {
662
+ u = a, a.provide(D, o), f && a.provide(j, f), n && a.provide(K, n), r && a.provide(B, r), a.config.globalProperties.$t = (i, d, p, k) => o.t(i, d, p, k), a.config.globalProperties.$ts = (i, d, p, k) => o.ts(i, d, p, k), a.config.globalProperties.$tc = (i, d, p) => o.tc(i, d, p), a.config.globalProperties.$tn = (i, d) => o.tn(i, d), a.config.globalProperties.$td = (i, d) => o.td(i, d), a.config.globalProperties.$tdr = (i, d) => o.tdr(i, d), a.config.globalProperties.$has = (i, d) => o.has(i, d), a.config.globalProperties.$i18n = o, a.component("I18nT", te), a.component("I18nLink", Y), a.component("I18nGroup", X), a.component("I18nSwitcher", ee);
663
+ }
664
+ };
665
+ }
635
666
  function ue(t, e, n) {
636
667
  const r = e.map((o) => o.code), c = (o, u) => {
637
668
  const l = (typeof o == "string" ? o : o.path || "/").split("/").filter(Boolean), a = l[0];
638
669
  a !== void 0 && r.includes(a) && l.shift();
639
- const i = "/" + l.join("/");
670
+ const i = `/${l.join("/")}`;
640
671
  return u === n ? i : `/${u}${i === "/" ? "" : i}`;
641
672
  };
642
673
  return {
@@ -660,17 +691,17 @@ function ue(t, e, n) {
660
691
  export {
661
692
  he as FormatService,
662
693
  B as I18nDefaultLocaleKey,
663
- te as I18nGroup,
694
+ X as I18nGroup,
664
695
  D as I18nInjectionKey,
665
- ee as I18nLink,
696
+ Y as I18nLink,
666
697
  K as I18nLocalesKey,
667
- ne as I18nSwitcher,
668
- Y as I18nT,
669
- X as VueI18n,
670
- ce as createI18n,
698
+ ee as I18nSwitcher,
699
+ te as I18nT,
700
+ ae as VueI18n,
701
+ se as createI18n,
671
702
  ue as createVueRouterAdapter,
672
703
  ge as defaultPlural,
673
704
  ye as interpolate,
674
- ae as useI18n,
675
- se as useLocaleHead
705
+ ne as useI18n,
706
+ ce as useLocaleHead
676
707
  };
@@ -1,6 +1,6 @@
1
+ import { Locale } from '@i18n-micro/types';
1
2
  import { InjectionKey } from 'vue';
2
3
  import { VueI18n } from './composer';
3
- import { Locale } from '@i18n-micro/types';
4
4
  import { I18nRoutingStrategy } from './router/types';
5
5
  export declare const I18nInjectionKey: InjectionKey<VueI18n>;
6
6
  export declare const I18nLocalesKey: InjectionKey<Locale[]>;
package/dist/plugin.d.ts CHANGED
@@ -1,6 +1,6 @@
1
+ import { Locale } from '@i18n-micro/types';
1
2
  import { Plugin } from 'vue';
2
3
  import { VueI18n, VueI18nOptions } from './composer';
3
- import { Locale } from '@i18n-micro/types';
4
4
  import { I18nRoutingStrategy } from './router/types';
5
5
  export interface CreateI18nOptions extends VueI18nOptions {
6
6
  routingStrategy?: I18nRoutingStrategy;
@@ -1,6 +1,6 @@
1
+ import { Locale } from '@i18n-micro/types';
1
2
  import { Router } from 'vue-router';
2
3
  import { I18nRoutingStrategy } from './types';
3
- import { Locale } from '@i18n-micro/types';
4
4
  /**
5
5
  * Factory for Vue Router adapter
6
6
  * Implements routing utilities for Vue Router
@@ -1,5 +1,5 @@
1
- import { VueI18n } from './composer';
2
1
  import { Locale } from '@i18n-micro/types';
2
+ import { VueI18n } from './composer';
3
3
  export interface UseI18nOptions {
4
4
  locales?: Locale[];
5
5
  defaultLocale?: string;
@@ -9,9 +9,6 @@ declare module '@vue/runtime-core' {
9
9
  $td: (value: Date | number | string, options?: Intl.DateTimeFormatOptions) => string
10
10
  $tdr: (value: Date | number | string, options?: Intl.RelativeTimeFormatOptions) => string
11
11
  $has: (key: TranslationKey, routeName?: string) => boolean
12
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
13
12
  $i18n: any
14
13
  }
15
14
  }
16
-
17
- export {}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@i18n-micro/vue",
3
- "version": "1.2.0",
3
+ "version": "1.2.1",
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.1.0",
23
- "@i18n-micro/types": "1.1.0"
22
+ "@i18n-micro/core": "1.1.2",
23
+ "@i18n-micro/types": "1.1.1"
24
24
  },
25
25
  "peerDependencies": {
26
26
  "vue": "^3.5.25",