nuxt-i18n-micro 1.11.0 → 1.12.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 +6 -6
- package/dist/client/404.html +6 -6
- package/dist/client/_nuxt/{hsW9SqPc.js → -CPbXxGs.js} +1 -1
- package/dist/client/_nuxt/CPg1EBcD.js +119 -0
- package/dist/client/_nuxt/{DulLifOC.js → CoSSsslv.js} +1 -1
- package/dist/client/_nuxt/builds/latest.json +1 -1
- package/dist/client/_nuxt/builds/meta/24c74c8a-5e70-496a-9f3c-403618a1c940.json +1 -0
- package/dist/client/_nuxt/{5O6Zkut2.js → ySYvy69W.js} +1 -1
- package/dist/client/index.html +6 -6
- package/dist/module.d.mts +1 -0
- package/dist/module.d.ts +1 -0
- package/dist/module.json +1 -1
- package/dist/module.mjs +88 -39
- package/dist/runtime/components/i18n-link.vue +1 -1
- package/dist/runtime/components/i18n-switcher.vue +5 -2
- package/dist/runtime/plugins/01.plugin.js +6 -1
- package/dist/runtime/plugins/03.define.js +7 -3
- package/dist/runtime/server/middleware/i18n-redirect.js +5 -0
- package/package.json +1 -1
- package/dist/client/_nuxt/CX2tGbR4.js +0 -119
- package/dist/client/_nuxt/builds/meta/188e6c4c-cf5a-4166-a467-e82e4c5b743c.json +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{i as o,r as u,g as f,h as d,j as v,k as l,l as i,m as h,n as m}from"./
|
|
1
|
+
import{i as o,r as u,g as f,h as d,j as v,k as l,l as i,m as h,n as m}from"./CPg1EBcD.js";function U(t,a={}){const e=a.head||o();if(e)return e.ssr?e.push(t,a):p(e,t,a)}function p(t,a,e={}){const s=u(!1),n=u({});f(()=>{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":"24c74c8a-5e70-496a-9f3c-403618a1c940","timestamp":1725114367778}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"id":"24c74c8a-5e70-496a-9f3c-403618a1c940","timestamp":1725114367778,"matcher":{"static":{},"wildcard":{},"dynamic":{}},"prerendered":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{_ as a,o as s,c as i,a as e,t as o,b as u,w as c,d,e as l,p,f as h}from"./
|
|
1
|
+
import{_ as a,o as s,c as i,a as e,t as o,b as u,w as c,d,e as l,p,f as h}from"./CPg1EBcD.js";import{u as f}from"./CoSSsslv.js";const g=t=>(p("data-v-83de2354"),t=t(),h(),t),b={class:"font-sans antialiased bg-white dark:bg-black text-black dark:text-white grid min-h-screen place-content-center overflow-hidden"},x=g(()=>e("div",{class:"fixed left-0 right-0 spotlight z-10"},null,-1)),m={class:"max-w-520px text-center z-20"},y=["textContent"],_=["textContent"],k={class:"w-full flex items-center justify-center"},w={__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:[],style:[{children:'*,:before,:after{box-sizing:border-box;border-width:0;border-style:solid;border-color:var(--un-default-border-color, #e5e7eb)}:before,:after{--un-content:""}html{line-height:1.5;-webkit-text-size-adjust:100%;-moz-tab-size:4;tab-size:4;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;-webkit-tap-highlight-color:transparent}body{margin:0;line-height:inherit}h1{font-size:inherit;font-weight:inherit}a{color:inherit;text-decoration:inherit}h1,p{margin:0}*,:before,:after{--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 rgb(0 0 0 / 0);--un-ring-shadow:0 0 rgb(0 0 0 / 0);--un-shadow-inset: ;--un-shadow:0 0 rgb(0 0 0 / 0);--un-ring-inset: ;--un-ring-offset-width:0px;--un-ring-offset-color:#fff;--un-ring-width:0px;--un-ring-color:rgb(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: }'}]}),(z,S)=>{const r=l;return s(),i("div",b,[x,e("div",m,[e("h1",{class:"text-8xl sm:text-10xl font-medium mb-8",textContent:o(t.statusCode)},null,8,y),e("p",{class:"text-xl px-8 sm:px-0 sm:text-4xl font-light mb-16 leading-tight",textContent:o(t.description)},null,8,_),e("div",k,[u(r,{to:"/",class:"gradient-border text-md sm:text-xl py-2 px-4 sm:py-3 sm:px-6 cursor-pointer"},{default:c(()=>[d(o(t.backHome),1)]),_:1})])])])}}},N=a(w,[["__scopeId","data-v-83de2354"]]);export{N 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/CPg1EBcD.js">
|
|
5
5
|
<link rel="prefetch" as="script" crossorigin href="/__nuxt-i18n-micro/_nuxt/B6E6ObS_.js">
|
|
6
6
|
<link rel="prefetch" as="style" href="/__nuxt-i18n-micro/_nuxt/error-404.D-AvUzLt.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/ySYvy69W.js">
|
|
8
|
+
<link rel="prefetch" as="script" crossorigin href="/__nuxt-i18n-micro/_nuxt/CoSSsslv.js">
|
|
9
9
|
<link rel="prefetch" as="style" href="/__nuxt-i18n-micro/_nuxt/error-500.21ZDxC33.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/-CPbXxGs.js">
|
|
11
|
+
<script type="module" src="/__nuxt-i18n-micro/_nuxt/CPg1EBcD.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__">[{"serverRendered":1},false]</script>
|
|
12
|
+
<script>window.__NUXT__={};window.__NUXT__.config={public:{},app:{baseURL:"/__nuxt-i18n-micro",buildId:"24c74c8a-5e70-496a-9f3c-403618a1c940",buildAssetsDir:"/_nuxt/",cdnURL:""}}</script></body></html>
|
package/dist/module.d.mts
CHANGED
package/dist/module.d.ts
CHANGED
package/dist/module.json
CHANGED
package/dist/module.mjs
CHANGED
|
@@ -102,6 +102,7 @@ const module = defineNuxtModule({
|
|
|
102
102
|
translationDir: "locales",
|
|
103
103
|
autoDetectLanguage: true,
|
|
104
104
|
disablePageLocales: false,
|
|
105
|
+
disableWatcher: false,
|
|
105
106
|
includeDefaultLocaleRoute: false,
|
|
106
107
|
routesLocaleLinks: {},
|
|
107
108
|
plural: `function (translation, count, _locale) {
|
|
@@ -135,6 +136,7 @@ const module = defineNuxtModule({
|
|
|
135
136
|
meta: options.meta ?? true,
|
|
136
137
|
metaBaseUrl: options.metaBaseUrl ?? void 0,
|
|
137
138
|
define: options.define ?? true,
|
|
139
|
+
disableWatcher: options.disableWatcher ?? false,
|
|
138
140
|
defaultLocale: options.defaultLocale ?? "en",
|
|
139
141
|
translationDir: options.translationDir ?? "locales",
|
|
140
142
|
autoDetectLanguage: options.autoDetectLanguage ?? true,
|
|
@@ -186,16 +188,24 @@ const module = defineNuxtModule({
|
|
|
186
188
|
const pagesDir = path.resolve(nuxt.options.rootDir, options.translationDir, "pages");
|
|
187
189
|
extendPages((pages) => {
|
|
188
190
|
const customPaths = {};
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
191
|
+
function extractCustomPaths(pages2, parentPath = "") {
|
|
192
|
+
for (const page of pages2) {
|
|
193
|
+
if (page.file) {
|
|
194
|
+
const filePath = path.resolve(nuxt.options.rootDir, page.file);
|
|
195
|
+
const fileContent = readFileSync(filePath, "utf-8");
|
|
196
|
+
const i18nRouteConfig = extractDefineI18nRouteConfig(fileContent, filePath);
|
|
197
|
+
if (i18nRouteConfig && i18nRouteConfig.localeRoutes) {
|
|
198
|
+
const fullPath = parentPath ? `${parentPath}/${page.path}` : page.path;
|
|
199
|
+
customPaths[fullPath] = i18nRouteConfig.localeRoutes;
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
if (page.children && page.children.length > 0) {
|
|
203
|
+
const fullParentName = parentPath ? `${parentPath}/${page.path}` : page.path;
|
|
204
|
+
extractCustomPaths(page.children, fullParentName);
|
|
196
205
|
}
|
|
197
206
|
}
|
|
198
207
|
}
|
|
208
|
+
extractCustomPaths(pages);
|
|
199
209
|
const pagesNames = pages.map((page) => page.name).filter((name) => name && (!options.routesLocaleLinks || !options.routesLocaleLinks[name]));
|
|
200
210
|
function ensureFileExists(filePath) {
|
|
201
211
|
const fileDir = path.dirname(filePath);
|
|
@@ -218,6 +228,38 @@ const module = defineNuxtModule({
|
|
|
218
228
|
});
|
|
219
229
|
const newRoutes = [];
|
|
220
230
|
for (let i = 0; i < pages.length; i++) {
|
|
231
|
+
let localizeChildren = function(routes, parentPath = "") {
|
|
232
|
+
if (!parentPath.startsWith("/")) {
|
|
233
|
+
parentPath = "/" + parentPath;
|
|
234
|
+
}
|
|
235
|
+
return routes.map((route) => {
|
|
236
|
+
const fullPath = parentPath ? `${parentPath}/${route.path}` : route.path;
|
|
237
|
+
const customLocalePaths = customPaths[fullPath];
|
|
238
|
+
const localizedChildren = route.children ? localizeChildren(route.children, fullPath) : [];
|
|
239
|
+
const localizedRoutes = locales.map((locale) => {
|
|
240
|
+
let path2 = customLocalePaths && customLocalePaths[locale.code] ? `${customLocalePaths[locale.code]}` : `${fullPath}`;
|
|
241
|
+
if (path2.startsWith("/")) {
|
|
242
|
+
path2 = path2.slice(1);
|
|
243
|
+
}
|
|
244
|
+
return {
|
|
245
|
+
...route,
|
|
246
|
+
name: `localized-${route.name}-${locale.code}`,
|
|
247
|
+
path: path2,
|
|
248
|
+
children: localizedChildren
|
|
249
|
+
// Use localized children
|
|
250
|
+
};
|
|
251
|
+
});
|
|
252
|
+
if (customLocalePaths) {
|
|
253
|
+
return localizedRoutes;
|
|
254
|
+
}
|
|
255
|
+
return {
|
|
256
|
+
...route,
|
|
257
|
+
name: `localized-${route.name}`,
|
|
258
|
+
children: localizedChildren
|
|
259
|
+
// Use localized children
|
|
260
|
+
};
|
|
261
|
+
}).flat();
|
|
262
|
+
};
|
|
221
263
|
const page = pages[i];
|
|
222
264
|
if (page.redirect && !page.file) {
|
|
223
265
|
continue;
|
|
@@ -230,17 +272,6 @@ const module = defineNuxtModule({
|
|
|
230
272
|
});
|
|
231
273
|
}
|
|
232
274
|
});
|
|
233
|
-
const newRoute = {
|
|
234
|
-
file: page.file,
|
|
235
|
-
meta: { ...page.meta },
|
|
236
|
-
alias: page.alias,
|
|
237
|
-
redirect: page.redirect,
|
|
238
|
-
children: page.children,
|
|
239
|
-
mode: page.mode,
|
|
240
|
-
path: `/:locale(${modLocaleRegex.join("|")})${page.path}`,
|
|
241
|
-
name: `localized-${page.name}`
|
|
242
|
-
};
|
|
243
|
-
newRoutes.push(newRoute);
|
|
244
275
|
if (customPaths[page.path]) {
|
|
245
276
|
locales.forEach((locale) => {
|
|
246
277
|
if (customPaths[page.path][locale.code]) {
|
|
@@ -258,6 +289,20 @@ const module = defineNuxtModule({
|
|
|
258
289
|
}
|
|
259
290
|
});
|
|
260
291
|
}
|
|
292
|
+
if (!modLocaleRegex.length && !page.children?.length) {
|
|
293
|
+
continue;
|
|
294
|
+
}
|
|
295
|
+
const newRoute = {
|
|
296
|
+
file: page.file,
|
|
297
|
+
meta: { ...page.meta },
|
|
298
|
+
alias: page.alias,
|
|
299
|
+
redirect: page.redirect,
|
|
300
|
+
children: page.children ? localizeChildren(page.children, page.name) : [],
|
|
301
|
+
mode: page.mode,
|
|
302
|
+
path: `/:locale(${modLocaleRegex.join("|")})${page.path}`,
|
|
303
|
+
name: `localized-${page.name}`
|
|
304
|
+
};
|
|
305
|
+
newRoutes.push(newRoute);
|
|
261
306
|
}
|
|
262
307
|
pages.push(...newRoutes);
|
|
263
308
|
nuxt.options.generate.routes = Array.isArray(nuxt.options.generate.routes) ? nuxt.options.generate.routes : [];
|
|
@@ -284,22 +329,24 @@ const module = defineNuxtModule({
|
|
|
284
329
|
nitroConfig.prerender = nitroConfig.prerender || {};
|
|
285
330
|
nitroConfig.prerender.routes = routes;
|
|
286
331
|
});
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
332
|
+
if (!options.disableWatcher) {
|
|
333
|
+
nuxt.hook("nitro:build:before", async (_nitro) => {
|
|
334
|
+
const isProd = nuxt.options.dev === false;
|
|
335
|
+
if (!isProd) {
|
|
336
|
+
const translationPath = path.resolve(nuxt.options.rootDir, options.translationDir);
|
|
337
|
+
console.log("\u2139 add file watcher", translationPath);
|
|
338
|
+
const watcherEvent = async (path2) => {
|
|
339
|
+
watcher.close();
|
|
340
|
+
console.log("\u21BB update store item", path2);
|
|
341
|
+
nuxt.callHook("restart");
|
|
342
|
+
};
|
|
343
|
+
const watcher = watch(translationPath, { depth: 1, persistent: true }).on("change", watcherEvent);
|
|
344
|
+
nuxt.hook("close", () => {
|
|
345
|
+
watcher.close();
|
|
346
|
+
});
|
|
347
|
+
}
|
|
348
|
+
});
|
|
349
|
+
}
|
|
303
350
|
nuxt.hook("prerender:routes", async (prerenderRoutes) => {
|
|
304
351
|
const routesSet = prerenderRoutes.routes;
|
|
305
352
|
const additionalRoutes = /* @__PURE__ */ new Set();
|
|
@@ -354,12 +401,14 @@ function extractDefineI18nRouteConfig(content, path2) {
|
|
|
354
401
|
function validateDefineI18nRouteConfig(obj) {
|
|
355
402
|
if (typeof obj !== "object" || obj === null)
|
|
356
403
|
return false;
|
|
357
|
-
if (
|
|
358
|
-
|
|
359
|
-
for (const localeKey in obj.locales) {
|
|
360
|
-
const translations = obj.locales[localeKey];
|
|
361
|
-
if (typeof translations !== "object" || translations === null)
|
|
404
|
+
if (obj.locales) {
|
|
405
|
+
if (typeof obj.locales !== "object")
|
|
362
406
|
return false;
|
|
407
|
+
for (const localeKey in obj.locales) {
|
|
408
|
+
const translations = obj.locales[localeKey];
|
|
409
|
+
if (typeof translations !== "object" || translations === null)
|
|
410
|
+
return false;
|
|
411
|
+
}
|
|
363
412
|
}
|
|
364
413
|
if (obj.localeRoutes) {
|
|
365
414
|
if (typeof obj.localeRoutes !== "object")
|
|
@@ -66,7 +66,7 @@ const props = withDefaults(defineProps<Props>(), {
|
|
|
66
66
|
|
|
67
67
|
const { $localeRoute, $getLocales, $getLocale } = useNuxtApp()
|
|
68
68
|
const locales = ref($getLocales())
|
|
69
|
-
const currentLocale =
|
|
69
|
+
const currentLocale = computed(() => $getLocale())
|
|
70
70
|
const dropdownOpen = ref(false)
|
|
71
71
|
|
|
72
72
|
const toggleDropdown = () => {
|
|
@@ -81,7 +81,10 @@ const currentLocaleLabel = computed(() => localeLabel({ code: currentLocale.valu
|
|
|
81
81
|
|
|
82
82
|
const getLocaleLink = (locale: Locale) => {
|
|
83
83
|
const route = useRoute()
|
|
84
|
-
const routeName = (route?.name ?? '').toString()
|
|
84
|
+
const routeName = (route?.name ?? '').toString()
|
|
85
|
+
.replace(`localized-`, '')
|
|
86
|
+
.replace(new RegExp(`-${currentLocale.value}$`), '')
|
|
87
|
+
.replace(new RegExp(`-${locale}$`), '')
|
|
85
88
|
|
|
86
89
|
return $localeRoute({ name: routeName }, locale.code)
|
|
87
90
|
}
|
|
@@ -74,7 +74,7 @@ export default defineNuxtPlugin(async (nuxtApp) => {
|
|
|
74
74
|
const i18nConfig = config.public.i18nConfig;
|
|
75
75
|
const plural = new Function("return " + i18nConfig.plural)();
|
|
76
76
|
const initialLocale = getCurrentLocale(route, i18nConfig);
|
|
77
|
-
if (!i18nHelper.hasGeneralTranslation(initialLocale)) {
|
|
77
|
+
if (import.meta.server && !i18nHelper.hasGeneralTranslation(initialLocale)) {
|
|
78
78
|
const data = await $fetch(`/_locales/general/${initialLocale}/data.json?v=${i18nConfig.dateBuild}`, { baseURL: i18nConfig.baseURL });
|
|
79
79
|
await i18nHelper.loadTranslations(initialLocale, data ?? {});
|
|
80
80
|
}
|
|
@@ -94,6 +94,11 @@ export default defineNuxtPlugin(async (nuxtApp) => {
|
|
|
94
94
|
await loadTranslationsIfNeeded(locale, initialRouteName);
|
|
95
95
|
}
|
|
96
96
|
useRouter().beforeEach(async (to, from, next) => {
|
|
97
|
+
if (import.meta.client) {
|
|
98
|
+
const locale = getCurrentLocale(to, i18nConfig);
|
|
99
|
+
const data = await $fetch(`/_locales/general/${locale}/data.json?v=${i18nConfig.dateBuild}`, { baseURL: i18nConfig.baseURL });
|
|
100
|
+
await i18nHelper.loadTranslations(locale, data ?? {});
|
|
101
|
+
}
|
|
97
102
|
if (import.meta.client && !i18nConfig.disablePageLocales) {
|
|
98
103
|
const locale = getCurrentLocale(to, i18nConfig);
|
|
99
104
|
const routeName = getRouteName(to, locale);
|
|
@@ -20,17 +20,21 @@ export default defineNuxtPlugin((_nuxtApp) => {
|
|
|
20
20
|
const currentLocale = (route.params.locale || i18nConfig.defaultLocale).toString();
|
|
21
21
|
const normalizedLocales = normalizeLocales(routeDefinition.locales);
|
|
22
22
|
const { name } = route;
|
|
23
|
-
if (normalizedLocales[currentLocale]) {
|
|
23
|
+
if (!Object.values(normalizedLocales).length || normalizedLocales[currentLocale]) {
|
|
24
24
|
const translation = normalizedLocales[currentLocale];
|
|
25
25
|
const nuxtApp = useNuxtApp();
|
|
26
26
|
nuxtApp.$mergeTranslations(translation);
|
|
27
27
|
} else {
|
|
28
|
-
let defaultRouteName = name?.toString().replace("localized-", "");
|
|
28
|
+
let defaultRouteName = name?.toString().replace("localized-", "").replace(new RegExp(`-${currentLocale}$`), "");
|
|
29
29
|
const resolvedRoute = router.resolve({ name: defaultRouteName });
|
|
30
30
|
const newParams = { ...route.params };
|
|
31
31
|
delete newParams.locale;
|
|
32
32
|
if (i18nConfig.includeDefaultLocaleRoute) {
|
|
33
|
-
|
|
33
|
+
if (router.hasRoute(`localized-${defaultRouteName}-${currentLocale}`)) {
|
|
34
|
+
defaultRouteName = `localized-${defaultRouteName}-${currentLocale}`;
|
|
35
|
+
} else {
|
|
36
|
+
defaultRouteName = `localized-${defaultRouteName}`;
|
|
37
|
+
}
|
|
34
38
|
newParams.locale = i18nConfig.defaultLocale;
|
|
35
39
|
newParams.name = defaultRouteName;
|
|
36
40
|
}
|
|
@@ -9,6 +9,11 @@ export default defineEventHandler(async (event) => {
|
|
|
9
9
|
const locales = i18nConfig.locales || [];
|
|
10
10
|
const pathParts = event.path.split("/").filter(Boolean);
|
|
11
11
|
const localeCode = pathParts[0];
|
|
12
|
+
const lastPart = pathParts[pathParts.length - 1];
|
|
13
|
+
const hasFileExtension = /\.[^/?]+(?:\?.*)?$/.test(lastPart);
|
|
14
|
+
if (hasFileExtension) {
|
|
15
|
+
return;
|
|
16
|
+
}
|
|
12
17
|
const locale = locales.find((loc) => loc.code === localeCode);
|
|
13
18
|
if (!locale) {
|
|
14
19
|
const newPath = `/${i18nConfig.defaultLocale}/${pathParts.join("/")}`;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nuxt-i18n-micro",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.12.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",
|