nuxt-i18n-micro 1.54.1 → 1.55.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/af1dab1c-c3cf-4127-b3f8-8cfc1bb495ea.json +1 -0
- package/dist/client/index.html +2 -2
- package/dist/module.json +1 -1
- package/dist/module.mjs +0 -3
- package/dist/runtime/components/locale-redirect.vue +17 -1
- package/dist/runtime/plugins/01.plugin.js +28 -4
- package/package.json +1 -1
- package/dist/client/_nuxt/builds/meta/9eab4f13-a207-4610-bfb1-dfaa3d5e57ad.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/BzXxbhIZ.js">
|
|
9
9
|
<link rel="prefetch" as="style" crossorigin href="/__NUXT_DEVTOOLS_I18N_BASE__/_nuxt/error-500.DWqKq_Wn.css">
|
|
10
10
|
<link rel="prefetch" as="script" crossorigin href="/__NUXT_DEVTOOLS_I18N_BASE__/_nuxt/B85fdbn4.js">
|
|
11
|
-
<script type="module" src="/__NUXT_DEVTOOLS_I18N_BASE__/_nuxt/BhDLGWZB.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/BhDLGWZB.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},1735902518699,false]</script>
|
|
12
|
+
<script>window.__NUXT__={};window.__NUXT__.config={public:{},app:{baseURL:"/__NUXT_DEVTOOLS_I18N_BASE__/",buildId:"af1dab1c-c3cf-4127-b3f8-8cfc1bb495ea",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/BzXxbhIZ.js">
|
|
9
9
|
<link rel="prefetch" as="style" crossorigin href="/__NUXT_DEVTOOLS_I18N_BASE__/_nuxt/error-500.DWqKq_Wn.css">
|
|
10
10
|
<link rel="prefetch" as="script" crossorigin href="/__NUXT_DEVTOOLS_I18N_BASE__/_nuxt/B85fdbn4.js">
|
|
11
|
-
<script type="module" src="/__NUXT_DEVTOOLS_I18N_BASE__/_nuxt/BhDLGWZB.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/BhDLGWZB.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},1735902518700,false]</script>
|
|
12
|
+
<script>window.__NUXT__={};window.__NUXT__.config={public:{},app:{baseURL:"/__NUXT_DEVTOOLS_I18N_BASE__/",buildId:"af1dab1c-c3cf-4127-b3f8-8cfc1bb495ea",buildAssetsDir:"/_nuxt/",cdnURL:""}}</script></body></html>
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"id":"
|
|
1
|
+
{"id":"af1dab1c-c3cf-4127-b3f8-8cfc1bb495ea","timestamp":1735902513062}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"id":"af1dab1c-c3cf-4127-b3f8-8cfc1bb495ea","timestamp":1735902513062,"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/BzXxbhIZ.js">
|
|
9
9
|
<link rel="prefetch" as="style" crossorigin href="/__NUXT_DEVTOOLS_I18N_BASE__/_nuxt/error-500.DWqKq_Wn.css">
|
|
10
10
|
<link rel="prefetch" as="script" crossorigin href="/__NUXT_DEVTOOLS_I18N_BASE__/_nuxt/B85fdbn4.js">
|
|
11
|
-
<script type="module" src="/__NUXT_DEVTOOLS_I18N_BASE__/_nuxt/BhDLGWZB.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/BhDLGWZB.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},1735902518700,false]</script>
|
|
12
|
+
<script>window.__NUXT__={};window.__NUXT__.config={public:{},app:{baseURL:"/__NUXT_DEVTOOLS_I18N_BASE__/",buildId:"af1dab1c-c3cf-4127-b3f8-8cfc1bb495ea",buildAssetsDir:"/_nuxt/",cdnURL:""}}</script></body></html>
|
package/dist/module.json
CHANGED
package/dist/module.mjs
CHANGED
|
@@ -423,9 +423,6 @@ const module = defineNuxtModule({
|
|
|
423
423
|
options.strategy = "prefix_except_default";
|
|
424
424
|
}
|
|
425
425
|
}
|
|
426
|
-
if (isCloudflarePages && !isPrefixStrategy(options.strategy)) {
|
|
427
|
-
throw new Error('Nuxt-i18n-micro: "includeDefaultLocaleRoute" must be set to true when using Cloudflare Pages.');
|
|
428
|
-
}
|
|
429
426
|
const resolver = createResolver(import.meta.url);
|
|
430
427
|
const rootDirs = nuxt.options._layers.map((layer) => layer.config.rootDir).reverse();
|
|
431
428
|
const localeManager = new LocaleManager(options, rootDirs);
|
|
@@ -15,12 +15,21 @@ const firstSegment = pathSegments[1]
|
|
|
15
15
|
|
|
16
16
|
const generateRouteName = (segments) => {
|
|
17
17
|
return segments
|
|
18
|
-
.
|
|
18
|
+
.slice(1)
|
|
19
|
+
.map(segment => segment.replace(/:/g, ''))
|
|
20
|
+
.join('-')
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
const generateLocaleRouteName = (segments) => {
|
|
24
|
+
return segments
|
|
25
|
+
.filter(segment => segment && segment.trim() !== '')
|
|
26
|
+
.slice(1)
|
|
19
27
|
.map(segment => segment.replace(/:/g, ''))
|
|
20
28
|
.join('-')
|
|
21
29
|
}
|
|
22
30
|
|
|
23
31
|
const currentPageName = generateRouteName(pathSegments)
|
|
32
|
+
const currentLocalePageName = generateLocaleRouteName(pathSegments)
|
|
24
33
|
const globalLocaleRoutes = route.meta.globalLocaleRoutes ?? {}
|
|
25
34
|
|
|
26
35
|
if (globalLocaleRoutes && globalLocaleRoutes[currentPageName]) {
|
|
@@ -34,6 +43,13 @@ else if (!locales.includes(firstSegment)) {
|
|
|
34
43
|
const newPath = `/${defaultLocale}${route.fullPath}`
|
|
35
44
|
navigateTo(newPath, { redirectCode: 301, external: true })
|
|
36
45
|
}
|
|
46
|
+
else if (locales.includes(firstSegment) && globalLocaleRoutes && globalLocaleRoutes[currentLocalePageName]) {
|
|
47
|
+
const localizedRoutes = globalLocaleRoutes[currentLocalePageName]
|
|
48
|
+
if (localizedRoutes && localizedRoutes[firstSegment]) {
|
|
49
|
+
const localizedPath = `/${firstSegment}${localizedRoutes[firstSegment]}`
|
|
50
|
+
navigateTo(localizedPath, { redirectCode: 301, external: true })
|
|
51
|
+
}
|
|
52
|
+
}
|
|
37
53
|
else {
|
|
38
54
|
throw createError({
|
|
39
55
|
statusCode: 404,
|
|
@@ -60,7 +60,11 @@ function switchLocaleRoute(fromLocale, toLocale, route, router, i18nConfig, i18n
|
|
|
60
60
|
const newParams = { ...route.params, ...i18nRouteParams?.[toLocale] };
|
|
61
61
|
delete newParams.locale;
|
|
62
62
|
if (!isNoPrefixStrategy(i18nConfig.strategy)) {
|
|
63
|
-
|
|
63
|
+
if (routeName === "custom-fallback-route") {
|
|
64
|
+
newRouteName = routeName;
|
|
65
|
+
} else {
|
|
66
|
+
newRouteName = toLocale !== i18nConfig.defaultLocale || withPrefixStrategy(i18nConfig.strategy) ? `localized-${routeName}` : routeName;
|
|
67
|
+
}
|
|
64
68
|
if (toLocale !== i18nConfig.defaultLocale || withPrefixStrategy(i18nConfig.strategy)) {
|
|
65
69
|
newParams.locale = toLocale;
|
|
66
70
|
}
|
|
@@ -347,18 +351,38 @@ export default defineNuxtPlugin(async (nuxtApp) => {
|
|
|
347
351
|
switchLocale(fromLocale, toLocale, route, router, i18nConfig, i18nRouteParams.value);
|
|
348
352
|
},
|
|
349
353
|
switchRoute: (route, toLocale) => {
|
|
354
|
+
const currentRoute = router.currentRoute.value;
|
|
355
|
+
const fromLocale = getCurrentLocale(currentRoute, i18nConfig, hashLocale, noPrefixDefault);
|
|
356
|
+
const currentLocale = toLocale ?? fromLocale;
|
|
350
357
|
if (typeof route === "string") {
|
|
351
|
-
|
|
358
|
+
if (currentLocale !== i18nConfig.defaultLocale || withPrefixStrategy(i18nConfig.strategy)) {
|
|
359
|
+
const currentRoute2 = router.currentRoute.value;
|
|
360
|
+
const fromLocale2 = getCurrentLocale(currentRoute2, i18nConfig, hashLocale, noPrefixDefault);
|
|
361
|
+
route = router.resolve("/" + fromLocale2 + route);
|
|
362
|
+
} else {
|
|
363
|
+
route = router.resolve(route);
|
|
364
|
+
}
|
|
352
365
|
}
|
|
353
|
-
const fromLocale = getCurrentLocale(route, i18nConfig, hashLocale, noPrefixDefault);
|
|
354
366
|
if (i18nConfig.hashMode) {
|
|
355
367
|
hashLocale = toLocale ?? fromLocale;
|
|
356
368
|
}
|
|
357
369
|
switchLocale(fromLocale, toLocale ?? fromLocale, route, router, i18nConfig, i18nRouteParams.value);
|
|
358
370
|
},
|
|
359
371
|
localeRoute: (to, locale) => {
|
|
372
|
+
const currentRoute = router.currentRoute.value;
|
|
373
|
+
const fromLocale = getCurrentLocale(currentRoute, i18nConfig, hashLocale, noPrefixDefault);
|
|
374
|
+
const currentLocale = locale ?? fromLocale;
|
|
375
|
+
if (typeof to === "string") {
|
|
376
|
+
if (currentLocale !== i18nConfig.defaultLocale || withPrefixStrategy(i18nConfig.strategy)) {
|
|
377
|
+
const currentRoute2 = router.currentRoute.value;
|
|
378
|
+
const fromLocale2 = getCurrentLocale(currentRoute2, i18nConfig, hashLocale, noPrefixDefault);
|
|
379
|
+
to = router.resolve("/" + fromLocale2 + to);
|
|
380
|
+
} else {
|
|
381
|
+
to = router.resolve(to);
|
|
382
|
+
}
|
|
383
|
+
}
|
|
360
384
|
const route = router.currentRoute.value;
|
|
361
|
-
return getLocalizedRoute(to, router, route, i18nConfig,
|
|
385
|
+
return getLocalizedRoute(to, router, route, i18nConfig, currentLocale, hashLocale);
|
|
362
386
|
},
|
|
363
387
|
localePath: (to, locale) => {
|
|
364
388
|
const route = router.currentRoute.value;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nuxt-i18n-micro",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.55.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",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"id":"9eab4f13-a207-4610-bfb1-dfaa3d5e57ad","timestamp":1735535303428,"matcher":{"static":{},"wildcard":{},"dynamic":{}},"prerendered":[]}
|