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-add5ce5 to 0.0.0-b365939

4

dist/vue-i18n-routing.cjs.js

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

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

@@ -9,2 +9,3 @@ import { Composer } from '@intlify/vue-i18n-bridge';

import type { RouteLocation } from '@intlify/vue-router-bridge';
import type { RouteLocationNormalized } from '@intlify/vue-router-bridge';
import type { RouteLocationNormalizedLoaded } from '@intlify/vue-router-bridge';

@@ -33,6 +34,8 @@ import type { RouteLocationRaw } from '@intlify/vue-router-bridge';

export declare type ComputedRouteOptions = {
locales?: readonly string[];
paths?: Record<string, string>;
locales: readonly string[];
paths: Record<string, string>;
};
export declare function createLocaleFromRouteGetter(localeCodes: string[], routesNameSeparator: string, defaultLocaleRouteNameSuffix: string): (route: Route_2 | RouteLocationNormalizedLoaded | RouteLocationNormalized | string) => string;
/**

@@ -62,2 +65,4 @@ * Create a Vue Router instance

export declare function getLocale(i18n: I18n | Composer): Locale;
/**

@@ -210,2 +215,4 @@ * Get route base name

export declare function setLocale(i18n: I18n | Composer, locale: Locale): void;
declare const STRATEGIES: {

@@ -291,3 +298,4 @@ readonly PREFIX: "prefix";

*
* @remarks TODO:
* @remarks
* Can either be an array of string codes (e.g. `['en', 'fr']`) or an array of {@link LocaleObject} for more complex configurations
*

@@ -360,7 +368,19 @@ * @defaultValue []

export { }
import type { ComputedRef } from 'vue-demi'
declare module 'vue-i18n' {
export interface ComposerCustom {
locales: ComputedRef<string[] | LocaleObject[]>
__baseUrl: string
/**
* List of locales
*
* @defaultValue `undefined`
*/
locales?: ComputedRef<string[] | LocaleObject[]>
/**
* List of locale codes
*
* @defaultValue `undefined`
*/
localeCodes?: ComputedRef<string[]>
__baseUrl?: string
}

@@ -370,5 +390,16 @@ }

export interface ComposerCustom {
locales: ComputedRef<string[] | LocaleObject[]>
__baseUrl: string
/**
* List of locales
*
* @defaultValue `undefined`
*/
locales?: ComputedRef<string[] | LocaleObject[]>
/**
* List of locale codes
*
* @defaultValue `undefined`
*/
localeCodes?: ComputedRef<string[]>
__baseUrl?: string
}
}

@@ -46,2 +46,3 @@ var __defProp = Object.defineProperty;

const isSymbol = (val) => typeof val === "symbol";
const isObject = (val) => val !== null && typeof val === "object";
const TRAILING_SLASH_RE = /\/$|\/\?/;

@@ -279,2 +280,5 @@ function hasTrailingSlash(input = "", queryParams = false) {

function updateMeta(_route) {
if (i18n.locales == null || i18n.__baseUrl == null) {
return;
}
const locale = getLocale(i18n);

@@ -492,3 +496,3 @@ const currentLocale = getNormalizedLocales(i18n.locales.value).find((l) => l.code === locale) || {

}
function extendI18n(i18n, { locales = [], baseUrl = DEFAULT_BASE_URL } = {}) {
function extendI18n(i18n, { locales = [], localeCodes = [], baseUrl = DEFAULT_BASE_URL } = {}) {
if (!isComposer(i18n.global, i18n.mode)) {

@@ -498,3 +502,5 @@ 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, {});

@@ -511,10 +517,17 @@ }

const getLocaleFromRoute = (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];
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 (route.path) {
const matches = route.path.match(regexpPath);
} else if (isString(route)) {
const matches = route.match(regexpPath);
if (matches && matches.length > 1) {

@@ -559,3 +572,3 @@ return matches[1];

const getLocaleFromRoute = createLocaleFromRouteGetter(localeCodes, routesNameSeparator, defaultLocaleRouteNameSuffix);
extendI18n(i18n, { locales: normalizedLocaleCodes, baseUrl });
extendI18n(i18n, { locales: normalizedLocaleCodes, baseUrl, localeCodes });
const localizedRoutes = localizeRoutes(routes, {

@@ -597,2 +610,2 @@ locales,

const VERSION = "0.0.0";
export { VERSION, createRouter, getRouteBaseName, localeLocation, localePath, localeRoute, localizeRoutes, switchLocalePath, useI18nHead };
export { VERSION, createLocaleFromRouteGetter, createRouter, getLocale, getRouteBaseName, localeLocation, localePath, localeRoute, localizeRoutes, setLocale, switchLocalePath, useI18nHead };

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

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

@@ -18,5 +18,5 @@ "vue-demi": "^0.12.1"

"typescript": "^4.5.4",
"vite": "^2.7.4",
"vite": "latest",
"vite-plugin-dts": "^0.9.6",
"vitest": "^0.2.8",
"vite-plugin-dts": "^0.9.6",
"vue": "^3.2.23",

@@ -23,0 +23,0 @@ "vue-i18n": "npm:vue-i18n@next",

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