New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

vue-i18n-routing

Package Overview
Dependencies
Maintainers
1
Versions
239
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

vue-i18n-routing - npm Package Compare versions

Comparing version 0.0.0-ca50166 to 0.0.0-d4abcf5

dist/vue-i18n-routing.cjs.js

133

dist/vue-i18n-routing.es.js

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

const VueI18nRouting = {
routes: []
var __defProp = Object.defineProperty;
var __defProps = Object.defineProperties;
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __propIsEnum = Object.prototype.propertyIsEnumerable;
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
var __spreadValues = (a, b) => {
for (var prop in b || (b = {}))
if (__hasOwnProp.call(b, prop))
__defNormalProp(a, prop, b[prop]);
if (__getOwnPropSymbols)
for (var prop of __getOwnPropSymbols(b)) {
if (__propIsEnum.call(b, prop))
__defNormalProp(a, prop, b[prop]);
}
return a;
};
console.log("this is vue-i18n-rouging!");
export { VueI18nRouting };
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
import { isVue2 } from "vue-demi";
const VUE_I18N_ROUTING_DEFAULTS = {
defaultLocale: "en-US",
trailingSlash: false,
routesNameSeparator: "___",
defaultLocaleRouteNameSuffix: "default"
};
function adjustRoutePathForTrailingSlash(pagePath, trailingSlash, isChildWithRelativePath) {
return pagePath.replace(/\/+$/, "") + (trailingSlash ? "/" : "") || (isChildWithRelativePath ? "" : "/");
}
function localizeRoutes(routes, {
defaultLocale = VUE_I18N_ROUTING_DEFAULTS.defaultLocale,
trailingSlash = VUE_I18N_ROUTING_DEFAULTS.trailingSlash,
routesNameSeparator = VUE_I18N_ROUTING_DEFAULTS.routesNameSeparator,
defaultLocaleRouteNameSuffix = VUE_I18N_ROUTING_DEFAULTS.defaultLocaleRouteNameSuffix,
localeCodes = []
} = {}) {
function makeLocalizedRoutes(route, allowedLocaleCodes, isChild = false, isExtraPageTree = false) {
if (route.redirect && (!route.component || !route.file)) {
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) {
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;
if (shouldAddPrefix) {
path = `/${locale}${path}`;
}
if (path) {
path = adjustRoutePathForTrailingSlash(path, trailingSlash, isChildWithRelativePath);
}
localizedRoute.path = path;
_routes.push(localizedRoute);
return _routes;
}, []);
}
return routes.reduce((localized, route) => [...localized, ...makeLocalizedRoutes(route, localeCodes || [])], []);
}
const VueI18nRoutingPlugin = function(vueApp, {
router,
i18n,
defaultLocale = VUE_I18N_ROUTING_DEFAULTS.defaultLocale,
trailingSlash = VUE_I18N_ROUTING_DEFAULTS.trailingSlash,
routesNameSeparator = VUE_I18N_ROUTING_DEFAULTS.routesNameSeparator,
defaultLocaleRouteNameSuffix = VUE_I18N_ROUTING_DEFAULTS.defaultLocaleRouteNameSuffix,
localeCodes = []
} = {}) {
if (router == null) {
throw new Error("TODO");
}
if (isVue2) {
const _router = router;
const VueRouter = _router.constructor;
const routes = _router.options.routes || [];
const localizedRoutes = localizeRoutes(routes, {
localeCodes,
defaultLocale,
trailingSlash,
routesNameSeparator,
defaultLocaleRouteNameSuffix
});
const newRouter = new VueRouter({ mode: "history", routes: [] });
_router.matcher = newRouter.matcher;
localizedRoutes.forEach((route) => {
_router.addRoute(route);
});
} else {
const _router = router;
const routes = _router.options.routes || [];
const localizedRoutes = localizeRoutes(routes, {
localeCodes,
defaultLocale,
trailingSlash,
routesNameSeparator,
defaultLocaleRouteNameSuffix
});
console.log("vue3 routes", routes, localizedRoutes);
routes.forEach((r) => _router.removeRoute(r.name));
localizedRoutes.forEach((route) => _router.addRoute(route));
}
console.log("install vue-i18n-rouging!", router, i18n, defaultLocale, trailingSlash, routesNameSeparator, defaultLocaleRouteNameSuffix, localeCodes);
};
const VERSION = "0.0.0";
export { VERSION, VueI18nRoutingPlugin, localizeRoutes };

47

package.json
{
"name": "vue-i18n-routing",
"description": "The i18n routing with using vue-i18n",
"version": "0.0.0-ca50166",
"version": "0.0.0-d4abcf5",
"dependencies": {
"vue": "next",
"vue-router": "next"
"vue-demi": "*"
},
"devDependencies": {
"@vitejs/plugin-vue": "^1.9.3",
"vite": "^2.6.4"
"vite": "^2.6.4",
"vite-plugin-dts": "^0.9.6",
"vue": "^3.2.23",
"vue-router": "^4.0.12",
"vue2": "npm:vue@2",
"vue-router3": "npm:vue-router@latest",
"rimraf": "^3.0.2",
"@microsoft/api-extractor": "^7.18.20",
"api-docs-gen": "^0.4.0"
},
"peerDependencies": {
"@vue/composition-api": "^1.4.0",
"vue": "^2.6.14 || ^3.2.0",
"vue-router": "^3.5.3 || ^4.0.0"
},
"peerDependenciesMeta": {
"@vue/composition-api": {
"optional": true
}
},
"keywords": [

@@ -20,10 +36,19 @@ "i18n",

"files": [
"dist"
"dist",
"index.mjs",
"LICENSE",
"README.md"
],
"main": "./dist/vue-i18n-routing.umd.js",
"main": "./dist/vue-i18n-routing.cjs.js",
"module": "./dist/vue-i18n-routing.es.js",
"unpkg": "dist/vue-i18n-routing.iife.js",
"jsdelivr": "dist/vue-i18n-routing.iife.js",
"types": "dist/vue-i18n-routing.d.ts",
"exports": {
".": {
"import": "./dist/vue-i18n-routing.es.js",
"require": "./dist/vue-i18n-routing.umd.js"
"import": {
"node": "./index.mjs",
"default": "./dist/vue-i18n-routing.es.js"
},
"require": "./dist/vue-i18n-routing.cjs.js"
}

@@ -54,4 +79,6 @@ },

"dev": "vite",
"build": "vite build"
"build": "vite build",
"typecheck": "tsc -p . --noEmit",
"build:docs": "api-docs-gen ./temp/vue-i18n-routing.api.json -c ./docsgen.config.js -o ./ -g noprefix"
}
}

@@ -7,4 +7,8 @@ # vue-i18n-routing

## 🤝 API
About details, See the [API References]('./api.md)
## ©️ License
[MIT](http://opensource.org/licenses/MIT)
SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc