nuxt-i18n-micro 1.100.1 → 1.101.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/client/200.html +2 -2
- package/dist/client/404.html +2 -2
- package/dist/client/_nuxt/builds/latest.json +1 -1
- package/dist/client/_nuxt/builds/meta/3c2f5e13-457a-416f-af4d-c74141ba3650.json +1 -0
- package/dist/client/index.html +2 -2
- package/dist/module.json +1 -1
- package/dist/runtime/composables/useLocaleHead.js +2 -1
- package/dist/runtime/plugins/06.redirect.js +3 -6
- package/dist/runtime/utils/route-utils.d.ts +22 -0
- package/dist/runtime/utils/route-utils.js +19 -0
- package/package.json +3 -3
- package/dist/client/_nuxt/builds/meta/0b9a2a10-97c8-4c5c-9ebc-9ac0a7ea1fbf.json +0 -1
package/dist/client/200.html
CHANGED
|
@@ -8,5 +8,5 @@
|
|
|
8
8
|
<link rel="prefetch" as="script" crossorigin href="/__NUXT_DEVTOOLS_I18N_BASE__/_nuxt/T7szCJDf.js">
|
|
9
9
|
<link rel="prefetch" as="style" crossorigin href="/__NUXT_DEVTOOLS_I18N_BASE__/_nuxt/error-500.DGwSTbEi.css">
|
|
10
10
|
<link rel="prefetch" as="script" crossorigin href="/__NUXT_DEVTOOLS_I18N_BASE__/_nuxt/DTIY11lm.js">
|
|
11
|
-
<script type="module" src="/__NUXT_DEVTOOLS_I18N_BASE__/_nuxt/s7GTWWQo.js" crossorigin></script></head><body><div id="__nuxt"></div><div id="teleports"></div><script type="application/json" data-nuxt-data="nuxt-app" data-ssr="false" id="__NUXT_DATA__">[{"prerenderedAt":1,"serverRendered":2},
|
|
12
|
-
<script>window.__NUXT__={};window.__NUXT__.config={public:{},app:{baseURL:"/__NUXT_DEVTOOLS_I18N_BASE__/",buildId:"
|
|
11
|
+
<script type="module" src="/__NUXT_DEVTOOLS_I18N_BASE__/_nuxt/s7GTWWQo.js" crossorigin></script></head><body><div id="__nuxt"></div><div id="teleports"></div><script type="application/json" data-nuxt-data="nuxt-app" data-ssr="false" id="__NUXT_DATA__">[{"prerenderedAt":1,"serverRendered":2},1759936060690,false]</script>
|
|
12
|
+
<script>window.__NUXT__={};window.__NUXT__.config={public:{},app:{baseURL:"/__NUXT_DEVTOOLS_I18N_BASE__/",buildId:"3c2f5e13-457a-416f-af4d-c74141ba3650",buildAssetsDir:"/_nuxt/",cdnURL:""}}</script></body></html>
|
package/dist/client/404.html
CHANGED
|
@@ -8,5 +8,5 @@
|
|
|
8
8
|
<link rel="prefetch" as="script" crossorigin href="/__NUXT_DEVTOOLS_I18N_BASE__/_nuxt/T7szCJDf.js">
|
|
9
9
|
<link rel="prefetch" as="style" crossorigin href="/__NUXT_DEVTOOLS_I18N_BASE__/_nuxt/error-500.DGwSTbEi.css">
|
|
10
10
|
<link rel="prefetch" as="script" crossorigin href="/__NUXT_DEVTOOLS_I18N_BASE__/_nuxt/DTIY11lm.js">
|
|
11
|
-
<script type="module" src="/__NUXT_DEVTOOLS_I18N_BASE__/_nuxt/s7GTWWQo.js" crossorigin></script></head><body><div id="__nuxt"></div><div id="teleports"></div><script type="application/json" data-nuxt-data="nuxt-app" data-ssr="false" id="__NUXT_DATA__">[{"prerenderedAt":1,"serverRendered":2},
|
|
12
|
-
<script>window.__NUXT__={};window.__NUXT__.config={public:{},app:{baseURL:"/__NUXT_DEVTOOLS_I18N_BASE__/",buildId:"
|
|
11
|
+
<script type="module" src="/__NUXT_DEVTOOLS_I18N_BASE__/_nuxt/s7GTWWQo.js" crossorigin></script></head><body><div id="__nuxt"></div><div id="teleports"></div><script type="application/json" data-nuxt-data="nuxt-app" data-ssr="false" id="__NUXT_DATA__">[{"prerenderedAt":1,"serverRendered":2},1759936060690,false]</script>
|
|
12
|
+
<script>window.__NUXT__={};window.__NUXT__.config={public:{},app:{baseURL:"/__NUXT_DEVTOOLS_I18N_BASE__/",buildId:"3c2f5e13-457a-416f-af4d-c74141ba3650",buildAssetsDir:"/_nuxt/",cdnURL:""}}</script></body></html>
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"id":"
|
|
1
|
+
{"id":"3c2f5e13-457a-416f-af4d-c74141ba3650","timestamp":1759936052722}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"id":"3c2f5e13-457a-416f-af4d-c74141ba3650","timestamp":1759936052722,"matcher":{"static":{},"wildcard":{},"dynamic":{}},"prerendered":[]}
|
package/dist/client/index.html
CHANGED
|
@@ -8,5 +8,5 @@
|
|
|
8
8
|
<link rel="prefetch" as="script" crossorigin href="/__NUXT_DEVTOOLS_I18N_BASE__/_nuxt/T7szCJDf.js">
|
|
9
9
|
<link rel="prefetch" as="style" crossorigin href="/__NUXT_DEVTOOLS_I18N_BASE__/_nuxt/error-500.DGwSTbEi.css">
|
|
10
10
|
<link rel="prefetch" as="script" crossorigin href="/__NUXT_DEVTOOLS_I18N_BASE__/_nuxt/DTIY11lm.js">
|
|
11
|
-
<script type="module" src="/__NUXT_DEVTOOLS_I18N_BASE__/_nuxt/s7GTWWQo.js" crossorigin></script></head><body><div id="__nuxt"></div><div id="teleports"></div><script type="application/json" data-nuxt-data="nuxt-app" data-ssr="false" id="__NUXT_DATA__">[{"prerenderedAt":1,"serverRendered":2},
|
|
12
|
-
<script>window.__NUXT__={};window.__NUXT__.config={public:{},app:{baseURL:"/__NUXT_DEVTOOLS_I18N_BASE__/",buildId:"
|
|
11
|
+
<script type="module" src="/__NUXT_DEVTOOLS_I18N_BASE__/_nuxt/s7GTWWQo.js" crossorigin></script></head><body><div id="__nuxt"></div><div id="teleports"></div><script type="application/json" data-nuxt-data="nuxt-app" data-ssr="false" id="__NUXT_DATA__">[{"prerenderedAt":1,"serverRendered":2},1759936060691,false]</script>
|
|
12
|
+
<script>window.__NUXT__={};window.__NUXT__.config={public:{},app:{baseURL:"/__NUXT_DEVTOOLS_I18N_BASE__/",buildId:"3c2f5e13-457a-416f-af4d-c74141ba3650",buildAssetsDir:"/_nuxt/",cdnURL:""}}</script></body></html>
|
package/dist/module.json
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { joinURL, parseURL, withQuery } from "ufo";
|
|
2
2
|
import { isPrefixExceptDefaultStrategy, isNoPrefixStrategy } from "nuxt-i18n-micro-core";
|
|
3
3
|
import { unref, useRoute, useRuntimeConfig, watch, onUnmounted, ref, useNuxtApp } from "#imports";
|
|
4
|
+
import { findAllowedLocalesForRoute } from "../utils/route-utils.js";
|
|
4
5
|
export const useLocaleHead = async ({ addDirAttribute = true, identifierAttribute = "id", addSeoAttributes = true, baseUrl = "/" } = {}) => {
|
|
5
6
|
const metaObject = ref({
|
|
6
7
|
htmlAttrs: {},
|
|
@@ -28,7 +29,7 @@ export const useLocaleHead = async ({ addDirAttribute = true, identifierAttribut
|
|
|
28
29
|
const routeName = (route.name ?? "").toString();
|
|
29
30
|
const currentLocale = unref($getLocales().find((loc) => loc.code === locale));
|
|
30
31
|
if (!currentLocale) return;
|
|
31
|
-
const currentRouteLocales =
|
|
32
|
+
const currentRouteLocales = findAllowedLocalesForRoute(route, routeLocales);
|
|
32
33
|
const locales = currentRouteLocales ? allLocales.filter((loc) => currentRouteLocales.includes(loc.code)) : allLocales;
|
|
33
34
|
const currentIso = currentLocale.iso || locale;
|
|
34
35
|
const currentDir = currentLocale.dir || "auto";
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { isNoPrefixStrategy, isPrefixStrategy } from "nuxt-i18n-micro-core";
|
|
2
2
|
import { defineNuxtPlugin, useRuntimeConfig, useRoute, useRouter, navigateTo, createError } from "#imports";
|
|
3
|
+
import { findAllowedLocalesForRoute } from "../utils/route-utils.js";
|
|
3
4
|
export default defineNuxtPlugin(async (nuxtApp) => {
|
|
4
5
|
const config = useRuntimeConfig();
|
|
5
6
|
const i18nConfig = config.public.i18nConfig;
|
|
@@ -7,15 +8,11 @@ export default defineNuxtPlugin(async (nuxtApp) => {
|
|
|
7
8
|
const route = useRoute();
|
|
8
9
|
const router = useRouter();
|
|
9
10
|
const checkRouteLocales = (to) => {
|
|
10
|
-
const
|
|
11
|
-
const routeName = to.name?.toString();
|
|
12
|
-
const normalizedRouteName = routeName?.replace("localized-", "");
|
|
13
|
-
const normalizedRoutePath = normalizedRouteName ? `/${normalizedRouteName}` : void 0;
|
|
14
|
-
const allowedLocales = routeName && routeLocales?.[routeName] || normalizedRouteName && routeLocales?.[normalizedRouteName] || normalizedRoutePath && routeLocales?.[normalizedRoutePath] || routeLocales?.[routePath];
|
|
11
|
+
const allowedLocales = findAllowedLocalesForRoute(to, routeLocales);
|
|
15
12
|
if (!allowedLocales || allowedLocales.length === 0) {
|
|
16
13
|
return;
|
|
17
14
|
}
|
|
18
|
-
const pathSegments =
|
|
15
|
+
const pathSegments = to.path.split("/").filter(Boolean);
|
|
19
16
|
const firstSegment = pathSegments[0];
|
|
20
17
|
const allLocales = i18nConfig.locales?.map((l) => l.code) || [];
|
|
21
18
|
if (firstSegment && allLocales.includes(firstSegment) && !allowedLocales.includes(firstSegment)) {
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { RouteLocationNormalizedLoaded } from 'vue-router';
|
|
2
|
+
/**
|
|
3
|
+
* Extracts the base route pattern from a matched route path
|
|
4
|
+
* Converts Vue Router dynamic route patterns to file-based route patterns
|
|
5
|
+
*
|
|
6
|
+
* @param matchedPath - The matched route path from route.matched[0].path
|
|
7
|
+
* @returns The base route pattern (e.g., "/test/[param]")
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* extractBaseRoutePattern('/:locale(es)/test/:param()') // Returns '/test/[param]'
|
|
11
|
+
* extractBaseRoutePattern('/:locale(en)/static') // Returns '/static'
|
|
12
|
+
* extractBaseRoutePattern('/:locale(fr)/about/:id') // Returns '/about/[id]'
|
|
13
|
+
*/
|
|
14
|
+
export declare function extractBaseRoutePattern(matchedPath: string): string;
|
|
15
|
+
/**
|
|
16
|
+
* Finds allowed locales for a route using various matching strategies
|
|
17
|
+
*
|
|
18
|
+
* @param route - The route object
|
|
19
|
+
* @param routeLocales - The routeLocales configuration object
|
|
20
|
+
* @returns Array of allowed locale codes or null if no restrictions
|
|
21
|
+
*/
|
|
22
|
+
export declare function findAllowedLocalesForRoute(route: RouteLocationNormalizedLoaded, routeLocales: Record<string, string[]> | undefined): string[] | null;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export function extractBaseRoutePattern(matchedPath) {
|
|
2
|
+
return matchedPath.replace(/\/:locale\([^)]+\)/g, "").replace(/\/:([^()]+)\(\)/g, "/[$1]").replace(/\/:([^()]+)/g, "/[$1]");
|
|
3
|
+
}
|
|
4
|
+
export function findAllowedLocalesForRoute(route, routeLocales) {
|
|
5
|
+
const routePath = route.path;
|
|
6
|
+
const routeName = route.name?.toString();
|
|
7
|
+
const normalizedRouteName = routeName?.replace("localized-", "");
|
|
8
|
+
const normalizedRoutePath = normalizedRouteName ? `/${normalizedRouteName}` : void 0;
|
|
9
|
+
let allowedLocales = routeName && routeLocales?.[routeName] || normalizedRouteName && routeLocales?.[normalizedRouteName] || normalizedRoutePath && routeLocales?.[normalizedRoutePath] || routeLocales?.[routePath];
|
|
10
|
+
if (!allowedLocales && route.matched && route.matched.length > 0) {
|
|
11
|
+
const matchedRoute = route.matched[0];
|
|
12
|
+
const matchedPath = matchedRoute.path;
|
|
13
|
+
const baseRoutePattern = extractBaseRoutePattern(matchedPath);
|
|
14
|
+
if (routeLocales?.[baseRoutePattern]) {
|
|
15
|
+
allowedLocales = routeLocales[baseRoutePattern];
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
return allowedLocales || null;
|
|
19
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nuxt-i18n-micro",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.101.0",
|
|
4
4
|
"description": "Nuxt I18n Micro is a lightweight, high-performance internationalization module for Nuxt, designed to handle multi-language support with minimal overhead, fast build times, and efficient runtime performance.",
|
|
5
5
|
"repository": "s00d/nuxt-i18n-micro",
|
|
6
6
|
"license": "MIT",
|
|
@@ -62,8 +62,8 @@
|
|
|
62
62
|
"sirv": "^2.0.4",
|
|
63
63
|
"ufo": "^1.5.4",
|
|
64
64
|
"nuxt-i18n-micro-core": "1.0.18",
|
|
65
|
-
"nuxt-i18n-micro-
|
|
66
|
-
"nuxt-i18n-micro-
|
|
65
|
+
"nuxt-i18n-micro-types": "1.0.9",
|
|
66
|
+
"nuxt-i18n-micro-test-utils": "1.0.6"
|
|
67
67
|
},
|
|
68
68
|
"devDependencies": {
|
|
69
69
|
"@nuxt/devtools": "^2.6.3",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"id":"0b9a2a10-97c8-4c5c-9ebc-9ac0a7ea1fbf","timestamp":1759916788415,"matcher":{"static":{},"wildcard":{},"dynamic":{}},"prerendered":[]}
|