New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.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-d4abcf5 to 0.0.0-d5a38c7

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

6

dist/vue-i18n-routing.cjs.js

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

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

@@ -1,9 +0,400 @@

import type { RouteConfig } from 'vue-router3';
import type { Composer } from '@intlify/vue-i18n-bridge';
import { EffectScope } from 'vue-demi';
import type { I18n } from '@intlify/vue-i18n-bridge';
import type { Locale } from '@intlify/vue-i18n-bridge';
import type { RawLocation } from '@intlify/vue-router-bridge';
import type { Ref } from 'vue-demi';
import type { Route as Route_2 } from '@intlify/vue-router-bridge';
import type { RouteConfig } from '@intlify/vue-router-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';
import type { RouteLocationRaw } from '@intlify/vue-router-bridge';
import type { Router } from '@intlify/vue-router-bridge';
import type { RouterOptions } from '@intlify/vue-router-bridge';
import { useRoute } from '@intlify/vue-router-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 function localizeRoutes(routes: VueI18nRoute[], { defaultLocale, trailingSlash, routesNameSeparator, defaultLocaleRouteNameSuffix, localeCodes }?: Pick<VueI18nRoutingOptions, 'defaultLocale' | 'localeCodes' | 'routesNameSeparator' | 'trailingSlash' | 'defaultLocaleRouteNameSuffix'>): VueI18nRoute[];
export declare type BaseUrlResolveHandler<Context = unknown> = (context: Context) => string;
/**
* The browser locale info
*
* @remarks
* This type is used by {@link FindBrowserLocaleOptions#sorter | sorter} in {@link findBrowserLocale} function
*/
export declare type BrowserLocale = {
/**
* The locale code, such as BCP 47 (e.g `en-US`), or `ja`
*/
code: string;
/**
* The score number
*
* @remarks
* The score number that is used by `sorter` of {@link FindBrowserLocaleOptions}
*/
score: number;
};
/**
* The browser locale matcher
*
* @remarks
* This matcher is used by {@link findBrowserLocale} function
*
* @param locales - The target {@link LocaleObject | locale} list
* @param browserLocales - The locale code list that is used in browser
*
* @returns The matched {@link BrowserLocale | locale info}
*/
export declare type BrowserLocaleMatcher = (locales: TargetLocale[], browserLocales: string[]) => BrowserLocale[];
export declare type ComposableOptions = {
route?: ReturnType<typeof useRoute>;
router?: ReturnType<typeof useRouter>;
i18n?: Composer;
};
/**
* Options to compute route localizing
*
* @remarks
* The route options that is compute the route to be localized on {@link localizeRoutes}
*/
export declare type ComputedRouteOptions = {
locales: readonly string[];
paths: Record<string, string>;
};
export declare function createLocaleFromRouteGetter(localeCodes: string[], routesNameSeparator: string, defaultLocaleRouteNameSuffix: string): (route: Route_2 | RouteLocationNormalizedLoaded | RouteLocationNormalized | string) => string;
/**
* Create a Vue Router instance
*
* @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 I18nRoutingOptions}
*
* @returns A Vue Router instance
*
* @remakrs
* You can create a vue router instance to be used by the Vue app.
*
* The routes of the created router instance are handled with i18n routing.
*
* At the Vue 2 will return a [Vue Router v3 instance](https://router.vuejs.org/api/#router-construction-options), and at the Vue 3 will return a [Vue Router v4 instance](https://next.router.vuejs.org/api/#createrouter).
*
* @public
*/
export declare function createRouter<Options extends I18nRoutingOptions = I18nRoutingOptions>(i18n: I18n, options?: Options): Options['version'] extends 4 ? Router : VueRouter;
/**
* Direction
*/
export declare type Directions = 'ltr' | 'rtl' | 'auto';
export declare type ExtendComposerHook = (compser: Composer) => void;
export declare type ExtendExportedGlobalHook = (global: Composer) => ExtendProperyDescripters;
export declare interface ExtendHooks {
onExtendComposer?: ExtendComposerHook;
onExtendExportedGlobal?: ExtendExportedGlobalHook;
onExtendVueI18n?: ExtendVueI18nHook;
}
export declare function extendI18n<TI18n extends I18n>(i18n: TI18n, { locales, localeCodes, baseUrl, hooks }?: VueI18nExtendOptions): EffectScope;
export declare type ExtendProperyDescripters = {
[key: string]: Pick<PropertyDescriptor, 'get'>;
};
export declare type ExtendVueI18nHook = (composer: Composer) => ExtendProperyDescripters;
/**
* Find the browser locale
*
* @param locales - The target {@link LocaleObject | locale} list
* @param browserLocales - The locale code list that is used in browser
* @param options - The options for {@link findBrowserLocale} function
*
* @returns The matched the locale code
*/
export declare function findBrowserLocale(locales: LocaleObject[], browserLocales: string[], { matcher, comparer }?: FindBrowserLocaleOptions): string | '';
/**
* The options for {@link findBrowserLocale} function
*/
export declare type FindBrowserLocaleOptions = {
matcher?: BrowserLocaleMatcher;
comparer?: (a: BrowserLocale, b: BrowserLocale) => number;
};
/**
* 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
*
* @param i18n - An [I18n](https://vue-i18n.intlify.dev/api/general.html#i18n) instance or a [Composer](https://vue-i18n.intlify.dev/api/composition.html#composer) instance
*
* @returns A locale
*/
export declare function getLocale(i18n: I18n | Composer | VueI18n): Locale;
export declare function getRouteBaseName(this: RoutingProxy, givenRoute?: Route_2 | RouteLocationNormalizedLoaded): string | undefined;
export declare type I18nCommonRoutingOptions = Pick<I18nRoutingOptions, 'defaultLocale' | 'strategy' | 'defaultLocaleRouteNameSuffix' | 'trailingSlash' | 'locales' | 'routesNameSeparator'>;
export declare type I18nCommonRoutingOptionsWithComposable = I18nCommonRoutingOptions & ComposableOptions;
/**
* I18n header meta info
*/
export declare interface I18nHeadMetaInfo {
htmlAttrs?: MetaAttrs;
meta?: MetaAttrs[];
link?: MetaAttrs[];
}
/**
* Options for {@link localeHead} function
*/
export declare interface I18nHeadOptions {
/**
* Adds a `dir` attribute to the HTML element.
*
* @defaultValue false
*/
addDirAttribute?: boolean;
/**
* Adds various SEO attributes.
*
* @defaultValue false
*/
addSeoAttributes?: boolean | SeoAttributesOptions;
}
/**
* Route config for vue-i18n-routing
*/
export declare type I18nRoute = Route & RouteLegacy & {
redirect?: string;
};
/**
* 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
*
* @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 type LocaleLocationFunction = (route: RawLocation | RouteLocationRaw, locale?: Locale) => Location | RouteLocation | undefined;
/**
* Locale object
*/
export declare interface LocaleObject extends Record<string, any> {
code: Locale;
name?: string;
dir?: Directions;
domain?: string;
file?: string;
isCatchallLocale?: boolean;
iso?: string;
}
export declare function localePath(this: RoutingProxy, route: RawLocation | RouteLocationRaw, locale?: Locale): string;
/**
* 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
*
* @returns Returns the localized URL for a given route
*
* @see {@link useLocalePath}
*/
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 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
*
* @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 type LocaleRouteFunction = (route: RawLocation | RouteLocationRaw, locale?: Locale) => Route_2 | ReturnType<Router['resolve']> | undefined;
/**
* Localize routes
*
* @param routes - Some routes
* @param options - An options
*
* @returns Localized routes
*
* @public
*/
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;
}): 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}
*/
export declare function registerGlobalOptions<BaseUrl extends BaseUrlResolveHandler = BaseUrlResolveHandler>(router: Router | VueRouter, options: I18nRoutingGlobalOptions<BaseUrl>): void;
/**
* Resolve base url
*
* @param baseUrl - A base url to resolve on SEO and domain. if you want to resolve with dynamically, you can spacify {@link BaseUrlResolveHandler}
* @param context - A context to resolve base url, if you want to resolve base url with {@link BaseUrlResolveHandler}
*
* @returns A resolved base url
*/
export declare function resolveBaseUrl<Context = unknown>(baseUrl: string | BaseUrlResolveHandler<Context>, context: Context): string;
export declare function resolveRoute(this: RoutingProxy, route: any, locale?: Locale): any;
/**
* Route config for vue-router v4
*/
declare interface Route {
export declare interface Route {
name?: string;

@@ -20,3 +411,3 @@ path: string;

*/
declare interface RouteLegacy extends Pick<_Route, Exclude<keyof _Route, 'children' | 'component'>> {
export declare interface RouteLegacy extends Pick<_Route, Exclude<keyof _Route, 'children' | 'component'>> {
chunkName?: string;

@@ -28,5 +419,141 @@ chunkNames?: Record<string, string>;

/**
* Resolver for route localizing options
*/
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
*/
export declare interface SeoAttributesOptions {
/**
* An array of strings corresponding to query params you would like to include in your canonical URL.
*
* @defaultValue []
*/
canonicalQueries?: string[];
}
/**
* Set a locale
*
* @param i18n - An [I18n](https://vue-i18n.intlify.dev/api/general.html#i18n) instance or a [Composer](https://vue-i18n.intlify.dev/api/composition.html#composer) instance
* @param locale - A target locale
*/
export declare function setLocale(i18n: I18n | Composer, locale: Locale): void;
declare const STRATEGIES: {
readonly PREFIX: "prefix";
readonly PREFIX_EXCEPT_DEFAULT: "prefix_except_default";
readonly PREFIX_AND_DEFAULT: "prefix_and_default";
readonly NO_PREFIX: "no_prefix";
};
/**
* Routing strategy
*/
export declare type Strategies = typeof STRATEGIES[keyof typeof STRATEGIES];
export declare function switchLocalePath(this: RoutingProxy, locale: Locale): string;
/**
* Swtich locale path function
*
* @param locale - A locale code, if not specified, uses the current locale
*
* @returns Returns a link to the current route in another language
*
* @see {@link useSwitchLocalePath}
*/
export declare type SwitchLocalePathFunction = (locale?: Locale) => string;
/**
* The target locale info
*
* @remarks
* This type is used by {@link BrowserLocaleMatcher} first argument
*/
export declare type TargetLocale = Required<Pick<LocaleObject, 'code' | 'iso'>>;
declare type UnionToIntersection<T> = (T extends any ? (k: T) => void : never) extends (k: infer U) => void ? U : never;
/**
* Use localize head meta
*
* @param options - An options, see about details {@link I18nHeadOptions}, {@link ComposableOptions}, {@link I18nCommonRoutingOptions}
*
* @returns Genereated SEO head meta information
*/
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

@@ -39,30 +566,49 @@ *

/**
* 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[];
hooks?: ExtendHooks;
};
/**
* Vue I18n routing options
* An options of Vue I18n Routing Plugin
*/
export declare interface VueI18nRoutingOptions {
export declare interface VueI18nRoutingPluginOptions {
/**
* Vue Router instance
* Whether to inject some option APIs style methods into Vue instance
*
* @defaultValue `true`
*/
router?: unknown;
/**
* Vue I18n instance
*/
i18n?: unknown;
defaultLocale?: string;
localeCodes?: string[];
trailingSlash?: boolean;
routesNameSeparator?: string;
defaultLocaleRouteNameSuffix?: string;
inject?: boolean;
}
export declare const VueI18nRoutingPlugin: (vueApp: any, { router, i18n, defaultLocale, trailingSlash, routesNameSeparator, defaultLocaleRouteNameSuffix, localeCodes }?: VueI18nRoutingOptions) => void;
export { }
import type { ComputedRef } from 'vue-demi'
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' {
// eslint-disable-next-line @typescript-eslint/no-empty-interface
export interface ComposerCustom extends ComposerCustomProperties {}
}
declare module 'vue-i18n-bridge' {
// 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 {}
}

@@ -20,19 +20,337 @@ var __defProp = Object.defineProperty;

var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
import { isVue2 } from "vue-demi";
const VUE_I18N_ROUTING_DEFAULTS = {
defaultLocale: "en-US",
trailingSlash: false,
routesNameSeparator: "___",
defaultLocaleRouteNameSuffix: "default"
var __objRest = (source, exclude) => {
var target = {};
for (var prop in source)
if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
target[prop] = source[prop];
if (source != null && __getOwnPropSymbols)
for (var prop of __getOwnPropSymbols(source)) {
if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
target[prop] = source[prop];
}
return target;
};
import { isRef, isVue2, effectScope, 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.35
* (c) 2022 kazuya kawaguchi
* Released under the MIT License.
*/
const hasSymbol = typeof Symbol === "function" && typeof Symbol.toStringTag === "symbol";
const makeSymbol = (name) => hasSymbol ? Symbol(name) : name;
const assign = Object.assign;
const isArray = Array.isArray;
const isFunction = (val) => typeof val === "function";
const isString = (val) => typeof val === "string";
const isBoolean = (val) => typeof val === "boolean";
const isSymbol = (val) => typeof val === "symbol";
const isObject = (val) => val !== null && typeof val === "object";
const TRAILING_SLASH_RE = /\/$|\/\?/;
function hasTrailingSlash(input = "", queryParams = false) {
if (!queryParams) {
return input.endsWith("/");
}
return TRAILING_SLASH_RE.test(input);
}
function withoutTrailingSlash(input = "", queryParams = false) {
if (!queryParams) {
return (hasTrailingSlash(input) ? input.slice(0, -1) : input) || "/";
}
if (!hasTrailingSlash(input, true)) {
return input || "/";
}
const [s0, ...s] = input.split("?");
return (s0.slice(0, -1) || "/") + (s.length ? `?${s.join("?")}` : "");
}
function withTrailingSlash(input = "", queryParams = false) {
if (!queryParams) {
return input.endsWith("/") ? input : input + "/";
}
if (hasTrailingSlash(input, true)) {
return input || "/";
}
const [s0, ...s] = input.split("?");
return s0 + "/" + (s.length ? `?${s.join("?")}` : "");
}
const inBrowser = typeof window !== "undefined";
function warn(msg, err) {
if (typeof console !== "undefined") {
console.warn(`[vue-i18n-routing] ` + msg);
if (err) {
console.warn(err.stack);
}
}
}
function getNormalizedLocales(locales) {
locales = locales || [];
const normalized = [];
for (const locale of locales) {
if (isString(locale)) {
normalized.push({ code: locale });
} else {
normalized.push(locale);
}
}
return normalized;
}
function isI18nInstance(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) {
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) {
const target = isI18nInstance(i18n) ? i18n.global : i18n;
if (isComposer(target)) {
if (isVue2 && isLegacyVueI18n(i18n)) {
i18n.locale = locale;
} else {
target.locale.value = locale;
}
} else if (isExportedGlobalComposer(target) || isVueI18n(target) || isLegacyVueI18n(target)) {
target.locale = locale;
} else {
throw new Error("TODO:");
}
}
function adjustRoutePathForTrailingSlash(pagePath, trailingSlash, isChildWithRelativePath) {
return pagePath.replace(/\/+$/, "") + (trailingSlash ? "/" : "") || (isChildWithRelativePath ? "" : "/");
}
function toRawRoute(maybeRoute) {
return isVueRouter4 ? isRef(maybeRoute) ? maybeRoute.value : maybeRoute : isRef(maybeRoute) ? maybeRoute.value : maybeRoute;
}
function getRouteName(routeName) {
return isString(routeName) ? routeName : isSymbol(routeName) ? routeName.toString() : "(null)";
}
function getLocaleRouteName(routeName, locale, {
defaultLocale,
strategy,
routesNameSeparator,
defaultLocaleRouteNameSuffix
}) {
let name = getRouteName(routeName) + (strategy === "no_prefix" ? "" : routesNameSeparator + locale);
if (locale === defaultLocale && strategy === "prefix_and_default") {
name += routesNameSeparator + defaultLocaleRouteNameSuffix;
}
return name;
}
function resolveBaseUrl(baseUrl, context) {
if (isFunction(baseUrl)) {
return baseUrl(context);
}
return baseUrl;
}
function matchBrowserLocale(locales, browserLocales) {
const matchedLocales = [];
for (const [index, browserCode] of browserLocales.entries()) {
const matchedLocale = locales.find((l) => l.iso.toLowerCase() === browserCode.toLowerCase());
if (matchedLocale) {
matchedLocales.push({ code: matchedLocale.code, score: 1 - index / browserLocales.length });
break;
}
}
for (const [index, browserCode] of browserLocales.entries()) {
const languageCode = browserCode.split("-")[0].toLowerCase();
const matchedLocale = locales.find((l) => l.iso.split("-")[0].toLowerCase() === languageCode);
if (matchedLocale) {
matchedLocales.push({ code: matchedLocale.code, score: 0.999 - index / browserLocales.length });
break;
}
}
return matchedLocales;
}
const DefaultBrowserLocaleMatcher = matchBrowserLocale;
function compareBrowserLocale(a, b) {
if (a.score === b.score) {
return b.code.length - a.code.length;
}
return b.score - a.score;
}
const DefaultBrowerLocaleComparer = compareBrowserLocale;
function findBrowserLocale(locales, browserLocales, { matcher = DefaultBrowserLocaleMatcher, comparer = DefaultBrowerLocaleComparer } = {}) {
const normalizedLocales = [];
for (const l of locales) {
const { code } = l;
const iso = l.iso || code;
normalizedLocales.push({ code, iso });
}
const matchedLocales = matcher(normalizedLocales, browserLocales);
if (matchedLocales.length > 1) {
matchedLocales.sort(comparer);
}
return matchedLocales.length ? matchedLocales[0].code : "";
}
const STRATEGIES = {
PREFIX: "prefix",
PREFIX_EXCEPT_DEFAULT: "prefix_except_default",
PREFIX_AND_DEFAULT: "prefix_and_default",
NO_PREFIX: "no_prefix"
};
const DEFAULT_LOCALE = "";
const DEFAULT_STRATEGY = STRATEGIES.PREFIX_EXCEPT_DEFAULT;
const DEFAULT_TRAILING_SLASH = false;
const DEFAULT_ROUTES_NAME_SEPARATOR = "___";
const DEFAULT_LOCALE_ROUTE_NAME_SUFFIX = "default";
const DEFAULT_DETECTION_DIRECTION = "ltr";
const DEFAULT_BASE_URL = "";
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, hooks = {} } = {}) {
const scope = effectScope();
const orgInstall = i18n.install;
i18n.install = (vue, ...options) => {
Reflect.apply(orgInstall, i18n, [vue, ...options]);
const composer = getComposer(i18n);
scope.run(() => extendComposer(composer, { locales, localeCodes, baseUrl, hooks }));
if (isVueI18n(i18n.global)) {
extendVueI18n(i18n.global, hooks.onExtendVueI18n);
}
const app = vue;
const exported = i18n.mode === "composition" ? isVue3 ? app.config.globalProperties.$i18n : i18n : isVue2 ? i18n : null;
if (exported) {
extendExportedGlobal(exported, composer, hooks.onExtendExportedGlobal);
}
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)
}
});
}
if (app.unmount) {
const unmountApp = app.unmount;
app.unmount = () => {
scope.stop();
unmountApp();
};
}
};
return scope;
}
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, {});
if (options.hooks && options.hooks.onExtendComposer) {
options.hooks.onExtendComposer(composer);
}
}
function extendExportedGlobal(exported, global, hook) {
const properties = [
{
locales: {
get() {
return global.locales.value;
}
},
localeCodes: {
get() {
return global.localeCodes.value;
}
},
__baseUrl: {
get() {
return global.__baseUrl;
}
}
}
];
hook && properties.push(hook(global));
for (const property of properties) {
for (const [key, descriptor] of Object.entries(property)) {
Object.defineProperty(exported, key, descriptor);
}
}
}
function extendVueI18n(vueI18n, hook) {
const composer = getComposer(vueI18n);
const properties = [
{
locales: {
get() {
return composer.locales.value;
}
},
localeCodes: {
get() {
return composer.localeCodes.value;
}
},
__baseUrl: {
get() {
return composer.__baseUrl;
}
}
}
];
hook && properties.push(hook(composer));
for (const property of properties) {
for (const [key, descriptor] of Object.entries(property)) {
Object.defineProperty(vueI18n, key, descriptor);
}
}
}
function isPluginOptions(options) {
return isObject(options) && "inject" in options && isBoolean(options.inject);
}
function localizeRoutes(routes, {
defaultLocale = VUE_I18N_ROUTING_DEFAULTS.defaultLocale,
trailingSlash = VUE_I18N_ROUTING_DEFAULTS.trailingSlash,
routesNameSeparator = VUE_I18N_ROUTING_DEFAULTS.routesNameSeparator,
defaultLocaleRouteNameSuffix = VUE_I18N_ROUTING_DEFAULTS.defaultLocaleRouteNameSuffix,
localeCodes = []
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) {

@@ -42,2 +360,9 @@ if (route.redirect && (!route.component || !route.file)) {

}
let routeOptions = null;
if (optionsResolver != null) {
routeOptions = optionsResolver(route, allowedLocaleCodes);
if (routeOptions == null) {
return [route];
}
}
const targetLocales = allowedLocaleCodes;

@@ -55,3 +380,3 @@ return targetLocales.reduce((_routes, locale) => {

const isDefaultLocale = locale === defaultLocale;
if (isDefaultLocale) {
if (isDefaultLocale && strategy === "prefix_and_default") {
if (!isChild) {

@@ -74,3 +399,3 @@ const defaultRoute = __spreadProps(__spreadValues({}, localizedRoute), { path });

const isChildWithRelativePath = isChild && !path.startsWith("/");
const shouldAddPrefix = !isChildWithRelativePath && !isDefaultLocale;
const shouldAddPrefix = !isChildWithRelativePath && !(isDefaultLocale && strategy === "prefix_except_default");
if (shouldAddPrefix) {

@@ -82,2 +407,5 @@ path = `/${locale}${path}`;

}
if (shouldAddPrefix && isDefaultLocale && strategy === "prefix" && includeUprefixedFallback) {
_routes.push(__spreadValues({}, route));
}
localizedRoute.path = path;

@@ -88,49 +416,537 @@ _routes.push(localizedRoute);

}
return routes.reduce((localized, route) => [...localized, ...makeLocalizedRoutes(route, localeCodes || [])], []);
return routes.reduce((localized, route) => [...localized, ...makeLocalizedRoutes(route, _localeCodes || [])], []);
}
const VueI18nRoutingPlugin = function(vueApp, {
router,
i18n,
defaultLocale = VUE_I18N_ROUTING_DEFAULTS.defaultLocale,
trailingSlash = VUE_I18N_ROUTING_DEFAULTS.trailingSlash,
routesNameSeparator = VUE_I18N_ROUTING_DEFAULTS.routesNameSeparator,
defaultLocaleRouteNameSuffix = VUE_I18N_ROUTING_DEFAULTS.defaultLocaleRouteNameSuffix,
const GlobalOptionsRegistory = makeSymbol("vue-i18n-routing-gor");
function registerGlobalOptions(router, options) {
const _options = router[GlobalOptionsRegistory];
if (_options) {
warn("already registered global options");
} else {
router[GlobalOptionsRegistory] = options;
}
}
function getGlobalOptions(router) {
var _a;
return (_a = router[GlobalOptionsRegistory]) != null ? _a : {};
}
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 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 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 = DEFAULT_TRAILING_SLASH,
localeCodes = []
} = {}) {
if (router == null) {
throw new Error("TODO");
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;
}
if (isVue2) {
const _router = router;
const VueRouter = _router.constructor;
const routes = _router.options.routes || [];
const localizedRoutes = localizeRoutes(routes, {
localeCodes,
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;
if (isString(route)) {
if (_route[0] === "/") {
_route = { path: route };
} else {
_route = { name: route };
}
}
let localizedRoute = assign({}, _route);
if (localizedRoute.path && !localizedRoute.name) {
const _resolvedRoute = router.resolve(localizedRoute);
const resolvedRoute2 = isVue3 ? _resolvedRoute : _resolvedRoute.route;
const resolvedRouteName = getRouteBaseName.call(this, resolvedRoute2);
if (isString(resolvedRouteName)) {
localizedRoute = {
name: getLocaleRouteName(resolvedRouteName, _locale, {
defaultLocale,
strategy,
routesNameSeparator,
defaultLocaleRouteNameSuffix
}),
params: resolvedRoute2.params,
query: resolvedRoute2.query,
hash: resolvedRoute2.hash
};
} else {
const isDefaultLocale = _locale === defaultLocale;
const isPrefixed = !(isDefaultLocale && RESOLVED_PREFIXED.has(strategy)) && !(strategy === STRATEGIES.NO_PREFIX);
if (isPrefixed) {
localizedRoute.path = `/${_locale}${localizedRoute.path}`;
}
localizedRoute.path = trailingSlash ? withTrailingSlash(localizedRoute.path, true) : withoutTrailingSlash(localizedRoute.path, true);
}
} else {
localizedRoute.name = getLocaleRouteName(localizedRoute.name, _locale, {
defaultLocale,
trailingSlash,
strategy,
routesNameSeparator,
defaultLocaleRouteNameSuffix
});
const newRouter = new VueRouter({ mode: "history", routes: [] });
_router.matcher = newRouter.matcher;
localizedRoutes.forEach((route) => {
_router.addRoute(route);
const { params } = localizedRoute;
if (params && params["0"] === void 0 && params.pathMatch) {
params["0"] = params.pathMatch;
}
}
const resolvedRoute = router.resolve(localizedRoute);
if (isVue3 ? resolvedRoute.name : resolvedRoute.route.name) {
return resolvedRoute;
}
return router.resolve(route);
}
function switchLocalePath(locale) {
const route = this.route;
const name = getRouteBaseName.call(this, route);
if (!name) {
return "";
}
const _a = !isVue3 && isRef(route) ? route.value : route, { params } = _a, routeCopy = __objRest(_a, ["params"]);
const langSwitchParams = {};
const baseRoute = assign({}, routeCopy, {
name,
params: __spreadProps(__spreadValues(__spreadValues({}, params), langSwitchParams), {
0: params.pathMatch
})
});
const path = localePath.call(this, baseRoute, locale);
return path;
}
function localeHead({ addDirAttribute = false, addSeoAttributes = false } = {}) {
const router = this.router;
const i18n = this.i18n;
const { defaultDirection } = getI18nRoutingOptions(router, this);
const metaObject = {
htmlAttrs: {},
link: [],
meta: []
};
if (i18n.locales == null || i18n.__baseUrl == null) {
return metaObject;
}
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 (addSeoAttributes && locale && i18n.locales) {
if (currentLocaleIso) {
metaObject.htmlAttrs.lang = currentLocaleIso;
}
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) {
const router = this.router;
const { defaultLocale, strategy } = getI18nRoutingOptions(router, this);
if (strategy === STRATEGIES.NO_PREFIX) {
return;
}
const localeMap = /* @__PURE__ */ new Map();
for (const locale of locales) {
const localeIso = locale.iso;
if (!localeIso) {
warn("Locale ISO code is required to generate alternate link");
continue;
}
const [language, region] = localeIso.split("-");
if (language && region && (locale.isCatchallLocale || !localeMap.has(language))) {
localeMap.set(language, locale);
}
localeMap.set(localeIso, locale);
}
for (const [iso, mapLocale] of localeMap.entries()) {
const localePath2 = switchLocalePath.call(this, mapLocale.code);
if (localePath2) {
link.push({
hid: `i18n-alt-${iso}`,
rel: "alternate",
href: toAbsoluteUrl(localePath2, baseUrl),
hreflang: iso
});
}
}
if (defaultLocale) {
const localePath2 = switchLocalePath.call(this, defaultLocale);
if (localePath2) {
link.push({
hid: "i18n-xd",
rel: "alternate",
href: toAbsoluteUrl(localePath2, baseUrl),
hreflang: "x-default"
});
}
}
}
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 = isObject(seoAttributesOptions) && seoAttributesOptions.canonicalQueries || [];
if (canonicalQueries.length) {
const currentRouteQueryParams = currentRoute.query;
const params = new URLSearchParams();
for (const queryParamName of canonicalQueries) {
if (queryParamName in currentRouteQueryParams) {
const queryParamValue = currentRouteQueryParams[queryParamName];
if (isArray(queryParamValue)) {
queryParamValue.forEach((v) => params.append(queryParamName, v || ""));
} else {
params.append(queryParamName, queryParamValue || "");
}
}
}
const queryString = params.toString();
if (queryString) {
href = `${href}?${queryString}`;
}
}
link.push({
hid: "i18n-can",
rel: "canonical",
href
});
} else {
const _router = router;
const routes = _router.options.routes || [];
const localizedRoutes = localizeRoutes(routes, {
localeCodes,
}
}
function addCurrentOgLocale(currentLocale, currentLocaleIso, meta) {
const hasCurrentLocaleAndIso = currentLocale && currentLocaleIso;
if (!hasCurrentLocaleAndIso) {
return;
}
meta.push({
hid: "i18n-og",
property: "og:locale",
content: hypenToUnderscore(currentLocaleIso)
});
}
function addAlternateOgLocales(locales, currentLocaleIso, meta) {
const localesWithoutCurrent = locales.filter((locale) => {
const localeIso = locale.iso;
return localeIso && localeIso !== currentLocaleIso;
});
if (localesWithoutCurrent.length) {
const alternateLocales = localesWithoutCurrent.map((locale) => ({
hid: `i18n-og-alt-${locale.iso}`,
property: "og:locale:alternate",
content: hypenToUnderscore(locale.iso)
}));
meta.push(...alternateLocales);
}
}
function hypenToUnderscore(str) {
return (str || "").replace(/-/g, "_");
}
function toAbsoluteUrl(urlOrPath, baseUrl) {
if (urlOrPath.match(/^https?:\/\//)) {
return urlOrPath;
}
return baseUrl + urlOrPath;
}
function proxyForComposable(options, target) {
const {
router,
route,
i18n,
defaultLocale,
strategy,
defaultLocaleRouteNameSuffix,
trailingSlash,
routesNameSeparator
} = options;
return function(...args) {
return Reflect.apply(target, {
router,
route,
i18n,
defaultLocale,
strategy,
defaultLocaleRouteNameSuffix,
trailingSlash,
routesNameSeparator,
defaultLocaleRouteNameSuffix
});
console.log("vue3 routes", routes, localizedRoutes);
routes.forEach((r) => _router.removeRoute(r.name));
localizedRoutes.forEach((route) => _router.addRoute(route));
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,
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
}, 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: []
});
function cleanMeta() {
metaObject.value = {
htmlAttrs: {},
link: [],
meta: []
};
}
console.log("install vue-i18n-rouging!", router, i18n, defaultLocale, trailingSlash, routesNameSeparator, defaultLocaleRouteNameSuffix, localeCodes);
};
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);
}
} else {
updateMeta(toRawRoute(_router.currentRoute));
}
return metaObject;
}
const VERSION = "0.0.0";
export { VERSION, VueI18nRoutingPlugin, localizeRoutes };
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,1 +0,5 @@

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

43

package.json
{
"name": "vue-i18n-routing",
"description": "The i18n routing with using vue-i18n",
"version": "0.0.0-d4abcf5",
"version": "0.0.0-d5a38c7",
"dependencies": {
"vue-demi": "*"
"@intlify/shared": "next",
"@intlify/vue-i18n-bridge": "^0.3.5",
"@intlify/vue-router-bridge": "^0.3.5",
"ufo": "^0.7.9",
"vue-demi": "^0.12.1"
},
"devDependencies": {
"vite": "^2.6.4",
"@microsoft/api-extractor": "^7.18.20",
"@vue/test-utils": "^1.3.0",
"api-docs-gen": "^0.4.0",
"rimraf": "^3.0.2",
"typescript": "^4.5.4",
"vite": "latest",
"vite-plugin-dts": "^0.9.6",
"vitest": "^0.2.8",
"vue": "^3.2.23",
"vue-i18n": "npm:vue-i18n@next",
"vue-i18n-bridge": "next",
"vue-i18n-legacy": "npm:vue-i18n@8",
"vue-router": "^4.0.12",
"vue2": "npm:vue@2",
"vue-router3": "npm:vue-router@latest",
"rimraf": "^3.0.2",
"@microsoft/api-extractor": "^7.18.20",
"api-docs-gen": "^0.4.0"
"vue-router3": "npm:vue-router@3",
"vue-template-compiler": "^2.6.14",
"vue2": "npm:vue@2"
},

@@ -22,2 +33,4 @@ "peerDependencies": {

"vue": "^2.6.14 || ^3.2.0",
"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"

@@ -39,2 +52,3 @@ },

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

@@ -54,4 +68,10 @@ "README.md"

},
"require": "./dist/vue-i18n-routing.cjs.js"
}
"require": "./dist/vue-i18n-routing.cjs.js",
"types": "./dist/vue-i18n-routing.d.ts"
},
"./types": {
"types": "./types.d.ts"
},
"./package.json": "./package.json",
"./dist/*": "./dist/*"
},

@@ -83,4 +103,7 @@ "license": "MIT",

"typecheck": "tsc -p . --noEmit",
"test": "vitest run",
"test:watch": "vitest",
"test:cover": "vitest --coverage",
"build:docs": "api-docs-gen ./temp/vue-i18n-routing.api.json -c ./docsgen.config.js -o ./ -g noprefix"
}
}

Sorry, the diff of this file is not supported yet

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