vue-i18n-routing
Advanced tools
Comparing version 0.8.1 to 0.8.2-ddbe221
@@ -158,2 +158,4 @@ import type { Composer } from '@intlify/vue-i18n-bridge'; | ||
export declare function getComposer(i18n: I18n | VueI18n): Composer; | ||
/** | ||
@@ -160,0 +162,0 @@ * Get global i18n routing options |
@@ -1,2 +0,2 @@ | ||
var VueI18nRouting = function(exports, vueDemi, VueRouter3, vueI18nBridge) { | ||
var VueI18nRouting = function(exports, VueRouter3, vueDemi, vueI18nBridge) { | ||
"use strict"; | ||
@@ -601,2 +601,25 @@ const _interopDefaultLegacy = (e) => e && typeof e === "object" && "default" in e ? e : { default: e }; | ||
} | ||
function split(str, index) { | ||
const result = [str.slice(0, index), str.slice(index)]; | ||
return result; | ||
} | ||
function resolve(router, route, strategy, locale) { | ||
if (vueDemi.isVue3 && strategy === "prefix") { | ||
if (isArray(route.matched) && route.matched.length > 0) { | ||
return route.matched[0]; | ||
} | ||
const [rootSlash, restPath] = split(route.path, 1); | ||
const targetPath = `${rootSlash}${locale}${restPath === "" ? restPath : `/${restPath}`}`; | ||
const _route = router.options.routes.find((r) => r.path === targetPath); | ||
if (_route == null) { | ||
return route; | ||
} else { | ||
const _resolevableRoute = assign({}, _route); | ||
_resolevableRoute.path = targetPath; | ||
return router.resolve(_resolevableRoute); | ||
} | ||
} else { | ||
return router.resolve(route); | ||
} | ||
} | ||
const RESOLVED_PREFIXED = /* @__PURE__ */ new Set(["prefix_and_default", "prefix_except_default"]); | ||
@@ -648,3 +671,3 @@ function prefixable(optons) { | ||
try { | ||
_resolvedRoute = router.resolve(localizedRoute); | ||
_resolvedRoute = resolve(router, localizedRoute, strategy, _locale); | ||
} catch { | ||
@@ -1067,3 +1090,3 @@ } | ||
} | ||
const VERSION = "0.8.1"; | ||
const VERSION = "0.8.2"; | ||
exports.DEFAULT_BASE_URL = DEFAULT_BASE_URL; | ||
@@ -1086,2 +1109,3 @@ exports.DEFAULT_DETECTION_DIRECTION = DEFAULT_DETECTION_DIRECTION; | ||
exports.findBrowserLocale = findBrowserLocale; | ||
exports.getComposer = getComposer; | ||
exports.getGlobalOptions = getGlobalOptions; | ||
@@ -1117,2 +1141,2 @@ exports.getLocale = getLocale; | ||
return exports; | ||
}({}, VueDemi, VueRouter, VueI18n); | ||
}({}, VueRouter, VueDemi, VueI18n); |
"use strict"; | ||
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } }); | ||
const VueRouter3 = require("@intlify/vue-router-bridge"); | ||
const vueDemi = require("vue-demi"); | ||
const VueRouter3 = require("@intlify/vue-router-bridge"); | ||
const vueI18nBridge = require("@intlify/vue-i18n-bridge"); | ||
@@ -604,2 +604,25 @@ const _interopDefaultLegacy = (e) => e && typeof e === "object" && "default" in e ? e : { default: e }; | ||
} | ||
function split(str, index) { | ||
const result = [str.slice(0, index), str.slice(index)]; | ||
return result; | ||
} | ||
function resolve(router, route, strategy, locale) { | ||
if (vueDemi.isVue3 && strategy === "prefix") { | ||
if (isArray(route.matched) && route.matched.length > 0) { | ||
return route.matched[0]; | ||
} | ||
const [rootSlash, restPath] = split(route.path, 1); | ||
const targetPath = `${rootSlash}${locale}${restPath === "" ? restPath : `/${restPath}`}`; | ||
const _route = router.options.routes.find((r) => r.path === targetPath); | ||
if (_route == null) { | ||
return route; | ||
} else { | ||
const _resolevableRoute = assign({}, _route); | ||
_resolevableRoute.path = targetPath; | ||
return router.resolve(_resolevableRoute); | ||
} | ||
} else { | ||
return router.resolve(route); | ||
} | ||
} | ||
const RESOLVED_PREFIXED = /* @__PURE__ */ new Set(["prefix_and_default", "prefix_except_default"]); | ||
@@ -651,3 +674,3 @@ function prefixable(optons) { | ||
try { | ||
_resolvedRoute = router.resolve(localizedRoute); | ||
_resolvedRoute = resolve(router, localizedRoute, strategy, _locale); | ||
} catch { | ||
@@ -1070,3 +1093,3 @@ } | ||
} | ||
const VERSION = "0.8.1"; | ||
const VERSION = "0.8.2"; | ||
exports.DEFAULT_BASE_URL = DEFAULT_BASE_URL; | ||
@@ -1089,2 +1112,3 @@ exports.DEFAULT_DETECTION_DIRECTION = DEFAULT_DETECTION_DIRECTION; | ||
exports.findBrowserLocale = findBrowserLocale; | ||
exports.getComposer = getComposer; | ||
exports.getGlobalOptions = getGlobalOptions; | ||
@@ -1091,0 +1115,0 @@ exports.getLocale = getLocale; |
{ | ||
"name": "vue-i18n-routing", | ||
"description": "The i18n routing with using vue-i18n", | ||
"version": "0.8.1", | ||
"scripts": { | ||
"dev": "vite", | ||
"build": "vite build", | ||
"typecheck": "tsc -p . --noEmit", | ||
"switch:2": "vue-demi-switch 2 vue2 && vue-router-switch 3 vue-router3 && vue-i18n-switch 8 vue-i18n-legacy", | ||
"switch:3": "vue-demi-switch 3 && vue-router-switch 4 && vue-i18n-switch 9", | ||
"test": "vitest run", | ||
"test:watch": "vitest", | ||
"test:cover": "vitest --coverage", | ||
"build:docs": "api-docs-gen ./temp/vue-i18n-routing.api.json -c ./docsgen.config.js -o ./ -g noprefix" | ||
}, | ||
"version": "0.8.2-ddbe221", | ||
"dependencies": { | ||
@@ -20,4 +9,4 @@ "@intlify/shared": "next", | ||
"@intlify/vue-router-bridge": "^0.7.0", | ||
"ufo": "^0.8.5", | ||
"vue-demi": "^0.13.5" | ||
"ufo": "^0.8.6", | ||
"vue-demi": "^0.13.11" | ||
}, | ||
@@ -27,6 +16,6 @@ "devDependencies": { | ||
"api-docs-gen": "^0.4.0", | ||
"typescript": "^4.8.3", | ||
"vite": "^3.1.2", | ||
"typescript": "^4.8.4", | ||
"vite": "^3.2.2", | ||
"vite-plugin-dts": "^0.9.6", | ||
"vitest": "^0.23.4", | ||
"vitest": "^0.24.5", | ||
"vue": "^3.2.27", | ||
@@ -124,3 +113,14 @@ "vue-i18n": "npm:vue-i18n@next", | ||
}, | ||
"sideEffects": false | ||
} | ||
"sideEffects": false, | ||
"scripts": { | ||
"dev": "vite", | ||
"build": "vite build", | ||
"typecheck": "tsc -p . --noEmit", | ||
"switch:2": "vue-demi-switch 2 vue2 && vue-router-switch 3 vue-router3 && vue-i18n-switch 8 vue-i18n-legacy", | ||
"switch:3": "vue-demi-switch 3 && vue-router-switch 4 && vue-i18n-switch 9", | ||
"test": "vitest run", | ||
"test:watch": "vitest", | ||
"test:cover": "vitest --coverage", | ||
"build:docs": "api-docs-gen ./temp/vue-i18n-routing.api.json -c ./docsgen.config.js -o ./ -g noprefix" | ||
} | ||
} |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
154493
4172
Updatedufo@^0.8.6
Updatedvue-demi@^0.13.11