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

vue-i18n-routing

Package Overview
Dependencies
Maintainers
1
Versions
239
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

vue-i18n-routing - npm Package Compare versions

Comparing version 0.0.0-9551f85 to 0.0.0-9c21557

4

dist/vue-i18n-routing.cjs.js

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

"use strict";var H=Object.defineProperty,Y=Object.defineProperties;var J=Object.getOwnPropertyDescriptors;var I=Object.getOwnPropertySymbols;var N=Object.prototype.hasOwnProperty,C=Object.prototype.propertyIsEnumerable;var X=(e,t,o)=>t in e?H(e,t,{enumerable:!0,configurable:!0,writable:!0,value:o}):e[t]=o,F=(e,t)=>{for(var o in t||(t={}))N.call(t,o)&&X(e,o,t[o]);if(I)for(var o of I(t))C.call(t,o)&&X(e,o,t[o]);return e},S=(e,t)=>Y(e,J(t));var M=(e,t)=>{var o={};for(var u in e)N.call(e,u)&&t.indexOf(u)<0&&(o[u]=e[u]);if(e!=null&&I)for(var u of I(e))t.indexOf(u)<0&&C.call(e,u)&&(o[u]=e[u]);return o};Object.defineProperty(exports,"__esModule",{value:!0});exports[Symbol.toStringTag]="Module";var i=require("vue-demi"),j=require("vue-router"),K=require("vue-i18n");/*!
"use strict";var H=Object.defineProperty,Y=Object.defineProperties;var J=Object.getOwnPropertyDescriptors;var A=Object.getOwnPropertySymbols;var N=Object.prototype.hasOwnProperty,X=Object.prototype.propertyIsEnumerable;var C=(e,t,o)=>t in e?H(e,t,{enumerable:!0,configurable:!0,writable:!0,value:o}):e[t]=o,F=(e,t)=>{for(var o in t||(t={}))N.call(t,o)&&C(e,o,t[o]);if(A)for(var o of A(t))X.call(t,o)&&C(e,o,t[o]);return e},T=(e,t)=>Y(e,J(t));var M=(e,t)=>{var o={};for(var r in e)N.call(e,r)&&t.indexOf(r)<0&&(o[r]=e[r]);if(e!=null&&A)for(var r of A(e))t.indexOf(r)<0&&X.call(e,r)&&(o[r]=e[r]);return o};Object.defineProperty(exports,"__esModule",{value:!0});exports[Symbol.toStringTag]="Module";var E=require("vue-demi"),j=require("@intlify/vue-router-composable"),K=require("vue-i18n");/*!
* shared v9.2.0-beta.25
* (c) 2021 kazuya kawaguchi
* Released under the MIT License.
*/const q=Object.assign,P=e=>typeof e=="string",Q=e=>typeof e=="symbol",Z=e=>typeof e=="symbol";new Set(Object.getOwnPropertyNames(Symbol).map(e=>Symbol[e]).filter(Z));function T(e){return Boolean(e&&e.__v_isRef===!0)}Promise.resolve();function ee(e){e=e||[];const t=[];for(const o of e)P(o)?t.push({code:o}):t.push(o);return t}function w(e,t){return T(e.locale)&&t==="composition"}function G(e){return"global"in e&&"mode"in e}function y(e){return G(e)?w(e.global,e.mode)?e.global.locale.value:e.global.locale:T(e.locale)?e.locale.value:e.locale}function B(e,t){G(e)?w(e.global,e.mode)?e.global.locale.value=t:e.global.locale=t:T(e.locale)&&(e.locale.value=t)}function oe(e,t,o){return e.replace(/\/+$/,"")+(t?"/":"")||(o?"":"/")}function te(e,{localeCodes:t=[]}={}){if(!w(e.global,e.mode))throw new Error("");const o=i.ref(t);e.global.locales=i.computed(()=>o.value),console.log("... extends i18n done")}const ne={PREFIX:"prefix",PREFIX_EXCEPT_DEFAULT:"prefix_except_default",PREFIX_AND_DEFAULT:"prefix_and_default",NO_PREFIX:"no_prefix"},O="",W=ne.PREFIX_EXCEPT_DEFAULT,D=!1,V="___",z="default";function U(e,{defaultLocale:t=O,strategy:o=W,trailingSlash:u=D,routesNameSeparator:d=V,defaultLocaleRouteNameSuffix:m=z,includeUprefixedFallback:f=!1,localeCodes:$=[]}={}){if(o==="no_prefix")return e;const _=$.map(n=>P(n)?n:n.code);function h(n,g,E=!1,R=!1){return n.redirect&&(!n.component||!n.file)?[n]:g.reduce((r,s)=>{const{name:c}=n;let{path:a}=n;const l=F({},n);c&&(l.name=`${c}${d}${s}`),n.children&&(l.children=n.children.reduce((b,A)=>[...b,...h(A,[s],!0,R)],[]));const x=s===t;if(x&&o==="prefix_and_default")if(E)E&&R&&c&&(l.name+=`${d}${m}`);else{const b=S(F({},l),{path:a});if(c&&(b.name=`${l.name}${d}${m}`),n.children){b.children=[];for(const A of n.children)b.children=b.children.concat(h(A,[s],!0,!0))}r.push(b)}const p=E&&!a.startsWith("/"),v=!p&&!(x&&o==="prefix_except_default");return v&&(a=`/${s}${a}`),a&&(a=oe(a,u,p)),v&&x&&o==="prefix"&&f&&r.push(F({},n)),l.path=a,r.push(l),r},[])}return e.reduce((n,g)=>[...n,...h(g,_||[])],[])}function ce(e){return new RegExp(`^/(${e.join("|")})(?:/|$)`,"i")}function re(e,t,o){const u=`(${e.join("|")})`,d=`(?:${t}${o})?`,m=new RegExp(`${t}${u}${d}$`,"i"),f=ce(e);return _=>{if(_.name){const n=(P(_.name)?_.name:_.name.toString()).match(m);if(n&&n.length>1)return n[1]}else if(_.path){const h=_.path.match(f);if(h&&h.length>1)return h[1]}return""}}function se({router:e,i18n:t,defaultLocale:o=O,strategy:u=W,trailingSlash:d=D,routesNameSeparator:m=V,defaultLocaleRouteNameSuffix:f=z,localeCodes:$=[]}={}){const _=ee($),h=re(_.map(n=>n.code),m,f);if(te(t,{localeCodes:_}),i.isVue2){const n=e,g=n.constructor,E=n.options.routes||[],R=U(E,{localeCodes:$,defaultLocale:o,strategy:u,trailingSlash:d,routesNameSeparator:m,defaultLocaleRouteNameSuffix:f});console.log("vue2 routes",E,R);const L=new g({mode:"history",base:n.options.base,routes:R});return L.__defaultLocale=o,L.__strategy=u,L.__trailingSlash=d,L.__routesNameSeparator=m,L.__defaultLocaleRouteNameSuffix=f,L.beforeEach((r,s,c)=>{console.log("beforeEach",r,s);const a=y(t),l=h(r)||a||o||"";console.log("currentLocale",a,"finalLocale",l),a!==l&&B(t,l),c()}),L}else{const n=e,g=n.options.routes||[],E=U(g,{localeCodes:$,defaultLocale:o,strategy:u,trailingSlash:d,routesNameSeparator:m,defaultLocaleRouteNameSuffix:f});return console.log("vue3 routes",g,E,n),g.forEach(R=>n.removeRoute(R.name)),E.forEach(R=>n.addRoute(R)),n.__defaultLocale=o,n.__strategy=u,n.__trailingSlash=d,n.__routesNameSeparator=m,n.__defaultLocaleRouteNameSuffix=f,n.beforeEach((R,L,r)=>{console.log("beforeEach",R,L);const s=y(t),c=h(R)||s||o||"";console.log("currentLocale",s,"finalLocale",c),s!==c&&B(t,c),r()}),n}}const ue=()=>{const e=i.getCurrentInstance();if(e==null)throw new Error("should be used in setup");return e.$router},le=()=>{const e=i.getCurrentInstance();if(e==null)throw new Error("should be used in setup");return i.computed(()=>e.$route)};function ae(){return i.isVue2?le():j.useRoute()}function ie(){return i.isVue2?ue():j.useRouter()}function fe(){return K.useI18n()}function de(e={}){const t=fe(),o=ie(),u=ae(),d=e.defaultLocaleRouteNameSuffix||o.__defaultLocaleRouteNameSuffix,m=e.defaultLocale||o.__defaultLocale,f=e.routesNameSeparator||o.__routesNameSeparator,$=e.strategy||o.__strategy;function _(r){const s=r!=null?r:i.isRef(u)?u.value:u;return s.name?k(s.name).split(f)[0]:void 0}function h(r,s){let c=k(r)+($==="no_prefix"?"":f+s);return s===m&&$==="prefix_and_default"&&(c+=f+d),c}function n(r,s){const c=s||y(t);let a=r;P(r)&&(r[0]==="/"?a={path:r}:a={name:r});let l=q({},a);if(l.path&&!l.name){const p=o.resolve(l),v=i.isVue2?p.route:p,b=_(v);P(b)&&(l={name:h(b,c),params:v.params,query:v.query,hash:v.hash})}else{l.name=h(l.name,c);const{params:p}=l;p&&p["0"]===void 0&&p.pathMatch&&(p["0"]=p.pathMatch)}const x=o.resolve(l);return(i.isVue2?x.route.name:x.name)?x:o.resolve(r)}function g(r,s){const c=n(r,s);return c==null?"":i.isVue2?c.route.redirectedFrom||c.route.fullPath:c.redirectedFrom||c.fullPath}function E(r,s){const c=n(r,s);return c==null?void 0:i.isVue2?c.route:c}function R(r,s){const c=n(r,s);return c==null?void 0:i.isVue2?c.location:c.href}function L(r){const s=_();if(!s)return"";const v=i.isVue2&&i.isRef(u)?u.value:u,{params:c}=v,a=M(v,["params"]),l={},x=q({},a,{name:s,params:S(F(F({},c),l),{0:c.pathMatch})}),p=g(x,r);return console.log("switchLocalePath",t.locale.value,r,p),p}return{localePath:g,localeRoute:E,localeLocation:R,switchLocalePath:L}}function k(e){return P(e)?e:Q(e)?e.toString():""}function me({router:e,i18n:t,defaultLocale:o=O,trailingSlash:u=D,routesNameSeparator:d=V,defaultLocaleRouteNameSuffix:m=z,localeCodes:f=[]}={}){if(e==null)throw new Error("TODO");return se({router:e,i18n:t,defaultLocale:o,trailingSlash:u,routesNameSeparator:d,defaultLocaleRouteNameSuffix:m,localeCodes:f})}const _e="";exports.VERSION=_e;exports.extendRouting=me;exports.localizeRoutes=U;exports.useI18nRouting=de;
*/const q=Object.assign,P=e=>typeof e=="string",Q=e=>typeof e=="symbol",Z=e=>typeof e=="symbol";new Set(Object.getOwnPropertyNames(Symbol).map(e=>Symbol[e]).filter(Z));function I(e){return Boolean(e&&e.__v_isRef===!0)}Promise.resolve();function ee(e){e=e||[];const t=[];for(const o of e)P(o)?t.push({code:o}):t.push(o);return t}function y(e,t){return I(e.locale)&&t==="composition"}function G(e){return"global"in e&&"mode"in e}function O(e){return G(e)?y(e.global,e.mode)?e.global.locale.value:e.global.locale:I(e.locale)?e.locale.value:e.locale}function B(e,t){G(e)?y(e.global,e.mode)?e.global.locale.value=t:e.global.locale=t:I(e.locale)&&(e.locale.value=t)}function oe(e,t,o){return e.replace(/\/+$/,"")+(t?"/":"")||(o?"":"/")}function te(e,{localeCodes:t=[]}={}){if(!y(e.global,e.mode))throw new Error("");const o=E.ref(t);e.global.locales=E.computed(()=>o.value),console.log("... extends i18n done")}const ne={PREFIX:"prefix",PREFIX_EXCEPT_DEFAULT:"prefix_except_default",PREFIX_AND_DEFAULT:"prefix_and_default",NO_PREFIX:"no_prefix"},w="",W=ne.PREFIX_EXCEPT_DEFAULT,D=!1,z="___",U="default";function V(e,{defaultLocale:t=w,strategy:o=W,trailingSlash:r=D,routesNameSeparator:f=z,defaultLocaleRouteNameSuffix:_=U,includeUprefixedFallback:i=!1,localeCodes:$=[]}={}){if(o==="no_prefix")return e;const d=$.map(n=>P(n)?n:n.code);function m(n,p,L=!1,h=!1){return n.redirect&&(!n.component||!n.file)?[n]:p.reduce((l,s)=>{const{name:c}=n;let{path:u}=n;const a=F({},n);c&&(a.name=`${c}${f}${s}`),n.children&&(a.children=n.children.reduce((b,S)=>[...b,...m(S,[s],!0,h)],[]));const x=s===t;if(x&&o==="prefix_and_default")if(L)L&&h&&c&&(a.name+=`${f}${_}`);else{const b=T(F({},a),{path:u});if(c&&(b.name=`${a.name}${f}${_}`),n.children){b.children=[];for(const S of n.children)b.children=b.children.concat(m(S,[s],!0,!0))}l.push(b)}const R=L&&!u.startsWith("/"),v=!R&&!(x&&o==="prefix_except_default");return v&&(u=`/${s}${u}`),u&&(u=oe(u,r,R)),v&&x&&o==="prefix"&&i&&l.push(F({},n)),a.path=u,l.push(a),l},[])}return e.reduce((n,p)=>[...n,...m(p,d||[])],[])}function ce(e){return new RegExp(`^/(${e.join("|")})(?:/|$)`,"i")}function le(e,t,o){const r=`(${e.join("|")})`,f=`(?:${t}${o})?`,_=new RegExp(`${t}${r}${f}$`,"i"),i=ce(e);return d=>{if(d.name){const n=(P(d.name)?d.name:d.name.toString()).match(_);if(n&&n.length>1)return n[1]}else if(d.path){const m=d.path.match(i);if(m&&m.length>1)return m[1]}return""}}function se({router:e,i18n:t,defaultLocale:o=w,strategy:r=W,trailingSlash:f=D,routesNameSeparator:_=z,defaultLocaleRouteNameSuffix:i=U,localeCodes:$=[]}={}){const d=ee($),m=le(d.map(n=>n.code),_,i);if(te(t,{localeCodes:d}),E.isVue2){const n=e,p=n.constructor,L=n.options.routes||[],h=V(L,{localeCodes:$,defaultLocale:o,strategy:r,trailingSlash:f,routesNameSeparator:_,defaultLocaleRouteNameSuffix:i});console.log("vue2 routes",L,h);const g=new p({mode:"history",base:n.options.base,routes:h});return g.__defaultLocale=o,g.__strategy=r,g.__trailingSlash=f,g.__routesNameSeparator=_,g.__defaultLocaleRouteNameSuffix=i,g.beforeEach((l,s,c)=>{console.log("beforeEach",l,s);const u=O(t),a=m(l)||u||o||"";console.log("currentLocale",u,"finalLocale",a),u!==a&&B(t,a),c()}),g}else{const n=e,p=n.options.routes||[],L=V(p,{localeCodes:$,defaultLocale:o,strategy:r,trailingSlash:f,routesNameSeparator:_,defaultLocaleRouteNameSuffix:i});return console.log("vue3 routes",p,L,n),p.forEach(h=>n.removeRoute(h.name)),L.forEach(h=>n.addRoute(h)),n.__defaultLocale=o,n.__strategy=r,n.__trailingSlash=f,n.__routesNameSeparator=_,n.__defaultLocaleRouteNameSuffix=i,n.beforeEach((h,g,l)=>{console.log("beforeEach",h,g);const s=O(t),c=m(h)||s||o||"";console.log("currentLocale",s,"finalLocale",c),s!==c&&B(t,c),l()}),n}}function re(){return K.useI18n()}function ae(e={}){const t=re(),o=j.useRouter(),r=j.useRoute(),f=e.defaultLocaleRouteNameSuffix||o.__defaultLocaleRouteNameSuffix,_=e.defaultLocale||o.__defaultLocale,i=e.routesNameSeparator||o.__routesNameSeparator,$=e.strategy||o.__strategy;function d(l){const s=l!=null?l:E.isRef(r)?r.value:r;return s.name?k(s.name).split(i)[0]:void 0}function m(l,s){let c=k(l)+($==="no_prefix"?"":i+s);return s===_&&$==="prefix_and_default"&&(c+=i+f),c}function n(l,s){const c=s||O(t);let u=l;P(l)&&(l[0]==="/"?u={path:l}:u={name:l});let a=q({},u);if(a.path&&!a.name){const R=o.resolve(a),v=E.isVue2?R.route:R,b=d(v);P(b)&&(a={name:m(b,c),params:v.params,query:v.query,hash:v.hash})}else{a.name=m(a.name,c);const{params:R}=a;R&&R["0"]===void 0&&R.pathMatch&&(R["0"]=R.pathMatch)}const x=o.resolve(a);return(E.isVue2?x.route.name:x.name)?x:o.resolve(l)}function p(l,s){const c=n(l,s);return c==null?"":E.isVue2?c.route.redirectedFrom||c.route.fullPath:c.redirectedFrom||c.fullPath}function L(l,s){const c=n(l,s);return c==null?void 0:E.isVue2?c.route:c}function h(l,s){const c=n(l,s);return c==null?void 0:E.isVue2?c.location:c.href}function g(l){const s=d();if(!s)return"";const v=E.isVue2&&E.isRef(r)?r.value:r,{params:c}=v,u=M(v,["params"]),a={},x=q({},u,{name:s,params:T(F(F({},c),a),{0:c.pathMatch})}),R=p(x,l);return console.log("switchLocalePath",t.locale.value,l,R),R}return{localePath:p,localeRoute:L,localeLocation:h,switchLocalePath:g}}function k(e){return P(e)?e:Q(e)?e.toString():""}function ue({router:e,i18n:t,defaultLocale:o=w,trailingSlash:r=D,routesNameSeparator:f=z,defaultLocaleRouteNameSuffix:_=U,localeCodes:i=[]}={}){if(e==null)throw new Error("TODO");return se({router:e,i18n:t,defaultLocale:o,trailingSlash:r,routesNameSeparator:f,defaultLocaleRouteNameSuffix:_,localeCodes:i})}const ie="";exports.VERSION=ie;exports.extendRouting=ue;exports.localizeRoutes=V;exports.useI18nRouting=ae;

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

};
import { ref, computed, isVue2, getCurrentInstance, isRef as isRef$1 } from "vue-demi";
import { useRouter as useRouter$1, useRoute as useRoute$1 } from "vue-router";
import { ref, computed, isVue2, isRef as isRef$1 } from "vue-demi";
import { useRouter, useRoute } from "@intlify/vue-router-composable";
import { useI18n as useI18n$1 } from "vue-i18n";

@@ -272,22 +272,2 @@ /*!

}
const useLegacyRouter = () => {
const vm = getCurrentInstance();
if (vm == null) {
throw new Error(`should be used in setup`);
}
return vm.$router;
};
const useLegacyRoute = () => {
const vm = getCurrentInstance();
if (vm == null) {
throw new Error(`should be used in setup`);
}
return computed(() => vm.$route);
};
function useRoute() {
return isVue2 ? useLegacyRoute() : useRoute$1();
}
function useRouter() {
return isVue2 ? useLegacyRouter() : useRouter$1();
}
function useI18n() {

@@ -294,0 +274,0 @@ return useI18n$1();

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

var _e=Object.defineProperty,he=Object.defineProperties;var Re=Object.getOwnPropertyDescriptors;var x=Object.getOwnPropertySymbols;var k=Object.prototype.hasOwnProperty,H=Object.prototype.propertyIsEnumerable;var Y=(a,n,f)=>n in a?_e(a,n,{enumerable:!0,configurable:!0,writable:!0,value:f}):a[n]=f,w=(a,n)=>{for(var f in n||(n={}))k.call(n,f)&&Y(a,f,n[f]);if(x)for(var f of x(n))H.call(n,f)&&Y(a,f,n[f]);return a},M=(a,n)=>he(a,Re(n));var J=(a,n)=>{var f={};for(var $ in a)k.call(a,$)&&n.indexOf($)<0&&(f[$]=a[$]);if(a!=null&&x)for(var $ of x(a))n.indexOf($)<0&&H.call(a,$)&&(f[$]=a[$]);return f};var VueI18nRouting=function(a,n,f,$){"use strict";/*!
var ue=Object.defineProperty,ie=Object.defineProperties;var fe=Object.getOwnPropertyDescriptors;var x=Object.getOwnPropertySymbols;var W=Object.prototype.hasOwnProperty,k=Object.prototype.propertyIsEnumerable;var H=(r,s,f)=>s in r?ue(r,s,{enumerable:!0,configurable:!0,writable:!0,value:f}):r[s]=f,v=(r,s)=>{for(var f in s||(s={}))W.call(s,f)&&H(r,f,s[f]);if(x)for(var f of x(s))k.call(s,f)&&H(r,f,s[f]);return r},j=(r,s)=>ie(r,fe(s));var Y=(r,s)=>{var f={};for(var $ in r)W.call(r,$)&&s.indexOf($)<0&&(f[$]=r[$]);if(r!=null&&x)for(var $ of x(r))s.indexOf($)<0&&k.call(r,$)&&(f[$]=r[$]);return f};var VueI18nRouting=function(r,s,f,$){"use strict";/*!
* shared v9.2.0-beta.25
* (c) 2021 kazuya kawaguchi
* Released under the MIT License.
*/const j=Object.assign,T=e=>typeof e=="string",K=e=>typeof e=="symbol",Q=e=>typeof e=="symbol";new Set(Object.getOwnPropertyNames(Symbol).map(e=>Symbol[e]).filter(Q));function y(e){return Boolean(e&&e.__v_isRef===!0)}Promise.resolve();function Z(e){e=e||[];const r=[];for(const c of e)T(c)?r.push({code:c}):r.push(c);return r}function V(e,r){return y(e.locale)&&r==="composition"}function G(e){return"global"in e&&"mode"in e}function v(e){return G(e)?V(e.global,e.mode)?e.global.locale.value:e.global.locale:y(e.locale)?e.locale.value:e.locale}function q(e,r){G(e)?V(e.global,e.mode)?e.global.locale.value=r:e.global.locale=r:y(e.locale)&&(e.locale.value=r)}function D(e,r,c){return e.replace(/\/+$/,"")+(r?"/":"")||(c?"":"/")}function ee(e,{localeCodes:r=[]}={}){if(!V(e.global,e.mode))throw new Error("");const c=n.ref(r);e.global.locales=n.computed(()=>c.value),console.log("... extends i18n done")}const oe={PREFIX:"prefix",PREFIX_EXCEPT_DEFAULT:"prefix_except_default",PREFIX_AND_DEFAULT:"prefix_and_default",NO_PREFIX:"no_prefix"},O="",B=oe.PREFIX_EXCEPT_DEFAULT,z=!1,U="___",N="default";function C(e,{defaultLocale:r=O,strategy:c=B,trailingSlash:d=z,routesNameSeparator:h=U,defaultLocaleRouteNameSuffix:R=N,includeUprefixedFallback:_=!1,localeCodes:A=[]}={}){if(c==="no_prefix")return e;const m=A.map(o=>T(o)?o:o.code);function g(o,E,F=!1,p=!1){return o.redirect&&(!o.component||!o.file)?[o]:E.reduce((s,l)=>{const{name:t}=o;let{path:i}=o;const u=w({},o);t&&(u.name=`${t}${h}${l}`),o.children&&(u.children=o.children.reduce((P,X)=>[...P,...g(X,[l],!0,p)],[]));const S=l===r;if(S&&c==="prefix_and_default")if(F)F&&p&&t&&(u.name+=`${h}${R}`);else{const P=M(w({},u),{path:i});if(t&&(P.name=`${u.name}${h}${R}`),o.children){P.children=[];for(const X of o.children)P.children=P.children.concat(g(X,[l],!0,!0))}s.push(P)}const L=F&&!i.startsWith("/"),I=!L&&!(S&&c==="prefix_except_default");return I&&(i=`/${l}${i}`),i&&(i=D(i,d,L)),I&&S&&c==="prefix"&&_&&s.push(w({},o)),u.path=i,s.push(u),s},[])}return e.reduce((o,E)=>[...o,...g(E,m||[])],[])}function te(e){return new RegExp(`^/(${e.join("|")})(?:/|$)`,"i")}function ne(e,r,c){const d=`(${e.join("|")})`,h=`(?:${r}${c})?`,R=new RegExp(`${r}${d}${h}$`,"i"),_=te(e);return m=>{if(m.name){const o=(T(m.name)?m.name:m.name.toString()).match(R);if(o&&o.length>1)return o[1]}else if(m.path){const g=m.path.match(_);if(g&&g.length>1)return g[1]}return""}}function ce({router:e,i18n:r,defaultLocale:c=O,strategy:d=B,trailingSlash:h=z,routesNameSeparator:R=U,defaultLocaleRouteNameSuffix:_=N,localeCodes:A=[]}={}){const m=Z(A),g=ne(m.map(o=>o.code),R,_);if(ee(r,{localeCodes:m}),n.isVue2){const o=e,E=o.constructor,F=o.options.routes||[],p=C(F,{localeCodes:A,defaultLocale:c,strategy:d,trailingSlash:h,routesNameSeparator:R,defaultLocaleRouteNameSuffix:_});console.log("vue2 routes",F,p);const b=new E({mode:"history",base:o.options.base,routes:p});return b.__defaultLocale=c,b.__strategy=d,b.__trailingSlash=h,b.__routesNameSeparator=R,b.__defaultLocaleRouteNameSuffix=_,b.beforeEach((s,l,t)=>{console.log("beforeEach",s,l);const i=v(r),u=g(s)||i||c||"";console.log("currentLocale",i,"finalLocale",u),i!==u&&q(r,u),t()}),b}else{const o=e,E=o.options.routes||[],F=C(E,{localeCodes:A,defaultLocale:c,strategy:d,trailingSlash:h,routesNameSeparator:R,defaultLocaleRouteNameSuffix:_});return console.log("vue3 routes",E,F,o),E.forEach(p=>o.removeRoute(p.name)),F.forEach(p=>o.addRoute(p)),o.__defaultLocale=c,o.__strategy=d,o.__trailingSlash=h,o.__routesNameSeparator=R,o.__defaultLocaleRouteNameSuffix=_,o.beforeEach((p,b,s)=>{console.log("beforeEach",p,b);const l=v(r),t=g(p)||l||c||"";console.log("currentLocale",l,"finalLocale",t),l!==t&&q(r,t),s()}),o}}const se=()=>{const e=n.getCurrentInstance();if(e==null)throw new Error("should be used in setup");return e.$router},re=()=>{const e=n.getCurrentInstance();if(e==null)throw new Error("should be used in setup");return n.computed(()=>e.$route)};function le(){return n.isVue2?re():f.useRoute()}function ae(){return n.isVue2?se():f.useRouter()}function ue(){return $.useI18n()}function ie(e={}){const r=ue(),c=ae(),d=le(),h=e.defaultLocaleRouteNameSuffix||c.__defaultLocaleRouteNameSuffix,R=e.defaultLocale||c.__defaultLocale,_=e.routesNameSeparator||c.__routesNameSeparator,A=e.strategy||c.__strategy;function m(s){const l=s!=null?s:n.isRef(d)?d.value:d;return l.name?W(l.name).split(_)[0]:void 0}function g(s,l){let t=W(s)+(A==="no_prefix"?"":_+l);return l===R&&A==="prefix_and_default"&&(t+=_+h),t}function o(s,l){const t=l||v(r);let i=s;T(s)&&(s[0]==="/"?i={path:s}:i={name:s});let u=j({},i);if(u.path&&!u.name){const L=c.resolve(u),I=n.isVue2?L.route:L,P=m(I);T(P)&&(u={name:g(P,t),params:I.params,query:I.query,hash:I.hash})}else{u.name=g(u.name,t);const{params:L}=u;L&&L["0"]===void 0&&L.pathMatch&&(L["0"]=L.pathMatch)}const S=c.resolve(u);return(n.isVue2?S.route.name:S.name)?S:c.resolve(s)}function E(s,l){const t=o(s,l);return t==null?"":n.isVue2?t.route.redirectedFrom||t.route.fullPath:t.redirectedFrom||t.fullPath}function F(s,l){const t=o(s,l);return t==null?void 0:n.isVue2?t.route:t}function p(s,l){const t=o(s,l);return t==null?void 0:n.isVue2?t.location:t.href}function b(s){const l=m();if(!l)return"";const I=n.isVue2&&n.isRef(d)?d.value:d,{params:t}=I,i=J(I,["params"]),u={},S=j({},i,{name:l,params:M(w(w({},t),u),{0:t.pathMatch})}),L=E(S,s);return console.log("switchLocalePath",r.locale.value,s,L),L}return{localePath:E,localeRoute:F,localeLocation:p,switchLocalePath:b}}function W(e){return T(e)?e:K(e)?e.toString():""}function fe({router:e,i18n:r,defaultLocale:c=O,trailingSlash:d=z,routesNameSeparator:h=U,defaultLocaleRouteNameSuffix:R=N,localeCodes:_=[]}={}){if(e==null)throw new Error("TODO");return ce({router:e,i18n:r,defaultLocale:c,trailingSlash:d,routesNameSeparator:h,defaultLocaleRouteNameSuffix:R,localeCodes:_})}const de="";return a.VERSION=de,a.extendRouting=fe,a.localizeRoutes=C,a.useI18nRouting=ie,Object.defineProperty(a,"__esModule",{value:!0}),a[Symbol.toStringTag]="Module",a}({},VueDemi,VueRouter,VueI18n);
*/const C=Object.assign,T=e=>typeof e=="string",J=e=>typeof e=="symbol",K=e=>typeof e=="symbol";new Set(Object.getOwnPropertyNames(Symbol).map(e=>Symbol[e]).filter(K));function y(e){return Boolean(e&&e.__v_isRef===!0)}Promise.resolve();function Q(e){e=e||[];const l=[];for(const n of e)T(n)?l.push({code:n}):l.push(n);return l}function O(e,l){return y(e.locale)&&l==="composition"}function G(e){return"global"in e&&"mode"in e}function V(e){return G(e)?O(e.global,e.mode)?e.global.locale.value:e.global.locale:y(e.locale)?e.locale.value:e.locale}function q(e,l){G(e)?O(e.global,e.mode)?e.global.locale.value=l:e.global.locale=l:y(e.locale)&&(e.locale.value=l)}function Z(e,l,n){return e.replace(/\/+$/,"")+(l?"/":"")||(n?"":"/")}function ee(e,{localeCodes:l=[]}={}){if(!O(e.global,e.mode))throw new Error("");const n=s.ref(l);e.global.locales=s.computed(()=>n.value),console.log("... extends i18n done")}const oe={PREFIX:"prefix",PREFIX_EXCEPT_DEFAULT:"prefix_except_default",PREFIX_AND_DEFAULT:"prefix_and_default",NO_PREFIX:"no_prefix"},w="",B=oe.PREFIX_EXCEPT_DEFAULT,z=!1,U="___",N="default";function X(e,{defaultLocale:l=w,strategy:n=B,trailingSlash:_=z,routesNameSeparator:h=U,defaultLocaleRouteNameSuffix:m=N,includeUprefixedFallback:d=!1,localeCodes:I=[]}={}){if(n==="no_prefix")return e;const R=I.map(o=>T(o)?o:o.code);function g(o,E,F=!1,p=!1){return o.redirect&&(!o.component||!o.file)?[o]:E.reduce((c,a)=>{const{name:t}=o;let{path:i}=o;const u=v({},o);t&&(u.name=`${t}${h}${a}`),o.children&&(u.children=o.children.reduce((A,M)=>[...A,...g(M,[a],!0,p)],[]));const S=a===l;if(S&&n==="prefix_and_default")if(F)F&&p&&t&&(u.name+=`${h}${m}`);else{const A=j(v({},u),{path:i});if(t&&(A.name=`${u.name}${h}${m}`),o.children){A.children=[];for(const M of o.children)A.children=A.children.concat(g(M,[a],!0,!0))}c.push(A)}const L=F&&!i.startsWith("/"),P=!L&&!(S&&n==="prefix_except_default");return P&&(i=`/${a}${i}`),i&&(i=Z(i,_,L)),P&&S&&n==="prefix"&&d&&c.push(v({},o)),u.path=i,c.push(u),c},[])}return e.reduce((o,E)=>[...o,...g(E,R||[])],[])}function te(e){return new RegExp(`^/(${e.join("|")})(?:/|$)`,"i")}function ne(e,l,n){const _=`(${e.join("|")})`,h=`(?:${l}${n})?`,m=new RegExp(`${l}${_}${h}$`,"i"),d=te(e);return R=>{if(R.name){const o=(T(R.name)?R.name:R.name.toString()).match(m);if(o&&o.length>1)return o[1]}else if(R.path){const g=R.path.match(d);if(g&&g.length>1)return g[1]}return""}}function ce({router:e,i18n:l,defaultLocale:n=w,strategy:_=B,trailingSlash:h=z,routesNameSeparator:m=U,defaultLocaleRouteNameSuffix:d=N,localeCodes:I=[]}={}){const R=Q(I),g=ne(R.map(o=>o.code),m,d);if(ee(l,{localeCodes:R}),s.isVue2){const o=e,E=o.constructor,F=o.options.routes||[],p=X(F,{localeCodes:I,defaultLocale:n,strategy:_,trailingSlash:h,routesNameSeparator:m,defaultLocaleRouteNameSuffix:d});console.log("vue2 routes",F,p);const b=new E({mode:"history",base:o.options.base,routes:p});return b.__defaultLocale=n,b.__strategy=_,b.__trailingSlash=h,b.__routesNameSeparator=m,b.__defaultLocaleRouteNameSuffix=d,b.beforeEach((c,a,t)=>{console.log("beforeEach",c,a);const i=V(l),u=g(c)||i||n||"";console.log("currentLocale",i,"finalLocale",u),i!==u&&q(l,u),t()}),b}else{const o=e,E=o.options.routes||[],F=X(E,{localeCodes:I,defaultLocale:n,strategy:_,trailingSlash:h,routesNameSeparator:m,defaultLocaleRouteNameSuffix:d});return console.log("vue3 routes",E,F,o),E.forEach(p=>o.removeRoute(p.name)),F.forEach(p=>o.addRoute(p)),o.__defaultLocale=n,o.__strategy=_,o.__trailingSlash=h,o.__routesNameSeparator=m,o.__defaultLocaleRouteNameSuffix=d,o.beforeEach((p,b,c)=>{console.log("beforeEach",p,b);const a=V(l),t=g(p)||a||n||"";console.log("currentLocale",a,"finalLocale",t),a!==t&&q(l,t),c()}),o}}function le(){return $.useI18n()}function ae(e={}){const l=le(),n=f.useRouter(),_=f.useRoute(),h=e.defaultLocaleRouteNameSuffix||n.__defaultLocaleRouteNameSuffix,m=e.defaultLocale||n.__defaultLocale,d=e.routesNameSeparator||n.__routesNameSeparator,I=e.strategy||n.__strategy;function R(c){const a=c!=null?c:s.isRef(_)?_.value:_;return a.name?D(a.name).split(d)[0]:void 0}function g(c,a){let t=D(c)+(I==="no_prefix"?"":d+a);return a===m&&I==="prefix_and_default"&&(t+=d+h),t}function o(c,a){const t=a||V(l);let i=c;T(c)&&(c[0]==="/"?i={path:c}:i={name:c});let u=C({},i);if(u.path&&!u.name){const L=n.resolve(u),P=s.isVue2?L.route:L,A=R(P);T(A)&&(u={name:g(A,t),params:P.params,query:P.query,hash:P.hash})}else{u.name=g(u.name,t);const{params:L}=u;L&&L["0"]===void 0&&L.pathMatch&&(L["0"]=L.pathMatch)}const S=n.resolve(u);return(s.isVue2?S.route.name:S.name)?S:n.resolve(c)}function E(c,a){const t=o(c,a);return t==null?"":s.isVue2?t.route.redirectedFrom||t.route.fullPath:t.redirectedFrom||t.fullPath}function F(c,a){const t=o(c,a);return t==null?void 0:s.isVue2?t.route:t}function p(c,a){const t=o(c,a);return t==null?void 0:s.isVue2?t.location:t.href}function b(c){const a=R();if(!a)return"";const P=s.isVue2&&s.isRef(_)?_.value:_,{params:t}=P,i=Y(P,["params"]),u={},S=C({},i,{name:a,params:j(v(v({},t),u),{0:t.pathMatch})}),L=E(S,c);return console.log("switchLocalePath",l.locale.value,c,L),L}return{localePath:E,localeRoute:F,localeLocation:p,switchLocalePath:b}}function D(e){return T(e)?e:J(e)?e.toString():""}function se({router:e,i18n:l,defaultLocale:n=w,trailingSlash:_=z,routesNameSeparator:h=U,defaultLocaleRouteNameSuffix:m=N,localeCodes:d=[]}={}){if(e==null)throw new Error("TODO");return ce({router:e,i18n:l,defaultLocale:n,trailingSlash:_,routesNameSeparator:h,defaultLocaleRouteNameSuffix:m,localeCodes:d})}const re="";return r.VERSION=re,r.extendRouting=se,r.localizeRoutes=X,r.useI18nRouting=ae,Object.defineProperty(r,"__esModule",{value:!0}),r[Symbol.toStringTag]="Module",r}({},VueDemi,VueRouterComposable,VueI18n);
{
"name": "vue-i18n-routing",
"description": "The i18n routing with using vue-i18n",
"version": "0.0.0-9551f85",
"version": "0.0.0-9c21557",
"dependencies": {
"@intlify/shared": "beta",
"@intlify/vue-router-composable": "0.0.0-9c21557",
"vue-demi": "*"

@@ -8,0 +9,0 @@ },

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc