nuxt-i18n-micro 1.67.1 → 1.69.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 +8 -8
- package/dist/client/404.html +8 -8
- package/dist/client/_nuxt/{DT0mZaxo.js → Bc8-3my4.js} +1 -1
- package/dist/client/_nuxt/{ClTsZsex.js → C-ULErdD.js} +59 -59
- package/dist/client/_nuxt/{CcDaBmcC.js → D5DyI9oC.js} +1 -1
- package/dist/client/_nuxt/{rqhqIC0Q.js → I_HlWSXB.js} +1 -1
- package/dist/client/_nuxt/builds/latest.json +1 -1
- package/dist/client/_nuxt/builds/meta/1b477113-a1a7-4084-9d41-d3399aef42b8.json +1 -0
- package/dist/client/_nuxt/error-404.DzyMP_s0.css +1 -0
- package/dist/client/_nuxt/error-500.YF1CL0xw.css +1 -0
- package/dist/client/index.html +8 -8
- package/dist/module.json +1 -1
- package/dist/module.mjs +0 -96
- package/dist/runtime/components/i18n-link.vue +2 -2
- package/dist/runtime/plugins/01.plugin.d.ts +11 -11
- package/dist/runtime/server/routes/get.js +51 -8
- package/package.json +3 -3
- package/dist/client/_nuxt/builds/meta/a0710ba7-e099-433f-942a-33090226304f.json +0 -1
- package/dist/client/_nuxt/error-404.DCBEmQSD.css +0 -1
- package/dist/client/_nuxt/error-500.D1x2GrnM.css +0 -1
|
@@ -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"./C-ULErdD.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
|
-
import{_ as s,o as a,c as i,a as e,t as o}from"./
|
|
1
|
+
import{_ as s,o as a,c as i,a as e,t as o}from"./C-ULErdD.js";import{u}from"./D5DyI9oC.js";const l={class:"antialiased bg-white dark:bg-black dark:text-white font-sans grid min-h-screen overflow-hidden place-content-center text-black"},c={class:"max-w-520px text-center"},d=["textContent"],p=["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 r=t;return u({title:`${r.statusCode} - ${r.statusMessage} | ${r.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}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: }'}]}),(g,n)=>(a(),i("div",l,[n[0]||(n[0]=e("div",{class:"-bottom-1/2 fixed h-1/2 left-0 right-0 spotlight"},null,-1)),e("div",c,[e("h1",{class:"font-medium mb-8 sm:text-10xl text-8xl",textContent:o(t.statusCode)},null,8,d),e("p",{class:"font-light leading-tight mb-16 px-8 sm:px-0 sm:text-4xl text-xl",textContent:o(t.description)},null,8,p)])]))}},b=s(f,[["__scopeId","data-v-ea2ac144"]]);export{b as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"id":"
|
|
1
|
+
{"id":"1b477113-a1a7-4084-9d41-d3399aef42b8","timestamp":1737531897027}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"id":"1b477113-a1a7-4084-9d41-d3399aef42b8","timestamp":1737531897027,"matcher":{"static":{},"wildcard":{},"dynamic":{}},"prerendered":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
.spotlight[data-v-11ff7e00]{background:linear-gradient(45deg,#00dc82,#36e4da 50%,#0047e1);bottom:-30vh;filter:blur(20vh);height:40vh}.gradient-border[data-v-11ff7e00]{-webkit-backdrop-filter:blur(10px);backdrop-filter:blur(10px);border-radius:.5rem;position:relative}@media (prefers-color-scheme:light){.gradient-border[data-v-11ff7e00]{background-color:#ffffff4d}.gradient-border[data-v-11ff7e00]:before{background:linear-gradient(90deg,#e2e2e2,#e2e2e2 25%,#00dc82,#36e4da 75%,#0047e1)}}@media (prefers-color-scheme:dark){.gradient-border[data-v-11ff7e00]{background-color:#1414144d}.gradient-border[data-v-11ff7e00]:before{background:linear-gradient(90deg,#303030,#303030 25%,#00dc82,#36e4da 75%,#0047e1)}}.gradient-border[data-v-11ff7e00]: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-11ff7e00]:hover:before{background-position:-50% 0;opacity:1}.fixed[data-v-11ff7e00]{position:fixed}.left-0[data-v-11ff7e00]{left:0}.right-0[data-v-11ff7e00]{right:0}.z-10[data-v-11ff7e00]{z-index:10}.z-20[data-v-11ff7e00]{z-index:20}.grid[data-v-11ff7e00]{display:grid}.mb-16[data-v-11ff7e00]{margin-bottom:4rem}.mb-8[data-v-11ff7e00]{margin-bottom:2rem}.max-w-520px[data-v-11ff7e00]{max-width:520px}.min-h-screen[data-v-11ff7e00]{min-height:100vh}.w-full[data-v-11ff7e00]{width:100%}.flex[data-v-11ff7e00]{display:flex}.cursor-pointer[data-v-11ff7e00]{cursor:pointer}.place-content-center[data-v-11ff7e00]{place-content:center}.items-center[data-v-11ff7e00]{align-items:center}.justify-center[data-v-11ff7e00]{justify-content:center}.overflow-hidden[data-v-11ff7e00]{overflow:hidden}.bg-white[data-v-11ff7e00]{--un-bg-opacity:1;background-color:rgb(255 255 255/var(--un-bg-opacity))}.px-4[data-v-11ff7e00]{padding-left:1rem;padding-right:1rem}.px-8[data-v-11ff7e00]{padding-left:2rem;padding-right:2rem}.py-2[data-v-11ff7e00]{padding-bottom:.5rem;padding-top:.5rem}.text-center[data-v-11ff7e00]{text-align:center}.text-8xl[data-v-11ff7e00]{font-size:6rem;line-height:1}.text-xl[data-v-11ff7e00]{font-size:1.25rem;line-height:1.75rem}.text-black[data-v-11ff7e00]{--un-text-opacity:1;color:rgb(0 0 0/var(--un-text-opacity))}.font-light[data-v-11ff7e00]{font-weight:300}.font-medium[data-v-11ff7e00]{font-weight:500}.leading-tight[data-v-11ff7e00]{line-height:1.25}.font-sans[data-v-11ff7e00]{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-11ff7e00]{-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}@media (prefers-color-scheme:dark){.dark\:bg-black[data-v-11ff7e00]{--un-bg-opacity:1;background-color:rgb(0 0 0/var(--un-bg-opacity))}.dark\:text-white[data-v-11ff7e00]{--un-text-opacity:1;color:rgb(255 255 255/var(--un-text-opacity))}}@media (min-width:640px){.sm\:px-0[data-v-11ff7e00]{padding-left:0;padding-right:0}.sm\:px-6[data-v-11ff7e00]{padding-left:1.5rem;padding-right:1.5rem}.sm\:py-3[data-v-11ff7e00]{padding-bottom:.75rem;padding-top:.75rem}.sm\:text-4xl[data-v-11ff7e00]{font-size:2.25rem;line-height:2.5rem}.sm\:text-xl[data-v-11ff7e00]{font-size:1.25rem;line-height:1.75rem}}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
.spotlight[data-v-ea2ac144]{background:linear-gradient(45deg,#00dc82,#36e4da 50%,#0047e1);filter:blur(20vh)}.fixed[data-v-ea2ac144]{position:fixed}.-bottom-1\/2[data-v-ea2ac144]{bottom:-50%}.left-0[data-v-ea2ac144]{left:0}.right-0[data-v-ea2ac144]{right:0}.grid[data-v-ea2ac144]{display:grid}.mb-16[data-v-ea2ac144]{margin-bottom:4rem}.mb-8[data-v-ea2ac144]{margin-bottom:2rem}.h-1\/2[data-v-ea2ac144]{height:50%}.max-w-520px[data-v-ea2ac144]{max-width:520px}.min-h-screen[data-v-ea2ac144]{min-height:100vh}.place-content-center[data-v-ea2ac144]{place-content:center}.overflow-hidden[data-v-ea2ac144]{overflow:hidden}.bg-white[data-v-ea2ac144]{--un-bg-opacity:1;background-color:rgb(255 255 255/var(--un-bg-opacity))}.px-8[data-v-ea2ac144]{padding-left:2rem;padding-right:2rem}.text-center[data-v-ea2ac144]{text-align:center}.text-8xl[data-v-ea2ac144]{font-size:6rem;line-height:1}.text-xl[data-v-ea2ac144]{font-size:1.25rem;line-height:1.75rem}.text-black[data-v-ea2ac144]{--un-text-opacity:1;color:rgb(0 0 0/var(--un-text-opacity))}.font-light[data-v-ea2ac144]{font-weight:300}.font-medium[data-v-ea2ac144]{font-weight:500}.leading-tight[data-v-ea2ac144]{line-height:1.25}.font-sans[data-v-ea2ac144]{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-ea2ac144]{-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}@media (prefers-color-scheme:dark){.dark\:bg-black[data-v-ea2ac144]{--un-bg-opacity:1;background-color:rgb(0 0 0/var(--un-bg-opacity))}.dark\:text-white[data-v-ea2ac144]{--un-text-opacity:1;color:rgb(255 255 255/var(--un-text-opacity))}}@media (min-width:640px){.sm\:px-0[data-v-ea2ac144]{padding-left:0;padding-right:0}.sm\:text-4xl[data-v-ea2ac144]{font-size:2.25rem;line-height:2.5rem}}
|
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_DEVTOOLS_I18N_BASE__/_nuxt/entry.B5pGkSSX.css" crossorigin>
|
|
4
|
-
<link rel="modulepreload" as="script" crossorigin href="/__NUXT_DEVTOOLS_I18N_BASE__/_nuxt/
|
|
4
|
+
<link rel="modulepreload" as="script" crossorigin href="/__NUXT_DEVTOOLS_I18N_BASE__/_nuxt/C-ULErdD.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.
|
|
7
|
-
<link rel="prefetch" as="script" crossorigin href="/__NUXT_DEVTOOLS_I18N_BASE__/_nuxt/
|
|
8
|
-
<link rel="prefetch" as="script" crossorigin href="/__NUXT_DEVTOOLS_I18N_BASE__/_nuxt/
|
|
9
|
-
<link rel="prefetch" as="style" crossorigin href="/__NUXT_DEVTOOLS_I18N_BASE__/_nuxt/error-500.
|
|
10
|
-
<link rel="prefetch" as="script" crossorigin href="/__NUXT_DEVTOOLS_I18N_BASE__/_nuxt/
|
|
11
|
-
<script type="module" src="/__NUXT_DEVTOOLS_I18N_BASE__/_nuxt/
|
|
12
|
-
<script>window.__NUXT__={};window.__NUXT__.config={public:{},app:{baseURL:"/__NUXT_DEVTOOLS_I18N_BASE__/",buildId:"
|
|
6
|
+
<link rel="prefetch" as="style" crossorigin href="/__NUXT_DEVTOOLS_I18N_BASE__/_nuxt/error-404.DzyMP_s0.css">
|
|
7
|
+
<link rel="prefetch" as="script" crossorigin href="/__NUXT_DEVTOOLS_I18N_BASE__/_nuxt/Bc8-3my4.js">
|
|
8
|
+
<link rel="prefetch" as="script" crossorigin href="/__NUXT_DEVTOOLS_I18N_BASE__/_nuxt/D5DyI9oC.js">
|
|
9
|
+
<link rel="prefetch" as="style" crossorigin href="/__NUXT_DEVTOOLS_I18N_BASE__/_nuxt/error-500.YF1CL0xw.css">
|
|
10
|
+
<link rel="prefetch" as="script" crossorigin href="/__NUXT_DEVTOOLS_I18N_BASE__/_nuxt/I_HlWSXB.js">
|
|
11
|
+
<script type="module" src="/__NUXT_DEVTOOLS_I18N_BASE__/_nuxt/C-ULErdD.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},1737531901894,false]</script>
|
|
12
|
+
<script>window.__NUXT__={};window.__NUXT__.config={public:{},app:{baseURL:"/__NUXT_DEVTOOLS_I18N_BASE__/",buildId:"1b477113-a1a7-4084-9d41-d3399aef42b8",buildAssetsDir:"/_nuxt/",cdnURL:""}}</script></body></html>
|
package/dist/module.json
CHANGED
package/dist/module.mjs
CHANGED
|
@@ -1,10 +1,8 @@
|
|
|
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';
|
|
5
4
|
import { useNuxt, defineNuxtModule, useLogger, createResolver, addTemplate, addImportsDir, addPlugin, addServerHandler, addComponentsDir, addTypeTemplate, extendPages, addPrerenderRoutes } from '@nuxt/kit';
|
|
6
5
|
import { watch } from 'chokidar';
|
|
7
|
-
import { globby } from 'globby';
|
|
8
6
|
import { isPrefixAndDefaultStrategy, isPrefixStrategy, isNoPrefixStrategy, withPrefixStrategy } from 'nuxt-i18n-micro-core';
|
|
9
7
|
import { fileURLToPath } from 'node:url';
|
|
10
8
|
import { onDevToolsInitialized, extendServerRpc } from '@nuxt/devtools-kit';
|
|
@@ -400,34 +398,6 @@ declare module '#app' {
|
|
|
400
398
|
|
|
401
399
|
export {}`;
|
|
402
400
|
}
|
|
403
|
-
function deepMerge(target, source) {
|
|
404
|
-
if (typeof source !== "object" || source === null) {
|
|
405
|
-
return target === void 0 ? source : target;
|
|
406
|
-
}
|
|
407
|
-
if (Array.isArray(target)) {
|
|
408
|
-
return target;
|
|
409
|
-
}
|
|
410
|
-
if (source instanceof Object) {
|
|
411
|
-
if (!(target instanceof Object) || Array.isArray(target)) {
|
|
412
|
-
target = {};
|
|
413
|
-
}
|
|
414
|
-
for (const key in source) {
|
|
415
|
-
if (key === "__proto__" || key === "constructor")
|
|
416
|
-
continue;
|
|
417
|
-
if (target !== null && typeof target[key] === "object" && target[key] !== null) {
|
|
418
|
-
target[key] = deepMerge(
|
|
419
|
-
target[key],
|
|
420
|
-
source[key]
|
|
421
|
-
);
|
|
422
|
-
} else {
|
|
423
|
-
if (target instanceof Object && !(key in target)) {
|
|
424
|
-
target[key] = source[key];
|
|
425
|
-
}
|
|
426
|
-
}
|
|
427
|
-
}
|
|
428
|
-
}
|
|
429
|
-
return target;
|
|
430
|
-
}
|
|
431
401
|
const module = defineNuxtModule({
|
|
432
402
|
meta: {
|
|
433
403
|
name: "nuxt-i18n-micro",
|
|
@@ -635,14 +605,6 @@ const module = defineNuxtModule({
|
|
|
635
605
|
addPrerenderRoutes(prerenderRoutes);
|
|
636
606
|
});
|
|
637
607
|
nuxt.hook("nitro:config", (nitroConfig) => {
|
|
638
|
-
nitroConfig.bundledStorage = nitroConfig.bundledStorage || [];
|
|
639
|
-
nitroConfig.bundledStorage.push("/i18n-locales");
|
|
640
|
-
nitroConfig.storage = nitroConfig.storage || {};
|
|
641
|
-
nitroConfig.devStorage = nitroConfig.devStorage || {};
|
|
642
|
-
nitroConfig.devStorage["i18n-locales"] = {
|
|
643
|
-
driver: "fs",
|
|
644
|
-
base: path.join(nuxt.options.rootDir, "server/assets/i18n-locales")
|
|
645
|
-
};
|
|
646
608
|
if (nitroConfig.imports) {
|
|
647
609
|
nitroConfig.imports.presets = nitroConfig.imports.presets || [];
|
|
648
610
|
nitroConfig.imports.presets.push({
|
|
@@ -681,64 +643,6 @@ const module = defineNuxtModule({
|
|
|
681
643
|
}
|
|
682
644
|
}
|
|
683
645
|
});
|
|
684
|
-
nuxt.hook("nitro:init", async (nitro) => {
|
|
685
|
-
logger.debug("[nuxt-i18n-micro] clear storage cache");
|
|
686
|
-
await nitro.storage.clear("i18n-locales");
|
|
687
|
-
if (!await nitro.storage.hasItem(`i18n-locales:.gitignore`)) {
|
|
688
|
-
const dir = path.join(nuxt.options.rootDir, "server/assets/i18n-locales");
|
|
689
|
-
fs__default.mkdirSync(dir, { recursive: true });
|
|
690
|
-
fs__default.writeFileSync(`${dir}/.gitignore`, "*");
|
|
691
|
-
}
|
|
692
|
-
const translationDir = options.translationDir ?? "";
|
|
693
|
-
const fallbackLocale = options.fallbackLocale ?? null;
|
|
694
|
-
const translationsByLocale = {};
|
|
695
|
-
try {
|
|
696
|
-
for (const rootDir of rootDirs) {
|
|
697
|
-
const baseDir = path.resolve(rootDir, translationDir);
|
|
698
|
-
const files = await globby("**/*.json", { cwd: baseDir });
|
|
699
|
-
const promises = files.map(async (file) => {
|
|
700
|
-
const filePath = path.join(baseDir, file);
|
|
701
|
-
const content = await readFile(filePath, "utf-8");
|
|
702
|
-
const data = JSON.parse(content);
|
|
703
|
-
const parts = file.split("/");
|
|
704
|
-
const locale = parts.pop()?.replace(".json", "") || "";
|
|
705
|
-
const pageKey = parts.pop() || "general";
|
|
706
|
-
if (!translationsByLocale[locale]) {
|
|
707
|
-
translationsByLocale[locale] = {};
|
|
708
|
-
}
|
|
709
|
-
translationsByLocale[locale] = deepMerge({
|
|
710
|
-
[pageKey]: data
|
|
711
|
-
}, translationsByLocale[locale]);
|
|
712
|
-
});
|
|
713
|
-
await Promise.all(promises);
|
|
714
|
-
}
|
|
715
|
-
const savePromises = [];
|
|
716
|
-
for (const [locale, translations] of Object.entries(translationsByLocale)) {
|
|
717
|
-
for (const [key, value] of Object.entries(translations)) {
|
|
718
|
-
const storageKey = `i18n-locales:${locale}:${key}`;
|
|
719
|
-
const promise = (async () => {
|
|
720
|
-
let translation = value;
|
|
721
|
-
if (fallbackLocale) {
|
|
722
|
-
translation = deepMerge(
|
|
723
|
-
translation,
|
|
724
|
-
translationsByLocale[fallbackLocale][key] ?? {}
|
|
725
|
-
);
|
|
726
|
-
}
|
|
727
|
-
if (typeof translation === "object" && translation !== null) {
|
|
728
|
-
await nitro.storage.setItem(storageKey, translation);
|
|
729
|
-
if (options.debug) {
|
|
730
|
-
logger.log(`[nuxt-i18n-micro] Translation saved to Nitro storage with key: ${storageKey}`);
|
|
731
|
-
}
|
|
732
|
-
}
|
|
733
|
-
})();
|
|
734
|
-
savePromises.push(promise);
|
|
735
|
-
}
|
|
736
|
-
}
|
|
737
|
-
await Promise.all(savePromises);
|
|
738
|
-
} catch (err) {
|
|
739
|
-
logger.error("[nuxt-i18n-micro] Error processing translations:", err);
|
|
740
|
-
}
|
|
741
|
-
});
|
|
742
646
|
if (!options.disableUpdater) {
|
|
743
647
|
nuxt.hook("nitro:build:before", async (_nitro) => {
|
|
744
648
|
const isProd = nuxt.options.dev === false;
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
</template>
|
|
20
20
|
|
|
21
21
|
<script lang="ts" setup>
|
|
22
|
-
import type {
|
|
22
|
+
import type { RouteLocationNamedRaw, RouteLocationResolvedGeneric } from 'vue-router'
|
|
23
23
|
import { useNuxtApp, computed, useRoute, useRouter } from '#imports'
|
|
24
24
|
|
|
25
25
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
@@ -27,7 +27,7 @@ import { useNuxtApp, computed, useRoute, useRouter } from '#imports'
|
|
|
27
27
|
const { $localeRoute } = useNuxtApp()
|
|
28
28
|
|
|
29
29
|
interface Props {
|
|
30
|
-
to:
|
|
30
|
+
to: RouteLocationNamedRaw | RouteLocationResolvedGeneric | string
|
|
31
31
|
activeStyle?: Partial<CSSStyleValue>
|
|
32
32
|
}
|
|
33
33
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { RouteLocationNormalizedLoaded, RouteLocationRaw, RouteLocationResolved, RouteLocationResolvedGeneric, RouteLocationNamedRaw } from 'vue-router';
|
|
2
2
|
import type { Locale, I18nRouteParams, Params, Translation, Translations } from 'nuxt-i18n-micro-types';
|
|
3
3
|
declare const _default: import("nuxt/app").Plugin<{
|
|
4
4
|
i18n: undefined;
|
|
@@ -20,9 +20,9 @@ declare const _default: import("nuxt/app").Plugin<{
|
|
|
20
20
|
switchLocaleRoute: (toLocale: string) => string | import("vue-router").RouteLocationAsRelativeGeneric | import("vue-router").RouteLocationAsPathGeneric;
|
|
21
21
|
switchLocalePath: (toLocale: string) => string;
|
|
22
22
|
switchLocale: (toLocale: string) => string | false | void | import("vue-router").RouteLocationAsRelativeGeneric | import("vue-router").RouteLocationAsPathGeneric | Promise<false | void | import("vue-router").NavigationFailure>;
|
|
23
|
-
switchRoute: (route:
|
|
24
|
-
localeRoute: (to:
|
|
25
|
-
localePath: (to:
|
|
23
|
+
switchRoute: (route: RouteLocationNamedRaw | RouteLocationResolvedGeneric | string, toLocale?: string) => string | false | void | import("vue-router").RouteLocationAsRelativeGeneric | import("vue-router").RouteLocationAsPathGeneric | Promise<false | void | import("vue-router").NavigationFailure>;
|
|
24
|
+
localeRoute: (to: RouteLocationNamedRaw | RouteLocationResolvedGeneric | string, locale?: string) => RouteLocationResolved;
|
|
25
|
+
localePath: (to: RouteLocationNamedRaw | RouteLocationResolvedGeneric | string, locale?: string) => string;
|
|
26
26
|
setI18nRouteParams: (value: I18nRouteParams) => I18nRouteParams;
|
|
27
27
|
}> & import("nuxt/app").ObjectPlugin<{
|
|
28
28
|
i18n: undefined;
|
|
@@ -44,9 +44,9 @@ declare const _default: import("nuxt/app").Plugin<{
|
|
|
44
44
|
switchLocaleRoute: (toLocale: string) => string | import("vue-router").RouteLocationAsRelativeGeneric | import("vue-router").RouteLocationAsPathGeneric;
|
|
45
45
|
switchLocalePath: (toLocale: string) => string;
|
|
46
46
|
switchLocale: (toLocale: string) => string | false | void | import("vue-router").RouteLocationAsRelativeGeneric | import("vue-router").RouteLocationAsPathGeneric | Promise<false | void | import("vue-router").NavigationFailure>;
|
|
47
|
-
switchRoute: (route:
|
|
48
|
-
localeRoute: (to:
|
|
49
|
-
localePath: (to:
|
|
47
|
+
switchRoute: (route: RouteLocationNamedRaw | RouteLocationResolvedGeneric | string, toLocale?: string) => string | false | void | import("vue-router").RouteLocationAsRelativeGeneric | import("vue-router").RouteLocationAsPathGeneric | Promise<false | void | import("vue-router").NavigationFailure>;
|
|
48
|
+
localeRoute: (to: RouteLocationNamedRaw | RouteLocationResolvedGeneric | string, locale?: string) => RouteLocationResolved;
|
|
49
|
+
localePath: (to: RouteLocationNamedRaw | RouteLocationResolvedGeneric | string, locale?: string) => string;
|
|
50
50
|
setI18nRouteParams: (value: I18nRouteParams) => I18nRouteParams;
|
|
51
51
|
}>;
|
|
52
52
|
export default _default;
|
|
@@ -55,7 +55,7 @@ export interface PluginsInjections {
|
|
|
55
55
|
$getLocaleName: () => string | null;
|
|
56
56
|
$getLocales: () => Locale[];
|
|
57
57
|
$defaultLocale: () => string | undefined;
|
|
58
|
-
$getRouteName: (route?:
|
|
58
|
+
$getRouteName: (route?: RouteLocationNamedRaw | RouteLocationResolvedGeneric, locale?: string) => string;
|
|
59
59
|
$t: (key: string, params?: Params, defaultValue?: string | null) => Translation;
|
|
60
60
|
$ts: (key: string, params?: Params, defaultValue?: string) => string;
|
|
61
61
|
$tc: (key: string, params: number | Params, defaultValue?: string) => string;
|
|
@@ -68,8 +68,8 @@ export interface PluginsInjections {
|
|
|
68
68
|
$switchLocaleRoute: (locale: string) => RouteLocationRaw;
|
|
69
69
|
$switchLocalePath: (locale: string) => string;
|
|
70
70
|
$switchLocale: (locale: string) => void;
|
|
71
|
-
$switchRoute: (route:
|
|
72
|
-
$localeRoute: (to:
|
|
73
|
-
$localePath: (to:
|
|
71
|
+
$switchRoute: (route: RouteLocationNamedRaw | RouteLocationResolvedGeneric | string, toLocale?: string) => void;
|
|
72
|
+
$localeRoute: (to: RouteLocationNamedRaw | RouteLocationResolvedGeneric | string, locale?: string) => RouteLocationResolved;
|
|
73
|
+
$localePath: (to: RouteLocationNamedRaw | RouteLocationResolvedGeneric | string, locale?: string) => string;
|
|
74
74
|
$setI18nRouteParams: (value: I18nRouteParams) => I18nRouteParams;
|
|
75
75
|
}
|
|
@@ -1,18 +1,61 @@
|
|
|
1
|
+
import { resolve, join } from "node:path";
|
|
2
|
+
import { readFile } from "node:fs/promises";
|
|
1
3
|
import { defineEventHandler } from "h3";
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
4
|
+
import { useRuntimeConfig, createError, useStorage } from "#imports";
|
|
5
|
+
let storageInit = false;
|
|
6
|
+
function deepMerge(target, source) {
|
|
7
|
+
for (const key in source) {
|
|
8
|
+
if (key === "__proto__" || key === "constructor") continue;
|
|
9
|
+
if (Array.isArray(source[key])) {
|
|
10
|
+
target[key] = source[key];
|
|
11
|
+
} else if (source[key] instanceof Object) {
|
|
12
|
+
target[key] = target[key] instanceof Object ? deepMerge(target[key], source[key]) : source[key];
|
|
13
|
+
} else {
|
|
14
|
+
target[key] = source[key];
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
return target;
|
|
18
|
+
}
|
|
5
19
|
export default defineEventHandler(async (event) => {
|
|
6
20
|
const { page, locale } = event.context.params;
|
|
7
21
|
const config = useRuntimeConfig();
|
|
8
|
-
const {
|
|
22
|
+
const { rootDirs, debug } = config.i18nConfig;
|
|
23
|
+
const { translationDir, fallbackLocale, customRegexMatcher, locales } = config.public.i18nConfig;
|
|
9
24
|
if (customRegexMatcher && locales && !locales.map((l) => l.code).includes(locale)) {
|
|
10
25
|
throw createError({ statusCode: 404 });
|
|
11
26
|
}
|
|
12
|
-
const
|
|
13
|
-
|
|
14
|
-
|
|
27
|
+
const getTranslationPath = (locale2, page2) => page2 === "general" ? `${locale2}.json` : `pages/${page2}/${locale2}.json`;
|
|
28
|
+
let translations = {};
|
|
29
|
+
const serverStorage = useStorage("assets:server");
|
|
30
|
+
if (!storageInit) {
|
|
31
|
+
if (debug) console.log("[nuxt-i18n-micro] clear storage cache");
|
|
32
|
+
await Promise.all((await serverStorage.getKeys()).map((key) => serverStorage.removeItem(key)));
|
|
33
|
+
storageInit = true;
|
|
34
|
+
}
|
|
35
|
+
const cacheName = join("_locales", getTranslationPath(locale, page));
|
|
36
|
+
const isThereAsset = await serverStorage.hasItem(cacheName);
|
|
37
|
+
if (isThereAsset) {
|
|
38
|
+
const rawContent = await serverStorage.getItem(cacheName) ?? {};
|
|
15
39
|
return typeof rawContent === "string" ? JSON.parse(rawContent) : rawContent;
|
|
16
40
|
}
|
|
17
|
-
|
|
41
|
+
const createPaths = (locale2) => rootDirs.map((dir) => ({
|
|
42
|
+
translationPath: resolve(dir, translationDir, getTranslationPath(locale2, page)),
|
|
43
|
+
name: `_locales/${getTranslationPath(locale2, page)}`
|
|
44
|
+
}));
|
|
45
|
+
const paths = [
|
|
46
|
+
...fallbackLocale && fallbackLocale !== locale ? createPaths(fallbackLocale) : [],
|
|
47
|
+
...createPaths(locale)
|
|
48
|
+
];
|
|
49
|
+
for (const { translationPath, name } of paths) {
|
|
50
|
+
try {
|
|
51
|
+
if (debug) console.log("[nuxt-i18n-micro] load locale", translationPath, name);
|
|
52
|
+
const content = await readFile(translationPath, "utf-8");
|
|
53
|
+
const fileContent = JSON.parse(content);
|
|
54
|
+
translations = deepMerge(translations, fileContent);
|
|
55
|
+
} catch (e) {
|
|
56
|
+
if (debug) console.error("[nuxt-i18n-micro] load locale error", e);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
await serverStorage.setItem(cacheName, translations);
|
|
60
|
+
return translations;
|
|
18
61
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nuxt-i18n-micro",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.69.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",
|
|
@@ -53,7 +53,7 @@
|
|
|
53
53
|
"globby": "^14.0.2",
|
|
54
54
|
"sirv": "^2.0.4",
|
|
55
55
|
"ufo": "^1.5.4",
|
|
56
|
-
"nuxt-i18n-micro-core": "1.0.
|
|
56
|
+
"nuxt-i18n-micro-core": "1.0.15",
|
|
57
57
|
"nuxt-i18n-micro-test-utils": "1.0.6",
|
|
58
58
|
"nuxt-i18n-micro-types": "1.0.0"
|
|
59
59
|
},
|
|
@@ -73,7 +73,7 @@
|
|
|
73
73
|
"nuxt": "^3.15.2",
|
|
74
74
|
"ts-jest": "^29.2.5",
|
|
75
75
|
"typescript": "5.6.3",
|
|
76
|
-
"vitepress": "^1.
|
|
76
|
+
"vitepress": "^1.6.1",
|
|
77
77
|
"vitest": "^3.0.2",
|
|
78
78
|
"vue-tsc": "2.1.10"
|
|
79
79
|
},
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"id":"a0710ba7-e099-433f-942a-33090226304f","timestamp":1737386227680,"matcher":{"static":{},"wildcard":{},"dynamic":{}},"prerendered":[]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
.spotlight[data-v-f1dedcb8]{background:linear-gradient(45deg,#00dc82,#36e4da 50%,#0047e1);bottom:-30vh;filter:blur(20vh);height:40vh}.gradient-border[data-v-f1dedcb8]{-webkit-backdrop-filter:blur(10px);backdrop-filter:blur(10px);border-radius:.5rem;position:relative}@media (prefers-color-scheme:light){.gradient-border[data-v-f1dedcb8]{background-color:#ffffff4d}.gradient-border[data-v-f1dedcb8]:before{background:linear-gradient(90deg,#e2e2e2,#e2e2e2 25%,#00dc82,#36e4da 75%,#0047e1)}}@media (prefers-color-scheme:dark){.gradient-border[data-v-f1dedcb8]{background-color:#1414144d}.gradient-border[data-v-f1dedcb8]:before{background:linear-gradient(90deg,#303030,#303030 25%,#00dc82,#36e4da 75%,#0047e1)}}.gradient-border[data-v-f1dedcb8]: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-f1dedcb8]:hover:before{background-position:-50% 0;opacity:1}.fixed[data-v-f1dedcb8]{position:fixed}.left-0[data-v-f1dedcb8]{left:0}.right-0[data-v-f1dedcb8]{right:0}.z-10[data-v-f1dedcb8]{z-index:10}.z-20[data-v-f1dedcb8]{z-index:20}.grid[data-v-f1dedcb8]{display:grid}.mb-16[data-v-f1dedcb8]{margin-bottom:4rem}.mb-8[data-v-f1dedcb8]{margin-bottom:2rem}.max-w-520px[data-v-f1dedcb8]{max-width:520px}.min-h-screen[data-v-f1dedcb8]{min-height:100vh}.w-full[data-v-f1dedcb8]{width:100%}.flex[data-v-f1dedcb8]{display:flex}.cursor-pointer[data-v-f1dedcb8]{cursor:pointer}.place-content-center[data-v-f1dedcb8]{place-content:center}.items-center[data-v-f1dedcb8]{align-items:center}.justify-center[data-v-f1dedcb8]{justify-content:center}.overflow-hidden[data-v-f1dedcb8]{overflow:hidden}.bg-white[data-v-f1dedcb8]{--un-bg-opacity:1;background-color:rgb(255 255 255/var(--un-bg-opacity))}.px-4[data-v-f1dedcb8]{padding-left:1rem;padding-right:1rem}.px-8[data-v-f1dedcb8]{padding-left:2rem;padding-right:2rem}.py-2[data-v-f1dedcb8]{padding-bottom:.5rem;padding-top:.5rem}.text-center[data-v-f1dedcb8]{text-align:center}.text-8xl[data-v-f1dedcb8]{font-size:6rem;line-height:1}.text-xl[data-v-f1dedcb8]{font-size:1.25rem;line-height:1.75rem}.text-black[data-v-f1dedcb8]{--un-text-opacity:1;color:rgb(0 0 0/var(--un-text-opacity))}.font-light[data-v-f1dedcb8]{font-weight:300}.font-medium[data-v-f1dedcb8]{font-weight:500}.leading-tight[data-v-f1dedcb8]{line-height:1.25}.font-sans[data-v-f1dedcb8]{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-f1dedcb8]{-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}@media (prefers-color-scheme:dark){.dark\:bg-black[data-v-f1dedcb8]{--un-bg-opacity:1;background-color:rgb(0 0 0/var(--un-bg-opacity))}.dark\:text-white[data-v-f1dedcb8]{--un-text-opacity:1;color:rgb(255 255 255/var(--un-text-opacity))}}@media (min-width:640px){.sm\:px-0[data-v-f1dedcb8]{padding-left:0;padding-right:0}.sm\:px-6[data-v-f1dedcb8]{padding-left:1.5rem;padding-right:1.5rem}.sm\:py-3[data-v-f1dedcb8]{padding-bottom:.75rem;padding-top:.75rem}.sm\:text-4xl[data-v-f1dedcb8]{font-size:2.25rem;line-height:2.5rem}.sm\:text-xl[data-v-f1dedcb8]{font-size:1.25rem;line-height:1.75rem}}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
.spotlight[data-v-0d3db116]{background:linear-gradient(45deg,#00dc82,#36e4da 50%,#0047e1);filter:blur(20vh)}.fixed[data-v-0d3db116]{position:fixed}.-bottom-1\/2[data-v-0d3db116]{bottom:-50%}.left-0[data-v-0d3db116]{left:0}.right-0[data-v-0d3db116]{right:0}.grid[data-v-0d3db116]{display:grid}.mb-16[data-v-0d3db116]{margin-bottom:4rem}.mb-8[data-v-0d3db116]{margin-bottom:2rem}.h-1\/2[data-v-0d3db116]{height:50%}.max-w-520px[data-v-0d3db116]{max-width:520px}.min-h-screen[data-v-0d3db116]{min-height:100vh}.place-content-center[data-v-0d3db116]{place-content:center}.overflow-hidden[data-v-0d3db116]{overflow:hidden}.bg-white[data-v-0d3db116]{--un-bg-opacity:1;background-color:rgb(255 255 255/var(--un-bg-opacity))}.px-8[data-v-0d3db116]{padding-left:2rem;padding-right:2rem}.text-center[data-v-0d3db116]{text-align:center}.text-8xl[data-v-0d3db116]{font-size:6rem;line-height:1}.text-xl[data-v-0d3db116]{font-size:1.25rem;line-height:1.75rem}.text-black[data-v-0d3db116]{--un-text-opacity:1;color:rgb(0 0 0/var(--un-text-opacity))}.font-light[data-v-0d3db116]{font-weight:300}.font-medium[data-v-0d3db116]{font-weight:500}.leading-tight[data-v-0d3db116]{line-height:1.25}.font-sans[data-v-0d3db116]{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-0d3db116]{-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}@media (prefers-color-scheme:dark){.dark\:bg-black[data-v-0d3db116]{--un-bg-opacity:1;background-color:rgb(0 0 0/var(--un-bg-opacity))}.dark\:text-white[data-v-0d3db116]{--un-text-opacity:1;color:rgb(255 255 255/var(--un-text-opacity))}}@media (min-width:640px){.sm\:px-0[data-v-0d3db116]{padding-left:0;padding-right:0}.sm\:text-4xl[data-v-0d3db116]{font-size:2.25rem;line-height:2.5rem}}
|