Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

vue-i18n-routing

Package Overview
Dependencies
Maintainers
1
Versions
239
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

vue-i18n-routing - npm Package Compare versions

Comparing version 0.0.0-190b377 to 0.0.0-19fbb3c

dist/vue-i18n-routing.vue-i18n.d.ts

6

dist/vue-i18n-routing.cjs.js

@@ -1,5 +0,5 @@

"use strict";var fe=Object.defineProperty,de=Object.defineProperties;var he=Object.getOwnPropertyDescriptors;var x=Object.getOwnPropertySymbols;var G=Object.prototype.hasOwnProperty,H=Object.prototype.propertyIsEnumerable;var q=(e,t,o)=>t in e?fe(e,t,{enumerable:!0,configurable:!0,writable:!0,value:o}):e[t]=o,D=(e,t)=>{for(var o in t||(t={}))G.call(t,o)&&q(e,o,t[o]);if(x)for(var o of x(t))H.call(t,o)&&q(e,o,t[o]);return e},y=(e,t)=>de(e,he(t));var W=(e,t)=>{var o={};for(var a in e)G.call(e,a)&&t.indexOf(a)<0&&(o[a]=e[a]);if(e!=null&&x)for(var a of x(e))t.indexOf(a)<0&&H.call(e,a)&&(o[a]=e[a]);return o};Object.defineProperty(exports,"__esModule",{value:!0});exports[Symbol.toStringTag]="Module";var m=require("vue-demi"),S=require("@intlify/vue-router-bridge"),J=require("@intlify/vue-i18n-bridge");function me(e){return e&&typeof e=="object"&&"default"in e?e:{default:e}}var _e=me(S);/*!
* shared v9.2.0-beta.30
"use strict";var be=Object.defineProperty,ye=Object.defineProperties;var Ae=Object.getOwnPropertyDescriptors;var T=Object.getOwnPropertySymbols;var ce=Object.prototype.hasOwnProperty,se=Object.prototype.propertyIsEnumerable;var re=(e,t,o)=>t in e?be(e,t,{enumerable:!0,configurable:!0,writable:!0,value:o}):e[t]=o,I=(e,t)=>{for(var o in t||(t={}))ce.call(t,o)&&re(e,o,t[o]);if(T)for(var o of T(t))se.call(t,o)&&re(e,o,t[o]);return e},U=(e,t)=>ye(e,Ae(t));var ie=(e,t)=>{var o={};for(var n in e)ce.call(e,n)&&t.indexOf(n)<0&&(o[n]=e[n]);if(e!=null&&T)for(var n of T(e))t.indexOf(n)<0&&se.call(e,n)&&(o[n]=e[n]);return o};Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});var d=require("vue-demi"),m=require("@intlify/vue-router-bridge"),x=require("@intlify/vue-i18n-bridge");function we(e){return e&&typeof e=="object"&&"default"in e?e:{default:e}}var Ce=we(m);/*!
* shared v9.2.0-beta.34
* (c) 2022 kazuya kawaguchi
* Released under the MIT License.
*/const K=Object.assign,Le=Array.isArray,ge=e=>typeof e=="function",T=e=>typeof e=="string",Re=e=>typeof e=="boolean",pe=e=>typeof e=="symbol",Ee=e=>e!==null&&typeof e=="object",ve=/\/$|\/\?/;function b(e="",t=!1){return t?ve.test(e):e.endsWith("/")}function Se(e="",t=!1){if(!t)return(b(e)?e.slice(0,-1):e)||"/";if(!b(e,!0))return e||"/";const[o,...a]=e.split("?");return(o.slice(0,-1)||"/")+(a.length?`?${a.join("?")}`:"")}function Ae(e="",t=!1){if(!t)return e.endsWith("/")?e:e+"/";if(b(e,!0))return e||"/";const[o,...a]=e.split("?");return o+"/"+(a.length?`?${a.join("?")}`:"")}const Ie=typeof window!="undefined";function De(e,t){typeof console!="undefined"&&(console.warn("[vue-i18n-routing] "+e),t&&console.warn(t.stack))}function Z(e){e=e||[];const t=[];for(const o of e)T(o)?t.push({code:o}):t.push(o);return t}function X(e,t){return m.isRef(e.locale)&&t==="composition"}function ee(e){return"global"in e&&"mode"in e}function w(e){return ee(e)?X(e.global,e.mode)?e.global.locale.value:e.global.locale:e.locale.value}function te(e,t){ee(e)?X(e.global,e.mode)?e.global.locale.value=t:e.global.locale=t:m.isRef(e.locale)&&(e.locale.value=t)}function Te(e,t,o){return e.replace(/\/+$/,"")+(t?"/":"")||(o?"":"/")}function Q(e){return S.isVueRouter4,m.isRef(e)?e.value:e}function oe(e){return T(e)?e:pe(e)?e.toString():"(null)"}function Y(e,t,{defaultLocale:o,strategy:a,routesNameSeparator:l,defaultLocaleRouteNameSuffix:n}){let r=oe(e)+(a==="no_prefix"?"":l+t);return t===o&&a==="prefix_and_default"&&(r+=l+n),r}function ae(e,t){return ge(e)?e(t):e}function Fe(e,t){const o=[];for(const[a,l]of t.entries()){const n=e.find(r=>r.iso.toLowerCase()===l.toLowerCase());if(n){o.push({code:n.code,score:1-a/t.length});break}}for(const[a,l]of t.entries()){const n=l.split("-")[0].toLowerCase(),r=e.find(c=>c.iso.split("-")[0].toLowerCase()===n);if(r){o.push({code:r.code,score:.999-a/t.length});break}}return o}const Pe=Fe;function xe(e,t){return e.score===t.score?t.code.length-e.code.length:t.score-e.score}const ye=xe;function we(e,t,{matcher:o=Pe,comparer:a=ye}={}){const l=[];for(const r of e){const{code:c}=r,u=r.iso||c;l.push({code:c,iso:u})}const n=o(l,t);return n.length>1&&n.sort(a),n.length?n[0].code:""}const P={PREFIX:"prefix",PREFIX_EXCEPT_DEFAULT:"prefix_except_default",PREFIX_AND_DEFAULT:"prefix_and_default",NO_PREFIX:"no_prefix"},N="",$=P.PREFIX_EXCEPT_DEFAULT,ne=!1,U="___",M="default",Ne="ltr",le="",$e=new Set([P.PREFIX_AND_DEFAULT,P.PREFIX_EXCEPT_DEFAULT]);function C(e=S.useRoute(),{router:t=S.useRouter(),routesNameSeparator:o=U}={}){const a=o||t.__routesNameSeparator,l=m.unref(e);return l.name?oe(l.name).split(a)[0]:null}function re(e,t,o){const a=j(e,t,o);return a==null?"":m.isVue3?a.redirectedFrom||a.fullPath:a.route.redirectedFrom||a.route.fullPath}function ce(e,t,o){const a=j(e,t,o);return a==null?void 0:m.isVue3?a:a.route}function Ue(e,t,o){const a=j(e,t,o);return a==null?void 0:m.isVue3?a:a.location}function j(e,t,{router:o=S.useRouter(),i18n:a=J.useI18n(),defaultLocale:l=N,defaultLocaleRouteNameSuffix:n=M,routesNameSeparator:r=U,strategy:c=$,trailingSlash:u=!1}={}){const i=o.__defaultLocaleRouteNameSuffix||n,f=o.__defaultLocale||l,s=o.__routesNameSeparator||r,_=o.__strategy||c,L=t||w(a);let R=e;T(e)&&(R[0]==="/"?R={path:e}:R={name:e});let h=K({},R);if(h.path&&!h.name){const d=o.resolve(h),g=m.isVue3?d:d.route,A=C(g);T(A)?h={name:Y(A,L,{defaultLocale:f,strategy:_,routesNameSeparator:s,defaultLocaleRouteNameSuffix:i}),params:g.params,query:g.query,hash:g.hash}:(!(L===l&&$e.has(_))&&_!==P.NO_PREFIX&&(h.path=`/${L}${h.path}`),h.path=u?Ae(h.path,!0):Se(h.path,!0))}else{h.name=Y(h.name,L,{defaultLocale:f,strategy:_,routesNameSeparator:s,defaultLocaleRouteNameSuffix:i});const{params:d}=h;d&&d["0"]===void 0&&d.pathMatch&&(d["0"]=d.pathMatch)}const p=o.resolve(h);return(m.isVue3?p.name:p.route.name)?p:o.resolve(e)}function V(e,t){const o=t&&t.route||S.useRoute(),a=C(o,t);if(!a)return"";const i=!m.isVue3&&m.isRef(o)?o.value:o,{params:l}=i,n=W(i,["params"]),r={},c=K({},n,{name:a,params:y(D(D({},l),r),{0:l.pathMatch})});return re(c,e,t)}function Ce({addDirAttribute:e=!1,addSeoAttributes:t=!1,strategy:o=$,defaultLocale:a=N,route:l=S.useRoute(),router:n=S.useRouter(),i18n:r=J.useI18n()}={}){const c=n,u=a||c.__defaultLocale,i=o||c.__strategy,f=m.ref({htmlAttrs:{},link:[],meta:[]});function s(){f.value={htmlAttrs:{},link:[],meta:[]}}function _(L){if(r.locales==null||r.__baseUrl==null)return;const R=w(r),h=Z(r.locales.value).find(g=>g.code===R)||{code:R},p=h.iso,d=h.dir||n.__defaultDirection;if(e&&(f.value.htmlAttrs.dir=d),t&&R&&r.locales){p&&(f.value.htmlAttrs.lang=p);const g=r.locales.value;Oe(g,r.__baseUrl,f.value.link,{defaultLocale:u,strategy:i,route:l,router:n,i18n:r}),be(r.__baseUrl,f.value.link,t,{route:L,router:n,i18n:r}),Ve(h,p,f.value.meta),Be(g,p,f.value.meta)}}if(Ie)if(m.isVue3){const L=m.watchEffect(()=>{s(),_(Q(c.currentRoute))});m.onUnmounted(()=>L())}else{const L=c.afterEach((R,h)=>{s(),_(R)});m.onUnmounted(()=>L()),_(l)}else _(Q(c.currentRoute));return f}function Oe(e,t,o,a){if(a.strategy===P.NO_PREFIX)return;const l=new Map;for(const n of e){const r=n.iso;if(!r){De("Locale ISO code is required to generate alternate link");continue}const[c,u]=r.split("-");c&&u&&(n.isCatchallLocale||!l.has(c))&&l.set(c,n),l.set(r,n)}for(const[n,r]of l.entries()){const c=V(r.code,a);c&&o.push({hid:`i18n-alt-${n}`,rel:"alternate",href:B(c,t),hreflang:n})}if(a.defaultLocale){const n=V(a.defaultLocale,a);n&&o.push({hid:"i18n-xd",rel:"alternate",href:B(n,t),hreflang:"x-default"})}}function be(e,t,o,a){const{route:l}=a,n=ce(y(D({},l),{name:C(l,a)}),void 0,a);if(n){let r=B(n.path,e);const c=!Re(o)&&o.canonicalQueries||[];if(c.length){const u=n.query,i=new URLSearchParams;for(const s of c)if(s in u){const _=u[s];Le(_)?_.forEach(L=>i.append(s,L||"")):i.append(s,_||"")}const f=i.toString();f&&(r=`${r}?${f}`)}t.push({hid:"i18n-can",rel:"canonical",href:r})}}function Ve(e,t,o){!(e&&t)||o.push({hid:"i18n-og",property:"og:locale",content:se(t)})}function Be(e,t,o){const a=e.filter(l=>{const n=l.iso;return n&&n!==t});if(a.length){const l=a.map(n=>({hid:`i18n-og-alt-${n.iso}`,property:"og:locale:alternate",content:se(n.iso)}));o.push(...l)}}function se(e){return(e||"").replace(/-/g,"_")}function B(e,t){return e.match(/^https?:\/\//)?e:t+e}function ue(e,{defaultLocale:t=N,strategy:o=$,trailingSlash:a=ne,routesNameSeparator:l=U,defaultLocaleRouteNameSuffix:n=M,includeUprefixedFallback:r=!1,optionsResolver:c=void 0,locales:u=[]}={}){if(o==="no_prefix")return e;const i=u.map(s=>T(s)?s:s.code);function f(s,_,L=!1,R=!1){if(s.redirect&&(!s.component||!s.file))return[s];let h=null;return c!=null&&(h=c(s,_),h==null)?[s]:_.reduce((d,g)=>{const{name:A}=s;let{path:E}=s;const v=D({},s);A&&(v.name=`${A}${l}${g}`),s.children&&(v.children=s.children.reduce((I,O)=>[...I,...f(O,[g],!0,R)],[]));const F=g===t;if(F&&o==="prefix_and_default")if(L)L&&R&&A&&(v.name+=`${l}${n}`);else{const I=y(D({},v),{path:E});if(A&&(I.name=`${v.name}${l}${n}`),s.children){I.children=[];for(const O of s.children)I.children=I.children.concat(f(O,[g],!0,!0))}d.push(I)}const z=L&&!E.startsWith("/"),k=!z&&!(F&&o==="prefix_except_default");return k&&(E=`/${g}${E}`),E&&(E=Te(E,a,z)),k&&F&&o==="prefix"&&r&&d.push(D({},s)),v.path=E,d.push(v),d},[])}return e.reduce((s,_)=>[...s,...f(_,i||[])],[])}function Xe(e,{locales:t=[],localeCodes:o=[],baseUrl:a=le}={}){if(!X(e.global,e.mode))throw new Error("TODO:");const l=m.ref(t),n=m.ref(o);e.global.locales=m.computed(()=>l.value),e.global.localeCodes=m.computed(()=>n.value),e.global.__baseUrl=ae(a,{})}function Me(e,t={}){const{version:o,defaultLocale:a,locales:l,strategy:n,trailingSlash:r,routesNameSeparator:c,defaultLocaleRouteNameSuffix:u,defaultDirection:i,baseUrl:f,routes:s,routeOptionsResolver:_}=ke(t),L=Z(l),R=L.map(g=>g.code),h=ie(R,c,u);Xe(e,{locales:L,baseUrl:f,localeCodes:R});const p=ue(s,{locales:l,defaultLocale:a,strategy:n,trailingSlash:r,routesNameSeparator:c,defaultLocaleRouteNameSuffix:u,optionsResolver:_});t.routes=p;const d=je(t,o);return d.__defaultLocale=a,d.__localeCodes=R,d.__strategy=n,d.__trailingSlash=r,d.__routesNameSeparator=c,d.__defaultLocaleRouteNameSuffix=u,d.__defaultDirection=i,d.beforeEach((g,A,E)=>{const v=w(e),F=h(g)||v||a||"";v!==F&&te(e,F),E()}),d}function je(e,t){if(m.isVue3&&t===4)return S.createRouter(e);if(m.isVue2&&t===3)return new _e.default(e);throw new Error("TODO:")}function ze(e){return new RegExp(`^/(${e.join("|")})(?:/|$)`,"i")}function ie(e,t,o){const a=`(${e.join("|")})`,l=`(?:${t}${o})?`,n=new RegExp(`${t}${a}${l}$`,"i"),r=ze(e);return u=>{if(Ee(u)){if(u.name){const f=(T(u.name)?u.name:u.name.toString()).match(n);if(f&&f.length>1)return f[1]}else if(u.path){const i=u.path.match(r);if(i&&i.length>1)return i[1]}}else if(T(u)){const i=u.match(r);if(i&&i.length>1)return i[1]}return""}}function ke(e){var t,o,a,l,n,r,c,u,i,f;return e.version=(t=e.version)!=null?t:4,e.defaultLocale=(o=e.defaultLocale)!=null?o:N,e.strategy=(a=e.strategy)!=null?a:$,e.trailingSlash=(l=e.trailingSlash)!=null?l:ne,e.routesNameSeparator=(n=e.routesNameSeparator)!=null?n:U,e.defaultLocaleRouteNameSuffix=(r=e.defaultLocaleRouteNameSuffix)!=null?r:M,e.locales=(c=e.locales)!=null?c:[],e.defaultDirection=(u=e.defaultDirection)!=null?u:Ne,e.baseUrl=(i=e.baseUrl)!=null?i:le,e.routes=(f=e.routes)!=null?f:[],e}const qe="0.0.0";exports.VERSION=qe;exports.createLocaleFromRouteGetter=ie;exports.createRouter=Me;exports.findBrowserLocale=we;exports.getLocale=w;exports.getRouteBaseName=C;exports.localeLocation=Ue;exports.localePath=re;exports.localeRoute=ce;exports.localizeRoutes=ue;exports.resolveBaseUrl=ae;exports.setLocale=te;exports.switchLocalePath=V;exports.useI18nHead=Ce;
*/const de=Object.assign,De=Array.isArray,xe=e=>typeof e=="function",O=e=>typeof e=="string",Ne=e=>typeof e=="boolean",Fe=e=>typeof e=="symbol",Q=e=>e!==null&&typeof e=="object",Te=/\/$|\/\?/;function H(e="",t=!1){return t?Te.test(e):e.endsWith("/")}function Ue(e="",t=!1){if(!t)return(H(e)?e.slice(0,-1):e)||"/";if(!H(e,!0))return e||"/";const[o,...n]=e.split("?");return(o.slice(0,-1)||"/")+(n.length?`?${n.join("?")}`:"")}function $e(e="",t=!1){if(!t)return e.endsWith("/")?e:e+"/";if(H(e,!0))return e||"/";const[o,...n]=e.split("?");return o+"/"+(n.length?`?${n.join("?")}`:"")}const Ve=typeof window!="undefined";function je(e,t){typeof console!="undefined"&&(console.warn("[vue-i18n-routing] "+e),t&&console.warn(t.stack))}function he(e){e=e||[];const t=[];for(const o of e)O(o)?t.push({code:o}):t.push(o);return t}function V(e){return e!=null&&"global"in e&&"mode"in e}function j(e){return e!=null&&!("__composer"in e)&&d.isRef(e.locale)}function N(e){return e!=null&&"__composer"in e}function Y(e){return e!=null&&!("__composer"in e)&&!d.isRef(e.locale)}function y(e){return e!=null&&("__VUE_I18N_BRIDGE__"in e||"_sync"in e)}function me(e){return V(e)?j(e.global)?e.global:e.global.__composer:N(e)?e.__composer:e}function B(e){const t=V(e)?e.global:e;return j(t)?d.isVue2&&y(e)?e.locale:t.locale.value:(Y(t)||N(t)||y(t),t.locale)}function Be(e){const t=V(e)?e.global:e;return j(t)?d.isVue2&&y(e)?e.locales:t.locales.value:(Y(t)||N(t)||y(t),t.locales)}function Le(e,t){const o=V(e)?e.global:e;if(j(o))d.isVue2&&y(e)?e.locale=t:o.locale.value=t;else if(Y(o)||N(o)||y(o))o.locale=t;else throw new Error("TODO:")}function Me(e,t,o){return e.replace(/\/+$/,"")+(t?"/":"")||(o?"":"/")}function ue(e){return m.isVueRouter4,d.isRef(e)?e.value:e}function Re(e){return O(e)?e:Fe(e)?e.toString():"(null)"}function fe(e,t,{defaultLocale:o,strategy:n,routesNameSeparator:l,defaultLocaleRouteNameSuffix:a}){let r=Re(e)+(n==="no_prefix"?"":l+t);return t===o&&n==="prefix_and_default"&&(r+=l+a),r}function ge(e,t){return xe(e)?e(t):e}function Xe(e,t){const o=[];for(const[n,l]of t.entries()){const a=e.find(r=>r.iso.toLowerCase()===l.toLowerCase());if(a){o.push({code:a.code,score:1-n/t.length});break}}for(const[n,l]of t.entries()){const a=l.split("-")[0].toLowerCase(),r=e.find(c=>c.iso.split("-")[0].toLowerCase()===a);if(r){o.push({code:r.code,score:.999-n/t.length});break}}return o}const Ge=Xe;function ke(e,t){return e.score===t.score?t.code.length-e.code.length:t.score-e.score}const ze=ke;function qe(e,t,{matcher:o=Ge,comparer:n=ze}={}){const l=[];for(const r of e){const{code:c}=r,s=r.iso||c;l.push({code:c,iso:s})}const a=o(l,t);return a.length>1&&a.sort(n),a.length?a[0].code:""}const C={PREFIX:"prefix",PREFIX_EXCEPT_DEFAULT:"prefix_except_default",PREFIX_AND_DEFAULT:"prefix_and_default",NO_PREFIX:"no_prefix"},J="",K=C.PREFIX_EXCEPT_DEFAULT,Z=!1,ee="___",te="default",pe="ltr",_e="";function E(e){return function(){return Reflect.apply(e,{getRouteBaseName:this.getRouteBaseName,localePath:this.localePath,localeRoute:this.localeRoute,localeLocation:this.localeLocation,resolveRoute:this.resolveRoute,switchLocalePath:this.switchLocalePath,localeHead:this.localeHead,i18n:this.$i18n,route:this.$route,router:this.$router},arguments)}}function ve(e,{locales:t=[],localeCodes:o=[],baseUrl:n=_e}={}){const l=e.install;e.install=(a,...r)=>{Reflect.apply(l,e,[a,...r]);const c=me(e);He(c,{locales:t,localeCodes:o,baseUrl:n}),N(e.global)&&Qe(e.global);const s=a,i=e.mode==="composition"?d.isVue3?s.config.globalProperties.$i18n:e:d.isVue2?e:null;i&&We(i,c),(Ye(r[0])?r[0]:{inject:!0}).inject&&a.mixin({methods:{resolveRoute:E(F),localePath:E(X),localeRoute:E(G),localeLocation:E(oe),switchLocalePath:E(D),getRouteBaseName:E(A),localeHead:E(ne)}})}}function He(e,t){const{locales:o,localeCodes:n,baseUrl:l}=t,a=d.ref(o),r=d.ref(n);e.locales=d.computed(()=>a.value),e.localeCodes=d.computed(()=>r.value),e.__baseUrl=ge(l,{})}function We(e,t){Object.defineProperty(e,"locales",{get(){return t.locales.value}}),Object.defineProperty(e,"localeCodes",{get(){return t.localeCodes.value}}),Object.defineProperty(e,"__baseUrl",{get(){return t.__baseUrl}})}function Qe(e){const t=me(e);Object.defineProperty(e,"locales",{get(){return t.locales.value}}),Object.defineProperty(e,"localeCodes",{get(){return t.localeCodes.value}}),Object.defineProperty(e,"__baseUrl",{get(){return t.__baseUrl}})}function Ye(e){return Q(e)&&"inject"in e&&Ne(e.inject)}function Ee(e,{defaultLocale:t=J,strategy:o=K,trailingSlash:n=Z,routesNameSeparator:l=ee,defaultLocaleRouteNameSuffix:a=te,includeUprefixedFallback:r=!1,optionsResolver:c=void 0,locales:s=[]}={}){if(o==="no_prefix")return e;const i=s.map(u=>O(u)?u:u.code);function f(u,L,h=!1,R=!1){if(u.redirect&&(!u.component||!u.file))return[u];let S=null;return c!=null&&(S=c(u,L),S==null)?[u]:L.reduce((_,v)=>{const{name:w}=u;let{path:g}=u;const p=I({},u);w&&(p.name=`${w}${l}${v}`),u.children&&(p.children=u.children.reduce((P,q)=>[...P,...f(q,[v],!0,R)],[]));const b=v===t;if(b&&o==="prefix_and_default")if(h)h&&R&&w&&(p.name+=`${l}${a}`);else{const P=U(I({},p),{path:g});if(w&&(P.name=`${p.name}${l}${a}`),u.children){P.children=[];for(const q of u.children)P.children=P.children.concat(f(q,[v],!0,!0))}_.push(P)}const ae=h&&!g.startsWith("/"),le=!ae&&!(b&&o==="prefix_except_default");return le&&(g=`/${v}${g}`),g&&(g=Me(g,n,ae)),le&&b&&o==="prefix"&&r&&_.push(I({},u)),p.path=g,_.push(p),_},[])}return e.reduce((u,L)=>[...u,...f(L,i||[])],[])}const $=new Map;function Se(e,t){return $.has(e)?null:($.set(e,t),()=>$.delete(e))}function Pe(e){var t;return(t=$.get(e))!=null?t:{}}function Je(e,t={}){const{version:o,defaultLocale:n,locales:l,strategy:a,trailingSlash:r,routesNameSeparator:c,defaultLocaleRouteNameSuffix:s,defaultDirection:i,baseUrl:f,routes:u,routeOptionsResolver:L}=et(t),h=he(l),R=h.map(v=>v.code),S=Ie(R,c,s);ve(e,{locales:h,baseUrl:f,localeCodes:R});const z=Ee(u,{locales:l,defaultLocale:n,strategy:a,trailingSlash:r,routesNameSeparator:c,defaultLocaleRouteNameSuffix:s,optionsResolver:L});t.routes=z;const _=Ke(t,o);return Se(_,{defaultLocale:n,localeCodes:R,strategy:a,trailingSlash:r,routesNameSeparator:c,defaultLocaleRouteNameSuffix:s,defaultDirection:i}),_.beforeEach((v,w,g)=>{const p=B(e),b=S(v)||p||n||"";p!==b&&Le(e,b),g()}),_}function Ke(e,t){if(d.isVue3&&t===4)return m.createRouter(e);if(d.isVue2&&t===3)return new Ce.default(e);throw new Error("TODO:")}function Ze(e){return new RegExp(`^/(${e.join("|")})(?:/|$)`,"i")}function Ie(e,t,o){const n=`(${e.join("|")})`,l=`(?:${t}${o})?`,a=new RegExp(`${t}${n}${l}$`,"i"),r=Ze(e);return s=>{if(Q(s)){if(s.name){const f=(O(s.name)?s.name:s.name.toString()).match(a);if(f&&f.length>1)return f[1]}else if(s.path){const i=s.path.match(r);if(i&&i.length>1)return i[1]}}else if(O(s)){const i=s.match(r);if(i&&i.length>1)return i[1]}return""}}function et(e){var t,o,n,l,a,r,c,s,i,f;return e.version=(t=e.version)!=null?t:4,e.defaultLocale=(o=e.defaultLocale)!=null?o:J,e.strategy=(n=e.strategy)!=null?n:K,e.trailingSlash=(l=e.trailingSlash)!=null?l:Z,e.routesNameSeparator=(a=e.routesNameSeparator)!=null?a:ee,e.defaultLocaleRouteNameSuffix=(r=e.defaultLocaleRouteNameSuffix)!=null?r:te,e.locales=(c=e.locales)!=null?c:[],e.defaultDirection=(s=e.defaultDirection)!=null?s:pe,e.baseUrl=(i=e.baseUrl)!=null?i:_e,e.routes=(f=e.routes)!=null?f:[],e}function M(e,t,{defaultLocale:o=J,defaultDirection:n=pe,defaultLocaleRouteNameSuffix:l=te,routesNameSeparator:a=ee,strategy:r=K,trailingSlash:c=Z,localeCodes:s=[]}={}){const i=Pe(e);return{defaultLocale:t.defaultLocale||i.defaultLocale||o,defaultDirection:t.defaultDirection||i.defaultDirection||n,defaultLocaleRouteNameSuffix:t.defaultLocaleRouteNameSuffix||i.defaultLocaleRouteNameSuffix||l,routesNameSeparator:t.routesNameSeparator||i.routesNameSeparator||a,strategy:t.strategy||i.strategy||r,trailingSlash:t.trailingSlash||i.trailingSlash||c,localeCodes:t.localeCodes||i.localeCodes||s}}const tt=new Set([C.PREFIX_AND_DEFAULT,C.PREFIX_EXCEPT_DEFAULT]);function A(e){const t=this.router,{routesNameSeparator:o}=M(t,this),n=e!=null?d.isRef(e)?d.unref(e):e:this.route;return n.name?Re(n.name).split(o)[0]:void 0}function X(e,t){const o=F.call(this,e,t);return o==null?"":d.isVue3?o.redirectedFrom||o.fullPath:o.route.redirectedFrom||o.route.fullPath}function G(e,t){const o=F.call(this,e,t);return o==null?void 0:d.isVue3?o:o.route}function oe(e,t){const o=F.call(this,e,t);return o==null?void 0:d.isVue3?o:o.location}function F(e,t){const o=this.router,n=this.i18n,l=t||B(n),{routesNameSeparator:a,defaultLocale:r,defaultLocaleRouteNameSuffix:c,strategy:s,trailingSlash:i}=M(o,this);let f=e;O(e)&&(f[0]==="/"?f={path:e}:f={name:e});let u=de({},f);if(u.path&&!u.name){const h=o.resolve(u),R=d.isVue3?h:h.route,S=A.call(this,R);O(S)?u={name:fe(S,l,{defaultLocale:r,strategy:s,routesNameSeparator:a,defaultLocaleRouteNameSuffix:c}),params:R.params,query:R.query,hash:R.hash}:(!(l===r&&tt.has(s))&&s!==C.NO_PREFIX&&(u.path=`/${l}${u.path}`),u.path=i?$e(u.path,!0):Ue(u.path,!0))}else{u.name=fe(u.name,l,{defaultLocale:r,strategy:s,routesNameSeparator:a,defaultLocaleRouteNameSuffix:c});const{params:h}=u;h&&h["0"]===void 0&&h.pathMatch&&(h["0"]=h.pathMatch)}const L=o.resolve(u);return(d.isVue3?L.name:L.route.name)?L:o.resolve(e)}function D(e){const t=this.route,o=A.call(this,t);if(!o)return"";const s=!d.isVue3&&d.isRef(t)?t.value:t,{params:n}=s,l=ie(s,["params"]),a={},r=de({},l,{name:o,params:U(I(I({},n),a),{0:n.pathMatch})});return X.call(this,r,e)}function ne({addDirAttribute:e=!1,addSeoAttributes:t=!1}={}){const o=this.router,n=this.i18n,{defaultDirection:l}=M(o,this),a={htmlAttrs:{},link:[],meta:[]};if(n.locales==null||n.__baseUrl==null)return a;const r=B(n),c=Be(n),s=he(c).find(u=>u.code===r)||{code:r},i=s.iso,f=s.dir||l;return e&&(a.htmlAttrs.dir=f),t&&r&&n.locales&&(i&&(a.htmlAttrs.lang=i),ot.call(this,c,n.__baseUrl,a.link),nt.call(this,n.__baseUrl,a.link,t),at(s,i,a.meta),lt(c,i,a.meta)),a}function ot(e,t,o){const n=this.router,{defaultLocale:l,strategy:a}=M(n,this);if(a===C.NO_PREFIX)return;const r=new Map;for(const c of e){const s=c.iso;if(!s){je("Locale ISO code is required to generate alternate link");continue}const[i,f]=s.split("-");i&&f&&(c.isCatchallLocale||!r.has(i))&&r.set(i,c),r.set(s,c)}for(const[c,s]of r.entries()){const i=D.call(this,s.code);i&&o.push({hid:`i18n-alt-${c}`,rel:"alternate",href:W(i,t),hreflang:c})}if(l){const c=D.call(this,l);c&&o.push({hid:"i18n-xd",rel:"alternate",href:W(c,t),hreflang:"x-default"})}}function nt(e,t,o){const n=this.route,l=G.call(this,U(I({},n),{name:A.call(this,n)}));if(l){let a=W(l.path,e);const r=Q(o)&&o.canonicalQueries||[];if(r.length){const c=l.query,s=new URLSearchParams;for(const f of r)if(f in c){const u=c[f];De(u)?u.forEach(L=>s.append(f,L||"")):s.append(f,u||"")}const i=s.toString();i&&(a=`${a}?${i}`)}t.push({hid:"i18n-can",rel:"canonical",href:a})}}function at(e,t,o){!(e&&t)||o.push({hid:"i18n-og",property:"og:locale",content:Oe(t)})}function lt(e,t,o){const n=e.filter(l=>{const a=l.iso;return a&&a!==t});if(n.length){const l=n.map(a=>({hid:`i18n-og-alt-${a.iso}`,property:"og:locale:alternate",content:Oe(a.iso)}));o.push(...l)}}function Oe(e){return(e||"").replace(/-/g,"_")}function W(e,t){return e.match(/^https?:\/\//)?e:t+e}function k(e,t){const{router:o,route:n,i18n:l,defaultLocale:a,strategy:r,defaultLocaleRouteNameSuffix:c,trailingSlash:s,routesNameSeparator:i}=e;return function(...f){return Reflect.apply(t,{router:o,route:n,i18n:l,defaultLocale:a,strategy:r,defaultLocaleRouteNameSuffix:c,trailingSlash:s,routesNameSeparator:i},f)}}function rt(e=m.useRoute(),{router:t=m.useRouter(),routesNameSeparator:o=void 0}={}){const n={router:t,route:e,routesNameSeparator:o};return A.call(n,e)}function ct({router:e=m.useRouter(),route:t=m.useRoute(),i18n:o=x.useI18n(),defaultLocale:n=void 0,defaultLocaleRouteNameSuffix:l=void 0,routesNameSeparator:a=void 0,strategy:r=void 0,trailingSlash:c=void 0}={}){return k({router:e,route:t,i18n:o,defaultLocale:n,defaultLocaleRouteNameSuffix:l,routesNameSeparator:a,strategy:r,trailingSlash:c},X)}function st({router:e=m.useRouter(),route:t=m.useRoute(),i18n:o=x.useI18n(),defaultLocale:n=void 0,defaultLocaleRouteNameSuffix:l=void 0,routesNameSeparator:a=void 0,strategy:r=void 0,trailingSlash:c=void 0}={}){return k({router:e,route:t,i18n:o,defaultLocale:n,defaultLocaleRouteNameSuffix:l,routesNameSeparator:a,strategy:r,trailingSlash:c},G)}function it({router:e=m.useRouter(),route:t=m.useRoute(),i18n:o=x.useI18n(),defaultLocale:n=void 0,defaultLocaleRouteNameSuffix:l=void 0,routesNameSeparator:a=void 0,strategy:r=void 0,trailingSlash:c=void 0}={}){return k({router:e,route:t,i18n:o,defaultLocale:n,defaultLocaleRouteNameSuffix:l,routesNameSeparator:a,strategy:r,trailingSlash:c},oe)}function ut({router:e=m.useRouter(),route:t=m.useRoute(),i18n:o=x.useI18n(),defaultLocale:n=void 0,defaultLocaleRouteNameSuffix:l=void 0,routesNameSeparator:a=void 0,strategy:r=void 0,trailingSlash:c=void 0}={}){return k({router:e,route:t,i18n:o,defaultLocale:n,defaultLocaleRouteNameSuffix:l,routesNameSeparator:a,strategy:r,trailingSlash:c},D)}function ft({addDirAttribute:e=!1,addSeoAttributes:t=!1,strategy:o=void 0,defaultLocale:n=void 0,route:l=m.useRoute(),router:a=m.useRouter(),i18n:r=x.useI18n()}={}){const c=a,s=d.ref({htmlAttrs:{},link:[],meta:[]});function i(){s.value={htmlAttrs:{},link:[],meta:[]}}function f(u){s.value=Reflect.apply(ne,{router:a,route:u,i18n:r,defaultLocale:n,strategy:o},[{addDirAttribute:e,addSeoAttributes:t}])}if(Ve)if(d.isVue3){const u=d.watchEffect(()=>{i(),f(ue(c.currentRoute))});d.onUnmounted(()=>u())}else{const u=c.afterEach((L,h)=>{i(),f(L)});d.onUnmounted(()=>u()),f(l)}else f(ue(c.currentRoute));return s}const dt="0.0.0";exports.VERSION=dt;exports.createLocaleFromRouteGetter=Ie;exports.createRouter=Je;exports.extendI18n=ve;exports.findBrowserLocale=qe;exports.getGlobalOptions=Pe;exports.getLocale=B;exports.getRouteBaseName=A;exports.localeHead=ne;exports.localeLocation=oe;exports.localePath=X;exports.localeRoute=G;exports.localizeRoutes=Ee;exports.proxyVueInstance=E;exports.registerGlobalOptions=Se;exports.resolveBaseUrl=ge;exports.resolveRoute=F;exports.setLocale=Le;exports.switchLocalePath=D;exports.useLocaleHead=ft;exports.useLocaleLocation=it;exports.useLocalePath=ct;exports.useLocaleRoute=st;exports.useRouteBaseName=rt;exports.useSwitchLocalePath=ut;

@@ -1,2 +0,2 @@

import { Composer } from '@intlify/vue-i18n-bridge';
import type { Composer } from '@intlify/vue-i18n-bridge';
import type { I18n } from '@intlify/vue-i18n-bridge';

@@ -16,5 +16,6 @@ import type { Locale } from '@intlify/vue-i18n-bridge';

import { useRouter } from '@intlify/vue-router-bridge';
import type { VueI18n } from '@intlify/vue-i18n-bridge';
import type { VueRouter } from '@intlify/vue-router-bridge';
export declare type BaseUrlResolveHandler = (context: unknown) => string;
export declare type BaseUrlResolveHandler<Context = unknown> = (context: Context) => string;

@@ -77,3 +78,3 @@ /**

* @param i18n - A Vue I18n instance, see [Vue I18n API docs](https://vue-i18n.intlify.dev/api/general.html#i18n)
* @param options - An options, see {@link VueI18nRoutingOptions}
* @param options - An options, see {@link I18nRoutingOptions}
*

@@ -91,3 +92,3 @@ * @returns A Vue Router instance

*/
export declare function createRouter<Options extends VueI18nRoutingOptions = VueI18nRoutingOptions>(i18n: I18n, options?: Options): Options['version'] extends 4 ? Router : VueRouter;
export declare function createRouter<Options extends I18nRoutingOptions = I18nRoutingOptions>(i18n: I18n, options?: Options): Options['version'] extends 4 ? Router : VueRouter;

@@ -99,2 +100,4 @@ /**

export declare function extendI18n<TI18n extends I18n>(i18n: TI18n, { locales, localeCodes, baseUrl }?: VueI18nExtendOptions): void;
/**

@@ -120,2 +123,11 @@ * Find the browser locale

/**
* Get global i18n routing options
*
* @param router - A router instance, about router type
*
* @returns - {@link I18nRoutingGlobalOptions | global options} from i18n routing options registory, if registered, return it, else empty object
*/
export declare function getGlobalOptions(router: Router | VueRouter): I18nRoutingGlobalOptions;
/**
* Get a locale

@@ -127,14 +139,15 @@ *

*/
export declare function getLocale(i18n: I18n | Composer): Locale;
export declare function getLocale(i18n: I18n | Composer | VueI18n): Locale;
export declare function getRouteBaseName(this: RoutingProxy, givenRoute?: Route_2 | RouteLocationNormalizedLoaded): string | undefined;
/**
* Get route base name
*
* @param givenRoute - A route object, if not provided, the route is returned with `useRoute` will be used
* @param options - An options, see about details {@link I18nRoutingOptions}
*
* @returns The route base name, if route name is not defined, return null
* The unregister handler of global options for i18n routing
*/
export declare function getRouteBaseName(givenRoute?: Route_2 | RouteLocationNormalizedLoaded, { router, routesNameSeparator }?: I18nRoutingOptions): string | null;
export declare type GlobalOptionsUnregisterHandler = () => boolean;
export declare type I18nCommonRoutingOptions = Pick<I18nRoutingOptions, 'defaultLocale' | 'strategy' | 'defaultLocaleRouteNameSuffix' | 'trailingSlash' | 'locales' | 'routesNameSeparator'>;
export declare type I18nCommonRoutingOptionsWithComposable = I18nCommonRoutingOptions & ComposableOptions;
/**

@@ -150,3 +163,3 @@ * I18n header meta info

/**
* Options for {@link useI18nHead} function
* Options for {@link localeHead} function
*/

@@ -169,17 +182,130 @@ export declare interface I18nHeadOptions {

/**
* Options for vue-i18n-routing common
* Route config for vue-i18n-routing
*/
export declare type I18nRoutingOptions = Pick<VueI18nRoutingOptions, 'defaultLocale' | 'strategy' | 'defaultLocaleRouteNameSuffix' | 'trailingSlash' | 'locales' | 'routesNameSeparator'> & ComposableOptions;
export declare type I18nRoute = Route & RouteLegacy & {
redirect?: string;
};
/**
* Resolve locale location
* Global options for i18n routing
*/
export declare type I18nRoutingGlobalOptions<BaseUrl extends BaseUrlResolveHandler = BaseUrlResolveHandler> = Pick<I18nRoutingOptions<BaseUrl>, 'defaultLocale' | 'defaultDirection' | 'defaultLocaleRouteNameSuffix' | 'trailingSlash' | 'routesNameSeparator' | 'strategy'> & {
localeCodes?: string[];
};
/**
* Options to initialize a VueRouter instance
*
* @remarks
* This options is extended from Vue Router `RouterOptioins`, so you can specify those options.
*/
export declare type I18nRoutingOptions<BaseUrl extends BaseUrlResolveHandler = BaseUrlResolveHandler> = {
/**
* Vue Router version
*
* @remarks
* You can choice between vue-router v3 and v4.
*
* If you specify `3`, this function return Vue Router v3 instance, else specify `4`, this function return Vue Router v4 instance.
*
* @defaultValue 4
*/
version?: 3 | 4;
/**
* The app's default locale
*
* @remarks
* When using `prefix_except_default` strategy, URLs for locale specified here won't have a prefix.
*
* It's recommended to set this to some locale regardless of chosen strategy, as it will be used as a fallback locale when navigating to a non-existent route
*
* @defaultValue '' (emputy string)
*/
defaultLocale?: string;
/**
* List of locales supported by your app
*
* @remarks
* Can either be an array of string codes (e.g. `['en', 'fr']`) or an array of {@link LocaleObject} for more complex configurations
*
* @defaultValue []
*/
locales?: string[] | LocaleObject[];
/**
* Routes strategy
*
* @remarks
* Can be set to one of the following:
*
* - `no_prefix`: routes won't have a locale prefix
* - `prefix_except_default`: locale prefix added for every locale except default
* - `prefix`: locale prefix added for every locale
* - `prefix_and_default`: locale prefix added for every locale and default
*
* @defaultValue 'prefix_except_default'
*/
strategy?: Strategies;
/**
* Whether to use trailing slash
*
* @defaultValue false
*/
trailingSlash?: boolean;
/**
* Internal separator used for generated route names for each locale. You shouldn't need to change this
*
* @defaultValue '___'
*/
routesNameSeparator?: string;
/**
* Internal suffix added to generated route names for default locale
*
* @remarks
* if strategy is prefix_and_default. You shouldn't need to change this.
*
* @defaultValue 'default'
*/
defaultLocaleRouteNameSuffix?: string;
/**
* Default direction direction
*
* @defaultValue 'ltr'
*/
defaultDirection?: Directions;
/**
* The fallback base URL to use as a prefix for alternate URLs in hreflang tags.
*
* @remarks
* By default VueRouter's base URL will be used and only if that is not available, fallback URL will be used.
*
* Can also be a function (will be passed a Nuxt Context as a parameter) that returns a string.
*
* Useful to make base URL dynamic based on request headers.
*
* @defaultValue ''
*/
baseUrl?: string | BaseUrl;
/**
* Route options resolver
*
* @defaultValue undefined
*/
routeOptionsResolver?: RouteOptionsResolver;
} & RouterOptions;
export declare function localeHead(this: RoutingProxy, { addDirAttribute, addSeoAttributes }?: I18nHeadOptions): I18nHeadMetaInfo;
export declare function localeLocation(this: RoutingProxy, route: RawLocation | RouteLocationRaw, locale?: Locale): Location | RouteLocation | undefined;
/**
* Resolve locale location function
*
* @param route - A route location. The path or name of the route or an object for more complex routes
* @param locale - A locale code, if not specified, uses the current locale
* @param options - An options, see about details {@link I18nRoutingOptions}
*
* @returns Returns the location object for a given route, the location object is resolved by vue-router rather than just a full route path.
*
* @see {@link useLocaleLocation}
*/
export declare function localeLocation(route: RawLocation | RouteLocationRaw, locale?: Locale, // TODO: locale should be more type inference (completion)
options?: I18nRoutingOptions): Location | RouteLocation | undefined;
export declare type LocaleLocationFunction = (route: RawLocation | RouteLocationRaw, locale?: Locale) => Location | RouteLocation | undefined;

@@ -199,25 +325,29 @@ /**

export declare function localePath(this: RoutingProxy, route: RawLocation | RouteLocationRaw, locale?: Locale): string;
/**
* Resolve locale path
* Resolve locale path function
*
* @param route - A route location. The path or name of the route or an object for more complex routes
* @param locale - A locale code, if not specified, uses the current locale
* @param options - An options, see about details {@link I18nRoutingOptions}
*
* @returns Returns the localized URL for a given route
*
* @see {@link useLocalePath}
*/
export declare function localePath(route: RawLocation | RouteLocationRaw, locale?: Locale, // TODO: locale should be more type inference (completion)
options?: I18nRoutingOptions): string;
export declare type LocalePathFunction = (route: RawLocation | RouteLocation, locale?: Locale) => string;
export declare function localeRoute(this: RoutingProxy, route: RawLocation | RouteLocationRaw, locale?: Locale): Route_2 | ReturnType<Router['resolve']> | undefined;
/**
* Resolve locale route
* Resolve route fucntion
*
* @param route - A route location. The path or name of the route or an object for more complex routes
* @param locale - A locale code, if not specified, uses the current locale
* @param options - An options, see about details {@link I18nRoutingOptions}
*
* @returns Returns the route object for a given route, the route object is resolved by vue-router rather than just a full route path.
*
* @see {@link useLocaleRoute}
*/
export declare function localeRoute(route: RawLocation | RouteLocationRaw, locale?: Locale, // TODO: locale should be more type inference (completion)
options?: I18nRoutingOptions): Route_2 | ReturnType<Router['resolve']> | undefined;
export declare type LocaleRouteFunction = (route: RawLocation | RouteLocationRaw, locale?: Locale) => Route_2 | ReturnType<Router['resolve']> | undefined;

@@ -234,10 +364,22 @@ /**

*/
export declare function localizeRoutes(routes: VueI18nRoute[], { defaultLocale, strategy, trailingSlash, routesNameSeparator, defaultLocaleRouteNameSuffix, includeUprefixedFallback, optionsResolver, locales }?: Pick<VueI18nRoutingOptions, 'defaultLocale' | 'strategy' | 'locales' | 'routesNameSeparator' | 'trailingSlash' | 'defaultLocaleRouteNameSuffix'> & {
export declare function localizeRoutes(routes: I18nRoute[], { defaultLocale, strategy, trailingSlash, routesNameSeparator, defaultLocaleRouteNameSuffix, includeUprefixedFallback, optionsResolver, locales }?: Pick<I18nRoutingOptions, 'defaultLocale' | 'strategy' | 'locales' | 'routesNameSeparator' | 'trailingSlash' | 'defaultLocaleRouteNameSuffix'> & {
includeUprefixedFallback?: boolean;
optionsResolver?: RouteOptionsResolver;
}): VueI18nRoute[];
}): I18nRoute[];
export declare type MetaAttrs = Record<string, any>;
export declare function proxyVueInstance(target: Function): Function;
/**
* Register global i18n routing option registory
*
* @param router - A router instance, about router type
* @param options - A global options, about options type, see {@link I18nRoutingGlobalOptions}
*
* @returns - A {@link GlobalOptionsUnregisterHandler} to unregister the global options from registories, if registered, return it, else `null`
*/
export declare function registerGlobalOptions<BaseUrl extends BaseUrlResolveHandler = BaseUrlResolveHandler>(router: Router | VueRouter, options: I18nRoutingGlobalOptions<BaseUrl>): GlobalOptionsUnregisterHandler | null;
/**
* Resolve base url

@@ -250,4 +392,6 @@ *

*/
export declare function resolveBaseUrl(baseUrl: string | BaseUrlResolveHandler, context: unknown): string;
export declare function resolveBaseUrl<Context = unknown>(baseUrl: string | BaseUrlResolveHandler<Context>, context: Context): string;
export declare function resolveRoute(this: RoutingProxy, route: any, locale?: Locale): any;
/**

@@ -278,5 +422,28 @@ * Route config for vue-router v4

*/
export declare type RouteOptionsResolver = (route: VueI18nRoute, allowedLocaleCodes: string[]) => ComputedRouteOptions | null;
export declare type RouteOptionsResolver = (route: I18nRoute, allowedLocaleCodes: string[]) => ComputedRouteOptions | null;
/**
* Routing Proxy
*/
export declare type RoutingProxy = {
i18n: any;
getRouteBaseName: any;
localePath: any;
localeRoute: any;
localeLocation: any;
resolveRoute: any;
switchLocalePath: any;
localeHead: any;
route: Route_2 | RouteLocationNormalizedLoaded;
router: Router | VueRouter;
defaultLocale?: string;
localeCodes?: string[];
strategy?: Strategies;
defaultDirection?: Directions;
defaultLocaleRouteNameSuffix?: string;
trailingSlash?: boolean;
routesNameSeparator?: string;
};
/**
* SEO Attribute options

@@ -313,11 +480,14 @@ */

export declare function switchLocalePath(this: RoutingProxy, locale: Locale): string;
/**
* Switch locale path
* Swtich locale path function
*
* @param locale - A locale code, if not specified, uses the current locale
* @param options - An options, see about details {@link I18nRoutingOptions}
*
* @returns Returns a link to the current route in another language
*
* @see {@link useSwitchLocalePath}
*/
export declare function switchLocalePath(locale: Locale, options?: I18nRoutingOptions): string;
export declare type SwitchLocalePathFunction = (locale?: Locale) => string;

@@ -335,11 +505,57 @@ /**

/**
* Generate SEO head meta information
* Use localize head meta
*
* @param options - An options, see about details {@link I18nHeadOptions}
* @param options - An options, see about details {@link I18nHeadOptions}, {@link ComposableOptions}, {@link I18nCommonRoutingOptions}
*
* @returns Genereated SEO head meta information
*/
export declare function useI18nHead({ addDirAttribute, addSeoAttributes, strategy, defaultLocale, route, router, i18n }?: Pick<I18nRoutingOptions, 'strategy' | 'defaultLocale'> & ComposableOptions & I18nHeadOptions): Ref<I18nHeadMetaInfo>;
export declare function useLocaleHead({ addDirAttribute, addSeoAttributes, strategy, defaultLocale, route, router, i18n }?: Pick<I18nCommonRoutingOptionsWithComposable, 'strategy' | 'defaultLocale' | 'route' | 'router' | 'i18n'> & I18nHeadOptions): Ref<I18nHeadMetaInfo>;
/**
* Use resolve locale location
*
* @param options - An options, see about details {@link I18nRoutingOptions}
*
* @returns Returns a {@link LocaleLocationFunction}
*/
export declare function useLocaleLocation({ router, route, i18n, defaultLocale, defaultLocaleRouteNameSuffix, routesNameSeparator, strategy, trailingSlash }?: I18nCommonRoutingOptionsWithComposable): LocaleLocationFunction;
/**
* Use resolve locale path
*
* @param options - An options, see about details {@link I18nRoutingOptions}
*
* @returns Returns a {@link LocalePathFunction}
*/
export declare function useLocalePath({ router, route, i18n, defaultLocale, defaultLocaleRouteNameSuffix, routesNameSeparator, strategy, trailingSlash }?: I18nCommonRoutingOptionsWithComposable): LocalePathFunction;
/**
* Use resolve locale route
*
* @param options - An options, see about details {@link I18nRoutingOptions}
*
* @returns Returns a {@link LocaleRouteFunction}
*/
export declare function useLocaleRoute({ router, route, i18n, defaultLocale, defaultLocaleRouteNameSuffix, routesNameSeparator, strategy, trailingSlash }?: I18nCommonRoutingOptionsWithComposable): LocaleRouteFunction;
/**
* Use route base name
*
* @param givenRoute - A route object, if not provided, the route is returned with `useRoute` will be used
* @param options - An options, see about details {@link I18nRoutingOptions}
*
* @returns The route base name, if route name is not defined, return null
*/
export declare function useRouteBaseName(givenRoute?: Route_2 | RouteLocationNormalizedLoaded, { router, routesNameSeparator }?: I18nCommonRoutingOptionsWithComposable): string | undefined;
/**
* Use swtich locale path
*
* @param options - An options, see about details {@link I18nRoutingOptions}
*
* @returns Returns a {@link SwitchLocalePathFunction}
*/
export declare function useSwitchLocalePath({ router, route, i18n, defaultLocale, defaultLocaleRouteNameSuffix, routesNameSeparator, strategy, trailingSlash }?: I18nCommonRoutingOptionsWithComposable): SwitchLocalePathFunction;
/**
* Vue I18n Routing Version

@@ -352,108 +568,18 @@ *

/**
* Route config for vue-i18n-routing
*/
export declare type VueI18nRoute = Route & RouteLegacy & {
redirect?: string;
export declare type VueI18nExtendOptions = Pick<I18nRoutingOptions, 'baseUrl'> & {
locales?: string[] | LocaleObject[];
localeCodes?: string[];
};
/**
* Options to initialize a VueRouter instance
*
* @remarks
* This options is extended from Vue Router `RouterOptioins`, so you can specify those options.
* An options of Vue I18n Routing Plugin
*/
export declare type VueI18nRoutingOptions<BaseUrl extends BaseUrlResolveHandler = BaseUrlResolveHandler> = {
export declare interface VueI18nRoutingPluginOptions {
/**
* Vue Router version
* Whether to inject some option APIs style methods into Vue instance
*
* @remarks
* You can choice between vue-router v3 and v4.
*
* If you specify `3`, this function return Vue Router v3 instance, else specify `4`, this function return Vue Router v4 instance.
*
* @defaultValue 4
* @defaultValue `true`
*/
version?: 3 | 4;
/**
* The app's default locale
*
* @remarks
* When using `prefix_except_default` strategy, URLs for locale specified here won't have a prefix.
*
* It's recommended to set this to some locale regardless of chosen strategy, as it will be used as a fallback locale when navigating to a non-existent route
*
* @defaultValue '' (emputy string)
*/
defaultLocale?: string;
/**
* List of locales supported by your app
*
* @remarks
* Can either be an array of string codes (e.g. `['en', 'fr']`) or an array of {@link LocaleObject} for more complex configurations
*
* @defaultValue []
*/
locales?: string[] | LocaleObject[];
/**
* Routes strategy
*
* @remarks
* Can be set to one of the following:
*
* - `no_prefix`: routes won't have a locale prefix
* - `prefix_except_default`: locale prefix added for every locale except default
* - `prefix`: locale prefix added for every locale
* - `prefix_and_default`: locale prefix added for every locale and default
*
* @defaultValue 'prefix_except_default'
*/
strategy?: Strategies;
/**
* Whether to use trailing slash
*
* @defaultValue false
*/
trailingSlash?: boolean;
/**
* Internal separator used for generated route names for each locale. You shouldn't need to change this
*
* @defaultValue '___'
*/
routesNameSeparator?: string;
/**
* Internal suffix added to generated route names for default locale
*
* @remarks
* if strategy is prefix_and_default. You shouldn't need to change this.
*
* @defaultValue 'default'
*/
defaultLocaleRouteNameSuffix?: string;
/**
* Default direction direction
*
* @defaultValue 'ltr'
*/
defaultDirection?: Directions;
/**
* The fallback base URL to use as a prefix for alternate URLs in hreflang tags.
*
* @remarks
* By default VueRouter's base URL will be used and only if that is not available, fallback URL will be used.
*
* Can also be a function (will be passed a Nuxt Context as a parameter) that returns a string.
*
* Useful to make base URL dynamic based on request headers.
*
* @defaultValue ''
*/
baseUrl?: string | BaseUrl;
/**
* Route options resolver
*
* @defaultValue undefined
*/
routeOptionsResolver?: RouteOptionsResolver;
} & RouterOptions;
inject?: boolean;
}

@@ -463,35 +589,28 @@ export { }

export interface ComposerCustomProperties {
/**
* List of locales
*
* @remarks
* Can either be an array of string codes (e.g. `['en', 'fr']`) or an array of {@link LocaleObject} for more complex configurations
*/
locales: ComputedRef<string[] | LocaleObject[]>
/**
* List of locale codes
*/
localeCodes: ComputedRef<string[]>
__baseUrl: string
}
declare module 'vue-i18n' {
export interface ComposerCustom {
/**
* List of locales
*
* @defaultValue `undefined`
*/
locales?: ComputedRef<string[] | LocaleObject[]>
/**
* List of locale codes
*
* @defaultValue `undefined`
*/
localeCodes?: ComputedRef<string[]>
__baseUrl?: string
}
// eslint-disable-next-line @typescript-eslint/no-empty-interface
export interface ComposerCustom extends ComposerCustomProperties {}
}
declare module 'vue-i18n-bridge' {
export interface ComposerCustom {
/**
* List of locales
*
* @defaultValue `undefined`
*/
locales?: ComputedRef<string[] | LocaleObject[]>
/**
* List of locale codes
*
* @defaultValue `undefined`
*/
localeCodes?: ComputedRef<string[]>
__baseUrl?: string
}
// eslint-disable-next-line @typescript-eslint/no-empty-interface
export interface ComposerCustom extends ComposerCustomProperties {}
}
declare module '@intlify/vue-i18n-bridge' {
// eslint-disable-next-line @typescript-eslint/no-empty-interface
export interface ComposerCustom extends ComposerCustomProperties {}
}

@@ -32,7 +32,7 @@ var __defProp = Object.defineProperty;

};
import { isRef, unref, isVue3, ref, watchEffect, onUnmounted, computed, isVue2 } from "vue-demi";
import VueRouter3, { isVueRouter4, useRoute, useRouter, createRouter as createRouter$1 } from "@intlify/vue-router-bridge";
import { isRef, isVue2, isVue3, ref, computed, unref, watchEffect, onUnmounted } from "vue-demi";
import VueRouter3, { isVueRouter4, createRouter as createRouter$1, useRoute, useRouter } from "@intlify/vue-router-bridge";
import { useI18n } from "@intlify/vue-i18n-bridge";
/*!
* shared v9.2.0-beta.30
* shared v9.2.0-beta.34
* (c) 2022 kazuya kawaguchi

@@ -96,20 +96,40 @@ * Released under the MIT License.

}
function isComposer(target, mode) {
return isRef(target.locale) && mode === "composition";
}
function isI18nInstance(i18n) {
return "global" in i18n && "mode" in i18n;
return i18n != null && "global" in i18n && "mode" in i18n;
}
function isComposer(target) {
return target != null && !("__composer" in target) && isRef(target.locale);
}
function isVueI18n(target) {
return target != null && "__composer" in target;
}
function isExportedGlobalComposer(target) {
return target != null && !("__composer" in target) && !isRef(target.locale);
}
function isLegacyVueI18n(target) {
return target != null && ("__VUE_I18N_BRIDGE__" in target || "_sync" in target);
}
function getComposer(i18n) {
return isI18nInstance(i18n) ? isComposer(i18n.global) ? i18n.global : i18n.global.__composer : isVueI18n(i18n) ? i18n.__composer : i18n;
}
function getLocale(i18n) {
return isI18nInstance(i18n) ? isComposer(i18n.global, i18n.mode) ? i18n.global.locale.value : i18n.global.locale : i18n.locale.value;
const target = isI18nInstance(i18n) ? i18n.global : i18n;
return isComposer(target) ? isVue2 && isLegacyVueI18n(i18n) ? i18n.locale : target.locale.value : isExportedGlobalComposer(target) || isVueI18n(target) || isLegacyVueI18n(target) ? target.locale : target.locale;
}
function getLocales(i18n) {
const target = isI18nInstance(i18n) ? i18n.global : i18n;
return isComposer(target) ? isVue2 && isLegacyVueI18n(i18n) ? i18n.locales : target.locales.value : isExportedGlobalComposer(target) || isVueI18n(target) || isLegacyVueI18n(target) ? target.locales : target.locales;
}
function setLocale(i18n, locale) {
if (isI18nInstance(i18n)) {
if (isComposer(i18n.global, i18n.mode)) {
i18n.global.locale.value = locale;
const target = isI18nInstance(i18n) ? i18n.global : i18n;
if (isComposer(target)) {
if (isVue2 && isLegacyVueI18n(i18n)) {
i18n.locale = locale;
} else {
i18n.global.locale = locale;
target.locale.value = locale;
}
} else if (isRef(i18n.locale)) {
i18n.locale.value = locale;
} else if (isExportedGlobalComposer(target) || isVueI18n(target) || isLegacyVueI18n(target)) {
target.locale = locale;
} else {
throw new Error("TODO:");
}

@@ -197,38 +217,330 @@ }

const DEFAULT_BASE_URL = "";
const RESOLVED_PREFIXED = /* @__PURE__ */ new Set([STRATEGIES.PREFIX_AND_DEFAULT, STRATEGIES.PREFIX_EXCEPT_DEFAULT]);
function getRouteBaseName(givenRoute = useRoute(), { router = useRouter(), routesNameSeparator = DEFAULT_ROUTES_NAME_SEPARATOR } = {}) {
const _routesNameSeparator = routesNameSeparator || router.__routesNameSeparator;
const _route = unref(givenRoute);
if (!_route.name) {
function proxyVueInstance(target) {
return function() {
return Reflect.apply(target, {
getRouteBaseName: this.getRouteBaseName,
localePath: this.localePath,
localeRoute: this.localeRoute,
localeLocation: this.localeLocation,
resolveRoute: this.resolveRoute,
switchLocalePath: this.switchLocalePath,
localeHead: this.localeHead,
i18n: this.$i18n,
route: this.$route,
router: this.$router
}, arguments);
};
}
function extendI18n(i18n, { locales = [], localeCodes = [], baseUrl = DEFAULT_BASE_URL } = {}) {
const orgInstall = i18n.install;
i18n.install = (vue, ...options) => {
Reflect.apply(orgInstall, i18n, [vue, ...options]);
const composer = getComposer(i18n);
extendComposer(composer, { locales, localeCodes, baseUrl });
if (isVueI18n(i18n.global)) {
extendVueI18n(i18n.global);
}
const app = vue;
const exported = i18n.mode === "composition" ? isVue3 ? app.config.globalProperties.$i18n : i18n : isVue2 ? i18n : null;
if (exported) {
extendExportedGlobal(exported, composer);
}
const pluginOptions = isPluginOptions(options[0]) ? options[0] : { inject: true };
if (pluginOptions.inject) {
vue.mixin({
methods: {
resolveRoute: proxyVueInstance(resolveRoute),
localePath: proxyVueInstance(localePath),
localeRoute: proxyVueInstance(localeRoute),
localeLocation: proxyVueInstance(localeLocation),
switchLocalePath: proxyVueInstance(switchLocalePath),
getRouteBaseName: proxyVueInstance(getRouteBaseName),
localeHead: proxyVueInstance(localeHead)
}
});
}
};
}
function extendComposer(composer, options) {
const { locales, localeCodes, baseUrl } = options;
const _locales = ref(locales);
const _localeCodes = ref(localeCodes);
composer.locales = computed(() => _locales.value);
composer.localeCodes = computed(() => _localeCodes.value);
composer.__baseUrl = resolveBaseUrl(baseUrl, {});
}
function extendExportedGlobal(exported, global) {
Object.defineProperty(exported, "locales", {
get() {
return global.locales.value;
}
});
Object.defineProperty(exported, "localeCodes", {
get() {
return global.localeCodes.value;
}
});
Object.defineProperty(exported, "__baseUrl", {
get() {
return global.__baseUrl;
}
});
}
function extendVueI18n(vueI18n) {
const composer = getComposer(vueI18n);
Object.defineProperty(vueI18n, "locales", {
get() {
return composer.locales.value;
}
});
Object.defineProperty(vueI18n, "localeCodes", {
get() {
return composer.localeCodes.value;
}
});
Object.defineProperty(vueI18n, "__baseUrl", {
get() {
return composer.__baseUrl;
}
});
}
function isPluginOptions(options) {
return isObject(options) && "inject" in options && isBoolean(options.inject);
}
function localizeRoutes(routes, {
defaultLocale = DEFAULT_LOCALE,
strategy = DEFAULT_STRATEGY,
trailingSlash = DEFAULT_TRAILING_SLASH,
routesNameSeparator = DEFAULT_ROUTES_NAME_SEPARATOR,
defaultLocaleRouteNameSuffix = DEFAULT_LOCALE_ROUTE_NAME_SUFFIX,
includeUprefixedFallback = false,
optionsResolver = void 0,
locales = []
} = {}) {
if (strategy === "no_prefix") {
return routes;
}
const _localeCodes = locales.map((locale) => isString(locale) ? locale : locale.code);
function makeLocalizedRoutes(route, allowedLocaleCodes, isChild = false, isExtraPageTree = false) {
if (route.redirect && (!route.component || !route.file)) {
return [route];
}
let routeOptions = null;
if (optionsResolver != null) {
routeOptions = optionsResolver(route, allowedLocaleCodes);
if (routeOptions == null) {
return [route];
}
}
const targetLocales = allowedLocaleCodes;
return targetLocales.reduce((_routes, locale) => {
const { name } = route;
let { path } = route;
const localizedRoute = __spreadValues({}, route);
if (name) {
localizedRoute.name = `${name}${routesNameSeparator}${locale}`;
}
if (route.children) {
localizedRoute.children = route.children.reduce((children, child) => [...children, ...makeLocalizedRoutes(child, [locale], true, isExtraPageTree)], []);
}
const isDefaultLocale = locale === defaultLocale;
if (isDefaultLocale && strategy === "prefix_and_default") {
if (!isChild) {
const defaultRoute = __spreadProps(__spreadValues({}, localizedRoute), { path });
if (name) {
defaultRoute.name = `${localizedRoute.name}${routesNameSeparator}${defaultLocaleRouteNameSuffix}`;
}
if (route.children) {
defaultRoute.children = [];
for (const childRoute of route.children) {
defaultRoute.children = defaultRoute.children.concat(makeLocalizedRoutes(childRoute, [locale], true, true));
}
}
_routes.push(defaultRoute);
} else if (isChild && isExtraPageTree && name) {
localizedRoute.name += `${routesNameSeparator}${defaultLocaleRouteNameSuffix}`;
}
}
const isChildWithRelativePath = isChild && !path.startsWith("/");
const shouldAddPrefix = !isChildWithRelativePath && !(isDefaultLocale && strategy === "prefix_except_default");
if (shouldAddPrefix) {
path = `/${locale}${path}`;
}
if (path) {
path = adjustRoutePathForTrailingSlash(path, trailingSlash, isChildWithRelativePath);
}
if (shouldAddPrefix && isDefaultLocale && strategy === "prefix" && includeUprefixedFallback) {
_routes.push(__spreadValues({}, route));
}
localizedRoute.path = path;
_routes.push(localizedRoute);
return _routes;
}, []);
}
return routes.reduce((localized, route) => [...localized, ...makeLocalizedRoutes(route, _localeCodes || [])], []);
}
const optionsMap = /* @__PURE__ */ new Map();
function registerGlobalOptions(router, options) {
if (!optionsMap.has(router)) {
optionsMap.set(router, options);
return () => optionsMap.delete(router);
} else {
return null;
}
const name = getRouteName(_route.name);
return name.split(_routesNameSeparator)[0];
}
function localePath(route, locale, options) {
const localizedRoute = resolveRoute(route, locale, options);
return localizedRoute == null ? "" : isVue3 ? localizedRoute.redirectedFrom || localizedRoute.fullPath : localizedRoute.route.redirectedFrom || localizedRoute.route.fullPath;
function getGlobalOptions(router) {
var _a;
return (_a = optionsMap.get(router)) != null ? _a : {};
}
function localeRoute(route, locale, options) {
const resolved = resolveRoute(route, locale, options);
return resolved == null ? void 0 : isVue3 ? resolved : resolved.route;
function createRouter(i18n, options = {}) {
const {
version,
defaultLocale,
locales,
strategy,
trailingSlash,
routesNameSeparator,
defaultLocaleRouteNameSuffix,
defaultDirection,
baseUrl,
routes,
routeOptionsResolver: optionsResolver
} = asDefaultVueI18nRouterOptions(options);
const normalizedLocaleCodes = getNormalizedLocales(locales);
const localeCodes = normalizedLocaleCodes.map((l) => l.code);
const getLocaleFromRoute = createLocaleFromRouteGetter(localeCodes, routesNameSeparator, defaultLocaleRouteNameSuffix);
extendI18n(i18n, { locales: normalizedLocaleCodes, baseUrl, localeCodes });
const localizedRoutes = localizeRoutes(routes, {
locales,
defaultLocale,
strategy,
trailingSlash,
routesNameSeparator,
defaultLocaleRouteNameSuffix,
optionsResolver
});
options.routes = localizedRoutes;
const router = createVueRouter(options, version);
registerGlobalOptions(router, {
defaultLocale,
localeCodes,
strategy,
trailingSlash,
routesNameSeparator,
defaultLocaleRouteNameSuffix,
defaultDirection
});
router.beforeEach((to, from, next) => {
const currentLocale = getLocale(i18n);
const finalLocale = getLocaleFromRoute(to) || currentLocale || defaultLocale || "";
if (currentLocale !== finalLocale) {
setLocale(i18n, finalLocale);
}
next();
});
return router;
}
function localeLocation(route, locale, options) {
const resolved = resolveRoute(route, locale, options);
return resolved == null ? void 0 : isVue3 ? resolved : resolved.location;
function createVueRouter(options, version) {
if (isVue3 && version === 4) {
return createRouter$1(options);
} else if (isVue2 && version === 3) {
return new VueRouter3(options);
} else {
throw new Error("TODO:");
}
}
function resolveRoute(route, locale, {
router = useRouter(),
i18n = useI18n(),
function getLocalesRegex(localeCodes) {
return new RegExp(`^/(${localeCodes.join("|")})(?:/|$)`, "i");
}
function createLocaleFromRouteGetter(localeCodes, routesNameSeparator, defaultLocaleRouteNameSuffix) {
const localesPattern = `(${localeCodes.join("|")})`;
const defaultSuffixPattern = `(?:${routesNameSeparator}${defaultLocaleRouteNameSuffix})?`;
const regexpName = new RegExp(`${routesNameSeparator}${localesPattern}${defaultSuffixPattern}$`, "i");
const regexpPath = getLocalesRegex(localeCodes);
const getLocaleFromRoute = (route) => {
if (isObject(route)) {
if (route.name) {
const name = isString(route.name) ? route.name : route.name.toString();
const matches = name.match(regexpName);
if (matches && matches.length > 1) {
return matches[1];
}
} else if (route.path) {
const matches = route.path.match(regexpPath);
if (matches && matches.length > 1) {
return matches[1];
}
}
} else if (isString(route)) {
const matches = route.match(regexpPath);
if (matches && matches.length > 1) {
return matches[1];
}
}
return "";
};
return getLocaleFromRoute;
}
function asDefaultVueI18nRouterOptions(options) {
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
options.version = (_a = options.version) != null ? _a : 4;
options.defaultLocale = (_b = options.defaultLocale) != null ? _b : DEFAULT_LOCALE;
options.strategy = (_c = options.strategy) != null ? _c : DEFAULT_STRATEGY;
options.trailingSlash = (_d = options.trailingSlash) != null ? _d : DEFAULT_TRAILING_SLASH;
options.routesNameSeparator = (_e = options.routesNameSeparator) != null ? _e : DEFAULT_ROUTES_NAME_SEPARATOR;
options.defaultLocaleRouteNameSuffix = (_f = options.defaultLocaleRouteNameSuffix) != null ? _f : DEFAULT_LOCALE_ROUTE_NAME_SUFFIX;
options.locales = (_g = options.locales) != null ? _g : [];
options.defaultDirection = (_h = options.defaultDirection) != null ? _h : DEFAULT_DETECTION_DIRECTION;
options.baseUrl = (_i = options.baseUrl) != null ? _i : DEFAULT_BASE_URL;
options.routes = (_j = options.routes) != null ? _j : [];
return options;
}
function getI18nRoutingOptions(router, proxy, {
defaultLocale = DEFAULT_LOCALE,
defaultDirection = DEFAULT_DETECTION_DIRECTION,
defaultLocaleRouteNameSuffix = DEFAULT_LOCALE_ROUTE_NAME_SUFFIX,
routesNameSeparator = DEFAULT_ROUTES_NAME_SEPARATOR,
strategy = DEFAULT_STRATEGY,
trailingSlash = false
trailingSlash = DEFAULT_TRAILING_SLASH,
localeCodes = []
} = {}) {
const _defaultLocaleRouteNameSuffix = router.__defaultLocaleRouteNameSuffix || defaultLocaleRouteNameSuffix;
const _defaultLocale = router.__defaultLocale || defaultLocale;
const _routesNameSeparator = router.__routesNameSeparator || routesNameSeparator;
const _strategy = router.__strategy || strategy;
const options = getGlobalOptions(router);
return {
defaultLocale: proxy.defaultLocale || options.defaultLocale || defaultLocale,
defaultDirection: proxy.defaultDirection || options.defaultDirection || defaultDirection,
defaultLocaleRouteNameSuffix: proxy.defaultLocaleRouteNameSuffix || options.defaultLocaleRouteNameSuffix || defaultLocaleRouteNameSuffix,
routesNameSeparator: proxy.routesNameSeparator || options.routesNameSeparator || routesNameSeparator,
strategy: proxy.strategy || options.strategy || strategy,
trailingSlash: proxy.trailingSlash || options.trailingSlash || trailingSlash,
localeCodes: proxy.localeCodes || options.localeCodes || localeCodes
};
}
const RESOLVED_PREFIXED = /* @__PURE__ */ new Set([STRATEGIES.PREFIX_AND_DEFAULT, STRATEGIES.PREFIX_EXCEPT_DEFAULT]);
function getRouteBaseName(givenRoute) {
const router = this.router;
const { routesNameSeparator } = getI18nRoutingOptions(router, this);
const route = givenRoute != null ? isRef(givenRoute) ? unref(givenRoute) : givenRoute : this.route;
if (!route.name) {
return;
}
const name = getRouteName(route.name);
return name.split(routesNameSeparator)[0];
}
function localePath(route, locale) {
const localizedRoute = resolveRoute.call(this, route, locale);
return localizedRoute == null ? "" : isVue3 ? localizedRoute.redirectedFrom || localizedRoute.fullPath : localizedRoute.route.redirectedFrom || localizedRoute.route.fullPath;
}
function localeRoute(route, locale) {
const resolved = resolveRoute.call(this, route, locale);
return resolved == null ? void 0 : isVue3 ? resolved : resolved.route;
}
function localeLocation(route, locale) {
const resolved = resolveRoute.call(this, route, locale);
return resolved == null ? void 0 : isVue3 ? resolved : resolved.location;
}
function resolveRoute(route, locale) {
const router = this.router;
const i18n = this.i18n;
const _locale = locale || getLocale(i18n);
const { routesNameSeparator, defaultLocale, defaultLocaleRouteNameSuffix, strategy, trailingSlash } = getI18nRoutingOptions(router, this);
let _route = route;

@@ -246,10 +558,10 @@ if (isString(route)) {

const resolvedRoute2 = isVue3 ? _resolvedRoute : _resolvedRoute.route;
const resolvedRouteName = getRouteBaseName(resolvedRoute2);
const resolvedRouteName = getRouteBaseName.call(this, resolvedRoute2);
if (isString(resolvedRouteName)) {
localizedRoute = {
name: getLocaleRouteName(resolvedRouteName, _locale, {
defaultLocale: _defaultLocale,
strategy: _strategy,
routesNameSeparator: _routesNameSeparator,
defaultLocaleRouteNameSuffix: _defaultLocaleRouteNameSuffix
defaultLocale,
strategy,
routesNameSeparator,
defaultLocaleRouteNameSuffix
}),

@@ -262,3 +574,3 @@ params: resolvedRoute2.params,

const isDefaultLocale = _locale === defaultLocale;
const isPrefixed = !(isDefaultLocale && RESOLVED_PREFIXED.has(_strategy)) && !(_strategy === STRATEGIES.NO_PREFIX);
const isPrefixed = !(isDefaultLocale && RESOLVED_PREFIXED.has(strategy)) && !(strategy === STRATEGIES.NO_PREFIX);
if (isPrefixed) {

@@ -271,6 +583,6 @@ localizedRoute.path = `/${_locale}${localizedRoute.path}`;

localizedRoute.name = getLocaleRouteName(localizedRoute.name, _locale, {
defaultLocale: _defaultLocale,
strategy: _strategy,
routesNameSeparator: _routesNameSeparator,
defaultLocaleRouteNameSuffix: _defaultLocaleRouteNameSuffix
defaultLocale,
strategy,
routesNameSeparator,
defaultLocaleRouteNameSuffix
});

@@ -288,5 +600,5 @@ const { params } = localizedRoute;

}
function switchLocalePath(locale, options) {
const route = options && options.route || useRoute();
const name = getRouteBaseName(route, options);
function switchLocalePath(locale) {
const route = this.route;
const name = getRouteBaseName.call(this, route);
if (!name) {

@@ -303,81 +615,42 @@ return "";

});
const path = localePath(baseRoute, locale, options);
const path = localePath.call(this, baseRoute, locale);
return path;
}
function useI18nHead({
addDirAttribute = false,
addSeoAttributes = false,
strategy = DEFAULT_STRATEGY,
defaultLocale = DEFAULT_LOCALE,
route = useRoute(),
router = useRouter(),
i18n = useI18n()
} = {}) {
const _router = router;
const _defaultLocale = defaultLocale || _router.__defaultLocale;
const _strategy = strategy || _router.__strategy;
const metaObject = ref({
function localeHead({ addDirAttribute = false, addSeoAttributes = false } = {}) {
const router = this.router;
const i18n = this.i18n;
const { defaultDirection } = getI18nRoutingOptions(router, this);
const metaObject = {
htmlAttrs: {},
link: [],
meta: []
});
function cleanMeta() {
metaObject.value = {
htmlAttrs: {},
link: [],
meta: []
};
};
if (i18n.locales == null || i18n.__baseUrl == null) {
return metaObject;
}
function updateMeta(_route) {
if (i18n.locales == null || i18n.__baseUrl == null) {
return;
}
const locale = getLocale(i18n);
const currentLocale = getNormalizedLocales(i18n.locales.value).find((l) => l.code === locale) || {
code: locale
};
const currentLocaleIso = currentLocale.iso;
const currentLocaleDir = currentLocale.dir || router.__defaultDirection;
if (addDirAttribute) {
metaObject.value.htmlAttrs.dir = currentLocaleDir;
}
if (addSeoAttributes && locale && i18n.locales) {
if (currentLocaleIso) {
metaObject.value.htmlAttrs.lang = currentLocaleIso;
}
const locales = i18n.locales.value;
addHreflangLinks(locales, i18n.__baseUrl, metaObject.value.link, {
defaultLocale: _defaultLocale,
strategy: _strategy,
route,
router,
i18n
});
addCanonicalLinks(i18n.__baseUrl, metaObject.value.link, addSeoAttributes, { route: _route, router, i18n });
addCurrentOgLocale(currentLocale, currentLocaleIso, metaObject.value.meta);
addAlternateOgLocales(locales, currentLocaleIso, metaObject.value.meta);
}
const locale = getLocale(i18n);
const locales = getLocales(i18n);
const currentLocale = getNormalizedLocales(locales).find((l) => l.code === locale) || {
code: locale
};
const currentLocaleIso = currentLocale.iso;
const currentLocaleDir = currentLocale.dir || defaultDirection;
if (addDirAttribute) {
metaObject.htmlAttrs.dir = currentLocaleDir;
}
if (inBrowser) {
if (isVue3) {
const stop = watchEffect(() => {
cleanMeta();
updateMeta(toRawRoute(_router.currentRoute));
});
onUnmounted(() => stop());
} else {
const handler = _router.afterEach((to, from) => {
cleanMeta();
updateMeta(to);
});
onUnmounted(() => handler());
updateMeta(route);
if (addSeoAttributes && locale && i18n.locales) {
if (currentLocaleIso) {
metaObject.htmlAttrs.lang = currentLocaleIso;
}
} else {
updateMeta(toRawRoute(_router.currentRoute));
addHreflangLinks.call(this, locales, i18n.__baseUrl, metaObject.link);
addCanonicalLinks.call(this, i18n.__baseUrl, metaObject.link, addSeoAttributes);
addCurrentOgLocale(currentLocale, currentLocaleIso, metaObject.meta);
addAlternateOgLocales(locales, currentLocaleIso, metaObject.meta);
}
return metaObject;
}
function addHreflangLinks(locales, baseUrl, link, options) {
if (options.strategy === STRATEGIES.NO_PREFIX) {
function addHreflangLinks(locales, baseUrl, link) {
const router = this.router;
const { defaultLocale, strategy } = getI18nRoutingOptions(router, this);
if (strategy === STRATEGIES.NO_PREFIX) {
return;

@@ -399,3 +672,3 @@ }

for (const [iso, mapLocale] of localeMap.entries()) {
const localePath2 = switchLocalePath(mapLocale.code, options);
const localePath2 = switchLocalePath.call(this, mapLocale.code);
if (localePath2) {

@@ -410,4 +683,4 @@ link.push({

}
if (options.defaultLocale) {
const localePath2 = switchLocalePath(options.defaultLocale, options);
if (defaultLocale) {
const localePath2 = switchLocalePath.call(this, defaultLocale);
if (localePath2) {

@@ -423,10 +696,10 @@ link.push({

}
function addCanonicalLinks(baseUrl, link, seoAttributesOptions, options) {
const { route } = options;
const currentRoute = localeRoute(__spreadProps(__spreadValues({}, route), {
name: getRouteBaseName(route, options)
}), void 0, options);
function addCanonicalLinks(baseUrl, link, seoAttributesOptions) {
const route = this.route;
const currentRoute = localeRoute.call(this, __spreadProps(__spreadValues({}, route), {
name: getRouteBaseName.call(this, route)
}));
if (currentRoute) {
let href = toAbsoluteUrl(currentRoute.path, baseUrl);
const canonicalQueries = !isBoolean(seoAttributesOptions) && seoAttributesOptions.canonicalQueries || [];
const canonicalQueries = isObject(seoAttributesOptions) && seoAttributesOptions.canonicalQueries || [];
if (canonicalQueries.length) {

@@ -491,186 +764,161 @@ const currentRouteQueryParams = currentRoute.query;

}
function localizeRoutes(routes, {
defaultLocale = DEFAULT_LOCALE,
strategy = DEFAULT_STRATEGY,
trailingSlash = DEFAULT_TRAILING_SLASH,
routesNameSeparator = DEFAULT_ROUTES_NAME_SEPARATOR,
defaultLocaleRouteNameSuffix = DEFAULT_LOCALE_ROUTE_NAME_SUFFIX,
includeUprefixedFallback = false,
optionsResolver = void 0,
locales = []
} = {}) {
if (strategy === "no_prefix") {
return routes;
}
const _localeCodes = locales.map((locale) => isString(locale) ? locale : locale.code);
function makeLocalizedRoutes(route, allowedLocaleCodes, isChild = false, isExtraPageTree = false) {
if (route.redirect && (!route.component || !route.file)) {
return [route];
}
let routeOptions = null;
if (optionsResolver != null) {
routeOptions = optionsResolver(route, allowedLocaleCodes);
if (routeOptions == null) {
return [route];
}
}
const targetLocales = allowedLocaleCodes;
return targetLocales.reduce((_routes, locale) => {
const { name } = route;
let { path } = route;
const localizedRoute = __spreadValues({}, route);
if (name) {
localizedRoute.name = `${name}${routesNameSeparator}${locale}`;
}
if (route.children) {
localizedRoute.children = route.children.reduce((children, child) => [...children, ...makeLocalizedRoutes(child, [locale], true, isExtraPageTree)], []);
}
const isDefaultLocale = locale === defaultLocale;
if (isDefaultLocale && strategy === "prefix_and_default") {
if (!isChild) {
const defaultRoute = __spreadProps(__spreadValues({}, localizedRoute), { path });
if (name) {
defaultRoute.name = `${localizedRoute.name}${routesNameSeparator}${defaultLocaleRouteNameSuffix}`;
}
if (route.children) {
defaultRoute.children = [];
for (const childRoute of route.children) {
defaultRoute.children = defaultRoute.children.concat(makeLocalizedRoutes(childRoute, [locale], true, true));
}
}
_routes.push(defaultRoute);
} else if (isChild && isExtraPageTree && name) {
localizedRoute.name += `${routesNameSeparator}${defaultLocaleRouteNameSuffix}`;
}
}
const isChildWithRelativePath = isChild && !path.startsWith("/");
const shouldAddPrefix = !isChildWithRelativePath && !(isDefaultLocale && strategy === "prefix_except_default");
if (shouldAddPrefix) {
path = `/${locale}${path}`;
}
if (path) {
path = adjustRoutePathForTrailingSlash(path, trailingSlash, isChildWithRelativePath);
}
if (shouldAddPrefix && isDefaultLocale && strategy === "prefix" && includeUprefixedFallback) {
_routes.push(__spreadValues({}, route));
}
localizedRoute.path = path;
_routes.push(localizedRoute);
return _routes;
}, []);
}
return routes.reduce((localized, route) => [...localized, ...makeLocalizedRoutes(route, _localeCodes || [])], []);
}
function extendI18n(i18n, { locales = [], localeCodes = [], baseUrl = DEFAULT_BASE_URL } = {}) {
if (!isComposer(i18n.global, i18n.mode)) {
throw new Error("TODO:");
}
const _locales = ref(locales);
const _localeCodes = ref(localeCodes);
i18n.global.locales = computed(() => _locales.value);
i18n.global.localeCodes = computed(() => _localeCodes.value);
i18n.global.__baseUrl = resolveBaseUrl(baseUrl, {});
}
function createRouter(i18n, options = {}) {
function proxyForComposable(options, target) {
const {
version,
router,
route,
i18n,
defaultLocale,
locales,
strategy,
defaultLocaleRouteNameSuffix,
trailingSlash,
routesNameSeparator
} = options;
return function(...args) {
return Reflect.apply(target, {
router,
route,
i18n,
defaultLocale,
strategy,
defaultLocaleRouteNameSuffix,
trailingSlash,
routesNameSeparator
}, args);
};
}
function useRouteBaseName(givenRoute = useRoute(), { router = useRouter(), routesNameSeparator = void 0 } = {}) {
const proxy = {
router,
route: givenRoute,
routesNameSeparator
};
return getRouteBaseName.call(proxy, givenRoute);
}
function useLocalePath({
router = useRouter(),
route = useRoute(),
i18n = useI18n(),
defaultLocale = void 0,
defaultLocaleRouteNameSuffix = void 0,
routesNameSeparator = void 0,
strategy = void 0,
trailingSlash = void 0
} = {}) {
return proxyForComposable({ router, route, i18n, defaultLocale, defaultLocaleRouteNameSuffix, routesNameSeparator, strategy, trailingSlash }, localePath);
}
function useLocaleRoute({
router = useRouter(),
route = useRoute(),
i18n = useI18n(),
defaultLocale = void 0,
defaultLocaleRouteNameSuffix = void 0,
routesNameSeparator = void 0,
strategy = void 0,
trailingSlash = void 0
} = {}) {
return proxyForComposable({
router,
route,
i18n,
defaultLocale,
defaultLocaleRouteNameSuffix,
routesNameSeparator,
strategy,
trailingSlash
}, localeRoute);
}
function useLocaleLocation({
router = useRouter(),
route = useRoute(),
i18n = useI18n(),
defaultLocale = void 0,
defaultLocaleRouteNameSuffix = void 0,
routesNameSeparator = void 0,
strategy = void 0,
trailingSlash = void 0
} = {}) {
return proxyForComposable({
router,
route,
i18n,
defaultLocale,
defaultLocaleRouteNameSuffix,
defaultDirection,
baseUrl,
routes,
routeOptionsResolver: optionsResolver
} = asDefaultVueI18nRouterOptions(options);
const normalizedLocaleCodes = getNormalizedLocales(locales);
const localeCodes = normalizedLocaleCodes.map((l) => l.code);
const getLocaleFromRoute = createLocaleFromRouteGetter(localeCodes, routesNameSeparator, defaultLocaleRouteNameSuffix);
extendI18n(i18n, { locales: normalizedLocaleCodes, baseUrl, localeCodes });
const localizedRoutes = localizeRoutes(routes, {
locales,
routesNameSeparator,
strategy,
trailingSlash
}, localeLocation);
}
function useSwitchLocalePath({
router = useRouter(),
route = useRoute(),
i18n = useI18n(),
defaultLocale = void 0,
defaultLocaleRouteNameSuffix = void 0,
routesNameSeparator = void 0,
strategy = void 0,
trailingSlash = void 0
} = {}) {
return proxyForComposable({
router,
route,
i18n,
defaultLocale,
defaultLocaleRouteNameSuffix,
routesNameSeparator,
strategy,
trailingSlash,
routesNameSeparator,
defaultLocaleRouteNameSuffix,
optionsResolver
trailingSlash
}, switchLocalePath);
}
function useLocaleHead({
addDirAttribute = false,
addSeoAttributes = false,
strategy = void 0,
defaultLocale = void 0,
route = useRoute(),
router = useRouter(),
i18n = useI18n()
} = {}) {
const _router = router;
const metaObject = ref({
htmlAttrs: {},
link: [],
meta: []
});
options.routes = localizedRoutes;
const router = createVueRouter(options, version);
router.__defaultLocale = defaultLocale;
router.__localeCodes = localeCodes;
router.__strategy = strategy;
router.__trailingSlash = trailingSlash;
router.__routesNameSeparator = routesNameSeparator;
router.__defaultLocaleRouteNameSuffix = defaultLocaleRouteNameSuffix;
router.__defaultDirection = defaultDirection;
router.beforeEach((to, from, next) => {
const currentLocale = getLocale(i18n);
const finalLocale = getLocaleFromRoute(to) || currentLocale || defaultLocale || "";
if (currentLocale !== finalLocale) {
setLocale(i18n, finalLocale);
function cleanMeta() {
metaObject.value = {
htmlAttrs: {},
link: [],
meta: []
};
}
function updateMeta(_route) {
metaObject.value = Reflect.apply(localeHead, {
router,
route: _route,
i18n,
defaultLocale,
strategy
}, [{ addDirAttribute, addSeoAttributes }]);
}
if (inBrowser) {
if (isVue3) {
const stop = watchEffect(() => {
cleanMeta();
updateMeta(toRawRoute(_router.currentRoute));
});
onUnmounted(() => stop());
} else {
const handler = _router.afterEach((to, from) => {
cleanMeta();
updateMeta(to);
});
onUnmounted(() => handler());
updateMeta(route);
}
next();
});
return router;
}
function createVueRouter(options, version) {
if (isVue3 && version === 4) {
return createRouter$1(options);
} else if (isVue2 && version === 3) {
return new VueRouter3(options);
} else {
throw new Error("TODO:");
updateMeta(toRawRoute(_router.currentRoute));
}
return metaObject;
}
function getLocalesRegex(localeCodes) {
return new RegExp(`^/(${localeCodes.join("|")})(?:/|$)`, "i");
}
function createLocaleFromRouteGetter(localeCodes, routesNameSeparator, defaultLocaleRouteNameSuffix) {
const localesPattern = `(${localeCodes.join("|")})`;
const defaultSuffixPattern = `(?:${routesNameSeparator}${defaultLocaleRouteNameSuffix})?`;
const regexpName = new RegExp(`${routesNameSeparator}${localesPattern}${defaultSuffixPattern}$`, "i");
const regexpPath = getLocalesRegex(localeCodes);
const getLocaleFromRoute = (route) => {
if (isObject(route)) {
if (route.name) {
const name = isString(route.name) ? route.name : route.name.toString();
const matches = name.match(regexpName);
if (matches && matches.length > 1) {
return matches[1];
}
} else if (route.path) {
const matches = route.path.match(regexpPath);
if (matches && matches.length > 1) {
return matches[1];
}
}
} else if (isString(route)) {
const matches = route.match(regexpPath);
if (matches && matches.length > 1) {
return matches[1];
}
}
return "";
};
return getLocaleFromRoute;
}
function asDefaultVueI18nRouterOptions(options) {
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
options.version = (_a = options.version) != null ? _a : 4;
options.defaultLocale = (_b = options.defaultLocale) != null ? _b : DEFAULT_LOCALE;
options.strategy = (_c = options.strategy) != null ? _c : DEFAULT_STRATEGY;
options.trailingSlash = (_d = options.trailingSlash) != null ? _d : DEFAULT_TRAILING_SLASH;
options.routesNameSeparator = (_e = options.routesNameSeparator) != null ? _e : DEFAULT_ROUTES_NAME_SEPARATOR;
options.defaultLocaleRouteNameSuffix = (_f = options.defaultLocaleRouteNameSuffix) != null ? _f : DEFAULT_LOCALE_ROUTE_NAME_SUFFIX;
options.locales = (_g = options.locales) != null ? _g : [];
options.defaultDirection = (_h = options.defaultDirection) != null ? _h : DEFAULT_DETECTION_DIRECTION;
options.baseUrl = (_i = options.baseUrl) != null ? _i : DEFAULT_BASE_URL;
options.routes = (_j = options.routes) != null ? _j : [];
return options;
}
const VERSION = "0.0.0";
export { VERSION, createLocaleFromRouteGetter, createRouter, findBrowserLocale, getLocale, getRouteBaseName, localeLocation, localePath, localeRoute, localizeRoutes, resolveBaseUrl, setLocale, switchLocalePath, useI18nHead };
export { VERSION, createLocaleFromRouteGetter, createRouter, extendI18n, findBrowserLocale, getGlobalOptions, getLocale, getRouteBaseName, localeHead, localeLocation, localePath, localeRoute, localizeRoutes, proxyVueInstance, registerGlobalOptions, resolveBaseUrl, resolveRoute, setLocale, switchLocalePath, useLocaleHead, useLocaleLocation, useLocalePath, useLocaleRoute, useRouteBaseName, useSwitchLocalePath };

@@ -1,5 +0,5 @@

var ke=Object.defineProperty,qe=Object.defineProperties;var Ge=Object.getOwnPropertyDescriptors;var x=Object.getOwnPropertySymbols;var ue=Object.prototype.hasOwnProperty,fe=Object.prototype.propertyIsEnumerable;var se=(s,r,L)=>r in s?ke(s,r,{enumerable:!0,configurable:!0,writable:!0,value:L}):s[r]=L,N=(s,r)=>{for(var L in r||(r={}))ue.call(r,L)&&se(s,L,r[L]);if(x)for(var L of x(r))fe.call(r,L)&&se(s,L,r[L]);return s},X=(s,r)=>qe(s,Ge(r));var ie=(s,r)=>{var L={};for(var p in s)ue.call(s,p)&&r.indexOf(p)<0&&(L[p]=s[p]);if(s!=null&&x)for(var p of x(s))r.indexOf(p)<0&&fe.call(s,p)&&(L[p]=s[p]);return L};var VueI18nRouting=function(s,r,L,p){"use strict";function de(e){return e&&typeof e=="object"&&"default"in e?e:{default:e}}var he=de(L);/*!
* shared v9.2.0-beta.30
var ft=Object.defineProperty,dt=Object.defineProperties;var ht=Object.getOwnPropertyDescriptors;var x=Object.getOwnPropertySymbols;var Oe=Object.prototype.hasOwnProperty,Ae=Object.prototype.propertyIsEnumerable;var Ie=(f,d,L)=>d in f?ft(f,d,{enumerable:!0,configurable:!0,writable:!0,value:L}):f[d]=L,C=(f,d)=>{for(var L in d||(d={}))Oe.call(d,L)&&Ie(f,L,d[L]);if(x)for(var L of x(d))Ae.call(d,L)&&Ie(f,L,d[L]);return f},H=(f,d)=>dt(f,ht(d));var we=(f,d)=>{var L={};for(var R in f)Oe.call(f,R)&&d.indexOf(R)<0&&(L[R]=f[R]);if(f!=null&&x)for(var R of x(f))d.indexOf(R)<0&&Ae.call(f,R)&&(L[R]=f[R]);return L};var VueI18nRouting=function(f,d,L,R){"use strict";function Ce(e){return e&&typeof e=="object"&&"default"in e?e:{default:e}}var be=Ce(L);/*!
* shared v9.2.0-beta.34
* (c) 2022 kazuya kawaguchi
* Released under the MIT License.
*/const q=Object.assign,_e=Array.isArray,Le=e=>typeof e=="function",P=e=>typeof e=="string",ge=e=>typeof e=="boolean",me=e=>typeof e=="symbol",Re=e=>e!==null&&typeof e=="object",Ee=/\/$|\/\?/;function V(e="",t=!1){return t?Ee.test(e):e.endsWith("/")}function Se(e="",t=!1){if(!t)return(V(e)?e.slice(0,-1):e)||"/";if(!V(e,!0))return e||"/";const[a,...o]=e.split("?");return(a.slice(0,-1)||"/")+(o.length?`?${o.join("?")}`:"")}function pe(e="",t=!1){if(!t)return e.endsWith("/")?e:e+"/";if(V(e,!0))return e||"/";const[a,...o]=e.split("?");return a+"/"+(o.length?`?${o.join("?")}`:"")}const Ae=typeof window!="undefined";function Ie(e,t){typeof console!="undefined"&&(console.warn("[vue-i18n-routing] "+e),t&&console.warn(t.stack))}function G(e){e=e||[];const t=[];for(const a of e)P(a)?t.push({code:a}):t.push(a);return t}function B(e,t){return r.isRef(e.locale)&&t==="composition"}function H(e){return"global"in e&&"mode"in e}function U(e){return H(e)?B(e.global,e.mode)?e.global.locale.value:e.global.locale:e.locale.value}function W(e,t){H(e)?B(e.global,e.mode)?e.global.locale.value=t:e.global.locale=t:r.isRef(e.locale)&&(e.locale.value=t)}function Te(e,t,a){return e.replace(/\/+$/,"")+(t?"/":"")||(a?"":"/")}function Q(e){return L.isVueRouter4,r.isRef(e)?e.value:e}function Y(e){return P(e)?e:me(e)?e.toString():"(null)"}function J(e,t,{defaultLocale:a,strategy:o,routesNameSeparator:l,defaultLocaleRouteNameSuffix:n}){let c=Y(e)+(o==="no_prefix"?"":l+t);return t===a&&o==="prefix_and_default"&&(c+=l+n),c}function K(e,t){return Le(e)?e(t):e}function Fe(e,t){const a=[];for(const[o,l]of t.entries()){const n=e.find(c=>c.iso.toLowerCase()===l.toLowerCase());if(n){a.push({code:n.code,score:1-o/t.length});break}}for(const[o,l]of t.entries()){const n=l.split("-")[0].toLowerCase(),c=e.find(u=>u.iso.split("-")[0].toLowerCase()===n);if(c){a.push({code:c.code,score:.999-o/t.length});break}}return a}const Pe=Fe;function we(e,t){return e.score===t.score?t.code.length-e.code.length:t.score-e.score}const Ne=we;function ye(e,t,{matcher:a=Pe,comparer:o=Ne}={}){const l=[];for(const c of e){const{code:u}=c,i=c.iso||u;l.push({code:u,iso:i})}const n=a(l,t);return n.length>1&&n.sort(o),n.length?n[0].code:""}const $={PREFIX:"prefix",PREFIX_EXCEPT_DEFAULT:"prefix_except_default",PREFIX_AND_DEFAULT:"prefix_and_default",NO_PREFIX:"no_prefix"},C="",O=$.PREFIX_EXCEPT_DEFAULT,Z=!1,b="___",D="default",$e="ltr",ee="",Ue=new Set([$.PREFIX_AND_DEFAULT,$.PREFIX_EXCEPT_DEFAULT]);function v(e=L.useRoute(),{router:t=L.useRouter(),routesNameSeparator:a=b}={}){const o=a||t.__routesNameSeparator,l=r.unref(e);return l.name?Y(l.name).split(o)[0]:null}function te(e,t,a){const o=M(e,t,a);return o==null?"":r.isVue3?o.redirectedFrom||o.fullPath:o.route.redirectedFrom||o.route.fullPath}function ae(e,t,a){const o=M(e,t,a);return o==null?void 0:r.isVue3?o:o.route}function Ce(e,t,a){const o=M(e,t,a);return o==null?void 0:r.isVue3?o:o.location}function M(e,t,{router:a=L.useRouter(),i18n:o=p.useI18n(),defaultLocale:l=C,defaultLocaleRouteNameSuffix:n=D,routesNameSeparator:c=b,strategy:u=O,trailingSlash:i=!1}={}){const d=a.__defaultLocaleRouteNameSuffix||n,h=a.__defaultLocale||l,f=a.__routesNameSeparator||c,m=a.__strategy||u,R=t||U(o);let S=e;P(e)&&(S[0]==="/"?S={path:e}:S={name:e});let g=q({},S);if(g.path&&!g.name){const _=a.resolve(g),E=r.isVue3?_:_.route,F=v(E);P(F)?g={name:J(F,R,{defaultLocale:h,strategy:m,routesNameSeparator:f,defaultLocaleRouteNameSuffix:d}),params:E.params,query:E.query,hash:E.hash}:(!(R===l&&Ue.has(m))&&m!==$.NO_PREFIX&&(g.path=`/${R}${g.path}`),g.path=i?pe(g.path,!0):Se(g.path,!0))}else{g.name=J(g.name,R,{defaultLocale:h,strategy:m,routesNameSeparator:f,defaultLocaleRouteNameSuffix:d});const{params:_}=g;_&&_["0"]===void 0&&_.pathMatch&&(_["0"]=_.pathMatch)}const A=a.resolve(g);return(r.isVue3?A.name:A.route.name)?A:a.resolve(e)}function j(e,t){const a=t&&t.route||L.useRoute(),o=v(a,t);if(!o)return"";const d=!r.isVue3&&r.isRef(a)?a.value:a,{params:l}=d,n=ie(d,["params"]),c={},u=q({},n,{name:o,params:X(N(N({},l),c),{0:l.pathMatch})});return te(u,e,t)}function Oe({addDirAttribute:e=!1,addSeoAttributes:t=!1,strategy:a=O,defaultLocale:o=C,route:l=L.useRoute(),router:n=L.useRouter(),i18n:c=p.useI18n()}={}){const u=n,i=o||u.__defaultLocale,d=a||u.__strategy,h=r.ref({htmlAttrs:{},link:[],meta:[]});function f(){h.value={htmlAttrs:{},link:[],meta:[]}}function m(R){if(c.locales==null||c.__baseUrl==null)return;const S=U(c),g=G(c.locales.value).find(E=>E.code===S)||{code:S},A=g.iso,_=g.dir||n.__defaultDirection;if(e&&(h.value.htmlAttrs.dir=_),t&&S&&c.locales){A&&(h.value.htmlAttrs.lang=A);const E=c.locales.value;be(E,c.__baseUrl,h.value.link,{defaultLocale:i,strategy:d,route:l,router:n,i18n:c}),ve(c.__baseUrl,h.value.link,t,{route:R,router:n,i18n:c}),xe(g,A,h.value.meta),Xe(E,A,h.value.meta)}}if(Ae)if(r.isVue3){const R=r.watchEffect(()=>{f(),m(Q(u.currentRoute))});r.onUnmounted(()=>R())}else{const R=u.afterEach((S,g)=>{f(),m(S)});r.onUnmounted(()=>R()),m(l)}else m(Q(u.currentRoute));return h}function be(e,t,a,o){if(o.strategy===$.NO_PREFIX)return;const l=new Map;for(const n of e){const c=n.iso;if(!c){Ie("Locale ISO code is required to generate alternate link");continue}const[u,i]=c.split("-");u&&i&&(n.isCatchallLocale||!l.has(u))&&l.set(u,n),l.set(c,n)}for(const[n,c]of l.entries()){const u=j(c.code,o);u&&a.push({hid:`i18n-alt-${n}`,rel:"alternate",href:z(u,t),hreflang:n})}if(o.defaultLocale){const n=j(o.defaultLocale,o);n&&a.push({hid:"i18n-xd",rel:"alternate",href:z(n,t),hreflang:"x-default"})}}function ve(e,t,a,o){const{route:l}=o,n=ae(X(N({},l),{name:v(l,o)}),void 0,o);if(n){let c=z(n.path,e);const u=!ge(a)&&a.canonicalQueries||[];if(u.length){const i=n.query,d=new URLSearchParams;for(const f of u)if(f in i){const m=i[f];_e(m)?m.forEach(R=>d.append(f,R||"")):d.append(f,m||"")}const h=d.toString();h&&(c=`${c}?${h}`)}t.push({hid:"i18n-can",rel:"canonical",href:c})}}function xe(e,t,a){!(e&&t)||a.push({hid:"i18n-og",property:"og:locale",content:oe(t)})}function Xe(e,t,a){const o=e.filter(l=>{const n=l.iso;return n&&n!==t});if(o.length){const l=o.map(n=>({hid:`i18n-og-alt-${n.iso}`,property:"og:locale:alternate",content:oe(n.iso)}));a.push(...l)}}function oe(e){return(e||"").replace(/-/g,"_")}function z(e,t){return e.match(/^https?:\/\//)?e:t+e}function ne(e,{defaultLocale:t=C,strategy:a=O,trailingSlash:o=Z,routesNameSeparator:l=b,defaultLocaleRouteNameSuffix:n=D,includeUprefixedFallback:c=!1,optionsResolver:u=void 0,locales:i=[]}={}){if(a==="no_prefix")return e;const d=i.map(f=>P(f)?f:f.code);function h(f,m,R=!1,S=!1){if(f.redirect&&(!f.component||!f.file))return[f];let g=null;return u!=null&&(g=u(f,m),g==null)?[f]:m.reduce((_,E)=>{const{name:F}=f;let{path:I}=f;const T=N({},f);F&&(T.name=`${F}${l}${E}`),f.children&&(T.children=f.children.reduce((w,k)=>[...w,...h(k,[E],!0,S)],[]));const y=E===t;if(y&&a==="prefix_and_default")if(R)R&&S&&F&&(T.name+=`${l}${n}`);else{const w=X(N({},T),{path:I});if(F&&(w.name=`${T.name}${l}${n}`),f.children){w.children=[];for(const k of f.children)w.children=w.children.concat(h(k,[E],!0,!0))}_.push(w)}const ce=R&&!I.startsWith("/"),re=!ce&&!(y&&a==="prefix_except_default");return re&&(I=`/${E}${I}`),I&&(I=Te(I,o,ce)),re&&y&&a==="prefix"&&c&&_.push(N({},f)),T.path=I,_.push(T),_},[])}return e.reduce((f,m)=>[...f,...h(m,d||[])],[])}function Ve(e,{locales:t=[],localeCodes:a=[],baseUrl:o=ee}={}){if(!B(e.global,e.mode))throw new Error("TODO:");const l=r.ref(t),n=r.ref(a);e.global.locales=r.computed(()=>l.value),e.global.localeCodes=r.computed(()=>n.value),e.global.__baseUrl=K(o,{})}function Be(e,t={}){const{version:a,defaultLocale:o,locales:l,strategy:n,trailingSlash:c,routesNameSeparator:u,defaultLocaleRouteNameSuffix:i,defaultDirection:d,baseUrl:h,routes:f,routeOptionsResolver:m}=je(t),R=G(l),S=R.map(E=>E.code),g=le(S,u,i);Ve(e,{locales:R,baseUrl:h,localeCodes:S});const A=ne(f,{locales:l,defaultLocale:o,strategy:n,trailingSlash:c,routesNameSeparator:u,defaultLocaleRouteNameSuffix:i,optionsResolver:m});t.routes=A;const _=De(t,a);return _.__defaultLocale=o,_.__localeCodes=S,_.__strategy=n,_.__trailingSlash=c,_.__routesNameSeparator=u,_.__defaultLocaleRouteNameSuffix=i,_.__defaultDirection=d,_.beforeEach((E,F,I)=>{const T=U(e),y=g(E)||T||o||"";T!==y&&W(e,y),I()}),_}function De(e,t){if(r.isVue3&&t===4)return L.createRouter(e);if(r.isVue2&&t===3)return new he.default(e);throw new Error("TODO:")}function Me(e){return new RegExp(`^/(${e.join("|")})(?:/|$)`,"i")}function le(e,t,a){const o=`(${e.join("|")})`,l=`(?:${t}${a})?`,n=new RegExp(`${t}${o}${l}$`,"i"),c=Me(e);return i=>{if(Re(i)){if(i.name){const h=(P(i.name)?i.name:i.name.toString()).match(n);if(h&&h.length>1)return h[1]}else if(i.path){const d=i.path.match(c);if(d&&d.length>1)return d[1]}}else if(P(i)){const d=i.match(c);if(d&&d.length>1)return d[1]}return""}}function je(e){var t,a,o,l,n,c,u,i,d,h;return e.version=(t=e.version)!=null?t:4,e.defaultLocale=(a=e.defaultLocale)!=null?a:C,e.strategy=(o=e.strategy)!=null?o:O,e.trailingSlash=(l=e.trailingSlash)!=null?l:Z,e.routesNameSeparator=(n=e.routesNameSeparator)!=null?n:b,e.defaultLocaleRouteNameSuffix=(c=e.defaultLocaleRouteNameSuffix)!=null?c:D,e.locales=(u=e.locales)!=null?u:[],e.defaultDirection=(i=e.defaultDirection)!=null?i:$e,e.baseUrl=(d=e.baseUrl)!=null?d:ee,e.routes=(h=e.routes)!=null?h:[],e}const ze="0.0.0";return s.VERSION=ze,s.createLocaleFromRouteGetter=le,s.createRouter=Be,s.findBrowserLocale=ye,s.getLocale=U,s.getRouteBaseName=v,s.localeLocation=Ce,s.localePath=te,s.localeRoute=ae,s.localizeRoutes=ne,s.resolveBaseUrl=K,s.setLocale=W,s.switchLocalePath=j,s.useI18nHead=Oe,Object.defineProperty(s,"__esModule",{value:!0}),s[Symbol.toStringTag]="Module",s}({},VueDemi,VueRouter,VueI18n);
*/const le=Object.assign,ye=Array.isArray,Ne=e=>typeof e=="function",O=e=>typeof e=="string",Fe=e=>typeof e=="boolean",Te=e=>typeof e=="symbol",D=e=>e!==null&&typeof e=="object",Ue=/\/$|\/\?/;function q(e="",t=!1){return t?Ue.test(e):e.endsWith("/")}function $e(e="",t=!1){if(!t)return(q(e)?e.slice(0,-1):e)||"/";if(!q(e,!0))return e||"/";const[o,...n]=e.split("?");return(o.slice(0,-1)||"/")+(n.length?`?${n.join("?")}`:"")}function ve(e="",t=!1){if(!t)return e.endsWith("/")?e:e+"/";if(q(e,!0))return e||"/";const[o,...n]=e.split("?");return o+"/"+(n.length?`?${n.join("?")}`:"")}const je=typeof window!="undefined";function Ve(e,t){typeof console!="undefined"&&(console.warn("[vue-i18n-routing] "+e),t&&console.warn(t.stack))}function ce(e){e=e||[];const t=[];for(const o of e)O(o)?t.push({code:o}):t.push(o);return t}function j(e){return e!=null&&"global"in e&&"mode"in e}function V(e){return e!=null&&!("__composer"in e)&&d.isRef(e.locale)}function F(e){return e!=null&&"__composer"in e}function W(e){return e!=null&&!("__composer"in e)&&!d.isRef(e.locale)}function b(e){return e!=null&&("__VUE_I18N_BRIDGE__"in e||"_sync"in e)}function se(e){return j(e)?V(e.global)?e.global:e.global.__composer:F(e)?e.__composer:e}function B(e){const t=j(e)?e.global:e;return V(t)?d.isVue2&&b(e)?e.locale:t.locale.value:(W(t)||F(t)||b(t),t.locale)}function Be(e){const t=j(e)?e.global:e;return V(t)?d.isVue2&&b(e)?e.locales:t.locales.value:(W(t)||F(t)||b(t),t.locales)}function re(e,t){const o=j(e)?e.global:e;if(V(o))d.isVue2&&b(e)?e.locale=t:o.locale.value=t;else if(W(o)||F(o)||b(o))o.locale=t;else throw new Error("TODO:")}function Me(e,t,o){return e.replace(/\/+$/,"")+(t?"/":"")||(o?"":"/")}function ie(e){return L.isVueRouter4,d.isRef(e)?e.value:e}function ue(e){return O(e)?e:Te(e)?e.toString():"(null)"}function fe(e,t,{defaultLocale:o,strategy:n,routesNameSeparator:l,defaultLocaleRouteNameSuffix:a}){let c=ue(e)+(n==="no_prefix"?"":l+t);return t===o&&n==="prefix_and_default"&&(c+=l+a),c}function de(e,t){return Ne(e)?e(t):e}function Xe(e,t){const o=[];for(const[n,l]of t.entries()){const a=e.find(c=>c.iso.toLowerCase()===l.toLowerCase());if(a){o.push({code:a.code,score:1-n/t.length});break}}for(const[n,l]of t.entries()){const a=l.split("-")[0].toLowerCase(),c=e.find(s=>s.iso.split("-")[0].toLowerCase()===a);if(c){o.push({code:c.code,score:.999-n/t.length});break}}return o}const Ge=Xe;function ke(e,t){return e.score===t.score?t.code.length-e.code.length:t.score-e.score}const ze=ke;function xe(e,t,{matcher:o=Ge,comparer:n=ze}={}){const l=[];for(const c of e){const{code:s}=c,r=c.iso||s;l.push({code:s,iso:r})}const a=o(l,t);return a.length>1&&a.sort(n),a.length?a[0].code:""}const T={PREFIX:"prefix",PREFIX_EXCEPT_DEFAULT:"prefix_except_default",PREFIX_AND_DEFAULT:"prefix_and_default",NO_PREFIX:"no_prefix"},Q="",Y=T.PREFIX_EXCEPT_DEFAULT,J=!1,K="___",Z="default",he="ltr",Le="";function I(e){return function(){return Reflect.apply(e,{getRouteBaseName:this.getRouteBaseName,localePath:this.localePath,localeRoute:this.localeRoute,localeLocation:this.localeLocation,resolveRoute:this.resolveRoute,switchLocalePath:this.switchLocalePath,localeHead:this.localeHead,i18n:this.$i18n,route:this.$route,router:this.$router},arguments)}}function ge(e,{locales:t=[],localeCodes:o=[],baseUrl:n=Le}={}){const l=e.install;e.install=(a,...c)=>{Reflect.apply(l,e,[a,...c]);const s=se(e);He(s,{locales:t,localeCodes:o,baseUrl:n}),F(e.global)&&qe(e.global);const r=a,i=e.mode==="composition"?d.isVue3?r.config.globalProperties.$i18n:e:d.isVue2?e:null;i&&De(i,s),(We(c[0])?c[0]:{inject:!0}).inject&&a.mixin({methods:{resolveRoute:I(U),localePath:I(G),localeRoute:I(k),localeLocation:I(ee),switchLocalePath:I($),getRouteBaseName:I(y),localeHead:I(te)}})}}function He(e,t){const{locales:o,localeCodes:n,baseUrl:l}=t,a=d.ref(o),c=d.ref(n);e.locales=d.computed(()=>a.value),e.localeCodes=d.computed(()=>c.value),e.__baseUrl=de(l,{})}function De(e,t){Object.defineProperty(e,"locales",{get(){return t.locales.value}}),Object.defineProperty(e,"localeCodes",{get(){return t.localeCodes.value}}),Object.defineProperty(e,"__baseUrl",{get(){return t.__baseUrl}})}function qe(e){const t=se(e);Object.defineProperty(e,"locales",{get(){return t.locales.value}}),Object.defineProperty(e,"localeCodes",{get(){return t.localeCodes.value}}),Object.defineProperty(e,"__baseUrl",{get(){return t.__baseUrl}})}function We(e){return D(e)&&"inject"in e&&Fe(e.inject)}function Re(e,{defaultLocale:t=Q,strategy:o=Y,trailingSlash:n=J,routesNameSeparator:l=K,defaultLocaleRouteNameSuffix:a=Z,includeUprefixedFallback:c=!1,optionsResolver:s=void 0,locales:r=[]}={}){if(o==="no_prefix")return e;const i=r.map(u=>O(u)?u:u.code);function h(u,m,g=!1,_=!1){if(u.redirect&&(!u.component||!u.file))return[u];let A=null;return s!=null&&(A=s(u,m),A==null)?[u]:m.reduce((S,P)=>{const{name:v}=u;let{path:p}=u;const E=C({},u);v&&(E.name=`${v}${l}${P}`),u.children&&(E.children=u.children.reduce((w,ae)=>[...w,...h(ae,[P],!0,_)],[]));const N=P===t;if(N&&o==="prefix_and_default")if(g)g&&_&&v&&(E.name+=`${l}${a}`);else{const w=H(C({},E),{path:p});if(v&&(w.name=`${E.name}${l}${a}`),u.children){w.children=[];for(const ae of u.children)w.children=w.children.concat(h(ae,[P],!0,!0))}S.push(w)}const Se=g&&!p.startsWith("/"),Pe=!Se&&!(N&&o==="prefix_except_default");return Pe&&(p=`/${P}${p}`),p&&(p=Me(p,n,Se)),Pe&&N&&o==="prefix"&&c&&S.push(C({},u)),E.path=p,S.push(E),S},[])}return e.reduce((u,m)=>[...u,...h(m,i||[])],[])}const M=new Map;function me(e,t){return M.has(e)?null:(M.set(e,t),()=>M.delete(e))}function _e(e){var t;return(t=M.get(e))!=null?t:{}}function Qe(e,t={}){const{version:o,defaultLocale:n,locales:l,strategy:a,trailingSlash:c,routesNameSeparator:s,defaultLocaleRouteNameSuffix:r,defaultDirection:i,baseUrl:h,routes:u,routeOptionsResolver:m}=Ke(t),g=ce(l),_=g.map(P=>P.code),A=pe(_,s,r);ge(e,{locales:g,baseUrl:h,localeCodes:_});const ne=Re(u,{locales:l,defaultLocale:n,strategy:a,trailingSlash:c,routesNameSeparator:s,defaultLocaleRouteNameSuffix:r,optionsResolver:m});t.routes=ne;const S=Ye(t,o);return me(S,{defaultLocale:n,localeCodes:_,strategy:a,trailingSlash:c,routesNameSeparator:s,defaultLocaleRouteNameSuffix:r,defaultDirection:i}),S.beforeEach((P,v,p)=>{const E=B(e),N=A(P)||E||n||"";E!==N&&re(e,N),p()}),S}function Ye(e,t){if(d.isVue3&&t===4)return L.createRouter(e);if(d.isVue2&&t===3)return new be.default(e);throw new Error("TODO:")}function Je(e){return new RegExp(`^/(${e.join("|")})(?:/|$)`,"i")}function pe(e,t,o){const n=`(${e.join("|")})`,l=`(?:${t}${o})?`,a=new RegExp(`${t}${n}${l}$`,"i"),c=Je(e);return r=>{if(D(r)){if(r.name){const h=(O(r.name)?r.name:r.name.toString()).match(a);if(h&&h.length>1)return h[1]}else if(r.path){const i=r.path.match(c);if(i&&i.length>1)return i[1]}}else if(O(r)){const i=r.match(c);if(i&&i.length>1)return i[1]}return""}}function Ke(e){var t,o,n,l,a,c,s,r,i,h;return e.version=(t=e.version)!=null?t:4,e.defaultLocale=(o=e.defaultLocale)!=null?o:Q,e.strategy=(n=e.strategy)!=null?n:Y,e.trailingSlash=(l=e.trailingSlash)!=null?l:J,e.routesNameSeparator=(a=e.routesNameSeparator)!=null?a:K,e.defaultLocaleRouteNameSuffix=(c=e.defaultLocaleRouteNameSuffix)!=null?c:Z,e.locales=(s=e.locales)!=null?s:[],e.defaultDirection=(r=e.defaultDirection)!=null?r:he,e.baseUrl=(i=e.baseUrl)!=null?i:Le,e.routes=(h=e.routes)!=null?h:[],e}function X(e,t,{defaultLocale:o=Q,defaultDirection:n=he,defaultLocaleRouteNameSuffix:l=Z,routesNameSeparator:a=K,strategy:c=Y,trailingSlash:s=J,localeCodes:r=[]}={}){const i=_e(e);return{defaultLocale:t.defaultLocale||i.defaultLocale||o,defaultDirection:t.defaultDirection||i.defaultDirection||n,defaultLocaleRouteNameSuffix:t.defaultLocaleRouteNameSuffix||i.defaultLocaleRouteNameSuffix||l,routesNameSeparator:t.routesNameSeparator||i.routesNameSeparator||a,strategy:t.strategy||i.strategy||c,trailingSlash:t.trailingSlash||i.trailingSlash||s,localeCodes:t.localeCodes||i.localeCodes||r}}const Ze=new Set([T.PREFIX_AND_DEFAULT,T.PREFIX_EXCEPT_DEFAULT]);function y(e){const t=this.router,{routesNameSeparator:o}=X(t,this),n=e!=null?d.isRef(e)?d.unref(e):e:this.route;return n.name?ue(n.name).split(o)[0]:void 0}function G(e,t){const o=U.call(this,e,t);return o==null?"":d.isVue3?o.redirectedFrom||o.fullPath:o.route.redirectedFrom||o.route.fullPath}function k(e,t){const o=U.call(this,e,t);return o==null?void 0:d.isVue3?o:o.route}function ee(e,t){const o=U.call(this,e,t);return o==null?void 0:d.isVue3?o:o.location}function U(e,t){const o=this.router,n=this.i18n,l=t||B(n),{routesNameSeparator:a,defaultLocale:c,defaultLocaleRouteNameSuffix:s,strategy:r,trailingSlash:i}=X(o,this);let h=e;O(e)&&(h[0]==="/"?h={path:e}:h={name:e});let u=le({},h);if(u.path&&!u.name){const g=o.resolve(u),_=d.isVue3?g:g.route,A=y.call(this,_);O(A)?u={name:fe(A,l,{defaultLocale:c,strategy:r,routesNameSeparator:a,defaultLocaleRouteNameSuffix:s}),params:_.params,query:_.query,hash:_.hash}:(!(l===c&&Ze.has(r))&&r!==T.NO_PREFIX&&(u.path=`/${l}${u.path}`),u.path=i?ve(u.path,!0):$e(u.path,!0))}else{u.name=fe(u.name,l,{defaultLocale:c,strategy:r,routesNameSeparator:a,defaultLocaleRouteNameSuffix:s});const{params:g}=u;g&&g["0"]===void 0&&g.pathMatch&&(g["0"]=g.pathMatch)}const m=o.resolve(u);return(d.isVue3?m.name:m.route.name)?m:o.resolve(e)}function $(e){const t=this.route,o=y.call(this,t);if(!o)return"";const r=!d.isVue3&&d.isRef(t)?t.value:t,{params:n}=r,l=we(r,["params"]),a={},c=le({},l,{name:o,params:H(C(C({},n),a),{0:n.pathMatch})});return G.call(this,c,e)}function te({addDirAttribute:e=!1,addSeoAttributes:t=!1}={}){const o=this.router,n=this.i18n,{defaultDirection:l}=X(o,this),a={htmlAttrs:{},link:[],meta:[]};if(n.locales==null||n.__baseUrl==null)return a;const c=B(n),s=Be(n),r=ce(s).find(u=>u.code===c)||{code:c},i=r.iso,h=r.dir||l;return e&&(a.htmlAttrs.dir=h),t&&c&&n.locales&&(i&&(a.htmlAttrs.lang=i),et.call(this,s,n.__baseUrl,a.link),tt.call(this,n.__baseUrl,a.link,t),ot(r,i,a.meta),nt(s,i,a.meta)),a}function et(e,t,o){const n=this.router,{defaultLocale:l,strategy:a}=X(n,this);if(a===T.NO_PREFIX)return;const c=new Map;for(const s of e){const r=s.iso;if(!r){Ve("Locale ISO code is required to generate alternate link");continue}const[i,h]=r.split("-");i&&h&&(s.isCatchallLocale||!c.has(i))&&c.set(i,s),c.set(r,s)}for(const[s,r]of c.entries()){const i=$.call(this,r.code);i&&o.push({hid:`i18n-alt-${s}`,rel:"alternate",href:oe(i,t),hreflang:s})}if(l){const s=$.call(this,l);s&&o.push({hid:"i18n-xd",rel:"alternate",href:oe(s,t),hreflang:"x-default"})}}function tt(e,t,o){const n=this.route,l=k.call(this,H(C({},n),{name:y.call(this,n)}));if(l){let a=oe(l.path,e);const c=D(o)&&o.canonicalQueries||[];if(c.length){const s=l.query,r=new URLSearchParams;for(const h of c)if(h in s){const u=s[h];ye(u)?u.forEach(m=>r.append(h,m||"")):r.append(h,u||"")}const i=r.toString();i&&(a=`${a}?${i}`)}t.push({hid:"i18n-can",rel:"canonical",href:a})}}function ot(e,t,o){!(e&&t)||o.push({hid:"i18n-og",property:"og:locale",content:Ee(t)})}function nt(e,t,o){const n=e.filter(l=>{const a=l.iso;return a&&a!==t});if(n.length){const l=n.map(a=>({hid:`i18n-og-alt-${a.iso}`,property:"og:locale:alternate",content:Ee(a.iso)}));o.push(...l)}}function Ee(e){return(e||"").replace(/-/g,"_")}function oe(e,t){return e.match(/^https?:\/\//)?e:t+e}function z(e,t){const{router:o,route:n,i18n:l,defaultLocale:a,strategy:c,defaultLocaleRouteNameSuffix:s,trailingSlash:r,routesNameSeparator:i}=e;return function(...h){return Reflect.apply(t,{router:o,route:n,i18n:l,defaultLocale:a,strategy:c,defaultLocaleRouteNameSuffix:s,trailingSlash:r,routesNameSeparator:i},h)}}function at(e=L.useRoute(),{router:t=L.useRouter(),routesNameSeparator:o=void 0}={}){const n={router:t,route:e,routesNameSeparator:o};return y.call(n,e)}function lt({router:e=L.useRouter(),route:t=L.useRoute(),i18n:o=R.useI18n(),defaultLocale:n=void 0,defaultLocaleRouteNameSuffix:l=void 0,routesNameSeparator:a=void 0,strategy:c=void 0,trailingSlash:s=void 0}={}){return z({router:e,route:t,i18n:o,defaultLocale:n,defaultLocaleRouteNameSuffix:l,routesNameSeparator:a,strategy:c,trailingSlash:s},G)}function ct({router:e=L.useRouter(),route:t=L.useRoute(),i18n:o=R.useI18n(),defaultLocale:n=void 0,defaultLocaleRouteNameSuffix:l=void 0,routesNameSeparator:a=void 0,strategy:c=void 0,trailingSlash:s=void 0}={}){return z({router:e,route:t,i18n:o,defaultLocale:n,defaultLocaleRouteNameSuffix:l,routesNameSeparator:a,strategy:c,trailingSlash:s},k)}function st({router:e=L.useRouter(),route:t=L.useRoute(),i18n:o=R.useI18n(),defaultLocale:n=void 0,defaultLocaleRouteNameSuffix:l=void 0,routesNameSeparator:a=void 0,strategy:c=void 0,trailingSlash:s=void 0}={}){return z({router:e,route:t,i18n:o,defaultLocale:n,defaultLocaleRouteNameSuffix:l,routesNameSeparator:a,strategy:c,trailingSlash:s},ee)}function rt({router:e=L.useRouter(),route:t=L.useRoute(),i18n:o=R.useI18n(),defaultLocale:n=void 0,defaultLocaleRouteNameSuffix:l=void 0,routesNameSeparator:a=void 0,strategy:c=void 0,trailingSlash:s=void 0}={}){return z({router:e,route:t,i18n:o,defaultLocale:n,defaultLocaleRouteNameSuffix:l,routesNameSeparator:a,strategy:c,trailingSlash:s},$)}function it({addDirAttribute:e=!1,addSeoAttributes:t=!1,strategy:o=void 0,defaultLocale:n=void 0,route:l=L.useRoute(),router:a=L.useRouter(),i18n:c=R.useI18n()}={}){const s=a,r=d.ref({htmlAttrs:{},link:[],meta:[]});function i(){r.value={htmlAttrs:{},link:[],meta:[]}}function h(u){r.value=Reflect.apply(te,{router:a,route:u,i18n:c,defaultLocale:n,strategy:o},[{addDirAttribute:e,addSeoAttributes:t}])}if(je)if(d.isVue3){const u=d.watchEffect(()=>{i(),h(ie(s.currentRoute))});d.onUnmounted(()=>u())}else{const u=s.afterEach((m,g)=>{i(),h(m)});d.onUnmounted(()=>u()),h(l)}else h(ie(s.currentRoute));return r}const ut="0.0.0";return f.VERSION=ut,f.createLocaleFromRouteGetter=pe,f.createRouter=Qe,f.extendI18n=ge,f.findBrowserLocale=xe,f.getGlobalOptions=_e,f.getLocale=B,f.getRouteBaseName=y,f.localeHead=te,f.localeLocation=ee,f.localePath=G,f.localeRoute=k,f.localizeRoutes=Re,f.proxyVueInstance=I,f.registerGlobalOptions=me,f.resolveBaseUrl=de,f.resolveRoute=U,f.setLocale=re,f.switchLocalePath=$,f.useLocaleHead=it,f.useLocaleLocation=st,f.useLocalePath=lt,f.useLocaleRoute=ct,f.useRouteBaseName=at,f.useSwitchLocalePath=rt,Object.defineProperties(f,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}}),f}({},VueDemi,VueRouter,VueI18n);
{
"name": "vue-i18n-routing",
"description": "The i18n routing with using vue-i18n",
"version": "0.0.0-190b377",
"version": "0.0.0-19fbb3c",
"dependencies": {
"@intlify/shared": "beta",
"@intlify/shared": "next",
"@intlify/vue-i18n-bridge": "^0.3.5",

@@ -23,3 +23,3 @@ "@intlify/vue-router-bridge": "^0.3.5",

"vue-i18n": "npm:vue-i18n@next",
"vue-i18n-bridge": "beta",
"vue-i18n-bridge": "next",
"vue-i18n-legacy": "npm:vue-i18n@8",

@@ -34,4 +34,4 @@ "vue-router": "^4.0.12",

"vue": "^2.6.14 || ^3.2.0",
"vue-i18n": "^8.26.1 || ^9.2.0-beta.30",
"vue-i18n-bridge": "^9.2.0-beta.30",
"vue-i18n": "^8.26.1 || ^9.2.0-beta.34",
"vue-i18n-bridge": "^9.2.0-beta.34",
"vue-router": "^3.5.3 || ^4.0.0"

@@ -53,2 +53,3 @@ },

"index.mjs",
"types.d.ts",
"LICENSE",

@@ -71,4 +72,7 @@ "README.md"

},
"./dist/*": "./dist/*",
"./package.json": "./package.json"
"./types": {
"types": "./types.d.ts"
},
"./package.json": "./package.json",
"./dist/*": "./dist/*"
},

@@ -75,0 +79,0 @@ "license": "MIT",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc