nuxt-i18n-micro 3.12.0 → 3.13.1
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 +1 -1
- package/dist/client/404.html +1 -1
- package/dist/client/_nuxt/builds/latest.json +1 -1
- package/dist/client/_nuxt/builds/meta/de63387b-c983-467c-bbe3-fc436e608ff1.json +1 -0
- package/dist/client/index.html +1 -1
- package/dist/module.json +1 -1
- package/dist/module.mjs +3 -2
- package/dist/runtime/components/i18n-link.vue +5 -1
- package/dist/runtime/plugins/01.plugin.js +15 -11
- package/dist/runtime/plugins/05.hooks.js +2 -4
- package/dist/runtime/server/plugins/watcher.dev.js +25 -10
- package/dist/runtime/server/utils/server-loader.js +2 -1
- package/dist/runtime/utils/storage.js +1 -1
- package/package.json +4 -4
- package/dist/client/_nuxt/builds/meta/a43dcaa8-fe6b-46e4-b79a-c41b8cf3ab28.json +0 -1
package/dist/client/200.html
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
<!DOCTYPE html><html><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1"><link rel="stylesheet" href="/__NUXT_DEVTOOLS_I18N_BASE__/_nuxt/entry.Kj_DYE7z.css" crossorigin><link rel="modulepreload" as="script" crossorigin href="/__NUXT_DEVTOOLS_I18N_BASE__/_nuxt/D_aXYej0.js"><script type="module" src="/__NUXT_DEVTOOLS_I18N_BASE__/_nuxt/D_aXYej0.js" crossorigin></script><link rel="prefetch" as="style" crossorigin href="/__NUXT_DEVTOOLS_I18N_BASE__/_nuxt/error-404.CyBDSRXN.css"><link rel="prefetch" as="script" crossorigin href="/__NUXT_DEVTOOLS_I18N_BASE__/_nuxt/Brscz0ku.js"><link rel="prefetch" as="script" crossorigin href="/__NUXT_DEVTOOLS_I18N_BASE__/_nuxt/Dt5GiM1K.js"><link rel="prefetch" as="style" crossorigin href="/__NUXT_DEVTOOLS_I18N_BASE__/_nuxt/error-500.DJtCwW7w.css"><link rel="prefetch" as="script" crossorigin href="/__NUXT_DEVTOOLS_I18N_BASE__/_nuxt/CXlkzKTu.js"></head><body><div id="__nuxt"></div><div id="teleports"></div><script>window.__NUXT__={};window.__NUXT__.config={public:{},app:{baseURL:"/__NUXT_DEVTOOLS_I18N_BASE__/",buildId:"
|
|
1
|
+
<!DOCTYPE html><html><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1"><link rel="stylesheet" href="/__NUXT_DEVTOOLS_I18N_BASE__/_nuxt/entry.Kj_DYE7z.css" crossorigin><link rel="modulepreload" as="script" crossorigin href="/__NUXT_DEVTOOLS_I18N_BASE__/_nuxt/D_aXYej0.js"><script type="module" src="/__NUXT_DEVTOOLS_I18N_BASE__/_nuxt/D_aXYej0.js" crossorigin></script><link rel="prefetch" as="style" crossorigin href="/__NUXT_DEVTOOLS_I18N_BASE__/_nuxt/error-404.CyBDSRXN.css"><link rel="prefetch" as="script" crossorigin href="/__NUXT_DEVTOOLS_I18N_BASE__/_nuxt/Brscz0ku.js"><link rel="prefetch" as="script" crossorigin href="/__NUXT_DEVTOOLS_I18N_BASE__/_nuxt/Dt5GiM1K.js"><link rel="prefetch" as="style" crossorigin href="/__NUXT_DEVTOOLS_I18N_BASE__/_nuxt/error-500.DJtCwW7w.css"><link rel="prefetch" as="script" crossorigin href="/__NUXT_DEVTOOLS_I18N_BASE__/_nuxt/CXlkzKTu.js"></head><body><div id="__nuxt"></div><div id="teleports"></div><script>window.__NUXT__={};window.__NUXT__.config={public:{},app:{baseURL:"/__NUXT_DEVTOOLS_I18N_BASE__/",buildId:"de63387b-c983-467c-bbe3-fc436e608ff1",buildAssetsDir:"/_nuxt/",cdnURL:""}}</script><script type="application/json" data-nuxt-data="nuxt-app" data-ssr="false" id="__NUXT_DATA__">[{"prerenderedAt":1,"serverRendered":2},1772269229940,false]</script></body></html>
|
package/dist/client/404.html
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
<!DOCTYPE html><html><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1"><link rel="stylesheet" href="/__NUXT_DEVTOOLS_I18N_BASE__/_nuxt/entry.Kj_DYE7z.css" crossorigin><link rel="modulepreload" as="script" crossorigin href="/__NUXT_DEVTOOLS_I18N_BASE__/_nuxt/D_aXYej0.js"><script type="module" src="/__NUXT_DEVTOOLS_I18N_BASE__/_nuxt/D_aXYej0.js" crossorigin></script><link rel="prefetch" as="style" crossorigin href="/__NUXT_DEVTOOLS_I18N_BASE__/_nuxt/error-404.CyBDSRXN.css"><link rel="prefetch" as="script" crossorigin href="/__NUXT_DEVTOOLS_I18N_BASE__/_nuxt/Brscz0ku.js"><link rel="prefetch" as="script" crossorigin href="/__NUXT_DEVTOOLS_I18N_BASE__/_nuxt/Dt5GiM1K.js"><link rel="prefetch" as="style" crossorigin href="/__NUXT_DEVTOOLS_I18N_BASE__/_nuxt/error-500.DJtCwW7w.css"><link rel="prefetch" as="script" crossorigin href="/__NUXT_DEVTOOLS_I18N_BASE__/_nuxt/CXlkzKTu.js"></head><body><div id="__nuxt"></div><div id="teleports"></div><script>window.__NUXT__={};window.__NUXT__.config={public:{},app:{baseURL:"/__NUXT_DEVTOOLS_I18N_BASE__/",buildId:"
|
|
1
|
+
<!DOCTYPE html><html><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1"><link rel="stylesheet" href="/__NUXT_DEVTOOLS_I18N_BASE__/_nuxt/entry.Kj_DYE7z.css" crossorigin><link rel="modulepreload" as="script" crossorigin href="/__NUXT_DEVTOOLS_I18N_BASE__/_nuxt/D_aXYej0.js"><script type="module" src="/__NUXT_DEVTOOLS_I18N_BASE__/_nuxt/D_aXYej0.js" crossorigin></script><link rel="prefetch" as="style" crossorigin href="/__NUXT_DEVTOOLS_I18N_BASE__/_nuxt/error-404.CyBDSRXN.css"><link rel="prefetch" as="script" crossorigin href="/__NUXT_DEVTOOLS_I18N_BASE__/_nuxt/Brscz0ku.js"><link rel="prefetch" as="script" crossorigin href="/__NUXT_DEVTOOLS_I18N_BASE__/_nuxt/Dt5GiM1K.js"><link rel="prefetch" as="style" crossorigin href="/__NUXT_DEVTOOLS_I18N_BASE__/_nuxt/error-500.DJtCwW7w.css"><link rel="prefetch" as="script" crossorigin href="/__NUXT_DEVTOOLS_I18N_BASE__/_nuxt/CXlkzKTu.js"></head><body><div id="__nuxt"></div><div id="teleports"></div><script>window.__NUXT__={};window.__NUXT__.config={public:{},app:{baseURL:"/__NUXT_DEVTOOLS_I18N_BASE__/",buildId:"de63387b-c983-467c-bbe3-fc436e608ff1",buildAssetsDir:"/_nuxt/",cdnURL:""}}</script><script type="application/json" data-nuxt-data="nuxt-app" data-ssr="false" id="__NUXT_DATA__">[{"prerenderedAt":1,"serverRendered":2},1772269229941,false]</script></body></html>
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"id":"
|
|
1
|
+
{"id":"de63387b-c983-467c-bbe3-fc436e608ff1","timestamp":1772269226925}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"id":"de63387b-c983-467c-bbe3-fc436e608ff1","timestamp":1772269226925,"matcher":{"static":{},"wildcard":{},"dynamic":{}},"prerendered":[]}
|
package/dist/client/index.html
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
<!DOCTYPE html><html><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1"><link rel="stylesheet" href="/__NUXT_DEVTOOLS_I18N_BASE__/_nuxt/entry.Kj_DYE7z.css" crossorigin><link rel="modulepreload" as="script" crossorigin href="/__NUXT_DEVTOOLS_I18N_BASE__/_nuxt/D_aXYej0.js"><script type="module" src="/__NUXT_DEVTOOLS_I18N_BASE__/_nuxt/D_aXYej0.js" crossorigin></script><link rel="prefetch" as="style" crossorigin href="/__NUXT_DEVTOOLS_I18N_BASE__/_nuxt/error-404.CyBDSRXN.css"><link rel="prefetch" as="script" crossorigin href="/__NUXT_DEVTOOLS_I18N_BASE__/_nuxt/Brscz0ku.js"><link rel="prefetch" as="script" crossorigin href="/__NUXT_DEVTOOLS_I18N_BASE__/_nuxt/Dt5GiM1K.js"><link rel="prefetch" as="style" crossorigin href="/__NUXT_DEVTOOLS_I18N_BASE__/_nuxt/error-500.DJtCwW7w.css"><link rel="prefetch" as="script" crossorigin href="/__NUXT_DEVTOOLS_I18N_BASE__/_nuxt/CXlkzKTu.js"></head><body><div id="__nuxt"></div><div id="teleports"></div><script>window.__NUXT__={};window.__NUXT__.config={public:{},app:{baseURL:"/__NUXT_DEVTOOLS_I18N_BASE__/",buildId:"
|
|
1
|
+
<!DOCTYPE html><html><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1"><link rel="stylesheet" href="/__NUXT_DEVTOOLS_I18N_BASE__/_nuxt/entry.Kj_DYE7z.css" crossorigin><link rel="modulepreload" as="script" crossorigin href="/__NUXT_DEVTOOLS_I18N_BASE__/_nuxt/D_aXYej0.js"><script type="module" src="/__NUXT_DEVTOOLS_I18N_BASE__/_nuxt/D_aXYej0.js" crossorigin></script><link rel="prefetch" as="style" crossorigin href="/__NUXT_DEVTOOLS_I18N_BASE__/_nuxt/error-404.CyBDSRXN.css"><link rel="prefetch" as="script" crossorigin href="/__NUXT_DEVTOOLS_I18N_BASE__/_nuxt/Brscz0ku.js"><link rel="prefetch" as="script" crossorigin href="/__NUXT_DEVTOOLS_I18N_BASE__/_nuxt/Dt5GiM1K.js"><link rel="prefetch" as="style" crossorigin href="/__NUXT_DEVTOOLS_I18N_BASE__/_nuxt/error-500.DJtCwW7w.css"><link rel="prefetch" as="script" crossorigin href="/__NUXT_DEVTOOLS_I18N_BASE__/_nuxt/CXlkzKTu.js"></head><body><div id="__nuxt"></div><div id="teleports"></div><script>window.__NUXT__={};window.__NUXT__.config={public:{},app:{baseURL:"/__NUXT_DEVTOOLS_I18N_BASE__/",buildId:"de63387b-c983-467c-bbe3-fc436e608ff1",buildAssetsDir:"/_nuxt/",cdnURL:""}}</script><script type="application/json" data-nuxt-data="nuxt-app" data-ssr="false" id="__NUXT_DATA__">[{"prerenderedAt":1,"serverRendered":2},1772269229941,false]</script></body></html>
|
package/dist/module.json
CHANGED
package/dist/module.mjs
CHANGED
|
@@ -124,7 +124,7 @@ function generateHmrPlugin(files) {
|
|
|
124
124
|
let pageName = "";
|
|
125
125
|
let locale = "";
|
|
126
126
|
if (isPage) {
|
|
127
|
-
const m = /\/pages\/(
|
|
127
|
+
const m = /\/pages\/(.+)\/([^/]+)\.json$/.exec(file);
|
|
128
128
|
pageName = m?.[1] || "";
|
|
129
129
|
locale = m?.[2] || "";
|
|
130
130
|
} else {
|
|
@@ -525,7 +525,7 @@ const module = defineNuxtModule({
|
|
|
525
525
|
if (rawUrl.startsWith("http://") || rawUrl.startsWith("https://")) {
|
|
526
526
|
throw new Error("Nuxt-i18n-micro: Please use NUXT_I18N_APP_BASE_CLIENT_HOST or NUXT_I18N_APP_BASE_SERVER_HOST instead.");
|
|
527
527
|
}
|
|
528
|
-
const apiBaseUrl = rawUrl.replace(
|
|
528
|
+
const apiBaseUrl = rawUrl.replace(/^\/+|\/+$/g, "").replace(/\/{2,}/g, "/");
|
|
529
529
|
const fullConfig = {
|
|
530
530
|
locales: routeGenerator.locales ?? [],
|
|
531
531
|
metaBaseUrl: options.metaBaseUrl || void 0,
|
|
@@ -617,6 +617,7 @@ export function createI18nStrategy(router) {
|
|
|
617
617
|
const privateConfig = {
|
|
618
618
|
rootDir: nuxt.options.rootDir,
|
|
619
619
|
debug: options.debug ?? false,
|
|
620
|
+
locales: routeGenerator.locales ?? [],
|
|
620
621
|
fallbackLocale: options.fallbackLocale ?? void 0,
|
|
621
622
|
translationDir: options.translationDir ?? "locales",
|
|
622
623
|
customRegexMatcher: options.customRegexMatcher instanceof RegExp ? options.customRegexMatcher.source : options.customRegexMatcher,
|
|
@@ -27,6 +27,7 @@ const props = defineProps({
|
|
|
27
27
|
activeStyle: { type: Object, required: false }
|
|
28
28
|
});
|
|
29
29
|
const route = useRoute();
|
|
30
|
+
const router = useRouter();
|
|
30
31
|
const isExternalLink = computed(() => {
|
|
31
32
|
if (typeof props.to === "string") {
|
|
32
33
|
return /^(?:https?:\/\/|\/\/|[a-zA-Z0-9-]+\.[a-zA-Z]{2,})|tel:|mailto:/.test(props.to);
|
|
@@ -35,6 +36,9 @@ const isExternalLink = computed(() => {
|
|
|
35
36
|
});
|
|
36
37
|
const externalHref = computed(() => {
|
|
37
38
|
if (isExternalLink.value && typeof props.to === "string") {
|
|
39
|
+
if (props.to.startsWith("//")) {
|
|
40
|
+
return props.to;
|
|
41
|
+
}
|
|
38
42
|
if (!/^https?:\/\//.test(props.to)) {
|
|
39
43
|
return `https://${props.to}`;
|
|
40
44
|
}
|
|
@@ -47,7 +51,7 @@ const isActive = computed(() => {
|
|
|
47
51
|
return false;
|
|
48
52
|
}
|
|
49
53
|
const pathStr = $localePath(props.to);
|
|
50
|
-
return route.path ===
|
|
54
|
+
return route.path === router.resolve(pathStr).path;
|
|
51
55
|
});
|
|
52
56
|
const computedStyle = computed(() => {
|
|
53
57
|
return isActive.value ? { ...props.activeStyle } : {};
|
|
@@ -152,20 +152,20 @@ export default defineNuxtPlugin(async (nuxtApp) => {
|
|
|
152
152
|
const ctx = nuxtApp.ssrContext?.event.context;
|
|
153
153
|
if (ctx?._i18n && Object.keys(ctx._i18n).length > 0) {
|
|
154
154
|
let script = "window.__I18N__={};";
|
|
155
|
-
for (const [
|
|
156
|
-
|
|
155
|
+
for (const [key, value] of Object.entries(ctx._i18n)) {
|
|
156
|
+
const safeKey = JSON.stringify(key);
|
|
157
|
+
script += `window.__I18N__[${safeKey}]=${value};`;
|
|
157
158
|
}
|
|
158
159
|
useHead({
|
|
159
160
|
script: [{ innerHTML: script, type: "text/javascript", tagPosition: "bodyClose" }]
|
|
160
161
|
});
|
|
161
162
|
}
|
|
162
163
|
}
|
|
163
|
-
router.beforeEach(async (to, from
|
|
164
|
+
router.beforeEach(async (to, from) => {
|
|
164
165
|
if (to.name !== from.name) {
|
|
165
166
|
i18nRouteParams.value = {};
|
|
166
167
|
}
|
|
167
168
|
if (to.path === from.path && !isNoPrefixStrategy(i18nConfig.strategy)) {
|
|
168
|
-
if (next) next();
|
|
169
169
|
return;
|
|
170
170
|
}
|
|
171
171
|
try {
|
|
@@ -180,7 +180,7 @@ export default defineNuxtPlugin(async (nuxtApp) => {
|
|
|
180
180
|
} catch (e) {
|
|
181
181
|
if (isDev) console.error("[i18n] Navigation error:", e);
|
|
182
182
|
}
|
|
183
|
-
|
|
183
|
+
return;
|
|
184
184
|
});
|
|
185
185
|
const tFast = (key, params, defaultValue, route) => {
|
|
186
186
|
if (!key) return "";
|
|
@@ -315,13 +315,17 @@ export default defineNuxtPlugin(async (nuxtApp) => {
|
|
|
315
315
|
return "";
|
|
316
316
|
},
|
|
317
317
|
switchLocale: async (toLocale) => {
|
|
318
|
-
if (isValidLocale(toLocale)) {
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
const route = router.currentRoute.value;
|
|
322
|
-
const routeName = getPluginRouteName(route, toLocale);
|
|
323
|
-
await switchContext(toLocale, routeName);
|
|
318
|
+
if (!isValidLocale(toLocale)) {
|
|
319
|
+
if (isDev) {
|
|
320
|
+
console.warn(`[i18n] Invalid locale '${toLocale}'`);
|
|
324
321
|
}
|
|
322
|
+
return;
|
|
323
|
+
}
|
|
324
|
+
setLocale(toLocale);
|
|
325
|
+
if (isNoPrefixStrategy(i18nConfig.strategy) || i18nConfig.hashMode) {
|
|
326
|
+
const route = router.currentRoute.value;
|
|
327
|
+
const routeName = getPluginRouteName(route, toLocale);
|
|
328
|
+
await switchContext(toLocale, routeName);
|
|
325
329
|
}
|
|
326
330
|
return switchLocaleLogic(toLocale, unref(i18nRouteParams.value));
|
|
327
331
|
},
|
|
@@ -23,7 +23,7 @@ export default defineNuxtPlugin(async (nuxtApp) => {
|
|
|
23
23
|
},
|
|
24
24
|
locale
|
|
25
25
|
);
|
|
26
|
-
router.beforeEach(async (to, from
|
|
26
|
+
router.beforeEach(async (to, from) => {
|
|
27
27
|
if (to.path !== from.path || isNoPrefixStrategy(i18nConfig.strategy)) {
|
|
28
28
|
const locale2 = $getLocale(to);
|
|
29
29
|
const routeName2 = $getRouteName(to);
|
|
@@ -36,8 +36,6 @@ export default defineNuxtPlugin(async (nuxtApp) => {
|
|
|
36
36
|
locale2
|
|
37
37
|
);
|
|
38
38
|
}
|
|
39
|
-
|
|
40
|
-
next();
|
|
41
|
-
}
|
|
39
|
+
return;
|
|
42
40
|
});
|
|
43
41
|
});
|
|
@@ -3,6 +3,7 @@ import path from "node:path";
|
|
|
3
3
|
import { watch } from "chokidar";
|
|
4
4
|
import { defineNitroPlugin } from "nitropack/runtime";
|
|
5
5
|
import { getI18nPrivateConfig } from "#i18n-internal/config";
|
|
6
|
+
import { CacheControl } from "../../utils/cache-control.js";
|
|
6
7
|
const SERVER_CC_KEY = Symbol.for("__NUXT_I18N_SERVER_CACHE_CC__");
|
|
7
8
|
const STORAGE_CC_KEY = Symbol.for("__NUXT_I18N_STORAGE_CC__");
|
|
8
9
|
function getCacheByKey(key) {
|
|
@@ -16,6 +17,16 @@ function getCacheByKey(key) {
|
|
|
16
17
|
function getServerCache() {
|
|
17
18
|
return getCacheByKey(SERVER_CC_KEY);
|
|
18
19
|
}
|
|
20
|
+
function getOrCreateServerCache() {
|
|
21
|
+
const existing = getServerCache();
|
|
22
|
+
if (existing) {
|
|
23
|
+
return existing;
|
|
24
|
+
}
|
|
25
|
+
const g = globalThis;
|
|
26
|
+
const created = new CacheControl();
|
|
27
|
+
g[SERVER_CC_KEY] = created;
|
|
28
|
+
return created;
|
|
29
|
+
}
|
|
19
30
|
function getStorageCache() {
|
|
20
31
|
return getCacheByKey(STORAGE_CC_KEY);
|
|
21
32
|
}
|
|
@@ -57,6 +68,10 @@ export default defineNitroPlugin((nitroApp) => {
|
|
|
57
68
|
}
|
|
58
69
|
const log = (...args) => i18nConfig.debug && console.log("[i18n-hmr]", ...args);
|
|
59
70
|
const warn = (...args) => i18nConfig.debug && console.warn("[i18n-hmr]", ...args);
|
|
71
|
+
const rawLocales = i18nConfig.locales;
|
|
72
|
+
const configuredLocales = new Set(
|
|
73
|
+
(Array.isArray(rawLocales) ? rawLocales : []).map((l) => l.code).filter((code) => typeof code === "string" && code.length > 0)
|
|
74
|
+
);
|
|
60
75
|
const routesLocaleLinks = i18nConfig.routesLocaleLinks || {};
|
|
61
76
|
const translationsRoot = path.resolve(i18nConfig.rootDir, i18nConfig.translationDir);
|
|
62
77
|
log(`Watching for translation changes in: ${translationsRoot}`);
|
|
@@ -81,18 +96,14 @@ export default defineNitroPlugin((nitroApp) => {
|
|
|
81
96
|
log(`Re-merged and cached alias '${aliasKey}'`);
|
|
82
97
|
}
|
|
83
98
|
}
|
|
84
|
-
const invalidateAndRefresh = async (filePath) => {
|
|
99
|
+
const invalidateAndRefresh = async (filePath, event) => {
|
|
85
100
|
if (!filePath.endsWith(".json")) return;
|
|
86
101
|
const relativePath = path.relative(translationsRoot, filePath).replace(/\\/g, "/");
|
|
87
102
|
const isPageTranslation = relativePath.startsWith("pages/");
|
|
88
|
-
const serverCache =
|
|
89
|
-
if (!serverCache) {
|
|
90
|
-
log("Server cache not yet initialized, skipping invalidation for", relativePath);
|
|
91
|
-
return;
|
|
92
|
-
}
|
|
103
|
+
const serverCache = getOrCreateServerCache();
|
|
93
104
|
try {
|
|
94
105
|
if (isPageTranslation) {
|
|
95
|
-
const match = relativePath.match(/^pages\/([^/]+)
|
|
106
|
+
const match = relativePath.match(/^pages\/(.+)\/([^/]+)\.json$/);
|
|
96
107
|
if (!match || !match[1] || !match[2]) return;
|
|
97
108
|
const pageName = match[1];
|
|
98
109
|
const locale = match[2];
|
|
@@ -101,6 +112,10 @@ export default defineNitroPlugin((nitroApp) => {
|
|
|
101
112
|
const match = relativePath.match(/^([^/]+)\.json$/);
|
|
102
113
|
if (!match || !match[1]) return;
|
|
103
114
|
const locale = match[1];
|
|
115
|
+
if (!configuredLocales.has(locale)) {
|
|
116
|
+
warn(`Detected ${event} for '${relativePath}', but locale '${locale}' is not in i18n.locales. Update config and restart dev server.`);
|
|
117
|
+
return;
|
|
118
|
+
}
|
|
104
119
|
const pagesDir = path.join(translationsRoot, "pages");
|
|
105
120
|
if (existsSync(pagesDir)) {
|
|
106
121
|
const pageDirs = readdirSync(pagesDir, { withFileTypes: true }).filter((d) => d.isDirectory()).map((d) => d.name);
|
|
@@ -116,9 +131,9 @@ export default defineNitroPlugin((nitroApp) => {
|
|
|
116
131
|
}
|
|
117
132
|
};
|
|
118
133
|
const watcher = watch(translationsRoot, { persistent: true, ignoreInitial: true, depth: 5 });
|
|
119
|
-
watcher.on("add", invalidateAndRefresh);
|
|
120
|
-
watcher.on("change", invalidateAndRefresh);
|
|
121
|
-
watcher.on("unlink", invalidateAndRefresh);
|
|
134
|
+
watcher.on("add", (filePath) => invalidateAndRefresh(filePath, "add"));
|
|
135
|
+
watcher.on("change", (filePath) => invalidateAndRefresh(filePath, "change"));
|
|
136
|
+
watcher.on("unlink", (filePath) => invalidateAndRefresh(filePath, "unlink"));
|
|
122
137
|
watcherInstance = watcher;
|
|
123
138
|
nitroApp.hooks.hook("close", async () => {
|
|
124
139
|
if (watcherInstance) {
|
|
@@ -36,7 +36,8 @@ export async function loadTranslationsFromServer(locale, routeName) {
|
|
|
36
36
|
const resolvedPage = routesLocaleLinks[routeName] || routeName;
|
|
37
37
|
const normalizedPage = resolvedPage.replace(/\//g, ":");
|
|
38
38
|
const key = `${ASSETS_PREFIX}:pages:${normalizedPage}:${locale}.json`;
|
|
39
|
-
const
|
|
39
|
+
const loaded = await storage.getItem(key);
|
|
40
|
+
const data = toTranslations(loaded);
|
|
40
41
|
const json = JSON.stringify(data).replace(/</g, "\\u003c");
|
|
41
42
|
const entry = { data, json };
|
|
42
43
|
cc.set(cacheKey, entry);
|
|
@@ -51,7 +51,7 @@ class TranslationStorage {
|
|
|
51
51
|
}
|
|
52
52
|
if (import.meta.client && typeof window !== "undefined" && window.__I18N__?.[cacheKey]) {
|
|
53
53
|
const data = window.__I18N__[cacheKey];
|
|
54
|
-
window.__I18N__[cacheKey]
|
|
54
|
+
delete window.__I18N__[cacheKey];
|
|
55
55
|
this.cc.set(cacheKey, Object.freeze(data));
|
|
56
56
|
return { data: this.cc.get(cacheKey), cacheKey };
|
|
57
57
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nuxt-i18n-micro",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.13.1",
|
|
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",
|
|
@@ -74,11 +74,11 @@
|
|
|
74
74
|
"chokidar": "^3.6.0",
|
|
75
75
|
"globby": "^14.1.0",
|
|
76
76
|
"ufo": "^1.5.4",
|
|
77
|
-
"@i18n-micro/core": "1.2.0",
|
|
78
|
-
"@i18n-micro/path-strategy": "1.3.0",
|
|
79
77
|
"@i18n-micro/route-strategy": "1.1.4",
|
|
80
78
|
"@i18n-micro/test-utils": "1.2.0",
|
|
81
|
-
"@i18n-micro/types": "1.1.6"
|
|
79
|
+
"@i18n-micro/types": "1.1.6",
|
|
80
|
+
"@i18n-micro/core": "1.2.0",
|
|
81
|
+
"@i18n-micro/path-strategy": "1.3.0"
|
|
82
82
|
},
|
|
83
83
|
"devDependencies": {
|
|
84
84
|
"@biomejs/biome": "^2.3.14",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"id":"a43dcaa8-fe6b-46e4-b79a-c41b8cf3ab28","timestamp":1771487188542,"matcher":{"static":{},"wildcard":{},"dynamic":{}},"prerendered":[]}
|