nuxt-i18n-micro 1.61.0 → 1.63.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.
@@ -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"./C9njAg9E.js";import{u as f}from"./EwNUkbJF.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-3074ece5"]]);export{v as default};
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"./Ddb0iCRU.js";import{u as f}from"./AXE8DZQI.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-c1463376"]]);export{v as default};
@@ -1 +1 @@
1
- {"id":"019df560-5b4f-4d25-8ca1-a8cad935e3d2","timestamp":1736953866014}
1
+ {"id":"c4f80d33-396e-44b9-86d2-e62d781c506f","timestamp":1737031239960}
@@ -0,0 +1 @@
1
+ {"id":"c4f80d33-396e-44b9-86d2-e62d781c506f","timestamp":1737031239960,"matcher":{"static":{},"wildcard":{},"dynamic":{}},"prerendered":[]}
@@ -0,0 +1 @@
1
+ .spotlight[data-v-c1463376]{background:linear-gradient(45deg,#00dc82,#36e4da 50%,#0047e1);bottom:-30vh;filter:blur(20vh);height:40vh}.gradient-border[data-v-c1463376]{-webkit-backdrop-filter:blur(10px);backdrop-filter:blur(10px);border-radius:.5rem;position:relative}@media (prefers-color-scheme:light){.gradient-border[data-v-c1463376]{background-color:#ffffff4d}.gradient-border[data-v-c1463376]:before{background:linear-gradient(90deg,#e2e2e2,#e2e2e2 25%,#00dc82,#36e4da 75%,#0047e1)}}@media (prefers-color-scheme:dark){.gradient-border[data-v-c1463376]{background-color:#1414144d}.gradient-border[data-v-c1463376]:before{background:linear-gradient(90deg,#303030,#303030 25%,#00dc82,#36e4da 75%,#0047e1)}}.gradient-border[data-v-c1463376]:before{background-size:400% auto;border-radius:.5rem;bottom:0;content:"";left:0;-webkit-mask:linear-gradient(#fff 0 0) content-box,linear-gradient(#fff 0 0);mask:linear-gradient(#fff 0 0) content-box,linear-gradient(#fff 0 0);-webkit-mask-composite:xor;mask-composite:exclude;opacity:.5;padding:2px;position:absolute;right:0;top:0;transition:background-position .3s ease-in-out,opacity .2s ease-in-out;width:100%}.gradient-border[data-v-c1463376]:hover:before{background-position:-50% 0;opacity:1}.fixed[data-v-c1463376]{position:fixed}.left-0[data-v-c1463376]{left:0}.right-0[data-v-c1463376]{right:0}.z-10[data-v-c1463376]{z-index:10}.z-20[data-v-c1463376]{z-index:20}.grid[data-v-c1463376]{display:grid}.mb-16[data-v-c1463376]{margin-bottom:4rem}.mb-8[data-v-c1463376]{margin-bottom:2rem}.max-w-520px[data-v-c1463376]{max-width:520px}.min-h-screen[data-v-c1463376]{min-height:100vh}.w-full[data-v-c1463376]{width:100%}.flex[data-v-c1463376]{display:flex}.cursor-pointer[data-v-c1463376]{cursor:pointer}.place-content-center[data-v-c1463376]{place-content:center}.items-center[data-v-c1463376]{align-items:center}.justify-center[data-v-c1463376]{justify-content:center}.overflow-hidden[data-v-c1463376]{overflow:hidden}.bg-white[data-v-c1463376]{--un-bg-opacity:1;background-color:rgb(255 255 255/var(--un-bg-opacity))}.px-4[data-v-c1463376]{padding-left:1rem;padding-right:1rem}.px-8[data-v-c1463376]{padding-left:2rem;padding-right:2rem}.py-2[data-v-c1463376]{padding-bottom:.5rem;padding-top:.5rem}.text-center[data-v-c1463376]{text-align:center}.text-8xl[data-v-c1463376]{font-size:6rem;line-height:1}.text-xl[data-v-c1463376]{font-size:1.25rem;line-height:1.75rem}.text-black[data-v-c1463376]{--un-text-opacity:1;color:rgb(0 0 0/var(--un-text-opacity))}.font-light[data-v-c1463376]{font-weight:300}.font-medium[data-v-c1463376]{font-weight:500}.leading-tight[data-v-c1463376]{line-height:1.25}.font-sans[data-v-c1463376]{font-family:ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica Neue,Arial,Noto Sans,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji}.antialiased[data-v-c1463376]{-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}@media (prefers-color-scheme:dark){.dark\:bg-black[data-v-c1463376]{--un-bg-opacity:1;background-color:rgb(0 0 0/var(--un-bg-opacity))}.dark\:text-white[data-v-c1463376]{--un-text-opacity:1;color:rgb(255 255 255/var(--un-text-opacity))}}@media (min-width:640px){.sm\:px-0[data-v-c1463376]{padding-left:0;padding-right:0}.sm\:px-6[data-v-c1463376]{padding-left:1.5rem;padding-right:1.5rem}.sm\:py-3[data-v-c1463376]{padding-bottom:.75rem;padding-top:.75rem}.sm\:text-4xl[data-v-c1463376]{font-size:2.25rem;line-height:2.5rem}.sm\:text-xl[data-v-c1463376]{font-size:1.25rem;line-height:1.75rem}}
@@ -0,0 +1 @@
1
+ .spotlight[data-v-05ddf355]{background:linear-gradient(45deg,#00dc82,#36e4da 50%,#0047e1);filter:blur(20vh)}.fixed[data-v-05ddf355]{position:fixed}.-bottom-1\/2[data-v-05ddf355]{bottom:-50%}.left-0[data-v-05ddf355]{left:0}.right-0[data-v-05ddf355]{right:0}.grid[data-v-05ddf355]{display:grid}.mb-16[data-v-05ddf355]{margin-bottom:4rem}.mb-8[data-v-05ddf355]{margin-bottom:2rem}.h-1\/2[data-v-05ddf355]{height:50%}.max-w-520px[data-v-05ddf355]{max-width:520px}.min-h-screen[data-v-05ddf355]{min-height:100vh}.place-content-center[data-v-05ddf355]{place-content:center}.overflow-hidden[data-v-05ddf355]{overflow:hidden}.bg-white[data-v-05ddf355]{--un-bg-opacity:1;background-color:rgb(255 255 255/var(--un-bg-opacity))}.px-8[data-v-05ddf355]{padding-left:2rem;padding-right:2rem}.text-center[data-v-05ddf355]{text-align:center}.text-8xl[data-v-05ddf355]{font-size:6rem;line-height:1}.text-xl[data-v-05ddf355]{font-size:1.25rem;line-height:1.75rem}.text-black[data-v-05ddf355]{--un-text-opacity:1;color:rgb(0 0 0/var(--un-text-opacity))}.font-light[data-v-05ddf355]{font-weight:300}.font-medium[data-v-05ddf355]{font-weight:500}.leading-tight[data-v-05ddf355]{line-height:1.25}.font-sans[data-v-05ddf355]{font-family:ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica Neue,Arial,Noto Sans,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji}.antialiased[data-v-05ddf355]{-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}@media (prefers-color-scheme:dark){.dark\:bg-black[data-v-05ddf355]{--un-bg-opacity:1;background-color:rgb(0 0 0/var(--un-bg-opacity))}.dark\:text-white[data-v-05ddf355]{--un-text-opacity:1;color:rgb(255 255 255/var(--un-text-opacity))}}@media (min-width:640px){.sm\:px-0[data-v-05ddf355]{padding-left:0;padding-right:0}.sm\:text-4xl[data-v-05ddf355]{font-size:2.25rem;line-height:2.5rem}}
@@ -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_DEVTOOLS_I18N_BASE__/_nuxt/entry.B5pGkSSX.css" crossorigin>
4
- <link rel="modulepreload" as="script" crossorigin href="/__NUXT_DEVTOOLS_I18N_BASE__/_nuxt/C9njAg9E.js">
4
+ <link rel="modulepreload" as="script" crossorigin href="/__NUXT_DEVTOOLS_I18N_BASE__/_nuxt/Ddb0iCRU.js">
5
5
  <link rel="prefetch" as="script" crossorigin href="/__NUXT_DEVTOOLS_I18N_BASE__/_nuxt/CG55hV0U.js">
6
- <link rel="prefetch" as="style" crossorigin href="/__NUXT_DEVTOOLS_I18N_BASE__/_nuxt/error-404.C8aNxDEl.css">
7
- <link rel="prefetch" as="script" crossorigin href="/__NUXT_DEVTOOLS_I18N_BASE__/_nuxt/BIRJeTBr.js">
8
- <link rel="prefetch" as="script" crossorigin href="/__NUXT_DEVTOOLS_I18N_BASE__/_nuxt/EwNUkbJF.js">
9
- <link rel="prefetch" as="style" crossorigin href="/__NUXT_DEVTOOLS_I18N_BASE__/_nuxt/error-500.C2JGrgZX.css">
10
- <link rel="prefetch" as="script" crossorigin href="/__NUXT_DEVTOOLS_I18N_BASE__/_nuxt/DuZjM2Ym.js">
11
- <script type="module" src="/__NUXT_DEVTOOLS_I18N_BASE__/_nuxt/C9njAg9E.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},1736953870973,false]</script>
12
- <script>window.__NUXT__={};window.__NUXT__.config={public:{},app:{baseURL:"/__NUXT_DEVTOOLS_I18N_BASE__/",buildId:"019df560-5b4f-4d25-8ca1-a8cad935e3d2",buildAssetsDir:"/_nuxt/",cdnURL:""}}</script></body></html>
6
+ <link rel="prefetch" as="style" crossorigin href="/__NUXT_DEVTOOLS_I18N_BASE__/_nuxt/error-404.vh32VtAd.css">
7
+ <link rel="prefetch" as="script" crossorigin href="/__NUXT_DEVTOOLS_I18N_BASE__/_nuxt/Deg2o1hP.js">
8
+ <link rel="prefetch" as="script" crossorigin href="/__NUXT_DEVTOOLS_I18N_BASE__/_nuxt/AXE8DZQI.js">
9
+ <link rel="prefetch" as="style" crossorigin href="/__NUXT_DEVTOOLS_I18N_BASE__/_nuxt/error-500.EgQ3RNLZ.css">
10
+ <link rel="prefetch" as="script" crossorigin href="/__NUXT_DEVTOOLS_I18N_BASE__/_nuxt/D9gx-VEt.js">
11
+ <script type="module" src="/__NUXT_DEVTOOLS_I18N_BASE__/_nuxt/Ddb0iCRU.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},1737031245631,false]</script>
12
+ <script>window.__NUXT__={};window.__NUXT__.config={public:{},app:{baseURL:"/__NUXT_DEVTOOLS_I18N_BASE__/",buildId:"c4f80d33-396e-44b9-86d2-e62d781c506f",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.61.0",
4
+ "version": "1.63.0",
5
5
  "builder": {
6
6
  "@nuxt/module-builder": "0.8.4",
7
7
  "unbuild": "2.0.0"
package/dist/module.mjs CHANGED
@@ -1,8 +1,10 @@
1
1
  import path, { resolve } from 'node:path';
2
2
  import * as fs from 'node:fs';
3
3
  import fs__default, { readFileSync, existsSync, mkdirSync, writeFileSync } from 'node:fs';
4
+ import { readFile } from 'node:fs/promises';
4
5
  import { useNuxt, defineNuxtModule, useLogger, createResolver, addTemplate, addImportsDir, addPlugin, addServerHandler, addComponentsDir, addTypeTemplate, extendPages, addPrerenderRoutes } from '@nuxt/kit';
5
6
  import { watch } from 'chokidar';
7
+ import { globby } from 'globby';
6
8
  import { fileURLToPath } from 'node:url';
7
9
  import { onDevToolsInitialized, extendServerRpc } from '@nuxt/devtools-kit';
8
10
  import sirv from 'sirv';
@@ -22,6 +24,9 @@ function setupDevToolsUI(options, resolve2) {
22
24
  if (clientDirExists) {
23
25
  nuxt.hook("vite:serverCreated", (server) => {
24
26
  const indexHtmlPath = path.join(clientDir, "index.html");
27
+ if (!fs.existsSync(indexHtmlPath)) {
28
+ return;
29
+ }
25
30
  const indexContent = fs.readFileSync(indexHtmlPath);
26
31
  const handleStatic = sirv(clientDir, {
27
32
  dev: true,
@@ -374,6 +379,34 @@ declare module '#app' {
374
379
 
375
380
  export {}`;
376
381
  }
382
+ function deepMerge(target, source) {
383
+ if (typeof source !== "object" || source === null) {
384
+ return target === void 0 ? source : target;
385
+ }
386
+ if (Array.isArray(target)) {
387
+ return target;
388
+ }
389
+ if (source instanceof Object) {
390
+ if (!(target instanceof Object) || Array.isArray(target)) {
391
+ target = {};
392
+ }
393
+ for (const key in source) {
394
+ if (key === "__proto__" || key === "constructor")
395
+ continue;
396
+ if (target !== null && typeof target[key] === "object" && target[key] !== null) {
397
+ target[key] = deepMerge(
398
+ target[key],
399
+ source[key]
400
+ );
401
+ } else {
402
+ if (target instanceof Object && !(key in target)) {
403
+ target[key] = source[key];
404
+ }
405
+ }
406
+ }
407
+ }
408
+ return target;
409
+ }
377
410
  const module = defineNuxtModule({
378
411
  meta: {
379
412
  name: "nuxt-i18n-micro",
@@ -412,6 +445,7 @@ const module = defineNuxtModule({
412
445
  customRegexMatcher: void 0
413
446
  },
414
447
  async setup(options, nuxt) {
448
+ const defaultLocale = process.env.DEFAULT_LOCALE ?? options.defaultLocale ?? "en";
415
449
  const isSSG = nuxt.options._generate;
416
450
  const isCloudflarePages = nuxt.options.nitro.preset === "cloudflare_pages" || process.env.NITRO_PRESET === "cloudflare-pages";
417
451
  const logger = useLogger("nuxt-i18n-micro");
@@ -426,7 +460,7 @@ const module = defineNuxtModule({
426
460
  const resolver = createResolver(import.meta.url);
427
461
  const rootDirs = nuxt.options._layers.map((layer) => layer.config.rootDir).reverse();
428
462
  const localeManager = new LocaleManager(options, rootDirs);
429
- const pageManager = new PageManager(localeManager.locales, options.defaultLocale, options.strategy, options.globalLocaleRoutes);
463
+ const pageManager = new PageManager(localeManager.locales, defaultLocale, options.strategy, options.globalLocaleRoutes);
430
464
  addTemplate({
431
465
  filename: "i18n.plural.mjs",
432
466
  write: true,
@@ -437,11 +471,13 @@ const module = defineNuxtModule({
437
471
  plural: void 0,
438
472
  locales: localeManager.locales ?? [],
439
473
  meta: options.meta ?? true,
474
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
475
+ // @ts-ignore
440
476
  metaBaseUrl: options.metaBaseUrl ?? void 0,
441
477
  define: options.define ?? true,
442
478
  disableWatcher: options.disableWatcher ?? false,
443
479
  disableUpdater: options.disableUpdater ?? false,
444
- defaultLocale: options.defaultLocale ?? "en",
480
+ defaultLocale,
445
481
  translationDir: options.translationDir ?? "locales",
446
482
  localeCookie: options.localeCookie ?? "user-locale",
447
483
  autoDetectLanguage: options.autoDetectLanguage ?? true,
@@ -505,7 +541,7 @@ const module = defineNuxtModule({
505
541
  }
506
542
  addServerHandler({
507
543
  route: `/${apiBaseUrl}/:page/:locale/data.json`,
508
- handler: resolver.resolve("./runtime/server/middleware/i18n-loader")
544
+ handler: resolver.resolve("./runtime/server/routes/get")
509
545
  });
510
546
  await addComponentsDir({
511
547
  path: resolver.resolve("./runtime/components"),
@@ -519,27 +555,8 @@ const module = defineNuxtModule({
519
555
  });
520
556
  }
521
557
  extendPages((pages) => {
522
- if (isNoPrefixStrategy(options.strategy)) {
523
- return;
524
- }
525
- const pagesNames = pages.map((page) => page.name).filter((name) => name !== void 0 && (!options.routesLocaleLinks || !options.routesLocaleLinks[name]));
526
- if (!options.disableWatcher) {
527
- localeManager.ensureTranslationFilesExist(pagesNames, options.translationDir, nuxt.options.rootDir);
528
- }
529
- pageManager.extendPages(pages, options.customRegexMatcher, isCloudflarePages);
530
- if (isPrefixStrategy(options.strategy) && !isCloudflarePages) {
531
- const fallbackRoute = {
532
- path: "/:pathMatch(.*)*",
533
- name: "custom-fallback-route",
534
- file: resolver.resolve("./runtime/components/locale-redirect.vue"),
535
- meta: {
536
- globalLocaleRoutes: options.globalLocaleRoutes
537
- }
538
- };
539
- pages.push(fallbackRoute);
540
- }
541
- nuxt.options.generate.routes = Array.isArray(nuxt.options.generate.routes) ? nuxt.options.generate.routes : [];
542
558
  const prerenderRoutes = [];
559
+ const pagesNames = pages.map((page) => page.name).filter((name) => name !== void 0 && (!options.routesLocaleLinks || !options.routesLocaleLinks[name]));
543
560
  localeManager.locales.forEach((locale) => {
544
561
  if (!options.disablePageLocales) {
545
562
  pagesNames.forEach((name) => {
@@ -548,36 +565,61 @@ const module = defineNuxtModule({
548
565
  }
549
566
  prerenderRoutes.push(`/${apiBaseUrl}/general/${locale.code}/data.json`);
550
567
  });
551
- if (isCloudflarePages) {
552
- const processPageWithChildren = (page, parentPath = "") => {
553
- if (!page.path)
554
- return;
555
- const fullPath = path.posix.normalize(`${parentPath}/${page.path}`);
556
- const localeSegmentMatch = fullPath.match(/:locale\(([^)]+)\)/);
557
- if (localeSegmentMatch) {
558
- const availableLocales = localeSegmentMatch[1].split("|");
559
- localeManager.locales.forEach((locale) => {
560
- const localeCode = locale.code;
561
- if (availableLocales.includes(localeCode)) {
562
- let localizedPath = fullPath;
563
- localizedPath = localizedPath.replace(/:locale\([^)]+\)/, localeCode);
564
- prerenderRoutes.push(localizedPath);
565
- }
566
- });
567
- } else {
568
- prerenderRoutes.push(fullPath);
569
- }
570
- if (page.children && page.children.length) {
571
- page.children.forEach((childPage) => processPageWithChildren(childPage, fullPath));
572
- }
573
- };
574
- pages.forEach((page) => {
575
- processPageWithChildren(page);
576
- });
568
+ if (!isNoPrefixStrategy(options.strategy)) {
569
+ if (!options.disableWatcher) {
570
+ localeManager.ensureTranslationFilesExist(pagesNames, options.translationDir, nuxt.options.rootDir);
571
+ }
572
+ pageManager.extendPages(pages, options.customRegexMatcher, isCloudflarePages);
573
+ if (isPrefixStrategy(options.strategy) && !isCloudflarePages) {
574
+ const fallbackRoute = {
575
+ path: "/:pathMatch(.*)*",
576
+ name: "custom-fallback-route",
577
+ file: resolver.resolve("./runtime/components/locale-redirect.vue"),
578
+ meta: {
579
+ globalLocaleRoutes: options.globalLocaleRoutes
580
+ }
581
+ };
582
+ pages.push(fallbackRoute);
583
+ }
584
+ nuxt.options.generate.routes = Array.isArray(nuxt.options.generate.routes) ? nuxt.options.generate.routes : [];
585
+ if (isCloudflarePages) {
586
+ const processPageWithChildren = (page, parentPath = "") => {
587
+ if (!page.path)
588
+ return;
589
+ const fullPath = path.posix.normalize(`${parentPath}/${page.path}`);
590
+ const localeSegmentMatch = fullPath.match(/:locale\(([^)]+)\)/);
591
+ if (localeSegmentMatch) {
592
+ const availableLocales = localeSegmentMatch[1].split("|");
593
+ localeManager.locales.forEach((locale) => {
594
+ const localeCode = locale.code;
595
+ if (availableLocales.includes(localeCode)) {
596
+ let localizedPath = fullPath;
597
+ localizedPath = localizedPath.replace(/:locale\([^)]+\)/, localeCode);
598
+ prerenderRoutes.push(localizedPath);
599
+ }
600
+ });
601
+ } else {
602
+ prerenderRoutes.push(fullPath);
603
+ }
604
+ if (page.children && page.children.length) {
605
+ page.children.forEach((childPage) => processPageWithChildren(childPage, fullPath));
606
+ }
607
+ };
608
+ pages.forEach((page) => {
609
+ processPageWithChildren(page);
610
+ });
611
+ }
577
612
  }
578
613
  addPrerenderRoutes(prerenderRoutes);
579
614
  });
580
615
  nuxt.hook("nitro:config", (nitroConfig) => {
616
+ nitroConfig.bundledStorage = nitroConfig.bundledStorage || [];
617
+ nitroConfig.bundledStorage.push("i18n-locales");
618
+ nitroConfig.devStorage = nitroConfig.devStorage || {};
619
+ nitroConfig.devStorage["i18n-locales"] = {
620
+ driver: "fs",
621
+ base: path.join(nuxt.options.rootDir, "server/assets/i18n-locales")
622
+ };
581
623
  if (nitroConfig.imports) {
582
624
  nitroConfig.imports.presets = nitroConfig.imports.presets || [];
583
625
  nitroConfig.imports.presets.push({
@@ -592,7 +634,7 @@ const module = defineNuxtModule({
592
634
  nuxt.options.generate.routes = Array.isArray(nuxt.options.generate.routes) ? nuxt.options.generate.routes : [];
593
635
  const pages = nuxt.options.generate.routes || [];
594
636
  localeManager.locales.forEach((locale) => {
595
- if (locale.code !== options.defaultLocale || withPrefixStrategy(options.strategy)) {
637
+ if (locale.code !== defaultLocale || withPrefixStrategy(options.strategy)) {
596
638
  pages.forEach((page) => {
597
639
  if (!/\.[a-z0-9]+$/i.test(page)) {
598
640
  routes.push(`/${locale.code}${page}`);
@@ -616,6 +658,64 @@ const module = defineNuxtModule({
616
658
  }
617
659
  }
618
660
  });
661
+ nuxt.hook("nitro:init", async (nitro) => {
662
+ logger.debug("[nuxt-i18n-micro] clear storage cache");
663
+ await nitro.storage.clear("i18n-locales");
664
+ if (!await nitro.storage.hasItem(`i18n-locales:.gitignore`)) {
665
+ const dir = path.join(nuxt.options.rootDir, "server/assets/i18n-locales");
666
+ fs__default.mkdirSync(dir, { recursive: true });
667
+ fs__default.writeFileSync(`${dir}/.gitignore`, "*");
668
+ }
669
+ const translationDir = options.translationDir ?? "";
670
+ const fallbackLocale = options.fallbackLocale ?? null;
671
+ const translationsByLocale = {};
672
+ try {
673
+ for (const rootDir of rootDirs) {
674
+ const baseDir = path.resolve(rootDir, translationDir);
675
+ const files = await globby("**/*.json", { cwd: baseDir });
676
+ const promises = files.map(async (file) => {
677
+ const filePath = path.join(baseDir, file);
678
+ const content = await readFile(filePath, "utf-8");
679
+ const data = JSON.parse(content);
680
+ const parts = file.split("/");
681
+ const locale = parts.pop()?.replace(".json", "") || "";
682
+ const pageKey = parts.pop() || "general";
683
+ if (!translationsByLocale[locale]) {
684
+ translationsByLocale[locale] = {};
685
+ }
686
+ translationsByLocale[locale] = deepMerge({
687
+ [pageKey]: data
688
+ }, translationsByLocale[locale]);
689
+ });
690
+ await Promise.all(promises);
691
+ }
692
+ const savePromises = [];
693
+ for (const [locale, translations] of Object.entries(translationsByLocale)) {
694
+ for (const [key, value] of Object.entries(translations)) {
695
+ const storageKey = `i18n-locales:${locale}:${key}`;
696
+ const promise = (async () => {
697
+ let translation = value;
698
+ if (fallbackLocale) {
699
+ translation = deepMerge(
700
+ translation,
701
+ translationsByLocale[fallbackLocale][key] ?? {}
702
+ );
703
+ }
704
+ if (typeof translation === "object" && translation !== null) {
705
+ await nitro.storage.setItem(storageKey, translation);
706
+ if (options.debug) {
707
+ logger.log(`[nuxt-i18n-micro] Translation saved to Nitro storage with key: ${storageKey}`);
708
+ }
709
+ }
710
+ })();
711
+ savePromises.push(promise);
712
+ }
713
+ }
714
+ await Promise.all(savePromises);
715
+ } catch (err) {
716
+ logger.error("[nuxt-i18n-micro] Error processing translations:", err);
717
+ }
718
+ });
619
719
  if (!options.disableUpdater) {
620
720
  nuxt.hook("nitro:build:before", async (_nitro) => {
621
721
  const isProd = nuxt.options.dev === false;
@@ -623,7 +723,7 @@ const module = defineNuxtModule({
623
723
  const translationPath = path.resolve(nuxt.options.rootDir, options.translationDir);
624
724
  logger.log("\u2139 add file watcher: " + translationPath);
625
725
  const watcherEvent = async (path2) => {
626
- watcher.close();
726
+ await watcher.close();
627
727
  logger.log("\u21BB update store item: " + path2);
628
728
  nuxt.callHook("restart");
629
729
  };
@@ -643,7 +743,7 @@ const module = defineNuxtModule({
643
743
  routesSet.forEach((route) => {
644
744
  if (!/\.[a-z0-9]+$/i.test(route)) {
645
745
  localeManager.locales.forEach((locale) => {
646
- if (locale.code !== options.defaultLocale) {
746
+ if (locale.code !== defaultLocale) {
647
747
  if (route === "/") {
648
748
  additionalRoutes.add(`/${locale.code}`);
649
749
  } else {
@@ -12,6 +12,7 @@ export const useLocaleHead = ({ addDirAttribute = true, identifierAttribute = "i
12
12
  const { $getLocales, $getLocale } = useNuxtApp();
13
13
  const route = useRoute();
14
14
  const locale = unref($getLocale());
15
+ const locales = unref($getLocales());
15
16
  const routeName = (route.name ?? "").toString();
16
17
  const currentLocale = unref($getLocales().find((loc) => loc.code === locale));
17
18
  if (!currentLocale) {
@@ -22,14 +23,18 @@ export const useLocaleHead = ({ addDirAttribute = true, identifierAttribute = "i
22
23
  let fullPath = unref(route.fullPath);
23
24
  let ogUrl = joinURL(unref(baseUrl), fullPath);
24
25
  let indexUrl = joinURL(unref(baseUrl));
26
+ if (!fullPath.startsWith("/")) {
27
+ fullPath = `/${fullPath}`;
28
+ }
25
29
  if (!ogUrl.endsWith("/")) {
26
30
  ogUrl += "/";
27
31
  }
28
32
  if (!indexUrl.endsWith("/")) {
29
33
  indexUrl += "/";
30
34
  }
31
- if (routeName.startsWith("localized-") && fullPath.startsWith(`/${locale}`)) {
32
- fullPath = fullPath.slice(locale.length + 1);
35
+ const matchedLocale = locales.find((locale2) => fullPath.startsWith(`/${locale2.code}`));
36
+ if (routeName.startsWith("localized-") && matchedLocale) {
37
+ fullPath = fullPath.slice(matchedLocale.code.length + 1);
33
38
  ogUrl = joinURL(unref(baseUrl), locale, fullPath);
34
39
  }
35
40
  metaObject.value = {
@@ -1,6 +1,6 @@
1
1
  import type { RouteLocationAsPath, RouteLocationAsRelative, RouteLocationAsString, RouteLocationNormalizedLoaded, RouteLocationRaw, RouteLocationResolved, RouteLocationResolvedGeneric } from 'vue-router';
2
2
  import type { Translation, Translations } from 'nuxt-i18n-micro-core';
3
- import type { I18nRouteParams, Locale, Params } from '../../types.js';
3
+ import type { Locale, I18nRouteParams, Params } from '../../types.js';
4
4
  declare const _default: import("nuxt/app").Plugin<{
5
5
  i18n: undefined;
6
6
  __micro: boolean;
@@ -21,7 +21,7 @@ declare const _default: import("nuxt/app").Plugin<{
21
21
  switchLocaleRoute: (toLocale: string) => string | import("vue-router").RouteLocationAsRelativeGeneric | import("vue-router").RouteLocationAsPathGeneric;
22
22
  switchLocalePath: (toLocale: string) => string;
23
23
  switchLocale: (toLocale: string) => void;
24
- switchRoute: (to: RouteLocationNormalizedLoaded | RouteLocationResolvedGeneric | string, toLocale?: string) => void;
24
+ switchRoute: (route: RouteLocationNormalizedLoaded | RouteLocationResolvedGeneric | string, toLocale?: string) => void;
25
25
  localeRoute: (to: RouteLocationAsString | RouteLocationAsRelative | RouteLocationAsPath | string, locale?: string) => RouteLocationResolved;
26
26
  localePath: (to: RouteLocationAsString | RouteLocationAsRelative | RouteLocationAsPath, locale?: string) => string;
27
27
  setI18nRouteParams: (value: I18nRouteParams) => I18nRouteParams;
@@ -45,7 +45,7 @@ declare const _default: import("nuxt/app").Plugin<{
45
45
  switchLocaleRoute: (toLocale: string) => string | import("vue-router").RouteLocationAsRelativeGeneric | import("vue-router").RouteLocationAsPathGeneric;
46
46
  switchLocalePath: (toLocale: string) => string;
47
47
  switchLocale: (toLocale: string) => void;
48
- switchRoute: (to: RouteLocationNormalizedLoaded | RouteLocationResolvedGeneric | string, toLocale?: string) => void;
48
+ switchRoute: (route: RouteLocationNormalizedLoaded | RouteLocationResolvedGeneric | string, toLocale?: string) => void;
49
49
  localeRoute: (to: RouteLocationAsString | RouteLocationAsRelative | RouteLocationAsPath | string, locale?: string) => RouteLocationResolved;
50
50
  localePath: (to: RouteLocationAsString | RouteLocationAsRelative | RouteLocationAsPath, locale?: string) => string;
51
51
  setI18nRouteParams: (value: I18nRouteParams) => I18nRouteParams;