vue-i18n-routing
Advanced tools
Comparing version 0.0.0-1a08f42 to 0.0.0-1ba106d
@@ -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 l in e)G.call(e,l)&&t.indexOf(l)<0&&(a[l]=e[l]);if(e!=null&&F)for(var l of F(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 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);/*! | ||
* shared v9.2.0-beta.30 | ||
"use strict";var De=Object.defineProperty,Oe=Object.defineProperties;var be=Object.getOwnPropertyDescriptors;var N=Object.getOwnPropertySymbols;var ue=Object.prototype.hasOwnProperty,ie=Object.prototype.propertyIsEnumerable;var se=(e,t,o)=>t in e?De(e,t,{enumerable:!0,configurable:!0,writable:!0,value:o}):e[t]=o,I=(e,t)=>{for(var o in t||(t={}))ue.call(t,o)&&se(e,o,t[o]);if(N)for(var o of N(t))ie.call(t,o)&&se(e,o,t[o]);return e},w=(e,t)=>Oe(e,be(t));var fe=(e,t)=>{var o={};for(var n in e)ue.call(e,n)&&t.indexOf(n)<0&&(o[n]=e[n]);if(e!=null&&N)for(var n of N(e))t.indexOf(n)<0&&ie.call(e,n)&&(o[n]=e[n]);return o};Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});var d=require("vue-demi"),L=require("@intlify/vue-router-bridge"),U=require("@intlify/vue-i18n-bridge");function xe(e){return e&&typeof e=="object"&&"default"in e?e:{default:e}}var Ue=xe(L);const P={PREFIX:"prefix",PREFIX_EXCEPT_DEFAULT:"prefix_except_default",PREFIX_AND_DEFAULT:"prefix_and_default",NO_PREFIX:"no_prefix"},$="",V=P.PREFIX_EXCEPT_DEFAULT,B=!1,j="___",G="default",ee="ltr",te="";/*! | ||
* shared v9.2.0-beta.35 | ||
* (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,...l]=e.split("?");return(a.slice(0,-1)||"/")+(l.length?`?${l.join("?")}`:"")}function Le(e="",t=!1){if(!t)return e.endsWith("/")?e:e+"/";if(w(e,!0))return e||"/";const[a,...l]=e.split("?");return a+"/"+(l.length?`?${l.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:l,routesNameSeparator:o,defaultLocaleRouteNameSuffix:n}){let r=ee(e)+(l==="no_prefix"?"":o+t);return t===a&&l==="prefix_and_default"&&(r+=o+n),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 U(e=A.useRoute(),{router:t=A.useRouter(),routesNameSeparator:a=b}={}){const l=a||t.__routesNameSeparator,o=R.unref(e);return o.name?ee(o.name).split(l)[0]:null}function le(e,t,a){const l=z(e,t,a);return l==null?"":R.isVue3?l.redirectedFrom||l.fullPath:l.route.redirectedFrom||l.route.fullPath}function ne(e,t,a){const l=z(e,t,a);return l==null?void 0:R.isVue3?l:l.route}function Ie(e,t,a){const l=z(e,t,a);return l==null?void 0:R.isVue3?l:l.location}function z(e,t,{router:a=A.useRouter(),i18n:l=Y.useI18n(),defaultLocale:o=x,defaultLocaleRouteNameSuffix:n=q,routesNameSeparator:r=b,strategy:i=$,trailingSlash:f=!1}={}){const s=a.__defaultLocaleRouteNameSuffix||n,h=a.__defaultLocale||o,c=a.__routesNameSeparator||r,_=a.__strategy||i,m=t||M(l);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=U(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(),l=U(a,t);if(!l)return"";const s=!R.isVue3&&R.isRef(a)?a.value:a,{params:o}=s,n=W(s,["params"]),r={},i=J({},n,{name:l,params:N(I(I({},o),r),{0:o.pathMatch})});return le(i,e,t)}function Te({addDirAttribute:e=!1,addSeoAttributes:t=!1,strategy:a=$,defaultLocale:l=x,route:o=A.useRoute(),router:n=A.useRouter(),i18n:r=Y.useI18n()}={}){const i=l||n.__defaultLocale,f=a||n.__strategy,s=R.ref({htmlAttrs:{},link:[],meta:[]});function h(){s.value={htmlAttrs:{},link:[],meta:[]}}function c(_){if(r.locales==null||r.__baseUrl==null)return;const m=M(r),g=K(r.locales.value).find(u=>u.code===m)||{code:m},d=g.iso,v=g.dir||n.__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:n,i18n:r}),De(r.__baseUrl,s.value.link,t,{route:_,router:n,i18n:r}),Fe(g,d,s.value.meta),Ne(u,d,s.value.meta)}}return R.watch(n.currentRoute,_=>{h(),c(_)}),c(o),s}function Pe(e,t,a,l){if(l.strategy===D.NO_PREFIX)return;const o=new Map;for(const n of e){const r=n.iso;if(!r){Ee("Locale ISO code is required to generate alternate link");continue}const[i,f]=r.split("-");i&&f&&(n.isCatchallLocale||!o.has(i))&&o.set(i,n),o.set(r,n)}for(const[n,r]of o.entries()){const i=C(r.code,l);i&&a.push({hid:`i18n-alt-${n}`,rel:"alternate",href:V(i,t),hreflang:n})}if(l.defaultLocale){const n=C(l.defaultLocale,l);n&&a.push({hid:"i18n-xd",rel:"alternate",href:V(n,t),hreflang:"x-default"})}}function De(e,t,a,l){const{route:o}=l,n=ne(N(I({},o),{name:U(o,l)}),void 0,l);if(n){let r=V(n.path,e);const i=!_e(a)&&a.canonicalQueries||[];if(i.length){const f=n.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 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:oe(n.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:l=te,routesNameSeparator:o=b,defaultLocaleRouteNameSuffix:n=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,O)=>[...y,...h(O,[L],!0,g)],[]));const T=L===t;if(T&&a==="prefix_and_default")if(m)m&&g&&S&&(p.name+=`${o}${n}`);else{const y=N(I({},p),{path:E});if(S&&(y.name=`${p.name}${o}${n}`),c.children){y.children=[];for(const O of c.children)y.children=y.children.concat(h(O,[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,l,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 l=R.ref(t);e.global.locales=R.computed(()=>l.value),e.global.__baseUrl=Se(a,{})}function $e(e){return new RegExp(`^/(${e.join("|")})(?:/|$)`,"i")}function be(e,t,a){const l=`(${e.join("|")})`,o=`(?:${t}${a})?`,n=new RegExp(`${t}${l}${o}$`,"i"),r=$e(e);return f=>{if(f.name){const h=(P(f.name)?f.name:f.name.toString()).match(n);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 Ue(e){var t,a,l,o,n,r,i,f,s,h;return e.version=(t=e.version)!=null?t:4,e.defaultLocale=(a=e.defaultLocale)!=null?a:x,e.strategy=(l=e.strategy)!=null?l:$,e.trailingSlash=(o=e.trailingSlash)!=null?o:te,e.routesNameSeparator=(n=e.routesNameSeparator)!=null?n: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 Oe(e,t={}){const{version:a,defaultLocale:l,locales:o,strategy:n,trailingSlash:r,routesNameSeparator:i,defaultLocaleRouteNameSuffix:f,defaultDirection:s,baseUrl:h,routes:c,routeOptionsResolver:_}=Ue(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:l,strategy:n,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=l,u.__localeCodes=g,u.__strategy=n,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||l||"";p!==T&&pe(e,T),E()}),u}const we="0.0.0";exports.VERSION=we;exports.createRouter=Oe;exports.getRouteBaseName=U;exports.localeLocation=Ie;exports.localePath=le;exports.localeRoute=ne;exports.localizeRoutes=re;exports.switchLocalePath=C;exports.useI18nHead=Te; | ||
*/const Ce=typeof Symbol=="function"&&typeof Symbol.toStringTag=="symbol",Fe=e=>Ce?Symbol(e):e,me=Object.assign,Ne=Array.isArray,we=e=>typeof e=="function",T=e=>typeof e=="string",$e=e=>typeof e=="boolean",Ve=e=>typeof e=="symbol",oe=e=>e!==null&&typeof e=="object",Be=/\/$|\/\?/;function J(e="",t=!1){return t?Be.test(e):e.endsWith("/")}function je(e="",t=!1){if(!t)return(J(e)?e.slice(0,-1):e)||"/";if(!J(e,!0))return e||"/";const[o,...n]=e.split("?");return(o.slice(0,-1)||"/")+(n.length?`?${n.join("?")}`:"")}function Ge(e="",t=!1){if(!t)return e.endsWith("/")?e:e+"/";if(J(e,!0))return e||"/";const[o,...n]=e.split("?");return o+"/"+(n.length?`?${n.join("?")}`:"")}const Xe=typeof window!="undefined";function Le(e,t){typeof console!="undefined"&&(console.warn("[vue-i18n-routing] "+e),t&&console.warn(t.stack))}function pe(e){e=e||[];const t=[];for(const o of e)T(o)?t.push({code:o}):t.push(o);return t}function X(e){return e!=null&&"global"in e&&"mode"in e}function M(e){return e!=null&&!("__composer"in e)&&d.isRef(e.locale)}function C(e){return e!=null&&"__composer"in e}function ne(e){return e!=null&&!("__composer"in e)&&!d.isRef(e.locale)}function D(e){return e!=null&&("__VUE_I18N_BRIDGE__"in e||"_sync"in e)}function Re(e){return X(e)?M(e.global)?e.global:e.global.__composer:C(e)?e.__composer:e}function k(e){const t=X(e)?e.global:e;return M(t)?d.isVue2&&D(e)?e.locale:t.locale.value:(ne(t)||C(t)||D(t),t.locale)}function Me(e){const t=X(e)?e.global:e;return M(t)?d.isVue2&&D(e)?e.locales:t.locales.value:(ne(t)||C(t)||D(t),t.locales)}function ge(e,t){const o=X(e)?e.global:e;if(M(o))d.isVue2&&D(e)?e.locale=t:o.locale.value=t;else if(ne(o)||C(o)||D(o))o.locale=t;else throw new Error("TODO:")}function ke(e,t,o){return e.replace(/\/+$/,"")+(t?"/":"")||(o?"":"/")}function de(e){return L.isVueRouter4,d.isRef(e)?e.value:e}function _e(e){return T(e)?e:Ve(e)?e.toString():"(null)"}function he(e,t,{defaultLocale:o,strategy:n,routesNameSeparator:l,defaultLocaleRouteNameSuffix:a}){let r=_e(e)+(n==="no_prefix"?"":l+t);return t===o&&n==="prefix_and_default"&&(r+=l+a),r}function Ee(e,t){return we(e)?e(t):e}function ze(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 He=ze;function qe(e,t){return e.score===t.score?t.code.length-e.code.length:t.score-e.score}const We=qe;function Qe(e,t,{matcher:o=He,comparer:n=We}={}){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:""}function S(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 Se(e,{locales:t=[],localeCodes:o=[],baseUrl:n=te,hooks:l={}}={}){const a=d.effectScope(),r=e.install;return e.install=(c,...s)=>{Reflect.apply(r,e,[c,...s]);const i=Re(e);a.run(()=>Ye(i,{locales:t,localeCodes:o,baseUrl:n,hooks:l})),C(e.global)&&Ke(e.global,l.onExtendVueI18n);const f=c,u=e.mode==="composition"?d.isVue3?f.config.globalProperties.$i18n:e:d.isVue2?e:null;if(u&&Je(u,i,l.onExtendExportedGlobal),(Ze(s[0])?s[0]:{inject:!0}).inject&&c.mixin({methods:{resolveRoute:S(F),localePath:S(H),localeRoute:S(q),localeLocation:S(ae),switchLocalePath:S(x),getRouteBaseName:S(O),localeHead:S(le)}}),f.unmount){const h=f.unmount;f.unmount=()=>{a.stop(),h()}}},a}function Ye(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=Ee(l,{}),t.hooks&&t.hooks.onExtendComposer&&t.hooks.onExtendComposer(e)}function Je(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 Ke(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,r]of Object.entries(l))Object.defineProperty(e,a,r)}function Ze(e){return oe(e)&&"inject"in e&&$e(e.inject)}function ve(e,{defaultLocale:t=$,strategy:o=V,trailingSlash:n=B,routesNameSeparator:l=j,defaultLocaleRouteNameSuffix:a=G,includeUprefixedFallback:r=!1,optionsResolver:c=void 0,locales:s=[]}={}){if(o==="no_prefix")return e;const i=s.map(u=>T(u)?u:u.code);function f(u,m,h=!1,p=!1){if(u.redirect&&(!u.component||!u.file))return[u];let v=null;return c!=null&&(v=c(u,m),v==null)?[u]:m.reduce((_,E)=>{const{name:b}=u;let{path:R}=u;const g=I({},u);b&&(g.name=`${b}${l}${E}`),u.children&&(g.children=u.children.reduce((A,Y)=>[...A,...f(Y,[E],!0,p)],[]));const y=E===t;if(y&&o==="prefix_and_default")if(h)h&&p&&b&&(g.name+=`${l}${a}`);else{const A=w(I({},g),{path:R});if(b&&(A.name=`${g.name}${l}${a}`),u.children){A.children=[];for(const Y of u.children)A.children=A.children.concat(f(Y,[E],!0,!0))}_.push(A)}const re=h&&!R.startsWith("/"),ce=!re&&!(y&&o==="prefix_except_default");return ce&&(R=`/${E}${R}`),R&&(R=ke(R,n,re)),ce&&y&&o==="prefix"&&r&&_.push(I({},u)),g.path=R,_.push(g),_},[])}return e.reduce((u,m)=>[...u,...f(m,i||[])],[])}const K=Fe("vue-i18n-routing-gor");function Ae(e,t){e[K]?Le("already registered global options"):e[K]=t}function Ie(e){var t;return(t=e[K])!=null?t:{}}function et(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=pe(l),p=h.map(E=>E.code),v=ye(p,c,s);Se(e,{locales:h,baseUrl:f,localeCodes:p});const Q=ve(u,{locales:l,defaultLocale:n,strategy:a,trailingSlash:r,routesNameSeparator:c,defaultLocaleRouteNameSuffix:s,optionsResolver:m});t.routes=Q;const _=tt(t,o);return Ae(_,{defaultLocale:n,localeCodes:p,strategy:a,trailingSlash:r,routesNameSeparator:c,defaultLocaleRouteNameSuffix:s,defaultDirection:i}),_.beforeEach((E,b,R)=>{const g=k(e),y=v(E)||g||n||"";g!==y&&ge(e,y),R()}),_}function tt(e,t){if(d.isVue3&&t===4)return L.createRouter(e);if(d.isVue2&&t===3)return new Ue.default(e);throw new Error("TODO:")}function Te(e){return new RegExp(`^/(${e.join("|")})(?:/|$)`,"i")}function ye(e,t,o){const n=`(${e.join("|")})`,l=`(?:${t}${o})?`,a=new RegExp(`${t}${n}${l}$`,"i"),r=Te(e);return s=>{if(oe(s)){if(s.name){const f=(T(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(T(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:$,e.strategy=(n=e.strategy)!=null?n:V,e.trailingSlash=(l=e.trailingSlash)!=null?l:B,e.routesNameSeparator=(a=e.routesNameSeparator)!=null?a:j,e.defaultLocaleRouteNameSuffix=(r=e.defaultLocaleRouteNameSuffix)!=null?r:G,e.locales=(c=e.locales)!=null?c:[],e.defaultDirection=(s=e.defaultDirection)!=null?s:ee,e.baseUrl=(i=e.baseUrl)!=null?i:te,e.routes=(f=e.routes)!=null?f:[],e}function z(e,t,{defaultLocale:o=$,defaultDirection:n=ee,defaultLocaleRouteNameSuffix:l=G,routesNameSeparator:a=j,strategy:r=V,trailingSlash:c=B,localeCodes:s=[]}={}){const i=Ie(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([P.PREFIX_AND_DEFAULT,P.PREFIX_EXCEPT_DEFAULT]);function O(e){const t=this.router,{routesNameSeparator:o}=z(t,this),n=e!=null?d.isRef(e)?d.unref(e):e:this.route;return n.name?_e(n.name).split(o)[0]:void 0}function H(e,t){const o=F.call(this,e,t);return o==null?"":d.isVue3?o.redirectedFrom||o.fullPath:o.route.redirectedFrom||o.route.fullPath}function q(e,t){const o=F.call(this,e,t);return o==null?void 0:d.isVue3?o:o.route}function ae(e,t){const o=F.call(this,e,t);return o==null?void 0:d.isVue3?o:o.location}function F(e,t){const o=this.router,n=this.i18n,l=t||k(n),{routesNameSeparator:a,defaultLocale:r,defaultLocaleRouteNameSuffix:c,strategy:s,trailingSlash:i}=z(o,this);let f=e;T(e)&&(f[0]==="/"?f={path:e}:f={name:e});let u=me({},f);if(u.path&&!u.name){const h=o.resolve(u),p=d.isVue3?h:h.route,v=O.call(this,p);T(v)?u={name:he(v,l,{defaultLocale:r,strategy:s,routesNameSeparator:a,defaultLocaleRouteNameSuffix:c}),params:p.params,query:p.query,hash:p.hash}:(!(l===r&&nt.has(s))&&s!==P.NO_PREFIX&&(u.path=`/${l}${u.path}`),u.path=i?Ge(u.path,!0):je(u.path,!0))}else{u.name=he(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 x(e){const t=this.route,o=O.call(this,t);if(!o)return"";const s=!d.isVue3&&d.isRef(t)?t.value:t,{params:n}=s,l=fe(s,["params"]),a={},r=me({},l,{name:o,params:w(I(I({},n),a),{0:n.pathMatch})});return H.call(this,r,e)}function le({addDirAttribute:e=!1,addSeoAttributes:t=!1}={}){const o=this.router,n=this.i18n,{defaultDirection:l}=z(o,this),a={htmlAttrs:{},link:[],meta:[]};if(n.locales==null||n.__baseUrl==null)return a;const r=k(n),c=Me(n),s=pe(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}=z(n,this);if(a===P.NO_PREFIX)return;const r=new Map;for(const c of e){const s=c.iso;if(!s){Le("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=x.call(this,s.code);i&&o.push({hid:`i18n-alt-${c}`,rel:"alternate",href:Z(i,t),hreflang:c})}if(l){const c=x.call(this,l);c&&o.push({hid:"i18n-xd",rel:"alternate",href:Z(c,t),hreflang:"x-default"})}}function lt(e,t,o){const n=this.route,l=q.call(this,w(I({},n),{name:O.call(this,n)}));if(l){let a=Z(l.path,e);const r=oe(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];Ne(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:Pe(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:Pe(a.iso)}));o.push(...l)}}function Pe(e){return(e||"").replace(/-/g,"_")}function Z(e,t){return e.match(/^https?:\/\//)?e:t+e}function W(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=L.useRoute(),{router:t=L.useRouter(),routesNameSeparator:o=void 0}={}){const n={router:t,route:e,routesNameSeparator:o};return O.call(n,e)}function ut({router:e=L.useRouter(),route:t=L.useRoute(),i18n:o=U.useI18n(),defaultLocale:n=void 0,defaultLocaleRouteNameSuffix:l=void 0,routesNameSeparator:a=void 0,strategy:r=void 0,trailingSlash:c=void 0}={}){return W({router:e,route:t,i18n:o,defaultLocale:n,defaultLocaleRouteNameSuffix:l,routesNameSeparator:a,strategy:r,trailingSlash:c},H)}function it({router:e=L.useRouter(),route:t=L.useRoute(),i18n:o=U.useI18n(),defaultLocale:n=void 0,defaultLocaleRouteNameSuffix:l=void 0,routesNameSeparator:a=void 0,strategy:r=void 0,trailingSlash:c=void 0}={}){return W({router:e,route:t,i18n:o,defaultLocale:n,defaultLocaleRouteNameSuffix:l,routesNameSeparator:a,strategy:r,trailingSlash:c},q)}function ft({router:e=L.useRouter(),route:t=L.useRoute(),i18n:o=U.useI18n(),defaultLocale:n=void 0,defaultLocaleRouteNameSuffix:l=void 0,routesNameSeparator:a=void 0,strategy:r=void 0,trailingSlash:c=void 0}={}){return W({router:e,route:t,i18n:o,defaultLocale:n,defaultLocaleRouteNameSuffix:l,routesNameSeparator:a,strategy:r,trailingSlash:c},ae)}function dt({router:e=L.useRouter(),route:t=L.useRoute(),i18n:o=U.useI18n(),defaultLocale:n=void 0,defaultLocaleRouteNameSuffix:l=void 0,routesNameSeparator:a=void 0,strategy:r=void 0,trailingSlash:c=void 0}={}){return W({router:e,route:t,i18n:o,defaultLocale:n,defaultLocaleRouteNameSuffix:l,routesNameSeparator:a,strategy:r,trailingSlash:c},x)}function ht({addDirAttribute:e=!1,addSeoAttributes:t=!1,strategy:o=void 0,defaultLocale:n=void 0,route:l=L.useRoute(),router:a=L.useRouter(),i18n:r=U.useI18n()}={}){const c=a,s=d.ref({htmlAttrs:{},link:[],meta:[]});function i(){s.value={htmlAttrs:{},link:[],meta:[]}}function f(u){s.value=Reflect.apply(le,{router:a,route:u,i18n:r,defaultLocale:n,strategy:o},[{addDirAttribute:e,addSeoAttributes:t}])}if(Xe)if(d.isVue3){const u=d.watchEffect(()=>{i(),f(de(c.currentRoute))});d.onUnmounted(()=>u())}else{const u=c.afterEach((m,h)=>{i(),f(m)});d.onUnmounted(()=>u()),f(l)}else f(de(c.currentRoute));return s}const mt="0.0.0";exports.DEFAULT_BASE_URL=te;exports.DEFAULT_DETECTION_DIRECTION=ee;exports.DEFAULT_LOCALE=$;exports.DEFAULT_LOCALE_ROUTE_NAME_SUFFIX=G;exports.DEFAULT_ROUTES_NAME_SEPARATOR=j;exports.DEFAULT_STRATEGY=V;exports.DEFAULT_TRAILING_SLASH=B;exports.STRATEGIES=P;exports.VERSION=mt;exports.createLocaleFromRouteGetter=ye;exports.createRouter=et;exports.extendI18n=Se;exports.findBrowserLocale=Qe;exports.getGlobalOptions=Ie;exports.getLocale=k;exports.getLocalesRegex=Te;exports.getRouteBaseName=O;exports.localeHead=le;exports.localeLocation=ae;exports.localePath=H;exports.localeRoute=q;exports.localizeRoutes=ve;exports.proxyVueInstance=S;exports.registerGlobalOptions=Ae;exports.resolveBaseUrl=Ee;exports.resolveRoute=F;exports.setLocale=ge;exports.switchLocalePath=x;exports.useLocaleHead=ht;exports.useLocaleLocation=ft;exports.useLocalePath=ut;exports.useLocaleRoute=it;exports.useRouteBaseName=st;exports.useSwitchLocalePath=dt; |
@@ -1,2 +0,3 @@ | ||
import { Composer } from '@intlify/vue-i18n-bridge'; | ||
import type { Composer } from '@intlify/vue-i18n-bridge'; | ||
import { EffectScope } from 'vue-demi'; | ||
import type { I18n } from '@intlify/vue-i18n-bridge'; | ||
@@ -6,6 +7,7 @@ import type { Locale } from '@intlify/vue-i18n-bridge'; | ||
import type { Ref } from 'vue-demi'; | ||
import type { Route as Route_2 } from '@intlify/vue-router-bridge'; | ||
import { Route } from '@intlify/vue-router-bridge'; | ||
import type { RouteConfig } from '@intlify/vue-router-bridge'; | ||
import type { RouteLocation } from '@intlify/vue-router-bridge'; | ||
import type { RouteLocationNormalizedLoaded } from '@intlify/vue-router-bridge'; | ||
import { RouteLocationNormalized } from '@intlify/vue-router-bridge'; | ||
import { RouteLocationNormalizedLoaded } from '@intlify/vue-router-bridge'; | ||
import type { RouteLocationRaw } from '@intlify/vue-router-bridge'; | ||
@@ -16,6 +18,40 @@ import type { Router } 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 type BaseUrlResolveHandler = (context: unknown) => string; | ||
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 = { | ||
@@ -38,2 +74,4 @@ route?: ReturnType<typeof useRoute>; | ||
export declare function createLocaleFromRouteGetter(localeCodes: string[], routesNameSeparator: string, defaultLocaleRouteNameSuffix: string): (route: Route | RouteLocationNormalizedLoaded | RouteLocationNormalized | string) => string; | ||
/** | ||
@@ -43,3 +81,3 @@ * 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 VueI18nRoutingOptions} | ||
* @param options - An options, see {@link I18nRoutingOptions} | ||
* | ||
@@ -57,4 +95,18 @@ * @returns A Vue Router instance | ||
*/ | ||
export declare function createRouter<Options extends VueI18nRoutingOptions = VueI18nRoutingOptions>(i18n: I18n, options?: Options): Options['version'] extends 4 ? Router : VueRouter; | ||
export declare function createRouter<Options extends I18nRoutingOptions = I18nRoutingOptions>(i18n: I18n, options?: Options): Options['version'] extends 4 ? Router : VueRouter; | ||
export declare const DEFAULT_BASE_URL = ""; | ||
export declare const DEFAULT_DETECTION_DIRECTION = "ltr"; | ||
export declare const DEFAULT_LOCALE = ""; | ||
export declare const DEFAULT_LOCALE_ROUTE_NAME_SUFFIX = "default"; | ||
export declare const DEFAULT_ROUTES_NAME_SEPARATOR = "___"; | ||
export declare const DEFAULT_STRATEGY: "prefix_except_default"; | ||
export declare const DEFAULT_TRAILING_SLASH = false; | ||
/** | ||
@@ -65,13 +117,66 @@ * Direction | ||
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; | ||
/** | ||
* Get route base name | ||
* Find the browser locale | ||
* | ||
* @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} | ||
* @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 route base name, if route name is not defined, return null | ||
* @returns The matched the locale code | ||
*/ | ||
export declare function getRouteBaseName(givenRoute?: Route_2 | RouteLocationNormalizedLoaded, { router, routesNameSeparator }?: I18nRoutingOptions): string | null; | ||
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 getLocalesRegex(localeCodes: string[]): RegExp; | ||
export declare function getRouteBaseName(this: RoutingProxy, givenRoute?: Route | 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 | ||
@@ -86,3 +191,3 @@ */ | ||
/** | ||
* Options for {@link useI18nHead} function | ||
* Options for {@link localeHead} function | ||
*/ | ||
@@ -105,17 +210,130 @@ export declare interface I18nHeadOptions { | ||
/** | ||
* Options for vue-i18n-routing common | ||
* Route config for vue-i18n-routing | ||
*/ | ||
export declare type I18nRoutingOptions = Pick<VueI18nRoutingOptions, 'defaultLocale' | 'strategy' | 'defaultLocaleRouteNameSuffix' | 'trailingSlash' | 'locales' | 'routesNameSeparator'> & ComposableOptions; | ||
export declare type I18nRoute = Route_2 & RouteLegacy & { | ||
redirect?: string; | ||
}; | ||
/** | ||
* Resolve locale location | ||
* Global options for i18n routing | ||
*/ | ||
export declare type I18nRoutingGlobalOptions<BaseUrl extends BaseUrlResolveHandler = BaseUrlResolveHandler> = Pick<I18nRoutingOptions<BaseUrl>, 'defaultLocale' | 'defaultDirection' | 'defaultLocaleRouteNameSuffix' | 'trailingSlash' | 'routesNameSeparator' | 'strategy'> & { | ||
localeCodes?: string[]; | ||
}; | ||
/** | ||
* Options to initialize a VueRouter instance | ||
* | ||
* @remarks | ||
* This options is extended from Vue Router `RouterOptioins`, so you can specify those options. | ||
*/ | ||
export declare type I18nRoutingOptions<BaseUrl extends BaseUrlResolveHandler = BaseUrlResolveHandler> = { | ||
/** | ||
* Vue Router version | ||
* | ||
* @remarks | ||
* You can choice between vue-router v3 and v4. | ||
* | ||
* If you specify `3`, this function return Vue Router v3 instance, else specify `4`, this function return Vue Router v4 instance. | ||
* | ||
* @defaultValue 4 | ||
*/ | ||
version?: 3 | 4; | ||
/** | ||
* The app's default locale | ||
* | ||
* @remarks | ||
* When using `prefix_except_default` strategy, URLs for locale specified here won't have a prefix. | ||
* | ||
* It's recommended to set this to some locale regardless of chosen strategy, as it will be used as a fallback locale when navigating to a non-existent route | ||
* | ||
* @defaultValue '' (emputy string) | ||
*/ | ||
defaultLocale?: string; | ||
/** | ||
* List of locales supported by your app | ||
* | ||
* @remarks | ||
* Can either be an array of string codes (e.g. `['en', 'fr']`) or an array of {@link LocaleObject} for more complex configurations | ||
* | ||
* @defaultValue [] | ||
*/ | ||
locales?: string[] | LocaleObject[]; | ||
/** | ||
* Routes strategy | ||
* | ||
* @remarks | ||
* Can be set to one of the following: | ||
* | ||
* - `no_prefix`: routes won't have a locale prefix | ||
* - `prefix_except_default`: locale prefix added for every locale except default | ||
* - `prefix`: locale prefix added for every locale | ||
* - `prefix_and_default`: locale prefix added for every locale and default | ||
* | ||
* @defaultValue 'prefix_except_default' | ||
*/ | ||
strategy?: Strategies; | ||
/** | ||
* Whether to use trailing slash | ||
* | ||
* @defaultValue false | ||
*/ | ||
trailingSlash?: boolean; | ||
/** | ||
* Internal separator used for generated route names for each locale. You shouldn't need to change this | ||
* | ||
* @defaultValue '___' | ||
*/ | ||
routesNameSeparator?: string; | ||
/** | ||
* Internal suffix added to generated route names for default locale | ||
* | ||
* @remarks | ||
* if strategy is prefix_and_default. You shouldn't need to change this. | ||
* | ||
* @defaultValue 'default' | ||
*/ | ||
defaultLocaleRouteNameSuffix?: string; | ||
/** | ||
* Default direction direction | ||
* | ||
* @defaultValue 'ltr' | ||
*/ | ||
defaultDirection?: Directions; | ||
/** | ||
* The fallback base URL to use as a prefix for alternate URLs in hreflang tags. | ||
* | ||
* @remarks | ||
* By default VueRouter's base URL will be used and only if that is not available, fallback URL will be used. | ||
* | ||
* Can also be a function (will be passed a Nuxt Context as a parameter) that returns a string. | ||
* | ||
* Useful to make base URL dynamic based on request headers. | ||
* | ||
* @defaultValue '' | ||
*/ | ||
baseUrl?: string | BaseUrl; | ||
/** | ||
* Route options resolver | ||
* | ||
* @defaultValue undefined | ||
*/ | ||
routeOptionsResolver?: RouteOptionsResolver; | ||
} & RouterOptions; | ||
export declare function localeHead(this: RoutingProxy, { addDirAttribute, addSeoAttributes }?: I18nHeadOptions): I18nHeadMetaInfo; | ||
export declare function localeLocation(this: RoutingProxy, route: RawLocation | RouteLocationRaw, locale?: Locale): Location | RouteLocation | undefined; | ||
/** | ||
* Resolve locale location function | ||
* | ||
* @param route - A route location. The path or name of the route or an object for more complex routes | ||
* @param locale - A locale code, if not specified, uses the current locale | ||
* @param options - An options, see about details {@link I18nRoutingOptions} | ||
* | ||
* @returns Returns the location object for a given route, the location object is resolved by vue-router rather than just a full route path. | ||
* | ||
* @see {@link useLocaleLocation} | ||
*/ | ||
export declare function localeLocation(route: RawLocation | RouteLocationRaw, locale?: Locale, // TODO: locale should be more type inference (completion) | ||
options?: I18nRoutingOptions): Location | RouteLocation | undefined; | ||
export declare type LocaleLocationFunction = (route: RawLocation | RouteLocationRaw, locale?: Locale) => Location | RouteLocation | undefined; | ||
@@ -135,25 +353,29 @@ /** | ||
export declare function localePath(this: RoutingProxy, route: RawLocation | RouteLocationRaw, locale?: Locale): string; | ||
/** | ||
* Resolve locale path | ||
* Resolve locale path function | ||
* | ||
* @param route - A route location. The path or name of the route or an object for more complex routes | ||
* @param locale - A locale code, if not specified, uses the current locale | ||
* @param options - An options, see about details {@link I18nRoutingOptions} | ||
* | ||
* @returns Returns the localized URL for a given route | ||
* | ||
* @see {@link useLocalePath} | ||
*/ | ||
export declare function localePath(route: RawLocation | RouteLocationRaw, locale?: Locale, // TODO: locale should be more type inference (completion) | ||
options?: I18nRoutingOptions): string; | ||
export declare type LocalePathFunction = (route: RawLocation | RouteLocation, locale?: Locale) => string; | ||
export declare function localeRoute(this: RoutingProxy, route: RawLocation | RouteLocationRaw, locale?: Locale): Route | ReturnType<Router['resolve']> | undefined; | ||
/** | ||
* Resolve locale route | ||
* Resolve route fucntion | ||
* | ||
* @param route - A route location. The path or name of the route or an object for more complex routes | ||
* @param locale - A locale code, if not specified, uses the current locale | ||
* @param options - An options, see about details {@link I18nRoutingOptions} | ||
* | ||
* @returns Returns the route object for a given route, the route object is resolved by vue-router rather than just a full route path. | ||
* | ||
* @see {@link useLocaleRoute} | ||
*/ | ||
export declare function localeRoute(route: RawLocation | RouteLocationRaw, locale?: Locale, // TODO: locale should be more type inference (completion) | ||
options?: I18nRoutingOptions): Route_2 | ReturnType<Router['resolve']> | undefined; | ||
export declare type LocaleRouteFunction = (route: RawLocation | RouteLocationRaw, locale?: Locale) => Route | ReturnType<Router['resolve']> | undefined; | ||
@@ -170,21 +392,45 @@ /** | ||
*/ | ||
export declare function localizeRoutes(routes: VueI18nRoute[], { defaultLocale, strategy, trailingSlash, routesNameSeparator, defaultLocaleRouteNameSuffix, includeUprefixedFallback, optionsResolver, locales }?: Pick<VueI18nRoutingOptions, 'defaultLocale' | 'strategy' | 'locales' | 'routesNameSeparator' | 'trailingSlash' | 'defaultLocaleRouteNameSuffix'> & { | ||
export declare function localizeRoutes(routes: I18nRoute[], { defaultLocale, strategy, trailingSlash, routesNameSeparator, defaultLocaleRouteNameSuffix, includeUprefixedFallback, optionsResolver, locales }?: Pick<I18nRoutingOptions, 'defaultLocale' | 'strategy' | 'locales' | 'routesNameSeparator' | 'trailingSlash' | 'defaultLocaleRouteNameSuffix'> & { | ||
includeUprefixedFallback?: boolean; | ||
optionsResolver?: RouteOptionsResolver; | ||
}): VueI18nRoute[]; | ||
}): I18nRoute[]; | ||
export declare type MetaAttrs = Record<string, any>; | ||
export declare function proxyVueInstance(target: Function): Function; | ||
/** | ||
* Register global i18n routing option registory | ||
* | ||
* @param router - A router instance, about router type | ||
* @param options - A global options, about options type, see {@link I18nRoutingGlobalOptions} | ||
*/ | ||
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; | ||
export { Route } | ||
declare type _Route = UnionToIntersection<RouteConfig>; | ||
/** | ||
* Route config for vue-router v4 | ||
*/ | ||
export declare interface Route { | ||
declare interface Route_2 { | ||
name?: string; | ||
path: string; | ||
file?: string; | ||
children?: Route[]; | ||
children?: Route_2[]; | ||
} | ||
declare type _Route = UnionToIntersection<RouteConfig>; | ||
/** | ||
@@ -200,8 +446,35 @@ * Route config for lagacy vue-router v3 | ||
export { RouteLocationNormalized } | ||
export { RouteLocationNormalizedLoaded } | ||
/** | ||
* Resolver for route localizing options | ||
*/ | ||
export declare type RouteOptionsResolver = (route: VueI18nRoute, allowedLocaleCodes: string[]) => ComputedRouteOptions | null; | ||
export declare type RouteOptionsResolver = (route: I18nRoute, allowedLocaleCodes: string[]) => ComputedRouteOptions | null; | ||
/** | ||
* Routing Proxy | ||
*/ | ||
export declare type RoutingProxy = { | ||
i18n: any; | ||
getRouteBaseName: any; | ||
localePath: any; | ||
localeRoute: any; | ||
localeLocation: any; | ||
resolveRoute: any; | ||
switchLocalePath: any; | ||
localeHead: any; | ||
route: Route | RouteLocationNormalizedLoaded; | ||
router: Router | VueRouter; | ||
defaultLocale?: string; | ||
localeCodes?: string[]; | ||
strategy?: Strategies; | ||
defaultDirection?: Directions; | ||
defaultLocaleRouteNameSuffix?: string; | ||
trailingSlash?: boolean; | ||
routesNameSeparator?: string; | ||
}; | ||
/** | ||
* SEO Attribute options | ||
@@ -218,3 +491,11 @@ */ | ||
declare const STRATEGIES: { | ||
/** | ||
* 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; | ||
export declare const STRATEGIES: { | ||
readonly PREFIX: "prefix"; | ||
@@ -231,24 +512,81 @@ readonly PREFIX_EXCEPT_DEFAULT: "prefix_except_default"; | ||
export declare function switchLocalePath(this: RoutingProxy, locale: Locale): string; | ||
/** | ||
* Switch locale path | ||
* Swtich locale path function | ||
* | ||
* @param locale - A locale code, if not specified, uses the current locale | ||
* @param options - An options, see about details {@link I18nRoutingOptions} | ||
* | ||
* @returns Returns a link to the current route in another language | ||
* | ||
* @see {@link useSwitchLocalePath} | ||
*/ | ||
export declare function switchLocalePath(locale: Locale, options?: I18nRoutingOptions): string; | ||
export declare type SwitchLocalePathFunction = (locale?: Locale) => string; | ||
/** | ||
* 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; | ||
/** | ||
* Generate SEO head meta information | ||
* Use localize head meta | ||
* | ||
* @param options - An options, see about details {@link I18nHeadOptions} | ||
* @param options - An options, see about details {@link I18nHeadOptions}, {@link ComposableOptions}, {@link I18nCommonRoutingOptions} | ||
* | ||
* @returns Genereated SEO head meta information | ||
*/ | ||
export declare function useI18nHead({ addDirAttribute, addSeoAttributes, strategy, defaultLocale, route, router, i18n }?: Pick<I18nRoutingOptions, 'strategy' | 'defaultLocale'> & ComposableOptions & I18nHeadOptions): Ref<I18nHeadMetaInfo>; | ||
export declare function useLocaleHead({ addDirAttribute, addSeoAttributes, strategy, defaultLocale, route, router, i18n }?: Pick<I18nCommonRoutingOptionsWithComposable, 'strategy' | 'defaultLocale' | 'route' | 'router' | 'i18n'> & I18nHeadOptions): Ref<I18nHeadMetaInfo>; | ||
/** | ||
* Use resolve locale location | ||
* | ||
* @param options - An options, see about details {@link I18nRoutingOptions} | ||
* | ||
* @returns Returns a {@link LocaleLocationFunction} | ||
*/ | ||
export declare function useLocaleLocation({ router, route, i18n, defaultLocale, defaultLocaleRouteNameSuffix, routesNameSeparator, strategy, trailingSlash }?: I18nCommonRoutingOptionsWithComposable): LocaleLocationFunction; | ||
/** | ||
* Use resolve locale path | ||
* | ||
* @param options - An options, see about details {@link I18nRoutingOptions} | ||
* | ||
* @returns Returns a {@link LocalePathFunction} | ||
*/ | ||
export declare function useLocalePath({ router, route, i18n, defaultLocale, defaultLocaleRouteNameSuffix, routesNameSeparator, strategy, trailingSlash }?: I18nCommonRoutingOptionsWithComposable): LocalePathFunction; | ||
/** | ||
* Use resolve locale route | ||
* | ||
* @param options - An options, see about details {@link I18nRoutingOptions} | ||
* | ||
* @returns Returns a {@link LocaleRouteFunction} | ||
*/ | ||
export declare function useLocaleRoute({ router, route, i18n, defaultLocale, defaultLocaleRouteNameSuffix, routesNameSeparator, strategy, trailingSlash }?: I18nCommonRoutingOptionsWithComposable): LocaleRouteFunction; | ||
/** | ||
* Use route base name | ||
* | ||
* @param givenRoute - A route object, if not provided, the route is returned with `useRoute` will be used | ||
* @param options - An options, see about details {@link I18nRoutingOptions} | ||
* | ||
* @returns The route base name, if route name is not defined, return null | ||
*/ | ||
export declare function useRouteBaseName(givenRoute?: Route | 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 | ||
@@ -261,121 +599,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; | ||
}; | ||
/** | ||
* Options to initialize a VueRouter instance | ||
* | ||
* @remarks | ||
* This options is extended from Vue Router `RouterOptioins`, so you can specify those options. | ||
* An options of Vue I18n Routing Plugin | ||
*/ | ||
export declare type VueI18nRoutingOptions<BaseUrl extends BaseUrlResolveHandler = BaseUrlResolveHandler> = { | ||
export declare interface VueI18nRoutingPluginOptions { | ||
/** | ||
* Vue Router version | ||
* Whether to inject some option APIs style methods into Vue instance | ||
* | ||
* @remarks | ||
* You can choice between vue-router v3 and v4. | ||
* | ||
* If you specify `3`, this function return Vue Router v3 instance, else specify `4`, this function return Vue Router v4 instance. | ||
* | ||
* @defaultValue 4 | ||
* @defaultValue `true` | ||
*/ | ||
version?: 3 | 4; | ||
/** | ||
* The app's default locale | ||
* | ||
* @remarks | ||
* When using `prefix_except_default` strategy, URLs for locale specified here won't have a prefix. | ||
* | ||
* It's recommended to set this to some locale regardless of chosen strategy, as it will be used as a fallback locale when navigating to a non-existent route | ||
* | ||
* @defaultValue '' (emputy string) | ||
*/ | ||
defaultLocale?: string; | ||
/** | ||
* List of locales supported by your app | ||
* | ||
* @remarks TODO: | ||
* | ||
* @defaultValue [] | ||
*/ | ||
locales?: string[] | LocaleObject[]; | ||
/** | ||
* Routes strategy | ||
* | ||
* @remarks | ||
* Can be set to one of the following: | ||
* | ||
* - `no_prefix`: routes won't have a locale prefix | ||
* - `prefix_except_default`: locale prefix added for every locale except default | ||
* - `prefix`: locale prefix added for every locale | ||
* - `prefix_and_default`: locale prefix added for every locale and default | ||
* | ||
* @defaultValue 'prefix_except_default' | ||
*/ | ||
strategy?: Strategies; | ||
/** | ||
* Whether to use trailing slash | ||
* | ||
* @defaultValue false | ||
*/ | ||
trailingSlash?: boolean; | ||
/** | ||
* Internal separator used for generated route names for each locale. You shouldn't need to change this | ||
* | ||
* @defaultValue '___' | ||
*/ | ||
routesNameSeparator?: string; | ||
/** | ||
* Internal suffix added to generated route names for default locale | ||
* | ||
* @remarks | ||
* if strategy is prefix_and_default. You shouldn't need to change this. | ||
* | ||
* @defaultValue 'default' | ||
*/ | ||
defaultLocaleRouteNameSuffix?: string; | ||
/** | ||
* Default direction direction | ||
* | ||
* @defaultValue 'ltr' | ||
*/ | ||
defaultDirection?: Directions; | ||
/** | ||
* The fallback base URL to use as a prefix for alternate URLs in hreflang tags. | ||
* | ||
* @remarks | ||
* By default VueRouter's base URL will be used and only if that is not available, fallback URL will be used. | ||
* | ||
* Can also be a function (will be passed a Nuxt Context as a parameter) that returns a string. | ||
* | ||
* Useful to make base URL dynamic based on request headers. | ||
* | ||
* @defaultValue '' | ||
*/ | ||
baseUrl?: string | BaseUrl; | ||
/** | ||
* Route options resolver | ||
* | ||
* @defaultValue undefined | ||
*/ | ||
routeOptionsResolver?: RouteOptionsResolver; | ||
} & RouterOptions; | ||
inject?: boolean; | ||
} | ||
export { } | ||
import type { ComputedRef } from 'vue-demi' | ||
export interface ComposerCustomProperties { | ||
/** | ||
* List of locales | ||
* | ||
* @remarks | ||
* Can either be an array of string codes (e.g. `['en', 'fr']`) or an array of {@link LocaleObject} for more complex configurations | ||
*/ | ||
locales: ComputedRef<string[] | LocaleObject[]> | ||
/** | ||
* List of locale codes | ||
*/ | ||
localeCodes: ComputedRef<string[]> | ||
__baseUrl: string | ||
} | ||
declare module 'vue-i18n' { | ||
export interface ComposerCustom { | ||
locales?: ComputedRef<string[] | LocaleObject[]> | ||
__baseUrl?: string | ||
} | ||
// eslint-disable-next-line @typescript-eslint/no-empty-interface | ||
export interface ComposerCustom extends ComposerCustomProperties {} | ||
} | ||
declare module 'vue-i18n-bridge' { | ||
export interface ComposerCustom { | ||
locales?: ComputedRef<string[] | LocaleObject[]> | ||
__baseUrl?: string | ||
} | ||
// eslint-disable-next-line @typescript-eslint/no-empty-interface | ||
export interface ComposerCustom extends ComposerCustomProperties {} | ||
} | ||
declare module '@intlify/vue-i18n-bridge' { | ||
// eslint-disable-next-line @typescript-eslint/no-empty-interface | ||
export interface ComposerCustom extends ComposerCustomProperties {} | ||
} |
@@ -32,10 +32,25 @@ var __defProp = Object.defineProperty; | ||
}; | ||
import { isRef, unref, isVue3, ref, watch, computed, isVue2 } from "vue-demi"; | ||
import VueRouter3, { useRoute, useRouter, createRouter as createRouter$1 } from "@intlify/vue-router-bridge"; | ||
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"; | ||
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 = ""; | ||
/*! | ||
* shared v9.2.0-beta.30 | ||
* 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; | ||
@@ -47,2 +62,3 @@ const isArray = Array.isArray; | ||
const isSymbol = (val) => typeof val === "symbol"; | ||
const isObject = (val) => val !== null && typeof val === "object"; | ||
const TRAILING_SLASH_RE = /\/$|\/\?/; | ||
@@ -75,2 +91,3 @@ function hasTrailingSlash(input = "", queryParams = false) { | ||
} | ||
const inBrowser = typeof window !== "undefined"; | ||
function warn(msg, err) { | ||
@@ -96,20 +113,40 @@ if (typeof console !== "undefined") { | ||
} | ||
function isComposer(target, mode) { | ||
return isRef(target.locale) && mode === "composition"; | ||
} | ||
function isI18nInstance(i18n) { | ||
return "global" in i18n && "mode" in i18n; | ||
return i18n != null && "global" in i18n && "mode" in i18n; | ||
} | ||
function isComposer(target) { | ||
return target != null && !("__composer" in target) && isRef(target.locale); | ||
} | ||
function isVueI18n(target) { | ||
return target != null && "__composer" in target; | ||
} | ||
function isExportedGlobalComposer(target) { | ||
return target != null && !("__composer" in target) && !isRef(target.locale); | ||
} | ||
function isLegacyVueI18n(target) { | ||
return target != null && ("__VUE_I18N_BRIDGE__" in target || "_sync" in target); | ||
} | ||
function getComposer(i18n) { | ||
return isI18nInstance(i18n) ? isComposer(i18n.global) ? i18n.global : i18n.global.__composer : isVueI18n(i18n) ? i18n.__composer : i18n; | ||
} | ||
function getLocale(i18n) { | ||
return isI18nInstance(i18n) ? isComposer(i18n.global, i18n.mode) ? i18n.global.locale.value : i18n.global.locale : i18n.locale.value; | ||
const target = isI18nInstance(i18n) ? i18n.global : i18n; | ||
return isComposer(target) ? isVue2 && isLegacyVueI18n(i18n) ? i18n.locale : target.locale.value : isExportedGlobalComposer(target) || isVueI18n(target) || isLegacyVueI18n(target) ? target.locale : target.locale; | ||
} | ||
function getLocales(i18n) { | ||
const target = isI18nInstance(i18n) ? i18n.global : i18n; | ||
return isComposer(target) ? isVue2 && isLegacyVueI18n(i18n) ? i18n.locales : target.locales.value : isExportedGlobalComposer(target) || isVueI18n(target) || isLegacyVueI18n(target) ? target.locales : target.locales; | ||
} | ||
function setLocale(i18n, locale) { | ||
if (isI18nInstance(i18n)) { | ||
if (isComposer(i18n.global, i18n.mode)) { | ||
i18n.global.locale.value = locale; | ||
const target = isI18nInstance(i18n) ? i18n.global : i18n; | ||
if (isComposer(target)) { | ||
if (isVue2 && isLegacyVueI18n(i18n)) { | ||
i18n.locale = locale; | ||
} else { | ||
i18n.global.locale = locale; | ||
target.locale.value = locale; | ||
} | ||
} else if (isRef(i18n.locale)) { | ||
i18n.locale.value = locale; | ||
} else if (isExportedGlobalComposer(target) || isVueI18n(target) || isLegacyVueI18n(target)) { | ||
target.locale = locale; | ||
} else { | ||
throw new Error("TODO:"); | ||
} | ||
@@ -120,2 +157,5 @@ } | ||
} | ||
function toRawRoute(maybeRoute) { | ||
return isVueRouter4 ? isRef(maybeRoute) ? maybeRoute.value : maybeRoute : isRef(maybeRoute) ? maybeRoute.value : maybeRoute; | ||
} | ||
function getRouteName(routeName) { | ||
@@ -142,51 +182,402 @@ return isString(routeName) ? routeName : isSymbol(routeName) ? routeName.toString() : "(null)"; | ||
} | ||
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 = ""; | ||
const RESOLVED_PREFIXED = /* @__PURE__ */ new Set([STRATEGIES.PREFIX_AND_DEFAULT, STRATEGIES.PREFIX_EXCEPT_DEFAULT]); | ||
function getRouteBaseName(givenRoute = useRoute(), { router = useRouter(), routesNameSeparator = DEFAULT_ROUTES_NAME_SEPARATOR } = {}) { | ||
const _routesNameSeparator = routesNameSeparator || router.__routesNameSeparator; | ||
const _route = unref(givenRoute); | ||
if (!_route.name) { | ||
return null; | ||
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; | ||
} | ||
} | ||
const name = getRouteName(_route.name); | ||
return name.split(_routesNameSeparator)[0]; | ||
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; | ||
} | ||
function localePath(route, locale, options) { | ||
const localizedRoute = resolveRoute(route, locale, options); | ||
return localizedRoute == null ? "" : isVue3 ? localizedRoute.redirectedFrom || localizedRoute.fullPath : localizedRoute.route.redirectedFrom || localizedRoute.route.fullPath; | ||
const DefaultBrowserLocaleMatcher = matchBrowserLocale; | ||
function compareBrowserLocale(a, b) { | ||
if (a.score === b.score) { | ||
return b.code.length - a.code.length; | ||
} | ||
return b.score - a.score; | ||
} | ||
function localeRoute(route, locale, options) { | ||
const resolved = resolveRoute(route, locale, options); | ||
return resolved == null ? void 0 : isVue3 ? resolved : resolved.route; | ||
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 : ""; | ||
} | ||
function localeLocation(route, locale, options) { | ||
const resolved = resolveRoute(route, locale, options); | ||
return resolved == null ? void 0 : isVue3 ? resolved : resolved.location; | ||
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 resolveRoute(route, locale, { | ||
router = useRouter(), | ||
i18n = useI18n(), | ||
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 = DEFAULT_LOCALE, | ||
strategy = DEFAULT_STRATEGY, | ||
trailingSlash = DEFAULT_TRAILING_SLASH, | ||
routesNameSeparator = DEFAULT_ROUTES_NAME_SEPARATOR, | ||
defaultLocaleRouteNameSuffix = DEFAULT_LOCALE_ROUTE_NAME_SUFFIX, | ||
includeUprefixedFallback = false, | ||
optionsResolver = void 0, | ||
locales = [] | ||
} = {}) { | ||
if (strategy === "no_prefix") { | ||
return routes; | ||
} | ||
const _localeCodes = locales.map((locale) => isString(locale) ? locale : locale.code); | ||
function makeLocalizedRoutes(route, allowedLocaleCodes, isChild = false, isExtraPageTree = false) { | ||
if (route.redirect && (!route.component || !route.file)) { | ||
return [route]; | ||
} | ||
let routeOptions = null; | ||
if (optionsResolver != null) { | ||
routeOptions = optionsResolver(route, allowedLocaleCodes); | ||
if (routeOptions == null) { | ||
return [route]; | ||
} | ||
} | ||
const targetLocales = allowedLocaleCodes; | ||
return targetLocales.reduce((_routes, locale) => { | ||
const { name } = route; | ||
let { path } = route; | ||
const localizedRoute = __spreadValues({}, route); | ||
if (name) { | ||
localizedRoute.name = `${name}${routesNameSeparator}${locale}`; | ||
} | ||
if (route.children) { | ||
localizedRoute.children = route.children.reduce((children, child) => [...children, ...makeLocalizedRoutes(child, [locale], true, isExtraPageTree)], []); | ||
} | ||
const isDefaultLocale = locale === defaultLocale; | ||
if (isDefaultLocale && strategy === "prefix_and_default") { | ||
if (!isChild) { | ||
const defaultRoute = __spreadProps(__spreadValues({}, localizedRoute), { path }); | ||
if (name) { | ||
defaultRoute.name = `${localizedRoute.name}${routesNameSeparator}${defaultLocaleRouteNameSuffix}`; | ||
} | ||
if (route.children) { | ||
defaultRoute.children = []; | ||
for (const childRoute of route.children) { | ||
defaultRoute.children = defaultRoute.children.concat(makeLocalizedRoutes(childRoute, [locale], true, true)); | ||
} | ||
} | ||
_routes.push(defaultRoute); | ||
} else if (isChild && isExtraPageTree && name) { | ||
localizedRoute.name += `${routesNameSeparator}${defaultLocaleRouteNameSuffix}`; | ||
} | ||
} | ||
const isChildWithRelativePath = isChild && !path.startsWith("/"); | ||
const shouldAddPrefix = !isChildWithRelativePath && !(isDefaultLocale && strategy === "prefix_except_default"); | ||
if (shouldAddPrefix) { | ||
path = `/${locale}${path}`; | ||
} | ||
if (path) { | ||
path = adjustRoutePathForTrailingSlash(path, trailingSlash, isChildWithRelativePath); | ||
} | ||
if (shouldAddPrefix && isDefaultLocale && strategy === "prefix" && includeUprefixedFallback) { | ||
_routes.push(__spreadValues({}, route)); | ||
} | ||
localizedRoute.path = path; | ||
_routes.push(localizedRoute); | ||
return _routes; | ||
}, []); | ||
} | ||
return routes.reduce((localized, route) => [...localized, ...makeLocalizedRoutes(route, _localeCodes || [])], []); | ||
} | ||
const 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 = false | ||
trailingSlash = DEFAULT_TRAILING_SLASH, | ||
localeCodes = [] | ||
} = {}) { | ||
const _defaultLocaleRouteNameSuffix = router.__defaultLocaleRouteNameSuffix || defaultLocaleRouteNameSuffix; | ||
const _defaultLocale = router.__defaultLocale || defaultLocale; | ||
const _routesNameSeparator = router.__routesNameSeparator || routesNameSeparator; | ||
const _strategy = router.__strategy || strategy; | ||
const options = getGlobalOptions(router); | ||
return { | ||
defaultLocale: proxy.defaultLocale || options.defaultLocale || defaultLocale, | ||
defaultDirection: proxy.defaultDirection || options.defaultDirection || defaultDirection, | ||
defaultLocaleRouteNameSuffix: proxy.defaultLocaleRouteNameSuffix || options.defaultLocaleRouteNameSuffix || defaultLocaleRouteNameSuffix, | ||
routesNameSeparator: proxy.routesNameSeparator || options.routesNameSeparator || routesNameSeparator, | ||
strategy: proxy.strategy || options.strategy || strategy, | ||
trailingSlash: proxy.trailingSlash || options.trailingSlash || trailingSlash, | ||
localeCodes: proxy.localeCodes || options.localeCodes || localeCodes | ||
}; | ||
} | ||
const RESOLVED_PREFIXED = /* @__PURE__ */ new Set([STRATEGIES.PREFIX_AND_DEFAULT, STRATEGIES.PREFIX_EXCEPT_DEFAULT]); | ||
function getRouteBaseName(givenRoute) { | ||
const router = this.router; | ||
const { routesNameSeparator } = getI18nRoutingOptions(router, this); | ||
const route = givenRoute != null ? isRef(givenRoute) ? unref(givenRoute) : givenRoute : this.route; | ||
if (!route.name) { | ||
return; | ||
} | ||
const name = getRouteName(route.name); | ||
return name.split(routesNameSeparator)[0]; | ||
} | ||
function localePath(route, locale) { | ||
const localizedRoute = resolveRoute.call(this, route, locale); | ||
return localizedRoute == null ? "" : isVue3 ? localizedRoute.redirectedFrom || localizedRoute.fullPath : localizedRoute.route.redirectedFrom || localizedRoute.route.fullPath; | ||
} | ||
function localeRoute(route, locale) { | ||
const resolved = resolveRoute.call(this, route, locale); | ||
return resolved == null ? void 0 : isVue3 ? resolved : resolved.route; | ||
} | ||
function localeLocation(route, locale) { | ||
const resolved = resolveRoute.call(this, route, locale); | ||
return resolved == null ? void 0 : isVue3 ? resolved : resolved.location; | ||
} | ||
function resolveRoute(route, locale) { | ||
const router = this.router; | ||
const i18n = this.i18n; | ||
const _locale = locale || getLocale(i18n); | ||
const { routesNameSeparator, defaultLocale, defaultLocaleRouteNameSuffix, strategy, trailingSlash } = getI18nRoutingOptions(router, this); | ||
let _route = route; | ||
@@ -204,10 +595,10 @@ if (isString(route)) { | ||
const resolvedRoute2 = isVue3 ? _resolvedRoute : _resolvedRoute.route; | ||
const resolvedRouteName = getRouteBaseName(resolvedRoute2); | ||
const resolvedRouteName = getRouteBaseName.call(this, resolvedRoute2); | ||
if (isString(resolvedRouteName)) { | ||
localizedRoute = { | ||
name: getLocaleRouteName(resolvedRouteName, _locale, { | ||
defaultLocale: _defaultLocale, | ||
strategy: _strategy, | ||
routesNameSeparator: _routesNameSeparator, | ||
defaultLocaleRouteNameSuffix: _defaultLocaleRouteNameSuffix | ||
defaultLocale, | ||
strategy, | ||
routesNameSeparator, | ||
defaultLocaleRouteNameSuffix | ||
}), | ||
@@ -220,3 +611,3 @@ params: resolvedRoute2.params, | ||
const isDefaultLocale = _locale === defaultLocale; | ||
const isPrefixed = !(isDefaultLocale && RESOLVED_PREFIXED.has(_strategy)) && !(_strategy === STRATEGIES.NO_PREFIX); | ||
const isPrefixed = !(isDefaultLocale && RESOLVED_PREFIXED.has(strategy)) && !(strategy === STRATEGIES.NO_PREFIX); | ||
if (isPrefixed) { | ||
@@ -229,6 +620,6 @@ localizedRoute.path = `/${_locale}${localizedRoute.path}`; | ||
localizedRoute.name = getLocaleRouteName(localizedRoute.name, _locale, { | ||
defaultLocale: _defaultLocale, | ||
strategy: _strategy, | ||
routesNameSeparator: _routesNameSeparator, | ||
defaultLocaleRouteNameSuffix: _defaultLocaleRouteNameSuffix | ||
defaultLocale, | ||
strategy, | ||
routesNameSeparator, | ||
defaultLocaleRouteNameSuffix | ||
}); | ||
@@ -246,5 +637,5 @@ const { params } = localizedRoute; | ||
} | ||
function switchLocalePath(locale, options) { | ||
const route = options && options.route || useRoute(); | ||
const name = getRouteBaseName(route, options); | ||
function switchLocalePath(locale) { | ||
const route = this.route; | ||
const name = getRouteBaseName.call(this, route); | ||
if (!name) { | ||
@@ -261,67 +652,42 @@ return ""; | ||
}); | ||
const path = localePath(baseRoute, locale, options); | ||
const path = localePath.call(this, baseRoute, locale); | ||
return path; | ||
} | ||
function useI18nHead({ | ||
addDirAttribute = false, | ||
addSeoAttributes = false, | ||
strategy = DEFAULT_STRATEGY, | ||
defaultLocale = DEFAULT_LOCALE, | ||
route = useRoute(), | ||
router = useRouter(), | ||
i18n = useI18n() | ||
} = {}) { | ||
const _defaultLocale = defaultLocale || router.__defaultLocale; | ||
const _strategy = strategy || router.__strategy; | ||
const metaObject = ref({ | ||
function localeHead({ addDirAttribute = false, addSeoAttributes = false } = {}) { | ||
const router = this.router; | ||
const i18n = this.i18n; | ||
const { defaultDirection } = getI18nRoutingOptions(router, this); | ||
const metaObject = { | ||
htmlAttrs: {}, | ||
link: [], | ||
meta: [] | ||
}); | ||
function cleanMeta() { | ||
metaObject.value = { | ||
htmlAttrs: {}, | ||
link: [], | ||
meta: [] | ||
}; | ||
}; | ||
if (i18n.locales == null || i18n.__baseUrl == null) { | ||
return metaObject; | ||
} | ||
function updateMeta(_route) { | ||
if (i18n.locales == null || i18n.__baseUrl == null) { | ||
return; | ||
const locale = getLocale(i18n); | ||
const 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; | ||
} | ||
const locale = getLocale(i18n); | ||
const currentLocale = getNormalizedLocales(i18n.locales.value).find((l) => l.code === locale) || { | ||
code: locale | ||
}; | ||
const currentLocaleIso = currentLocale.iso; | ||
const currentLocaleDir = currentLocale.dir || router.__defaultDirection; | ||
if (addDirAttribute) { | ||
metaObject.value.htmlAttrs.dir = currentLocaleDir; | ||
} | ||
if (addSeoAttributes && locale && i18n.locales) { | ||
if (currentLocaleIso) { | ||
metaObject.value.htmlAttrs.lang = currentLocaleIso; | ||
} | ||
const locales = i18n.locales.value; | ||
addHreflangLinks(locales, i18n.__baseUrl, metaObject.value.link, { | ||
defaultLocale: _defaultLocale, | ||
strategy: _strategy, | ||
route, | ||
router, | ||
i18n | ||
}); | ||
addCanonicalLinks(i18n.__baseUrl, metaObject.value.link, addSeoAttributes, { route: _route, router, i18n }); | ||
addCurrentOgLocale(currentLocale, currentLocaleIso, metaObject.value.meta); | ||
addAlternateOgLocales(locales, currentLocaleIso, metaObject.value.meta); | ||
} | ||
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); | ||
} | ||
watch(router.currentRoute, (val) => { | ||
cleanMeta(); | ||
updateMeta(val); | ||
}); | ||
updateMeta(route); | ||
return metaObject; | ||
} | ||
function addHreflangLinks(locales, baseUrl, link, options) { | ||
if (options.strategy === STRATEGIES.NO_PREFIX) { | ||
function addHreflangLinks(locales, baseUrl, link) { | ||
const router = this.router; | ||
const { defaultLocale, strategy } = getI18nRoutingOptions(router, this); | ||
if (strategy === STRATEGIES.NO_PREFIX) { | ||
return; | ||
@@ -343,3 +709,3 @@ } | ||
for (const [iso, mapLocale] of localeMap.entries()) { | ||
const localePath2 = switchLocalePath(mapLocale.code, options); | ||
const localePath2 = switchLocalePath.call(this, mapLocale.code); | ||
if (localePath2) { | ||
@@ -354,4 +720,4 @@ link.push({ | ||
} | ||
if (options.defaultLocale) { | ||
const localePath2 = switchLocalePath(options.defaultLocale, options); | ||
if (defaultLocale) { | ||
const localePath2 = switchLocalePath.call(this, defaultLocale); | ||
if (localePath2) { | ||
@@ -367,10 +733,10 @@ link.push({ | ||
} | ||
function addCanonicalLinks(baseUrl, link, seoAttributesOptions, options) { | ||
const { route } = options; | ||
const currentRoute = localeRoute(__spreadProps(__spreadValues({}, route), { | ||
name: getRouteBaseName(route, options) | ||
}), void 0, options); | ||
function addCanonicalLinks(baseUrl, link, seoAttributesOptions) { | ||
const route = this.route; | ||
const currentRoute = localeRoute.call(this, __spreadProps(__spreadValues({}, route), { | ||
name: getRouteBaseName.call(this, route) | ||
})); | ||
if (currentRoute) { | ||
let href = toAbsoluteUrl(currentRoute.path, baseUrl); | ||
const canonicalQueries = !isBoolean(seoAttributesOptions) && seoAttributesOptions.canonicalQueries || []; | ||
const canonicalQueries = isObject(seoAttributesOptions) && seoAttributesOptions.canonicalQueries || []; | ||
if (canonicalQueries.length) { | ||
@@ -435,175 +801,161 @@ const currentRouteQueryParams = currentRoute.query; | ||
} | ||
function localizeRoutes(routes, { | ||
defaultLocale = DEFAULT_LOCALE, | ||
strategy = DEFAULT_STRATEGY, | ||
trailingSlash = DEFAULT_TRAILING_SLASH, | ||
routesNameSeparator = DEFAULT_ROUTES_NAME_SEPARATOR, | ||
defaultLocaleRouteNameSuffix = DEFAULT_LOCALE_ROUTE_NAME_SUFFIX, | ||
includeUprefixedFallback = false, | ||
optionsResolver = void 0, | ||
locales = [] | ||
} = {}) { | ||
if (strategy === "no_prefix") { | ||
return routes; | ||
} | ||
const _localeCodes = locales.map((locale) => isString(locale) ? locale : locale.code); | ||
function makeLocalizedRoutes(route, allowedLocaleCodes, isChild = false, isExtraPageTree = false) { | ||
if (route.redirect && (!route.component || !route.file)) { | ||
return [route]; | ||
} | ||
let routeOptions = null; | ||
if (optionsResolver != null) { | ||
routeOptions = optionsResolver(route, allowedLocaleCodes); | ||
if (routeOptions == null) { | ||
return [route]; | ||
} | ||
} | ||
const targetLocales = allowedLocaleCodes; | ||
return targetLocales.reduce((_routes, locale) => { | ||
const { name } = route; | ||
let { path } = route; | ||
const localizedRoute = __spreadValues({}, route); | ||
if (name) { | ||
localizedRoute.name = `${name}${routesNameSeparator}${locale}`; | ||
} | ||
if (route.children) { | ||
localizedRoute.children = route.children.reduce((children, child) => [...children, ...makeLocalizedRoutes(child, [locale], true, isExtraPageTree)], []); | ||
} | ||
const isDefaultLocale = locale === defaultLocale; | ||
if (isDefaultLocale && strategy === "prefix_and_default") { | ||
if (!isChild) { | ||
const defaultRoute = __spreadProps(__spreadValues({}, localizedRoute), { path }); | ||
if (name) { | ||
defaultRoute.name = `${localizedRoute.name}${routesNameSeparator}${defaultLocaleRouteNameSuffix}`; | ||
} | ||
if (route.children) { | ||
defaultRoute.children = []; | ||
for (const childRoute of route.children) { | ||
defaultRoute.children = defaultRoute.children.concat(makeLocalizedRoutes(childRoute, [locale], true, true)); | ||
} | ||
} | ||
_routes.push(defaultRoute); | ||
} else if (isChild && isExtraPageTree && name) { | ||
localizedRoute.name += `${routesNameSeparator}${defaultLocaleRouteNameSuffix}`; | ||
} | ||
} | ||
const isChildWithRelativePath = isChild && !path.startsWith("/"); | ||
const shouldAddPrefix = !isChildWithRelativePath && !(isDefaultLocale && strategy === "prefix_except_default"); | ||
if (shouldAddPrefix) { | ||
path = `/${locale}${path}`; | ||
} | ||
if (path) { | ||
path = adjustRoutePathForTrailingSlash(path, trailingSlash, isChildWithRelativePath); | ||
} | ||
if (shouldAddPrefix && isDefaultLocale && strategy === "prefix" && includeUprefixedFallback) { | ||
_routes.push(__spreadValues({}, route)); | ||
} | ||
localizedRoute.path = path; | ||
_routes.push(localizedRoute); | ||
return _routes; | ||
}, []); | ||
} | ||
return routes.reduce((localized, route) => [...localized, ...makeLocalizedRoutes(route, _localeCodes || [])], []); | ||
function 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 | ||
}, args); | ||
}; | ||
} | ||
function extendI18n(i18n, { locales = [], baseUrl = DEFAULT_BASE_URL } = {}) { | ||
if (!isComposer(i18n.global, i18n.mode)) { | ||
throw new Error("TODO:"); | ||
} | ||
const _locales = ref(locales); | ||
i18n.global.locales = computed(() => _locales.value); | ||
i18n.global.__baseUrl = resolveBaseUrl(baseUrl, {}); | ||
} | ||
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 (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]; | ||
} | ||
} | ||
return ""; | ||
function useRouteBaseName(givenRoute = useRoute(), { router = useRouter(), routesNameSeparator = void 0 } = {}) { | ||
const proxy = { | ||
router, | ||
route: givenRoute, | ||
routesNameSeparator | ||
}; | ||
return getLocaleFromRoute; | ||
return getRouteBaseName.call(proxy, givenRoute); | ||
} | ||
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 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 createRouter(i18n, options = {}) { | ||
const { | ||
version, | ||
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, | ||
locales, | ||
defaultLocaleRouteNameSuffix, | ||
routesNameSeparator, | ||
strategy, | ||
trailingSlash, | ||
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, | ||
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 }); | ||
const localizedRoutes = localizeRoutes(routes, { | ||
locales, | ||
defaultLocale, | ||
routesNameSeparator, | ||
strategy, | ||
trailingSlash, | ||
routesNameSeparator, | ||
defaultLocaleRouteNameSuffix, | ||
optionsResolver | ||
trailingSlash | ||
}, switchLocalePath); | ||
} | ||
function useLocaleHead({ | ||
addDirAttribute = false, | ||
addSeoAttributes = false, | ||
strategy = void 0, | ||
defaultLocale = void 0, | ||
route = useRoute(), | ||
router = useRouter(), | ||
i18n = useI18n() | ||
} = {}) { | ||
const _router = router; | ||
const metaObject = ref({ | ||
htmlAttrs: {}, | ||
link: [], | ||
meta: [] | ||
}); | ||
options.routes = localizedRoutes; | ||
let router = null; | ||
if (isVue3 && version === 4) { | ||
router = createRouter$1(options); | ||
} else if (isVue2 && version === 3) { | ||
router = new VueRouter3(options); | ||
function cleanMeta() { | ||
metaObject.value = { | ||
htmlAttrs: {}, | ||
link: [], | ||
meta: [] | ||
}; | ||
} | ||
function updateMeta(_route) { | ||
metaObject.value = Reflect.apply(localeHead, { | ||
router, | ||
route: _route, | ||
i18n, | ||
defaultLocale, | ||
strategy | ||
}, [{ addDirAttribute, addSeoAttributes }]); | ||
} | ||
if (inBrowser) { | ||
if (isVue3) { | ||
const stop = watchEffect(() => { | ||
cleanMeta(); | ||
updateMeta(toRawRoute(_router.currentRoute)); | ||
}); | ||
onUnmounted(() => stop()); | ||
} else { | ||
const handler = _router.afterEach((to, from) => { | ||
cleanMeta(); | ||
updateMeta(to); | ||
}); | ||
onUnmounted(() => handler()); | ||
updateMeta(route); | ||
} | ||
} else { | ||
throw new Error("TODO:"); | ||
updateMeta(toRawRoute(_router.currentRoute)); | ||
} | ||
router.__defaultLocale = defaultLocale; | ||
router.__localeCodes = localeCodes; | ||
router.__strategy = strategy; | ||
router.__trailingSlash = trailingSlash; | ||
router.__routesNameSeparator = routesNameSeparator; | ||
router.__defaultLocaleRouteNameSuffix = defaultLocaleRouteNameSuffix; | ||
router.__defaultDirection = defaultDirection; | ||
router.beforeEach((to, from, next) => { | ||
const currentLocale = getLocale(i18n); | ||
const finalLocale = getLocaleFromRoute(to) || currentLocale || defaultLocale || ""; | ||
if (currentLocale !== finalLocale) { | ||
setLocale(i18n, finalLocale); | ||
} | ||
next(); | ||
}); | ||
return router; | ||
return metaObject; | ||
} | ||
const VERSION = "0.0.0"; | ||
export { VERSION, createRouter, getRouteBaseName, localeLocation, localePath, localeRoute, localizeRoutes, switchLocalePath, useI18nHead }; | ||
export { DEFAULT_BASE_URL, DEFAULT_DETECTION_DIRECTION, DEFAULT_LOCALE, DEFAULT_LOCALE_ROUTE_NAME_SUFFIX, DEFAULT_ROUTES_NAME_SEPARATOR, DEFAULT_STRATEGY, DEFAULT_TRAILING_SLASH, STRATEGIES, VERSION, createLocaleFromRouteGetter, createRouter, extendI18n, findBrowserLocale, getGlobalOptions, getLocale, getLocalesRegex, getRouteBaseName, localeHead, localeLocation, localePath, localeRoute, localizeRoutes, proxyVueInstance, registerGlobalOptions, resolveBaseUrl, resolveRoute, setLocale, switchLocalePath, useLocaleHead, useLocaleLocation, useLocalePath, useLocaleRoute, useRouteBaseName, useSwitchLocalePath }; |
@@ -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 ne=(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,_)&&ne(u,_,s[_]);if(w)for(var _ of w(s))ce.call(s,_)&&ne(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(_);/*! | ||
* shared v9.2.0-beta.30 | ||
var VueI18nRouting=function(r,d,L,g){"use strict";var ht=Object.defineProperty,Lt=Object.defineProperties;var _t=Object.getOwnPropertyDescriptors;var W=Object.getOwnPropertySymbols;var ye=Object.prototype.hasOwnProperty,Oe=Object.prototype.propertyIsEnumerable;var Pe=(r,d,L)=>d in r?ht(r,d,{enumerable:!0,configurable:!0,writable:!0,value:L}):r[d]=L,O=(r,d)=>{for(var L in d||(d={}))ye.call(d,L)&&Pe(r,L,d[L]);if(W)for(var L of W(d))Oe.call(d,L)&&Pe(r,L,d[L]);return r},Q=(r,d)=>Lt(r,_t(d));var Ue=(r,d)=>{var L={};for(var g in r)ye.call(r,g)&&d.indexOf(g)<0&&(L[g]=r[g]);if(r!=null&&W)for(var g of W(r))d.indexOf(g)<0&&Oe.call(r,g)&&(L[g]=r[g]);return L};function Ce(e){return e&&typeof e=="object"&&"default"in e?e:{default:e}}var Fe=Ce(L);const U={PREFIX:"prefix",PREFIX_EXCEPT_DEFAULT:"prefix_except_default",PREFIX_AND_DEFAULT:"prefix_and_default",NO_PREFIX:"no_prefix"},j="",V=U.PREFIX_EXCEPT_DEFAULT,G=!1,D="___",B="default",Y="ltr",J="";/*! | ||
* shared v9.2.0-beta.35 | ||
* (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,...l]=e.split("?");return(a.slice(0,-1)||"/")+(l.length?`?${l.join("?")}`:"")}function ge(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 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:l,routesNameSeparator:o,defaultLocaleRouteNameSuffix:n}){let c=B(e)+(l==="no_prefix"?"":o+t);return t===a&&l==="prefix_and_default"&&(c+=o+n),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"},U="",b=v.PREFIX_EXCEPT_DEFAULT,Y=!1,O="___",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=O}={}){const l=a||t.__routesNameSeparator,o=s.unref(e);return o.name?B(o.name).split(l)[0]:null}function K(e,t,a){const l=z(e,t,a);return l==null?"":s.isVue3?l.redirectedFrom||l.fullPath:l.route.redirectedFrom||l.route.fullPath}function Z(e,t,a){const l=z(e,t,a);return l==null?void 0:s.isVue3?l:l.route}function Ie(e,t,a){const l=z(e,t,a);return l==null?void 0:s.isVue3?l:l.location}function z(e,t,{router:a=_.useRouter(),i18n:l=p.useI18n(),defaultLocale:o=U,defaultLocaleRouteNameSuffix:n=V,routesNameSeparator:c=O,strategy:d=b,trailingSlash:h=!1}={}){const f=a.__defaultLocaleRouteNameSuffix||n,g=a.__defaultLocale||o,r=a.__routesNameSeparator||c,L=a.__strategy||d,R=t||M(l);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(),l=x(a,t);if(!l)return"";const f=!s.isVue3&&s.isRef(a)?a.value:a,{params:o}=f,n=re(f,["params"]),c={},d=G({},n,{name:l,params:D(F(F({},o),c),{0:o.pathMatch})});return K(d,e,t)}function Te({addDirAttribute:e=!1,addSeoAttributes:t=!1,strategy:a=b,defaultLocale:l=U,route:o=_.useRoute(),router:n=_.useRouter(),i18n:c=p.useI18n()}={}){const d=l||n.__defaultLocale,h=a||n.__strategy,f=s.ref({htmlAttrs:{},link:[],meta:[]});function g(){f.value={htmlAttrs:{},link:[],meta:[]}}function r(L){if(c.locales==null||c.__baseUrl==null)return;const R=M(c),E=H(c.locales.value).find(i=>i.code===R)||{code:R},m=E.iso,T=E.dir||n.__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:n,i18n:c}),Pe(c.__baseUrl,f.value.link,t,{route:L,router:n,i18n:c}),Fe(E,m,f.value.meta),Ne(i,m,f.value.meta)}}return s.watch(n.currentRoute,L=>{g(),r(L)}),r(o),f}function ye(e,t,a,l){if(l.strategy===v.NO_PREFIX)return;const o=new Map;for(const n of e){const c=n.iso;if(!c){Le("Locale ISO code is required to generate alternate link");continue}const[d,h]=c.split("-");d&&h&&(n.isCatchallLocale||!o.has(d))&&o.set(d,n),o.set(c,n)}for(const[n,c]of o.entries()){const d=j(c.code,l);d&&a.push({hid:`i18n-alt-${n}`,rel:"alternate",href:k(d,t),hreflang:n})}if(l.defaultLocale){const n=j(l.defaultLocale,l);n&&a.push({hid:"i18n-xd",rel:"alternate",href:k(n,t),hreflang:"x-default"})}}function Pe(e,t,a,l){const{route:o}=l,n=Z(D(F({},o),{name:x(o,l)}),void 0,l);if(n){let c=k(n.path,e);const d=!de(a)&&a.canonicalQueries||[];if(d.length){const h=n.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 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:ee(n.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=U,strategy:a=b,trailingSlash:l=Y,routesNameSeparator:o=O,defaultLocaleRouteNameSuffix:n=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}${n}`);else{const P=D(F({},I),{path:A});if(y&&(P.name=`${I.name}${o}${n}`),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("/"),le=!ae&&!($&&a==="prefix_except_default");return le&&(A=`/${S}${A}`),A&&(A=Ee(A,l,ae)),le&&$&&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 l=s.ref(t);e.global.locales=s.computed(()=>l.value),e.global.__baseUrl=Se(a,{})}function ve(e){return new RegExp(`^/(${e.join("|")})(?:/|$)`,"i")}function Ue(e,t,a){const l=`(${e.join("|")})`,o=`(?:${t}${a})?`,n=new RegExp(`${t}${l}${o}$`,"i"),c=ve(e);return h=>{if(h.name){const g=(N(h.name)?h.name:h.name.toString()).match(n);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 be(e){var t,a,l,o,n,c,d,h,f,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:b,e.trailingSlash=(o=e.trailingSlash)!=null?o:Y,e.routesNameSeparator=(n=e.routesNameSeparator)!=null?n:O,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 Oe(e,t={}){const{version:a,defaultLocale:l,locales:o,strategy:n,trailingSlash:c,routesNameSeparator:d,defaultLocaleRouteNameSuffix:h,defaultDirection:f,baseUrl:g,routes:r,routeOptionsResolver:L}=be(t),R=H(o),E=R.map(S=>S.code),m=Ue(E,d,h);$e(e,{locales:R,baseUrl:g});const T=te(r,{locales:o,defaultLocale:l,strategy:n,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=l,i.__localeCodes=E,i.__strategy=n,i.__trailingSlash=c,i.__routesNameSeparator=d,i.__defaultLocaleRouteNameSuffix=h,i.__defaultDirection=f,i.beforeEach((S,y,A)=>{const I=M(e),$=m(S)||I||l||"";I!==$&&Re(e,$),A()}),i}const xe="0.0.0";return u.VERSION=xe,u.createRouter=Oe,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 be=typeof Symbol=="function"&&typeof Symbol.toStringTag=="symbol",Ne=e=>be?Symbol(e):e,se=Object.assign,we=Array.isArray,$e=e=>typeof e=="function",I=e=>typeof e=="string",ve=e=>typeof e=="boolean",je=e=>typeof e=="symbol",K=e=>e!==null&&typeof e=="object",Ve=/\/$|\/\?/;function Z(e="",t=!1){return t?Ve.test(e):e.endsWith("/")}function Ge(e="",t=!1){if(!t)return(Z(e)?e.slice(0,-1):e)||"/";if(!Z(e,!0))return e||"/";const[o,...n]=e.split("?");return(o.slice(0,-1)||"/")+(n.length?`?${n.join("?")}`:"")}function De(e="",t=!1){if(!t)return e.endsWith("/")?e:e+"/";if(Z(e,!0))return e||"/";const[o,...n]=e.split("?");return o+"/"+(n.length?`?${n.join("?")}`:"")}const Be=typeof window!="undefined";function re(e,t){typeof console!="undefined"&&(console.warn("[vue-i18n-routing] "+e),t&&console.warn(t.stack))}function ie(e){e=e||[];const t=[];for(const o of e)I(o)?t.push({code:o}):t.push(o);return t}function X(e){return e!=null&&"global"in e&&"mode"in e}function M(e){return e!=null&&!("__composer"in e)&&d.isRef(e.locale)}function N(e){return e!=null&&"__composer"in e}function ee(e){return e!=null&&!("__composer"in e)&&!d.isRef(e.locale)}function C(e){return e!=null&&("__VUE_I18N_BRIDGE__"in e||"_sync"in e)}function ue(e){return X(e)?M(e.global)?e.global:e.global.__composer:N(e)?e.__composer:e}function k(e){const t=X(e)?e.global:e;return M(t)?d.isVue2&&C(e)?e.locale:t.locale.value:(ee(t)||N(t)||C(t),t.locale)}function Xe(e){const t=X(e)?e.global:e;return M(t)?d.isVue2&&C(e)?e.locales:t.locales.value:(ee(t)||N(t)||C(t),t.locales)}function fe(e,t){const o=X(e)?e.global:e;if(M(o))d.isVue2&&C(e)?e.locale=t:o.locale.value=t;else if(ee(o)||N(o)||C(o))o.locale=t;else throw new Error("TODO:")}function Me(e,t,o){return e.replace(/\/+$/,"")+(t?"/":"")||(o?"":"/")}function de(e){return L.isVueRouter4,d.isRef(e)?e.value:e}function he(e){return I(e)?e:je(e)?e.toString():"(null)"}function Le(e,t,{defaultLocale:o,strategy:n,routesNameSeparator:l,defaultLocaleRouteNameSuffix:a}){let c=he(e)+(n==="no_prefix"?"":l+t);return t===o&&n==="prefix_and_default"&&(c+=l+a),c}function _e(e,t){return $e(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 ze=ke;function He(e,t){return e.score===t.score?t.code.length-e.code.length:t.score-e.score}const xe=He;function qe(e,t,{matcher:o=ze,comparer:n=xe}={}){const l=[];for(const c of e){const{code:s}=c,i=c.iso||s;l.push({code:s,iso:i})}const a=o(l,t);return a.length>1&&a.sort(n),a.length?a[0].code:""}function T(e){return function(){return Reflect.apply(e,{getRouteBaseName:this.getRouteBaseName,localePath:this.localePath,localeRoute:this.localeRoute,localeLocation:this.localeLocation,resolveRoute:this.resolveRoute,switchLocalePath:this.switchLocalePath,localeHead:this.localeHead,i18n:this.$i18n,route:this.$route,router:this.$router},arguments)}}function ge(e,{locales:t=[],localeCodes:o=[],baseUrl:n=J,hooks:l={}}={}){const a=d.effectScope(),c=e.install;return e.install=(s,...i)=>{Reflect.apply(c,e,[s,...i]);const f=ue(e);a.run(()=>We(f,{locales:t,localeCodes:o,baseUrl:n,hooks:l})),N(e.global)&&Ye(e.global,l.onExtendVueI18n);const h=s,u=e.mode==="composition"?d.isVue3?h.config.globalProperties.$i18n:e:d.isVue2?e:null;if(u&&Qe(u,f,l.onExtendExportedGlobal),(Je(i[0])?i[0]:{inject:!0}).inject&&s.mixin({methods:{resolveRoute:T(w),localePath:T(H),localeRoute:T(x),localeLocation:T(oe),switchLocalePath:T($),getRouteBaseName:T(F),localeHead:T(ne)}}),h.unmount){const _=h.unmount;h.unmount=()=>{a.stop(),_()}}},a}function We(e,t){const{locales:o,localeCodes:n,baseUrl:l}=t,a=d.ref(o),c=d.ref(n);e.locales=d.computed(()=>a.value),e.localeCodes=d.computed(()=>c.value),e.__baseUrl=_e(l,{}),t.hooks&&t.hooks.onExtendComposer&&t.hooks.onExtendComposer(e)}function Qe(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 Ye(e,t){const o=ue(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 Je(e){return K(e)&&"inject"in e&&ve(e.inject)}function Re(e,{defaultLocale:t=j,strategy:o=V,trailingSlash:n=G,routesNameSeparator:l=D,defaultLocaleRouteNameSuffix:a=B,includeUprefixedFallback:c=!1,optionsResolver:s=void 0,locales:i=[]}={}){if(o==="no_prefix")return e;const f=i.map(u=>I(u)?u:u.code);function h(u,R,_=!1,m=!1){if(u.redirect&&(!u.component||!u.file))return[u];let P=null;return s!=null&&(P=s(u,R),P==null)?[u]:R.reduce((S,A)=>{const{name:v}=u;let{path:p}=u;const E=O({},u);v&&(E.name=`${v}${l}${A}`),u.children&&(E.children=u.children.reduce((y,ce)=>[...y,...h(ce,[A],!0,m)],[]));const b=A===t;if(b&&o==="prefix_and_default")if(_)_&&m&&v&&(E.name+=`${l}${a}`);else{const y=Q(O({},E),{path:p});if(v&&(y.name=`${E.name}${l}${a}`),u.children){y.children=[];for(const ce of u.children)y.children=y.children.concat(h(ce,[A],!0,!0))}S.push(y)}const Te=_&&!p.startsWith("/"),Ie=!Te&&!(b&&o==="prefix_except_default");return Ie&&(p=`/${A}${p}`),p&&(p=Me(p,n,Te)),Ie&&b&&o==="prefix"&&c&&S.push(O({},u)),E.path=p,S.push(E),S},[])}return e.reduce((u,R)=>[...u,...h(R,f||[])],[])}const te=Ne("vue-i18n-routing-gor");function me(e,t){e[te]?re("already registered global options"):e[te]=t}function pe(e){var t;return(t=e[te])!=null?t:{}}function Ke(e,t={}){const{version:o,defaultLocale:n,locales:l,strategy:a,trailingSlash:c,routesNameSeparator:s,defaultLocaleRouteNameSuffix:i,defaultDirection:f,baseUrl:h,routes:u,routeOptionsResolver:R}=et(t),_=ie(l),m=_.map(A=>A.code),P=Se(m,s,i);ge(e,{locales:_,baseUrl:h,localeCodes:m});const le=Re(u,{locales:l,defaultLocale:n,strategy:a,trailingSlash:c,routesNameSeparator:s,defaultLocaleRouteNameSuffix:i,optionsResolver:R});t.routes=le;const S=Ze(t,o);return me(S,{defaultLocale:n,localeCodes:m,strategy:a,trailingSlash:c,routesNameSeparator:s,defaultLocaleRouteNameSuffix:i,defaultDirection:f}),S.beforeEach((A,v,p)=>{const E=k(e),b=P(A)||E||n||"";E!==b&&fe(e,b),p()}),S}function Ze(e,t){if(d.isVue3&&t===4)return L.createRouter(e);if(d.isVue2&&t===3)return new Fe.default(e);throw new Error("TODO:")}function Ee(e){return new RegExp(`^/(${e.join("|")})(?:/|$)`,"i")}function Se(e,t,o){const n=`(${e.join("|")})`,l=`(?:${t}${o})?`,a=new RegExp(`${t}${n}${l}$`,"i"),c=Ee(e);return i=>{if(K(i)){if(i.name){const h=(I(i.name)?i.name:i.name.toString()).match(a);if(h&&h.length>1)return h[1]}else if(i.path){const f=i.path.match(c);if(f&&f.length>1)return f[1]}}else if(I(i)){const f=i.match(c);if(f&&f.length>1)return f[1]}return""}}function et(e){var t,o,n,l,a,c,s,i,f,h;return e.version=(t=e.version)!=null?t:4,e.defaultLocale=(o=e.defaultLocale)!=null?o:j,e.strategy=(n=e.strategy)!=null?n:V,e.trailingSlash=(l=e.trailingSlash)!=null?l:G,e.routesNameSeparator=(a=e.routesNameSeparator)!=null?a:D,e.defaultLocaleRouteNameSuffix=(c=e.defaultLocaleRouteNameSuffix)!=null?c:B,e.locales=(s=e.locales)!=null?s:[],e.defaultDirection=(i=e.defaultDirection)!=null?i:Y,e.baseUrl=(f=e.baseUrl)!=null?f:J,e.routes=(h=e.routes)!=null?h:[],e}function z(e,t,{defaultLocale:o=j,defaultDirection:n=Y,defaultLocaleRouteNameSuffix:l=B,routesNameSeparator:a=D,strategy:c=V,trailingSlash:s=G,localeCodes:i=[]}={}){const f=pe(e);return{defaultLocale:t.defaultLocale||f.defaultLocale||o,defaultDirection:t.defaultDirection||f.defaultDirection||n,defaultLocaleRouteNameSuffix:t.defaultLocaleRouteNameSuffix||f.defaultLocaleRouteNameSuffix||l,routesNameSeparator:t.routesNameSeparator||f.routesNameSeparator||a,strategy:t.strategy||f.strategy||c,trailingSlash:t.trailingSlash||f.trailingSlash||s,localeCodes:t.localeCodes||f.localeCodes||i}}const tt=new Set([U.PREFIX_AND_DEFAULT,U.PREFIX_EXCEPT_DEFAULT]);function F(e){const t=this.router,{routesNameSeparator:o}=z(t,this),n=e!=null?d.isRef(e)?d.unref(e):e:this.route;return n.name?he(n.name).split(o)[0]:void 0}function H(e,t){const o=w.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=w.call(this,e,t);return o==null?void 0:d.isVue3?o:o.route}function oe(e,t){const o=w.call(this,e,t);return o==null?void 0:d.isVue3?o:o.location}function w(e,t){const o=this.router,n=this.i18n,l=t||k(n),{routesNameSeparator:a,defaultLocale:c,defaultLocaleRouteNameSuffix:s,strategy:i,trailingSlash:f}=z(o,this);let h=e;I(e)&&(h[0]==="/"?h={path:e}:h={name:e});let u=se({},h);if(u.path&&!u.name){const _=o.resolve(u),m=d.isVue3?_:_.route,P=F.call(this,m);I(P)?u={name:Le(P,l,{defaultLocale:c,strategy:i,routesNameSeparator:a,defaultLocaleRouteNameSuffix:s}),params:m.params,query:m.query,hash:m.hash}:(!(l===c&&tt.has(i))&&i!==U.NO_PREFIX&&(u.path=`/${l}${u.path}`),u.path=f?De(u.path,!0):Ge(u.path,!0))}else{u.name=Le(u.name,l,{defaultLocale:c,strategy:i,routesNameSeparator:a,defaultLocaleRouteNameSuffix:s});const{params:_}=u;_&&_["0"]===void 0&&_.pathMatch&&(_["0"]=_.pathMatch)}const R=o.resolve(u);return(d.isVue3?R.name:R.route.name)?R:o.resolve(e)}function $(e){const t=this.route,o=F.call(this,t);if(!o)return"";const i=!d.isVue3&&d.isRef(t)?t.value:t,{params:n}=i,l=Ue(i,["params"]),a={},c=se({},l,{name:o,params:Q(O(O({},n),a),{0:n.pathMatch})});return H.call(this,c,e)}function ne({addDirAttribute:e=!1,addSeoAttributes:t=!1}={}){const o=this.router,n=this.i18n,{defaultDirection:l}=z(o,this),a={htmlAttrs:{},link:[],meta:[]};if(n.locales==null||n.__baseUrl==null)return a;const c=k(n),s=Xe(n),i=ie(s).find(u=>u.code===c)||{code:c},f=i.iso,h=i.dir||l;return e&&(a.htmlAttrs.dir=h),t&&c&&n.locales&&(f&&(a.htmlAttrs.lang=f),ot.call(this,s,n.__baseUrl,a.link),nt.call(this,n.__baseUrl,a.link,t),at(i,f,a.meta),lt(s,f,a.meta)),a}function ot(e,t,o){const n=this.router,{defaultLocale:l,strategy:a}=z(n,this);if(a===U.NO_PREFIX)return;const c=new Map;for(const s of e){const i=s.iso;if(!i){re("Locale ISO code is required to generate alternate link");continue}const[f,h]=i.split("-");f&&h&&(s.isCatchallLocale||!c.has(f))&&c.set(f,s),c.set(i,s)}for(const[s,i]of c.entries()){const f=$.call(this,i.code);f&&o.push({hid:`i18n-alt-${s}`,rel:"alternate",href:ae(f,t),hreflang:s})}if(l){const s=$.call(this,l);s&&o.push({hid:"i18n-xd",rel:"alternate",href:ae(s,t),hreflang:"x-default"})}}function nt(e,t,o){const n=this.route,l=x.call(this,Q(O({},n),{name:F.call(this,n)}));if(l){let a=ae(l.path,e);const c=K(o)&&o.canonicalQueries||[];if(c.length){const s=l.query,i=new URLSearchParams;for(const h of c)if(h in s){const u=s[h];we(u)?u.forEach(R=>i.append(h,R||"")):i.append(h,u||"")}const f=i.toString();f&&(a=`${a}?${f}`)}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:Ae(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:Ae(a.iso)}));o.push(...l)}}function Ae(e){return(e||"").replace(/-/g,"_")}function ae(e,t){return e.match(/^https?:\/\//)?e:t+e}function q(e,t){const{router:o,route:n,i18n:l,defaultLocale:a,strategy:c,defaultLocaleRouteNameSuffix:s,trailingSlash:i,routesNameSeparator:f}=e;return function(...h){return Reflect.apply(t,{router:o,route:n,i18n:l,defaultLocale:a,strategy:c,defaultLocaleRouteNameSuffix:s,trailingSlash:i,routesNameSeparator:f},h)}}function ct(e=L.useRoute(),{router:t=L.useRouter(),routesNameSeparator:o=void 0}={}){const n={router:t,route:e,routesNameSeparator:o};return F.call(n,e)}function st({router:e=L.useRouter(),route:t=L.useRoute(),i18n:o=g.useI18n(),defaultLocale:n=void 0,defaultLocaleRouteNameSuffix:l=void 0,routesNameSeparator:a=void 0,strategy:c=void 0,trailingSlash:s=void 0}={}){return q({router:e,route:t,i18n:o,defaultLocale:n,defaultLocaleRouteNameSuffix:l,routesNameSeparator:a,strategy:c,trailingSlash:s},H)}function rt({router:e=L.useRouter(),route:t=L.useRoute(),i18n:o=g.useI18n(),defaultLocale:n=void 0,defaultLocaleRouteNameSuffix:l=void 0,routesNameSeparator:a=void 0,strategy:c=void 0,trailingSlash:s=void 0}={}){return q({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=g.useI18n(),defaultLocale:n=void 0,defaultLocaleRouteNameSuffix:l=void 0,routesNameSeparator:a=void 0,strategy:c=void 0,trailingSlash:s=void 0}={}){return q({router:e,route:t,i18n:o,defaultLocale:n,defaultLocaleRouteNameSuffix:l,routesNameSeparator:a,strategy:c,trailingSlash:s},oe)}function ut({router:e=L.useRouter(),route:t=L.useRoute(),i18n:o=g.useI18n(),defaultLocale:n=void 0,defaultLocaleRouteNameSuffix:l=void 0,routesNameSeparator:a=void 0,strategy:c=void 0,trailingSlash:s=void 0}={}){return q({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=g.useI18n()}={}){const s=a,i=d.ref({htmlAttrs:{},link:[],meta:[]});function f(){i.value={htmlAttrs:{},link:[],meta:[]}}function h(u){i.value=Reflect.apply(ne,{router:a,route:u,i18n:c,defaultLocale:n,strategy:o},[{addDirAttribute:e,addSeoAttributes:t}])}if(Be)if(d.isVue3){const u=d.watchEffect(()=>{f(),h(de(s.currentRoute))});d.onUnmounted(()=>u())}else{const u=s.afterEach((R,_)=>{f(),h(R)});d.onUnmounted(()=>u()),h(l)}else h(de(s.currentRoute));return i}const dt="0.0.0";return r.DEFAULT_BASE_URL=J,r.DEFAULT_DETECTION_DIRECTION=Y,r.DEFAULT_LOCALE=j,r.DEFAULT_LOCALE_ROUTE_NAME_SUFFIX=B,r.DEFAULT_ROUTES_NAME_SEPARATOR=D,r.DEFAULT_STRATEGY=V,r.DEFAULT_TRAILING_SLASH=G,r.STRATEGIES=U,r.VERSION=dt,r.createLocaleFromRouteGetter=Se,r.createRouter=Ke,r.extendI18n=ge,r.findBrowserLocale=qe,r.getGlobalOptions=pe,r.getLocale=k,r.getLocalesRegex=Ee,r.getRouteBaseName=F,r.localeHead=ne,r.localeLocation=oe,r.localePath=H,r.localeRoute=x,r.localizeRoutes=Re,r.proxyVueInstance=T,r.registerGlobalOptions=me,r.resolveBaseUrl=_e,r.resolveRoute=w,r.setLocale=fe,r.switchLocalePath=$,r.useLocaleHead=ft,r.useLocaleLocation=it,r.useLocalePath=st,r.useLocaleRoute=rt,r.useRouteBaseName=ct,r.useSwitchLocalePath=ut,Object.defineProperties(r,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}}),r}({},VueDemi,VueRouter,VueI18n); |
{ | ||
"name": "vue-i18n-routing", | ||
"description": "The i18n routing with using vue-i18n", | ||
"version": "0.0.0-1a08f42", | ||
"version": "0.0.0-1ba106d", | ||
"dependencies": { | ||
"@intlify/shared": "beta", | ||
"@intlify/vue-i18n-bridge": "^0.3.4", | ||
"@intlify/vue-router-bridge": "^0.3.4", | ||
"@intlify/shared": "next", | ||
"@intlify/vue-i18n-bridge": "^0.3.5", | ||
"@intlify/vue-router-bridge": "^0.3.5", | ||
"ufo": "^0.7.9", | ||
@@ -17,11 +17,11 @@ "vue-demi": "^0.12.1" | ||
"rimraf": "^3.0.2", | ||
"typescript": "^4.5.4", | ||
"vite": "^2.7.4", | ||
"typescript": "^4.6.3", | ||
"vite": "^2.9.8", | ||
"vite-plugin-dts": "^0.9.6", | ||
"vitest": "^0.2.8", | ||
"vite-plugin-dts": "^0.9.6", | ||
"vue": "^3.2.23", | ||
"vue-i18n": "npm:vue-i18n@next", | ||
"vue-i18n-bridge": "beta", | ||
"vue-i18n-bridge": "next", | ||
"vue-i18n-legacy": "npm:vue-i18n@8", | ||
"vue-router": "^4.0.12", | ||
"vue-router": "^4.0.15", | ||
"vue-router3": "npm:vue-router@3", | ||
@@ -34,4 +34,4 @@ "vue-template-compiler": "^2.6.14", | ||
"vue": "^2.6.14 || ^3.2.0", | ||
"vue-i18n": "^8.26.1 || ^9.2.0-beta.30", | ||
"vue-i18n-bridge": "^9.2.0-beta.30", | ||
"vue-i18n": "^8.26.1 || ^9.2.0-beta.35", | ||
"vue-i18n-bridge": "^9.2.0-beta.35", | ||
"vue-router": "^3.5.3 || ^4.0.0" | ||
@@ -53,2 +53,3 @@ }, | ||
"index.mjs", | ||
"types.d.ts", | ||
"LICENSE", | ||
@@ -71,4 +72,7 @@ "README.md" | ||
}, | ||
"./dist/*": "./dist/*", | ||
"./package.json": "./package.json" | ||
"./types": { | ||
"types": "./types.d.ts" | ||
}, | ||
"./package.json": "./package.json", | ||
"./dist/*": "./dist/*" | ||
}, | ||
@@ -75,0 +79,0 @@ "license": "MIT", |
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
95611
11
1742
1
+ Added@intlify/shared@11.0.0-rc.1(transitive)
- Removed@intlify/shared@9.3.0-beta.27(transitive)
Updated@intlify/shared@next