nuxt-i18n-micro 1.20.3 → 1.20.4
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 +6 -6
- package/dist/client/404.html +6 -6
- package/dist/client/_nuxt/{DncTPfG-.js → BKcmVa-6.js} +1 -1
- package/dist/client/_nuxt/{BA8hDhNh.js → CeFL7aT9.js} +47 -47
- package/dist/client/_nuxt/{BjjtSdue.js → CnNUpwZL.js} +1 -1
- package/dist/client/_nuxt/builds/latest.json +1 -1
- package/dist/client/_nuxt/builds/meta/7e0eb619-2ce4-4c24-a4f8-76cedd547d1a.json +1 -0
- package/dist/client/_nuxt/{Csoilh4_.js → ftQz2Awu.js} +1 -1
- package/dist/client/index.html +6 -6
- package/dist/module.json +1 -1
- package/dist/module.mjs +2 -7
- package/dist/runtime/plugins/01.plugin.js +8 -0
- package/dist/runtime/plugins/03.define.js +32 -16
- package/package.json +1 -1
- package/dist/client/_nuxt/builds/meta/8efb25ac-9a61-43e4-be1f-196730280b5c.json +0 -1
- package/dist/runtime/server/middleware/i18n-redirect.d.ts +0 -2
- package/dist/runtime/server/middleware/i18n-redirect.js +0 -22
|
@@ -1 +1 @@
|
|
|
1
|
-
import{i as f,r as u,f as o,g as d,h as v,j as l,k as i,l as h,m}from"./
|
|
1
|
+
import{i as f,r as u,f as o,g as d,h as v,j as l,k as i,l as h,m}from"./CeFL7aT9.js";function U(t,a={}){const e=a.head||f();if(e)return e.ssr?e.push(t,a):p(e,t,a)}function p(t,a,e={}){const s=u(!1),n=u({});o(()=>{n.value=s.value?{}:d(a)});const r=t.push(n.value,e);return v(n,c=>{r.patch(c)}),m()&&(l(()=>{r.dispose()}),i(()=>{s.value=!0}),h(()=>{s.value=!1})),r}export{U as u};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"id":"
|
|
1
|
+
{"id":"7e0eb619-2ce4-4c24-a4f8-76cedd547d1a","timestamp":1727445410428}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"id":"7e0eb619-2ce4-4c24-a4f8-76cedd547d1a","timestamp":1727445410428,"matcher":{"static":{},"wildcard":{},"dynamic":{}},"prerendered":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{_ as a,o as i,c as u,a as e,t as r,b as c,w as l,d,e as p}from"./
|
|
1
|
+
import{_ as a,o as i,c as u,a as e,t as r,b as c,w as l,d,e as p}from"./CeFL7aT9.js";import{u as f}from"./CnNUpwZL.js";const m={class:"antialiased bg-white dark:bg-black dark:text-white font-sans grid min-h-screen overflow-hidden place-content-center text-black"},g={class:"max-w-520px text-center z-20"},h=["textContent"],b=["textContent"],x={class:"flex items-center justify-center w-full"},y={__name:"error-404",props:{appName:{type:String,default:"Nuxt"},version:{type:String,default:""},statusCode:{type:Number,default:404},statusMessage:{type:String,default:"Not Found"},description:{type:String,default:"Sorry, the page you are looking for could not be found."},backHome:{type:String,default:"Go back home"}},setup(t){const n=t;return f({title:`${n.statusCode} - ${n.statusMessage} | ${n.appName}`,script:[{children:`!function(){const e=document.createElement("link").relList;if(!(e&&e.supports&&e.supports("modulepreload"))){for(const e of document.querySelectorAll('link[rel="modulepreload"]'))r(e);new MutationObserver((e=>{for(const o of e)if("childList"===o.type)for(const e of o.addedNodes)"LINK"===e.tagName&&"modulepreload"===e.rel&&r(e)})).observe(document,{childList:!0,subtree:!0})}function r(e){if(e.ep)return;e.ep=!0;const r=function(e){const r={};return e.integrity&&(r.integrity=e.integrity),e.referrerPolicy&&(r.referrerPolicy=e.referrerPolicy),"use-credentials"===e.crossOrigin?r.credentials="include":"anonymous"===e.crossOrigin?r.credentials="omit":r.credentials="same-origin",r}(e);fetch(e.href,r)}}();`}],style:[{children:'*,:after,:before{border-color:var(--un-default-border-color,#e5e7eb);border-style:solid;border-width:0;box-sizing:border-box}:after,:before{--un-content:""}html{line-height:1.5;-webkit-text-size-adjust:100%;font-family:ui-sans-serif,system-ui,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji;font-feature-settings:normal;font-variation-settings:normal;-moz-tab-size:4;tab-size:4;-webkit-tap-highlight-color:transparent}body{line-height:inherit;margin:0}h1{font-size:inherit;font-weight:inherit}a{color:inherit;text-decoration:inherit}h1,p{margin:0}*,:after,:before{--un-rotate:0;--un-rotate-x:0;--un-rotate-y:0;--un-rotate-z:0;--un-scale-x:1;--un-scale-y:1;--un-scale-z:1;--un-skew-x:0;--un-skew-y:0;--un-translate-x:0;--un-translate-y:0;--un-translate-z:0;--un-pan-x: ;--un-pan-y: ;--un-pinch-zoom: ;--un-scroll-snap-strictness:proximity;--un-ordinal: ;--un-slashed-zero: ;--un-numeric-figure: ;--un-numeric-spacing: ;--un-numeric-fraction: ;--un-border-spacing-x:0;--un-border-spacing-y:0;--un-ring-offset-shadow:0 0 transparent;--un-ring-shadow:0 0 transparent;--un-shadow-inset: ;--un-shadow:0 0 transparent;--un-ring-inset: ;--un-ring-offset-width:0px;--un-ring-offset-color:#fff;--un-ring-width:0px;--un-ring-color:rgba(147,197,253,.5);--un-blur: ;--un-brightness: ;--un-contrast: ;--un-drop-shadow: ;--un-grayscale: ;--un-hue-rotate: ;--un-invert: ;--un-saturate: ;--un-sepia: ;--un-backdrop-blur: ;--un-backdrop-brightness: ;--un-backdrop-contrast: ;--un-backdrop-grayscale: ;--un-backdrop-hue-rotate: ;--un-backdrop-invert: ;--un-backdrop-opacity: ;--un-backdrop-saturate: ;--un-backdrop-sepia: }'}]}),(k,o)=>{const s=p;return i(),u("div",m,[o[0]||(o[0]=e("div",{class:"fixed left-0 right-0 spotlight z-10"},null,-1)),e("div",g,[e("h1",{class:"font-medium mb-8 sm:text-10xl text-8xl",textContent:r(t.statusCode)},null,8,h),e("p",{class:"font-light leading-tight mb-16 px-8 sm:px-0 sm:text-4xl text-xl",textContent:r(t.description)},null,8,b),e("div",x,[c(s,{to:"/",class:"cursor-pointer gradient-border px-4 py-2 sm:px-6 sm:py-3 sm:text-xl text-md"},{default:l(()=>[d(r(t.backHome),1)]),_:1})])])])}}},v=a(y,[["__scopeId","data-v-28c488d2"]]);export{v as default};
|
package/dist/client/index.html
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
<!DOCTYPE html><html data-capo=""><head><meta charset="utf-8">
|
|
2
2
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
3
3
|
<link rel="stylesheet" href="/__nuxt-i18n-micro/_nuxt/entry.DjxsrOxm.css">
|
|
4
|
-
<link rel="modulepreload" as="script" crossorigin href="/__nuxt-i18n-micro/_nuxt/
|
|
4
|
+
<link rel="modulepreload" as="script" crossorigin href="/__nuxt-i18n-micro/_nuxt/CeFL7aT9.js">
|
|
5
5
|
<link rel="prefetch" as="script" crossorigin href="/__nuxt-i18n-micro/_nuxt/B6E6ObS_.js">
|
|
6
6
|
<link rel="prefetch" as="style" crossorigin href="/__nuxt-i18n-micro/_nuxt/error-404.C_4C5G96.css">
|
|
7
|
-
<link rel="prefetch" as="script" crossorigin href="/__nuxt-i18n-micro/_nuxt/
|
|
8
|
-
<link rel="prefetch" as="script" crossorigin href="/__nuxt-i18n-micro/_nuxt/
|
|
7
|
+
<link rel="prefetch" as="script" crossorigin href="/__nuxt-i18n-micro/_nuxt/ftQz2Awu.js">
|
|
8
|
+
<link rel="prefetch" as="script" crossorigin href="/__nuxt-i18n-micro/_nuxt/CnNUpwZL.js">
|
|
9
9
|
<link rel="prefetch" as="style" crossorigin href="/__nuxt-i18n-micro/_nuxt/error-500.CBAEdpZV.css">
|
|
10
|
-
<link rel="prefetch" as="script" crossorigin href="/__nuxt-i18n-micro/_nuxt/
|
|
11
|
-
<script type="module" src="/__nuxt-i18n-micro/_nuxt/
|
|
12
|
-
<script>window.__NUXT__={};window.__NUXT__.config={public:{},app:{baseURL:"/__nuxt-i18n-micro",buildId:"
|
|
10
|
+
<link rel="prefetch" as="script" crossorigin href="/__nuxt-i18n-micro/_nuxt/BKcmVa-6.js">
|
|
11
|
+
<script type="module" src="/__nuxt-i18n-micro/_nuxt/CeFL7aT9.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},1727445423464,false]</script>
|
|
12
|
+
<script>window.__NUXT__={};window.__NUXT__.config={public:{},app:{baseURL:"/__nuxt-i18n-micro",buildId:"7e0eb619-2ce4-4c24-a4f8-76cedd547d1a",buildAssetsDir:"/_nuxt/",cdnURL:""}}</script></body></html>
|
package/dist/module.json
CHANGED
package/dist/module.mjs
CHANGED
|
@@ -435,7 +435,8 @@ const module = defineNuxtModule({
|
|
|
435
435
|
fallbackLocale: options.fallbackLocale ?? void 0,
|
|
436
436
|
dateBuild: Date.now(),
|
|
437
437
|
baseURL: nuxt.options.app.baseURL,
|
|
438
|
-
hashMode: nuxt.options?.router?.options?.hashMode ?? false
|
|
438
|
+
hashMode: nuxt.options?.router?.options?.hashMode ?? false,
|
|
439
|
+
globalLocaleRoutes: options.globalLocaleRoutes ?? {}
|
|
439
440
|
};
|
|
440
441
|
nuxt.options.runtimeConfig.i18nConfig = {
|
|
441
442
|
rootDir: nuxt.options.rootDir,
|
|
@@ -465,12 +466,6 @@ const module = defineNuxtModule({
|
|
|
465
466
|
});
|
|
466
467
|
}
|
|
467
468
|
addImportsDir(resolver.resolve("./runtime/composables"));
|
|
468
|
-
if (options.includeDefaultLocaleRoute) {
|
|
469
|
-
addServerHandler({
|
|
470
|
-
middleware: true,
|
|
471
|
-
handler: resolver.resolve("./runtime/server/middleware/i18n-redirect")
|
|
472
|
-
});
|
|
473
|
-
}
|
|
474
469
|
addServerHandler({
|
|
475
470
|
route: "/_locales/:page/:locale/data.json",
|
|
476
471
|
handler: resolver.resolve("./runtime/server/middleware/i18n-loader")
|
|
@@ -72,6 +72,14 @@ function getLocalizedRoute(to, router, route, i18nConfig, locale, hashLocale) {
|
|
|
72
72
|
name: `localized-${routeName}-${currentLocale}`
|
|
73
73
|
});
|
|
74
74
|
}
|
|
75
|
+
if (i18nConfig.includeDefaultLocaleRoute) {
|
|
76
|
+
const globalLocaleRoutes = i18nConfig.globalLocaleRoutes ?? {};
|
|
77
|
+
if (globalLocaleRoutes[routeName] == false) {
|
|
78
|
+
const newParams2 = resolveParams(to);
|
|
79
|
+
delete newParams2.locale;
|
|
80
|
+
return router.resolve({ name: routeName, params: newParams2 });
|
|
81
|
+
}
|
|
82
|
+
}
|
|
75
83
|
const newRouteName = currentLocale !== i18nConfig.defaultLocale || i18nConfig.includeDefaultLocaleRoute ? `localized-${routeName}` : routeName;
|
|
76
84
|
const newParams = resolveParams(to);
|
|
77
85
|
delete newParams.locale;
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { defineNuxtPlugin, navigateTo, useNuxtApp, useRuntimeConfig } from "#app";
|
|
2
2
|
import { useRoute, useRouter } from "#imports";
|
|
3
|
-
export default defineNuxtPlugin((_nuxtApp) => {
|
|
3
|
+
export default defineNuxtPlugin(async (_nuxtApp) => {
|
|
4
4
|
const config = useRuntimeConfig();
|
|
5
5
|
const route = useRoute();
|
|
6
6
|
const router = useRouter();
|
|
7
7
|
const i18nConfig = config.public.i18nConfig;
|
|
8
|
+
const globalLocaleRoutes = i18nConfig.globalLocaleRoutes ?? {};
|
|
8
9
|
const normalizeLocales = (locales) => {
|
|
9
10
|
if (Array.isArray(locales)) {
|
|
10
11
|
return locales.reduce((acc, locale) => {
|
|
@@ -16,22 +17,33 @@ export default defineNuxtPlugin((_nuxtApp) => {
|
|
|
16
17
|
}
|
|
17
18
|
return {};
|
|
18
19
|
};
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
newParams.name = defaultRouteName;
|
|
33
|
-
await navigateTo({ name: defaultRouteName, params: newParams }, { redirectCode: 301, external: true });
|
|
20
|
+
const handleRedirect = async (to) => {
|
|
21
|
+
const currentLocale = (to.params.locale || i18nConfig.defaultLocale).toString();
|
|
22
|
+
const { name } = to;
|
|
23
|
+
let defaultRouteName = name?.toString().replace("localized-", "").replace(new RegExp(`-${currentLocale}$`), "");
|
|
24
|
+
if (!to.params.locale) {
|
|
25
|
+
const name2 = to.name?.toString() ?? "";
|
|
26
|
+
if (globalLocaleRoutes[name2] === false) {
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
if (router.hasRoute(`localized-${to.name?.toString()}-${currentLocale}`)) {
|
|
30
|
+
defaultRouteName = `localized-${to.name?.toString()}-${currentLocale}`;
|
|
31
|
+
} else {
|
|
32
|
+
defaultRouteName = `localized-${to.name?.toString()}`;
|
|
34
33
|
}
|
|
34
|
+
const newParams = { ...to.params };
|
|
35
|
+
newParams.locale = i18nConfig.defaultLocale;
|
|
36
|
+
return navigateTo({ name: defaultRouteName, params: newParams }, { redirectCode: 301, external: true });
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
if (import.meta.server) {
|
|
40
|
+
if (i18nConfig.includeDefaultLocaleRoute) {
|
|
41
|
+
await handleRedirect(route);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
router.beforeEach(async (to, from, next) => {
|
|
45
|
+
if (i18nConfig.includeDefaultLocaleRoute) {
|
|
46
|
+
await handleRedirect(to);
|
|
35
47
|
}
|
|
36
48
|
next();
|
|
37
49
|
});
|
|
@@ -50,6 +62,10 @@ export default defineNuxtPlugin((_nuxtApp) => {
|
|
|
50
62
|
const newParams = { ...route.params };
|
|
51
63
|
delete newParams.locale;
|
|
52
64
|
if (i18nConfig.includeDefaultLocaleRoute) {
|
|
65
|
+
const name = route.name?.toString() ?? "";
|
|
66
|
+
if (globalLocaleRoutes[name] === false) {
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
53
69
|
if (router.hasRoute(`localized-${defaultRouteName}-${currentLocale}`)) {
|
|
54
70
|
defaultRouteName = `localized-${defaultRouteName}-${currentLocale}`;
|
|
55
71
|
} else {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nuxt-i18n-micro",
|
|
3
|
-
"version": "1.20.
|
|
3
|
+
"version": "1.20.4",
|
|
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":"8efb25ac-9a61-43e4-be1f-196730280b5c","timestamp":1727433075097,"matcher":{"static":{},"wildcard":{},"dynamic":{}},"prerendered":[]}
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { defineEventHandler, sendRedirect } from "h3";
|
|
2
|
-
import { useRuntimeConfig } from "#imports";
|
|
3
|
-
export default defineEventHandler(async (event) => {
|
|
4
|
-
const config = useRuntimeConfig();
|
|
5
|
-
const i18nConfig = config.public.i18nConfig;
|
|
6
|
-
if (!i18nConfig.defaultLocale) {
|
|
7
|
-
throw new Error("defaultLocale is not defined in the module configuration");
|
|
8
|
-
}
|
|
9
|
-
const locales = i18nConfig.locales || [];
|
|
10
|
-
const pathParts = event.path.split("/").filter(Boolean);
|
|
11
|
-
const localeCode = pathParts[0];
|
|
12
|
-
const lastPart = pathParts[pathParts.length - 1];
|
|
13
|
-
const hasFileExtension = /\.[^/?]+(?:\?.*)?$/.test(lastPart);
|
|
14
|
-
if (hasFileExtension) {
|
|
15
|
-
return;
|
|
16
|
-
}
|
|
17
|
-
const locale = locales.find((loc) => loc.code === localeCode);
|
|
18
|
-
if (!locale) {
|
|
19
|
-
const newPath = `/${i18nConfig.defaultLocale}/${pathParts.join("/")}`;
|
|
20
|
-
return sendRedirect(event, newPath, 301);
|
|
21
|
-
}
|
|
22
|
-
});
|