nuxt-i18n-micro 2.11.0 → 2.12.1
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/df255026-5ffe-4c47-b2f1-585895bcd2e6.json +1 -0
- package/dist/client/index.html +2 -2
- package/dist/module.json +1 -1
- package/dist/runtime/components/locale-redirect.vue +62 -12
- package/package.json +31 -33
- package/dist/client/_nuxt/builds/meta/7323731f-46c9-4bc3-8e1d-f2e545f99ff5.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/CBxwnKtU.js">
|
|
9
9
|
<link rel="prefetch" as="style" crossorigin href="/__NUXT_DEVTOOLS_I18N_BASE__/_nuxt/error-500.BqKd8Zt-.css">
|
|
10
10
|
<link rel="prefetch" as="script" crossorigin href="/__NUXT_DEVTOOLS_I18N_BASE__/_nuxt/BYEpoBUk.js">
|
|
11
|
-
<script type="module" src="/__NUXT_DEVTOOLS_I18N_BASE__/_nuxt/XZXfxmri.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/XZXfxmri.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},1764744435308,false]</script>
|
|
12
|
+
<script>window.__NUXT__={};window.__NUXT__.config={public:{},app:{baseURL:"/__NUXT_DEVTOOLS_I18N_BASE__/",buildId:"df255026-5ffe-4c47-b2f1-585895bcd2e6",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/CBxwnKtU.js">
|
|
9
9
|
<link rel="prefetch" as="style" crossorigin href="/__NUXT_DEVTOOLS_I18N_BASE__/_nuxt/error-500.BqKd8Zt-.css">
|
|
10
10
|
<link rel="prefetch" as="script" crossorigin href="/__NUXT_DEVTOOLS_I18N_BASE__/_nuxt/BYEpoBUk.js">
|
|
11
|
-
<script type="module" src="/__NUXT_DEVTOOLS_I18N_BASE__/_nuxt/XZXfxmri.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/XZXfxmri.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},1764744435308,false]</script>
|
|
12
|
+
<script>window.__NUXT__={};window.__NUXT__.config={public:{},app:{baseURL:"/__NUXT_DEVTOOLS_I18N_BASE__/",buildId:"df255026-5ffe-4c47-b2f1-585895bcd2e6",buildAssetsDir:"/_nuxt/",cdnURL:""}}</script></body></html>
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"id":"
|
|
1
|
+
{"id":"df255026-5ffe-4c47-b2f1-585895bcd2e6","timestamp":1764744429004}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"id":"df255026-5ffe-4c47-b2f1-585895bcd2e6","timestamp":1764744429004,"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/CBxwnKtU.js">
|
|
9
9
|
<link rel="prefetch" as="style" crossorigin href="/__NUXT_DEVTOOLS_I18N_BASE__/_nuxt/error-500.BqKd8Zt-.css">
|
|
10
10
|
<link rel="prefetch" as="script" crossorigin href="/__NUXT_DEVTOOLS_I18N_BASE__/_nuxt/BYEpoBUk.js">
|
|
11
|
-
<script type="module" src="/__NUXT_DEVTOOLS_I18N_BASE__/_nuxt/XZXfxmri.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/XZXfxmri.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},1764744435308,false]</script>
|
|
12
|
+
<script>window.__NUXT__={};window.__NUXT__.config={public:{},app:{baseURL:"/__NUXT_DEVTOOLS_I18N_BASE__/",buildId:"df255026-5ffe-4c47-b2f1-585895bcd2e6",buildAssetsDir:"/_nuxt/",cdnURL:""}}</script></body></html>
|
package/dist/module.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
</template>
|
|
4
4
|
|
|
5
5
|
<script setup>
|
|
6
|
-
import { useRoute, useRouter, useI18n, createError, navigateTo, useRuntimeConfig } from "#imports";
|
|
6
|
+
import { useRoute, useRouter, useI18n, createError, navigateTo, useRuntimeConfig, showError } from "#imports";
|
|
7
7
|
import { isInternalPath } from "../utils/path-utils";
|
|
8
8
|
import { isPrefixStrategy, isPrefixExceptDefaultStrategy } from "nuxt-i18n-micro-core";
|
|
9
9
|
const route = useRoute();
|
|
@@ -17,10 +17,17 @@ const defaultLocale = $defaultLocale() || "en";
|
|
|
17
17
|
const pathSegments = route.fullPath.split("/");
|
|
18
18
|
const firstSegment = pathSegments[1];
|
|
19
19
|
if (isInternalPath(route.fullPath, i18nConfig?.excludePatterns)) {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
20
|
+
if (import.meta.client) {
|
|
21
|
+
showError({
|
|
22
|
+
statusCode: 404,
|
|
23
|
+
statusMessage: "Static file - should not be processed by i18n"
|
|
24
|
+
});
|
|
25
|
+
} else {
|
|
26
|
+
throw createError({
|
|
27
|
+
statusCode: 404,
|
|
28
|
+
statusMessage: "Static file - should not be processed by i18n"
|
|
29
|
+
});
|
|
30
|
+
}
|
|
24
31
|
}
|
|
25
32
|
const handleRedirect = (path) => {
|
|
26
33
|
const finalPath = route.query && Object.keys(route.query).length > 0 ? `${path}?${new URLSearchParams(route.query).toString()}` : path;
|
|
@@ -41,31 +48,74 @@ const routeExists = (path) => {
|
|
|
41
48
|
};
|
|
42
49
|
const globalLocaleRoutes = route.meta.globalLocaleRoutes ?? {};
|
|
43
50
|
const currentPageName = route.path.split("/").filter(Boolean).join("-");
|
|
51
|
+
let shouldThrow404 = false;
|
|
52
|
+
let redirectHandled = false;
|
|
44
53
|
if (locales.includes(firstSegment)) {
|
|
45
54
|
const pathWithoutPrefix = "/" + pathSegments.slice(2).join("/");
|
|
46
55
|
if (isPrefixExceptDefaultStrategy(strategy) && firstSegment === defaultLocale) {
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
56
|
+
if (import.meta.client) {
|
|
57
|
+
showError({
|
|
58
|
+
statusCode: 404,
|
|
59
|
+
statusMessage: `Page not found for default locale with prefix ('${firstSegment}')`
|
|
60
|
+
});
|
|
61
|
+
} else {
|
|
62
|
+
throw createError({
|
|
63
|
+
statusCode: 404,
|
|
64
|
+
statusMessage: `Page not found for default locale with prefix ('${firstSegment}')`
|
|
65
|
+
});
|
|
66
|
+
}
|
|
51
67
|
}
|
|
52
68
|
const customPath = globalLocaleRoutes[currentPageName]?.[firstSegment];
|
|
53
69
|
if (customPath && customPath !== pathWithoutPrefix) {
|
|
54
70
|
handleRedirect(`/${firstSegment}${customPath}`);
|
|
71
|
+
redirectHandled = true;
|
|
72
|
+
} else if (isPrefixExceptDefaultStrategy(strategy) && firstSegment !== defaultLocale) {
|
|
73
|
+
if (!routeExists(route.fullPath)) {
|
|
74
|
+
shouldThrow404 = true;
|
|
75
|
+
}
|
|
76
|
+
} else if (isPrefixStrategy(strategy)) {
|
|
77
|
+
if (!routeExists(route.fullPath)) {
|
|
78
|
+
shouldThrow404 = true;
|
|
79
|
+
}
|
|
80
|
+
} else {
|
|
81
|
+
if (!redirectHandled) {
|
|
82
|
+
shouldThrow404 = true;
|
|
83
|
+
}
|
|
55
84
|
}
|
|
56
85
|
} else {
|
|
57
86
|
const customPath = globalLocaleRoutes[currentPageName]?.[defaultLocale];
|
|
58
87
|
if (customPath && customPath !== route.fullPath) {
|
|
59
88
|
const targetPath = isPrefixStrategy(strategy) ? `/${defaultLocale}${customPath}` : customPath;
|
|
60
89
|
handleRedirect(targetPath);
|
|
90
|
+
redirectHandled = true;
|
|
61
91
|
} else if (isPrefixStrategy(strategy)) {
|
|
62
92
|
const newPathWithPrefix = `/${defaultLocale}${route.fullPath}`;
|
|
63
93
|
if (routeExists(newPathWithPrefix)) {
|
|
64
94
|
handleRedirect(newPathWithPrefix);
|
|
95
|
+
redirectHandled = true;
|
|
96
|
+
} else {
|
|
97
|
+
shouldThrow404 = true;
|
|
98
|
+
}
|
|
99
|
+
} else if (isPrefixExceptDefaultStrategy(strategy)) {
|
|
100
|
+
if (!routeExists(route.fullPath)) {
|
|
101
|
+
shouldThrow404 = true;
|
|
65
102
|
}
|
|
103
|
+
} else {
|
|
104
|
+
if (!redirectHandled) {
|
|
105
|
+
shouldThrow404 = true;
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
if (shouldThrow404) {
|
|
110
|
+
if (import.meta.client) {
|
|
111
|
+
showError({
|
|
112
|
+
statusCode: 404,
|
|
113
|
+
statusMessage: "Page Not Found"
|
|
114
|
+
});
|
|
115
|
+
} else {
|
|
116
|
+
throw createError({
|
|
117
|
+
statusCode: 404
|
|
118
|
+
});
|
|
66
119
|
}
|
|
67
120
|
}
|
|
68
|
-
throw createError({
|
|
69
|
-
statusCode: 404
|
|
70
|
-
});
|
|
71
121
|
</script>
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nuxt-i18n-micro",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.12.1",
|
|
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",
|
|
@@ -48,32 +48,6 @@
|
|
|
48
48
|
"dist",
|
|
49
49
|
"internals.d.mts"
|
|
50
50
|
],
|
|
51
|
-
"scripts": {
|
|
52
|
-
"prepack": "pnpm --filter \"./packages/**\" run build && nuxt-module-build build --stub && nuxt-module-build prepare && nuxt-module-build build && pnpm run client:build",
|
|
53
|
-
"dev": "nuxi dev playground",
|
|
54
|
-
"dev:build": "nuxi build playground",
|
|
55
|
-
"dev:prepare": "nuxt-module-build build --stub && nuxt-module-build prepare && nuxi prepare playground",
|
|
56
|
-
"dev:generate": "nuxi generate playground",
|
|
57
|
-
"release": "pnpm run lint && pnpm run typecheck && pnpm run test:types && pnpm run test && pnpm run test:vitest && pnpm run test:workspaces && pnpm run prepack && changelogen --release && pnpm publish -r && git push --follow-tags",
|
|
58
|
-
"lint": "eslint .",
|
|
59
|
-
"lint:fix": "eslint . --fix",
|
|
60
|
-
"test": "playwright test",
|
|
61
|
-
"test:vitest": "vitest run",
|
|
62
|
-
"test:watch": "vitest watch",
|
|
63
|
-
"test:types": "vue-tsc --noEmit && cd playground && vue-tsc --noEmit",
|
|
64
|
-
"test:workspaces": "pnpm recursive run test",
|
|
65
|
-
"client:build": "nuxi generate client",
|
|
66
|
-
"client:prepare": "nuxi client:prepare client",
|
|
67
|
-
"client:dev": "nuxi dev client --port 3300",
|
|
68
|
-
"clean": "find . \\( -name 'node_modules' -o -name '.nuxt' -o -name '.output' -o -name 'dist' \\) -type d -prune -exec rm -rf '{}' + && find . \\( -name 'pnpm-lock.yaml' -o -name 'package-lock.json' \\) -type f -exec rm -f '{}' +",
|
|
69
|
-
"typecheck": "tsc --noEmit",
|
|
70
|
-
"typecheck:nuxt": "nuxt typecheck --no-emit",
|
|
71
|
-
"docs:dev": "vitepress dev docs",
|
|
72
|
-
"docs:build": "vitepress build docs",
|
|
73
|
-
"docs:serve": "vitepress serve docs",
|
|
74
|
-
"docs:clean-dev": "vitepress dev docs --clean-cache",
|
|
75
|
-
"docs:preview": "vitepress preview docs"
|
|
76
|
-
},
|
|
77
51
|
"stackblitz": {
|
|
78
52
|
"startCommand": "pnpm install && pnpm --filter \"./packages/**\" run build && pnpm run dev:prepare && pnpm run dev",
|
|
79
53
|
"env": {
|
|
@@ -85,11 +59,11 @@
|
|
|
85
59
|
"@nuxt/kit": "^3.18.1 || ^4.0.0",
|
|
86
60
|
"chokidar": "^3.6.0",
|
|
87
61
|
"globby": "^14.1.0",
|
|
88
|
-
"nuxt-i18n-micro-core": "workspace:*",
|
|
89
|
-
"nuxt-i18n-micro-test-utils": "workspace:*",
|
|
90
|
-
"nuxt-i18n-micro-types": "workspace:*",
|
|
91
62
|
"sirv": "^2.0.4",
|
|
92
|
-
"ufo": "^1.5.4"
|
|
63
|
+
"ufo": "^1.5.4",
|
|
64
|
+
"nuxt-i18n-micro-core": "1.0.25",
|
|
65
|
+
"nuxt-i18n-micro-test-utils": "1.0.7",
|
|
66
|
+
"nuxt-i18n-micro-types": "1.0.15"
|
|
93
67
|
},
|
|
94
68
|
"devDependencies": {
|
|
95
69
|
"@nuxt/devtools": "^2.6.3",
|
|
@@ -121,5 +95,29 @@
|
|
|
121
95
|
"client",
|
|
122
96
|
"test/fixtures/**/*"
|
|
123
97
|
],
|
|
124
|
-
"
|
|
125
|
-
|
|
98
|
+
"scripts": {
|
|
99
|
+
"dev": "nuxi dev playground",
|
|
100
|
+
"dev:build": "nuxi build playground",
|
|
101
|
+
"dev:prepare": "nuxt-module-build build --stub && nuxt-module-build prepare && nuxi prepare playground",
|
|
102
|
+
"dev:generate": "nuxi generate playground",
|
|
103
|
+
"release": "pnpm run lint && pnpm run typecheck && pnpm run test:types && pnpm run test && pnpm run test:vitest && pnpm run test:workspaces && pnpm run prepack && changelogen --release && pnpm publish -r && git push --follow-tags",
|
|
104
|
+
"lint": "eslint .",
|
|
105
|
+
"lint:fix": "eslint . --fix",
|
|
106
|
+
"test": "playwright test",
|
|
107
|
+
"test:vitest": "vitest run",
|
|
108
|
+
"test:watch": "vitest watch",
|
|
109
|
+
"test:types": "vue-tsc --noEmit && cd playground && vue-tsc --noEmit",
|
|
110
|
+
"test:workspaces": "pnpm recursive run test",
|
|
111
|
+
"client:build": "nuxi generate client",
|
|
112
|
+
"client:prepare": "nuxi client:prepare client",
|
|
113
|
+
"client:dev": "nuxi dev client --port 3300",
|
|
114
|
+
"clean": "find . \\( -name 'node_modules' -o -name '.nuxt' -o -name '.output' -o -name 'dist' \\) -type d -prune -exec rm -rf '{}' + && find . \\( -name 'pnpm-lock.yaml' -o -name 'package-lock.json' \\) -type f -exec rm -f '{}' +",
|
|
115
|
+
"typecheck": "tsc --noEmit",
|
|
116
|
+
"typecheck:nuxt": "nuxt typecheck --no-emit",
|
|
117
|
+
"docs:dev": "vitepress dev docs",
|
|
118
|
+
"docs:build": "vitepress build docs",
|
|
119
|
+
"docs:serve": "vitepress serve docs",
|
|
120
|
+
"docs:clean-dev": "vitepress dev docs --clean-cache",
|
|
121
|
+
"docs:preview": "vitepress preview docs"
|
|
122
|
+
}
|
|
123
|
+
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"id":"7323731f-46c9-4bc3-8e1d-f2e545f99ff5","timestamp":1763644592721,"matcher":{"static":{},"wildcard":{},"dynamic":{}},"prerendered":[]}
|