nuxt-i18n-micro 1.25.5 → 1.26.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 +2 -2
- package/dist/client/404.html +2 -2
- package/dist/client/_nuxt/builds/latest.json +1 -1
- package/dist/client/_nuxt/builds/meta/6c8b64c3-676f-4bad-bc98-3c29fe70f766.json +1 -0
- package/dist/client/index.html +2 -2
- package/dist/module.d.mts +2 -0
- package/dist/module.d.ts +2 -0
- package/dist/module.json +1 -1
- package/dist/module.mjs +3 -1
- package/dist/runtime/server/middleware/i18n-loader.js +24 -7
- package/package.json +1 -1
- package/dist/client/_nuxt/builds/meta/bf81ecd1-1ffc-4e1d-8901-d9000a7c0fc9.json +0 -1
package/dist/client/200.html
CHANGED
|
@@ -8,5 +8,5 @@
|
|
|
8
8
|
<link rel="prefetch" as="script" crossorigin href="/__nuxt-i18n-micro/_nuxt/0GmYR_kR.js">
|
|
9
9
|
<link rel="prefetch" as="style" crossorigin href="/__nuxt-i18n-micro/_nuxt/error-500.CBAEdpZV.css">
|
|
10
10
|
<link rel="prefetch" as="script" crossorigin href="/__nuxt-i18n-micro/_nuxt/2C6ahHCU.js">
|
|
11
|
-
<script type="module" src="/__nuxt-i18n-micro/_nuxt/Czi4MokJ.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},
|
|
12
|
-
<script>window.__NUXT__={};window.__NUXT__.config={public:{},app:{baseURL:"/__nuxt-i18n-micro",buildId:"
|
|
11
|
+
<script type="module" src="/__nuxt-i18n-micro/_nuxt/Czi4MokJ.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},1729191460637,false]</script>
|
|
12
|
+
<script>window.__NUXT__={};window.__NUXT__.config={public:{},app:{baseURL:"/__nuxt-i18n-micro",buildId:"6c8b64c3-676f-4bad-bc98-3c29fe70f766",buildAssetsDir:"/_nuxt/",cdnURL:""}}</script></body></html>
|
package/dist/client/404.html
CHANGED
|
@@ -8,5 +8,5 @@
|
|
|
8
8
|
<link rel="prefetch" as="script" crossorigin href="/__nuxt-i18n-micro/_nuxt/0GmYR_kR.js">
|
|
9
9
|
<link rel="prefetch" as="style" crossorigin href="/__nuxt-i18n-micro/_nuxt/error-500.CBAEdpZV.css">
|
|
10
10
|
<link rel="prefetch" as="script" crossorigin href="/__nuxt-i18n-micro/_nuxt/2C6ahHCU.js">
|
|
11
|
-
<script type="module" src="/__nuxt-i18n-micro/_nuxt/Czi4MokJ.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},
|
|
12
|
-
<script>window.__NUXT__={};window.__NUXT__.config={public:{},app:{baseURL:"/__nuxt-i18n-micro",buildId:"
|
|
11
|
+
<script type="module" src="/__nuxt-i18n-micro/_nuxt/Czi4MokJ.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},1729191460638,false]</script>
|
|
12
|
+
<script>window.__NUXT__={};window.__NUXT__.config={public:{},app:{baseURL:"/__nuxt-i18n-micro",buildId:"6c8b64c3-676f-4bad-bc98-3c29fe70f766",buildAssetsDir:"/_nuxt/",cdnURL:""}}</script></body></html>
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"id":"
|
|
1
|
+
{"id":"6c8b64c3-676f-4bad-bc98-3c29fe70f766","timestamp":1729191450208}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"id":"6c8b64c3-676f-4bad-bc98-3c29fe70f766","timestamp":1729191450208,"matcher":{"static":{},"wildcard":{},"dynamic":{}},"prerendered":[]}
|
package/dist/client/index.html
CHANGED
|
@@ -8,5 +8,5 @@
|
|
|
8
8
|
<link rel="prefetch" as="script" crossorigin href="/__nuxt-i18n-micro/_nuxt/0GmYR_kR.js">
|
|
9
9
|
<link rel="prefetch" as="style" crossorigin href="/__nuxt-i18n-micro/_nuxt/error-500.CBAEdpZV.css">
|
|
10
10
|
<link rel="prefetch" as="script" crossorigin href="/__nuxt-i18n-micro/_nuxt/2C6ahHCU.js">
|
|
11
|
-
<script type="module" src="/__nuxt-i18n-micro/_nuxt/Czi4MokJ.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},
|
|
12
|
-
<script>window.__NUXT__={};window.__NUXT__.config={public:{},app:{baseURL:"/__nuxt-i18n-micro",buildId:"
|
|
11
|
+
<script type="module" src="/__nuxt-i18n-micro/_nuxt/Czi4MokJ.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},1729191460638,false]</script>
|
|
12
|
+
<script>window.__NUXT__={};window.__NUXT__.config={public:{},app:{baseURL:"/__nuxt-i18n-micro",buildId:"6c8b64c3-676f-4bad-bc98-3c29fe70f766",buildAssetsDir:"/_nuxt/",cdnURL:""}}</script></body></html>
|
package/dist/module.d.mts
CHANGED
|
@@ -29,6 +29,7 @@ interface ModuleOptions {
|
|
|
29
29
|
disablePageLocales?: boolean;
|
|
30
30
|
fallbackLocale?: string;
|
|
31
31
|
localeCookie?: string;
|
|
32
|
+
debug?: boolean;
|
|
32
33
|
globalLocaleRoutes?: GlobalLocaleRoutes;
|
|
33
34
|
customRegexMatcher?: string | RegExp;
|
|
34
35
|
}
|
|
@@ -42,6 +43,7 @@ interface ModuleOptionsExtend extends ModuleOptions {
|
|
|
42
43
|
interface ModulePrivateOptionsExtend extends ModuleOptions {
|
|
43
44
|
rootDir: string;
|
|
44
45
|
rootDirs: string[];
|
|
46
|
+
debug: boolean;
|
|
45
47
|
}
|
|
46
48
|
|
|
47
49
|
declare const _default: _nuxt_schema.NuxtModule<ModuleOptions, ModuleOptions, false>;
|
package/dist/module.d.ts
CHANGED
|
@@ -29,6 +29,7 @@ interface ModuleOptions {
|
|
|
29
29
|
disablePageLocales?: boolean;
|
|
30
30
|
fallbackLocale?: string;
|
|
31
31
|
localeCookie?: string;
|
|
32
|
+
debug?: boolean;
|
|
32
33
|
globalLocaleRoutes?: GlobalLocaleRoutes;
|
|
33
34
|
customRegexMatcher?: string | RegExp;
|
|
34
35
|
}
|
|
@@ -42,6 +43,7 @@ interface ModuleOptionsExtend extends ModuleOptions {
|
|
|
42
43
|
interface ModulePrivateOptionsExtend extends ModuleOptions {
|
|
43
44
|
rootDir: string;
|
|
44
45
|
rootDirs: string[];
|
|
46
|
+
debug: boolean;
|
|
45
47
|
}
|
|
46
48
|
|
|
47
49
|
declare const _default: _nuxt_schema.NuxtModule<ModuleOptions, ModuleOptions, false>;
|
package/dist/module.json
CHANGED
package/dist/module.mjs
CHANGED
|
@@ -369,6 +369,7 @@ const module = defineNuxtModule({
|
|
|
369
369
|
defaults: {
|
|
370
370
|
locales: [],
|
|
371
371
|
meta: true,
|
|
372
|
+
debug: false,
|
|
372
373
|
define: true,
|
|
373
374
|
defaultLocale: "en",
|
|
374
375
|
translationDir: "locales",
|
|
@@ -439,7 +440,8 @@ const module = defineNuxtModule({
|
|
|
439
440
|
}
|
|
440
441
|
nuxt.options.runtimeConfig.i18nConfig = {
|
|
441
442
|
rootDir: nuxt.options.rootDir,
|
|
442
|
-
rootDirs
|
|
443
|
+
rootDirs,
|
|
444
|
+
debug: options.debug ?? false
|
|
443
445
|
};
|
|
444
446
|
addPlugin({
|
|
445
447
|
src: resolver.resolve("./runtime/plugins/01.plugin"),
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { resolve } from "node:path";
|
|
2
2
|
import { readFile } from "node:fs/promises";
|
|
3
3
|
import { defineEventHandler } from "h3";
|
|
4
|
-
import { useRuntimeConfig, createError } from "#imports";
|
|
4
|
+
import { useRuntimeConfig, createError, useStorage } from "#imports";
|
|
5
5
|
function deepMerge(target, source) {
|
|
6
6
|
for (const key of Object.keys(source)) {
|
|
7
7
|
if (key === "__proto__" || key === "constructor") {
|
|
@@ -24,7 +24,7 @@ function isEmptyObject(obj) {
|
|
|
24
24
|
export default defineEventHandler(async (event) => {
|
|
25
25
|
const { page, locale } = event.context.params;
|
|
26
26
|
const config = useRuntimeConfig();
|
|
27
|
-
const { rootDirs } = config.i18nConfig;
|
|
27
|
+
const { rootDirs, debug } = config.i18nConfig;
|
|
28
28
|
const { translationDir, fallbackLocale, customRegexMatcher, locales } = config.public.i18nConfig;
|
|
29
29
|
if (customRegexMatcher && locales && !locales.map((l) => l.code).includes(locale)) {
|
|
30
30
|
throw createError({
|
|
@@ -37,23 +37,40 @@ export default defineEventHandler(async (event) => {
|
|
|
37
37
|
const paths = [];
|
|
38
38
|
if (fallbackLocale && fallbackLocale !== locale) {
|
|
39
39
|
rootDirs.forEach((dir) => {
|
|
40
|
-
paths.push(
|
|
40
|
+
paths.push({
|
|
41
|
+
translationPath: resolve(dir, translationDir, getTranslationPath(fallbackLocale, page)),
|
|
42
|
+
name: `_locales/${getTranslationPath(fallbackLocale, page)}`
|
|
43
|
+
});
|
|
41
44
|
});
|
|
42
45
|
}
|
|
43
46
|
rootDirs.forEach((dir) => {
|
|
44
|
-
paths.push(
|
|
47
|
+
paths.push({
|
|
48
|
+
translationPath: resolve(dir, translationDir, getTranslationPath(locale, page)),
|
|
49
|
+
name: `_locales/${getTranslationPath(locale, page)}`
|
|
50
|
+
});
|
|
45
51
|
});
|
|
46
52
|
let translations = {};
|
|
47
|
-
|
|
53
|
+
const serverStorage = await useStorage("assets:server");
|
|
54
|
+
for (const { translationPath, name } of paths) {
|
|
48
55
|
try {
|
|
49
|
-
|
|
56
|
+
if (debug) {
|
|
57
|
+
console.log("[nuxt-i18n-micro] load locale", translationPath, name);
|
|
58
|
+
}
|
|
59
|
+
const isThereAsset = await serverStorage.hasItem(name);
|
|
60
|
+
const fileContent = isThereAsset && !import.meta.prerender ? await serverStorage.getItemRaw(name) : await readFile(translationPath, "utf-8");
|
|
50
61
|
const content = JSON.parse(fileContent);
|
|
62
|
+
if (!isThereAsset && import.meta.prerender) {
|
|
63
|
+
await serverStorage.setItem(name, fileContent);
|
|
64
|
+
}
|
|
51
65
|
if (isEmptyObject(translations)) {
|
|
52
66
|
translations = content;
|
|
53
67
|
} else {
|
|
54
68
|
translations = deepMerge(translations, content);
|
|
55
69
|
}
|
|
56
|
-
} catch {
|
|
70
|
+
} catch (e) {
|
|
71
|
+
if (debug) {
|
|
72
|
+
console.error("[nuxt-i18n-micro] load locale error", e);
|
|
73
|
+
}
|
|
57
74
|
}
|
|
58
75
|
}
|
|
59
76
|
return translations;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nuxt-i18n-micro",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.26.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",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"id":"bf81ecd1-1ffc-4e1d-8901-d9000a7c0fc9","timestamp":1729171708637,"matcher":{"static":{},"wildcard":{},"dynamic":{}},"prerendered":[]}
|