nuxt-i18n-micro 1.12.1 → 1.12.2

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.
@@ -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"./D1fvHJQV.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
+ 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"./DD0NUamG.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
- import{u as o}from"./DxMn4SAe.js";import{_ as a,o as s,c as i,a as e,t as r,p as u,f as l}from"./D1fvHJQV.js";const c=t=>(u("data-v-b63e9691"),t=t(),l(),t),d={class:"font-sans antialiased bg-white dark:bg-black text-black dark:text-white grid min-h-screen place-content-center overflow-hidden"},p=c(()=>e("div",{class:"fixed -bottom-1/2 left-0 right-0 h-1/2 spotlight"},null,-1)),h={class:"max-w-520px text-center"},b=["textContent"],g=["textContent"],f={__name:"error-500",props:{appName:{type:String,default:"Nuxt"},version:{type:String,default:""},statusCode:{type:Number,default:500},statusMessage:{type:String,default:"Server error"},description:{type:String,default:"This page is temporarily unavailable."}},setup(t){const n=t;return o({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}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: }'}]}),(m,x)=>(s(),i("div",d,[p,e("div",h,[e("h1",{class:"text-8xl sm:text-10xl font-medium mb-8",textContent:r(t.statusCode)},null,8,b),e("p",{class:"text-xl px-8 sm:px-0 sm:text-4xl font-light mb-16 leading-tight",textContent:r(t.description)},null,8,g)])]))}},w=a(f,[["__scopeId","data-v-b63e9691"]]);export{w as default};
1
+ import{u as o}from"./IYJk2P0o.js";import{_ as a,o as s,c as i,a as e,t as r,p as u,f as l}from"./DD0NUamG.js";const c=t=>(u("data-v-b63e9691"),t=t(),l(),t),d={class:"font-sans antialiased bg-white dark:bg-black text-black dark:text-white grid min-h-screen place-content-center overflow-hidden"},p=c(()=>e("div",{class:"fixed -bottom-1/2 left-0 right-0 h-1/2 spotlight"},null,-1)),h={class:"max-w-520px text-center"},b=["textContent"],g=["textContent"],f={__name:"error-500",props:{appName:{type:String,default:"Nuxt"},version:{type:String,default:""},statusCode:{type:Number,default:500},statusMessage:{type:String,default:"Server error"},description:{type:String,default:"This page is temporarily unavailable."}},setup(t){const n=t;return o({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}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: }'}]}),(m,x)=>(s(),i("div",d,[p,e("div",h,[e("h1",{class:"text-8xl sm:text-10xl font-medium mb-8",textContent:r(t.statusCode)},null,8,b),e("p",{class:"text-xl px-8 sm:px-0 sm:text-4xl font-light mb-16 leading-tight",textContent:r(t.description)},null,8,g)])]))}},w=a(f,[["__scopeId","data-v-b63e9691"]]);export{w as default};
@@ -1 +1 @@
1
- {"id":"1ab60d52-2c05-4618-8e25-19d2de5cb6af","timestamp":1725115421029}
1
+ {"id":"ebef9bab-73b3-451c-9eee-7e9b779ac677","timestamp":1725188700332}
@@ -0,0 +1 @@
1
+ {"id":"ebef9bab-73b3-451c-9eee-7e9b779ac677","timestamp":1725188700332,"matcher":{"static":{},"wildcard":{},"dynamic":{}},"prerendered":[]}
@@ -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/D1fvHJQV.js">
4
+ <link rel="modulepreload" as="script" crossorigin href="/__nuxt-i18n-micro/_nuxt/DD0NUamG.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/BpNRGTHy.js">
8
- <link rel="prefetch" as="script" crossorigin href="/__nuxt-i18n-micro/_nuxt/DxMn4SAe.js">
7
+ <link rel="prefetch" as="script" crossorigin href="/__nuxt-i18n-micro/_nuxt/BMM8J4-o.js">
8
+ <link rel="prefetch" as="script" crossorigin href="/__nuxt-i18n-micro/_nuxt/IYJk2P0o.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/DzdJBprQ.js">
11
- <script type="module" src="/__nuxt-i18n-micro/_nuxt/D1fvHJQV.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:"1ab60d52-2c05-4618-8e25-19d2de5cb6af",buildAssetsDir:"/_nuxt/",cdnURL:""}}</script></body></html>
10
+ <link rel="prefetch" as="script" crossorigin href="/__nuxt-i18n-micro/_nuxt/RtVXrbos.js">
11
+ <script type="module" src="/__nuxt-i18n-micro/_nuxt/DD0NUamG.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:"ebef9bab-73b3-451c-9eee-7e9b779ac677",buildAssetsDir:"/_nuxt/",cdnURL:""}}</script></body></html>
package/dist/module.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "nuxt-i18n-micro",
3
3
  "configKey": "i18n",
4
- "version": "1.12.1",
4
+ "version": "1.12.2",
5
5
  "builder": {
6
6
  "@nuxt/module-builder": "0.8.3",
7
7
  "unbuild": "2.0.0"
package/dist/module.mjs CHANGED
@@ -230,37 +230,28 @@ const module = defineNuxtModule({
230
230
  }
231
231
  const newRoutes = [];
232
232
  for (let i = 0; i < pages.length; i++) {
233
- let localizeChildren = function(routes, parentPath = "") {
234
- if (!parentPath.startsWith("/")) {
235
- parentPath = "/" + parentPath;
236
- }
237
- return routes.map((route) => {
238
- const fullPath = parentPath ? `${parentPath}/${route.path}` : route.path;
239
- const customLocalePaths = customPaths[fullPath];
240
- const localizedChildren = route.children ? localizeChildren(route.children, fullPath) : [];
241
- const localizedRoutes = locales.map((locale) => {
242
- let path2 = customLocalePaths && customLocalePaths[locale.code] ? `${customLocalePaths[locale.code]}` : `${fullPath}`;
233
+ let localizeChildren = function(routes, parentPath = "", currentLocales = [], modifyName = true, addLocalePrefix = false) {
234
+ return routes.flatMap((route) => {
235
+ const routePath = route.path.startsWith("/") ? route.path.slice(1) : route.path;
236
+ const customLocalePaths = customPaths[`${parentPath}/${routePath}`];
237
+ const localizedChildren = route.children ? localizeChildren(route.children, "", currentLocales, modifyName, false) : [];
238
+ return currentLocales.map((locale) => {
239
+ let path2 = customLocalePaths && customLocalePaths[locale] ? customLocalePaths[locale] : routePath;
243
240
  if (path2.startsWith("/")) {
244
241
  path2 = path2.slice(1);
245
242
  }
243
+ const isDefault = locale === options.defaultLocale && !options.includeDefaultLocaleRoute;
244
+ const routeName = modifyName && !isDefault ? `localized-${route.name}-${locale}` : route.name;
245
+ const finalPath = addLocalePrefix && !isDefault ? `/:locale(${locale})/${path2}` : path2;
246
246
  return {
247
247
  ...route,
248
- name: `localized-${route.name}-${locale.code}`,
249
- path: path2,
248
+ name: routeName,
249
+ path: finalPath,
250
250
  children: localizedChildren
251
251
  // Use localized children
252
252
  };
253
253
  });
254
- if (customLocalePaths) {
255
- return localizedRoutes;
256
- }
257
- return {
258
- ...route,
259
- name: `localized-${route.name}`,
260
- children: localizedChildren
261
- // Use localized children
262
- };
263
- }).flat();
254
+ });
264
255
  };
265
256
  const page = pages[i];
266
257
  if (page.redirect && !page.file) {
@@ -270,41 +261,59 @@ const module = defineNuxtModule({
270
261
  locales.forEach((locale) => {
271
262
  if (customPaths[page.path] && customPaths[page.path][locale.code]) {
272
263
  modLocaleRegex = modLocaleRegex.filter((locale2) => {
273
- return !Object.values(customPaths).some((paths) => paths[locale2]);
264
+ return !customPaths[page.path][locale2];
274
265
  });
275
266
  }
276
267
  });
268
+ const children = [...page.children ?? []];
269
+ if (modLocaleRegex.length) {
270
+ const newRoute = {
271
+ file: page.file,
272
+ meta: { ...page.meta },
273
+ alias: page.alias,
274
+ redirect: page.redirect,
275
+ children: page.children ? localizeChildren(children, page.path, modLocaleRegex) : [],
276
+ mode: page.mode,
277
+ path: `/:locale(${modLocaleRegex.join("|")})${page.path}`,
278
+ name: `localized-${page.name}`
279
+ };
280
+ newRoutes.push(newRoute);
281
+ }
277
282
  if (customPaths[page.path]) {
278
283
  locales.forEach((locale) => {
279
284
  if (customPaths[page.path][locale.code]) {
280
- const newRoute2 = {
281
- file: page.file,
282
- meta: { ...page.meta },
283
- alias: page.alias,
284
- redirect: page.redirect,
285
- children: page.children,
286
- mode: page.mode,
287
- path: `/:locale(${locale.code})${customPaths[page.path][locale.code]}`,
288
- name: `localized-${page.name}-${locale.code}`
289
- };
290
- newRoutes.push(newRoute2);
285
+ if (locale.code === options.defaultLocale && !options.includeDefaultLocaleRoute) {
286
+ if (page.children) {
287
+ page.children = localizeChildren(children, `/${page.name}`, [locale.code], false, false);
288
+ }
289
+ } else {
290
+ const newRoute = {
291
+ file: page.file,
292
+ meta: { ...page.meta },
293
+ alias: page.alias,
294
+ redirect: page.redirect,
295
+ children: page.children ? localizeChildren(children, page.path, [locale.code], true, false) : [],
296
+ mode: page.mode,
297
+ path: `/:locale(${locale.code})${customPaths[page.path][locale.code]}`,
298
+ // Use custom path for the locale
299
+ name: `localized-${page.name}-${locale.code}`
300
+ };
301
+ newRoutes.push(newRoute);
302
+ }
291
303
  }
292
304
  });
293
305
  }
294
- if (!modLocaleRegex.length && !page.children?.length) {
295
- continue;
306
+ if (!options.includeDefaultLocaleRoute) {
307
+ if (customPaths[page.path]) {
308
+ page.path = customPaths[page.path][options.defaultLocale] ?? page.path;
309
+ }
310
+ if (page.children?.length) {
311
+ page.children = [
312
+ ...children,
313
+ ...localizeChildren(children, `/${page.name}`, locales.filter((locale) => locale.code === options.defaultLocale).map((locale) => locale.code), false)
314
+ ];
315
+ }
296
316
  }
297
- const newRoute = {
298
- file: page.file,
299
- meta: { ...page.meta },
300
- alias: page.alias,
301
- redirect: page.redirect,
302
- children: page.children ? localizeChildren(page.children, page.name) : [],
303
- mode: page.mode,
304
- path: `/:locale(${modLocaleRegex.join("|")})${page.path}`,
305
- name: `localized-${page.name}`
306
- };
307
- newRoutes.push(newRoute);
308
317
  }
309
318
  pages.push(...newRoutes);
310
319
  nuxt.options.generate.routes = Array.isArray(nuxt.options.generate.routes) ? nuxt.options.generate.routes : [];
@@ -368,25 +377,12 @@ const module = defineNuxtModule({
368
377
  }
369
378
  }
370
379
  });
371
- function cleanObjectString(objectString) {
372
- let cleanedString = objectString.replace(/'/g, '"');
373
- cleanedString = cleanedString.replace(/([{,]\s*)(\w+)(\s*:)/g, '$1"$2"$3');
374
- cleanedString = cleanedString.replace(/,(\s*[}\]])/g, "$1");
375
- cleanedString = cleanedString.replace(/,+/g, ",");
376
- cleanedString = cleanedString.replace(/(\{|\[)\s*,/g, "$1");
377
- cleanedString = cleanedString.replace(/,(\s*[}\]])/g, "$1");
378
- cleanedString = cleanedString.trim();
379
- if (!cleanedString.startsWith("{") || !cleanedString.endsWith("}")) {
380
- throw new Error("Invalid object format after cleaning");
381
- }
382
- return cleanedString;
383
- }
384
380
  function extractDefineI18nRouteConfig(content, path2) {
385
- const match = content.match(/\$defineI18nRoute\((\{[\s\S]*?\})\)/);
381
+ const match = content.match(/^[ \t]*\$defineI18nRoute\((\{[\s\S]*?\})\)/m);
386
382
  if (match && match[1]) {
387
383
  try {
388
- const cleanedString = cleanObjectString(match[1]);
389
- const configObject = JSON.parse(cleanedString);
384
+ const parsedObject = Function('"use strict";return (' + match[1] + ")")();
385
+ const configObject = parsedObject;
390
386
  if (validateDefineI18nRouteConfig(configObject)) {
391
387
  return configObject;
392
388
  } else {
@@ -8,13 +8,13 @@
8
8
  </template>
9
9
 
10
10
  <script lang="ts" setup>
11
+ import type { RouteLocationRaw } from 'vue-router'
11
12
  import { useNuxtApp, computed, useRoute, useRouter } from '#imports'
12
- import type { NuxtLinkProps } from '#app/components/nuxt-link'
13
13
 
14
14
  const { $localeRoute } = useNuxtApp()
15
15
 
16
16
  interface Props {
17
- to: NuxtLinkProps | string
17
+ to: RouteLocationRaw | string
18
18
  activeStyle?: Partial<CSSStyleDeclaration>
19
19
  }
20
20
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nuxt-i18n-micro",
3
- "version": "1.12.1",
3
+ "version": "1.12.2",
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":"1ab60d52-2c05-4618-8e25-19d2de5cb6af","timestamp":1725115421029,"matcher":{"static":{},"wildcard":{},"dynamic":{}},"prerendered":[]}