nuxt-i18n-micro 1.21.4 → 1.22.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/81c32536-cb91-403a-af78-cc7ad6759ac9.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 +20 -13
- package/dist/runtime/plugins/01.plugin.d.ts +0 -16
- package/dist/runtime/plugins/01.plugin.js +3 -2
- package/package.json +2 -2
- package/dist/client/_nuxt/builds/meta/5beda9dc-b03a-48eb-9130-880c63a71b4a.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/CnNUpwZL.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/BKcmVa-6.js">
|
|
11
|
-
<script type="module" src="/__nuxt-i18n-micro/_nuxt/CeFL7aT9.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/CeFL7aT9.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},1728386455198,false]</script>
|
|
12
|
+
<script>window.__NUXT__={};window.__NUXT__.config={public:{},app:{baseURL:"/__nuxt-i18n-micro",buildId:"81c32536-cb91-403a-af78-cc7ad6759ac9",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/CnNUpwZL.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/BKcmVa-6.js">
|
|
11
|
-
<script type="module" src="/__nuxt-i18n-micro/_nuxt/CeFL7aT9.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/CeFL7aT9.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},1728386455199,false]</script>
|
|
12
|
+
<script>window.__NUXT__={};window.__NUXT__.config={public:{},app:{baseURL:"/__nuxt-i18n-micro",buildId:"81c32536-cb91-403a-af78-cc7ad6759ac9",buildAssetsDir:"/_nuxt/",cdnURL:""}}</script></body></html>
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"id":"
|
|
1
|
+
{"id":"81c32536-cb91-403a-af78-cc7ad6759ac9","timestamp":1728386444211}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"id":"81c32536-cb91-403a-af78-cc7ad6759ac9","timestamp":1728386444211,"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/CnNUpwZL.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/BKcmVa-6.js">
|
|
11
|
-
<script type="module" src="/__nuxt-i18n-micro/_nuxt/CeFL7aT9.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/CeFL7aT9.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},1728386455199,false]</script>
|
|
12
|
+
<script>window.__NUXT__={};window.__NUXT__.config={public:{},app:{baseURL:"/__nuxt-i18n-micro",buildId:"81c32536-cb91-403a-af78-cc7ad6759ac9",buildAssetsDir:"/_nuxt/",cdnURL:""}}</script></body></html>
|
package/dist/module.d.mts
CHANGED
|
@@ -17,6 +17,7 @@ interface ModuleOptions {
|
|
|
17
17
|
metaBaseUrl?: string;
|
|
18
18
|
define?: boolean;
|
|
19
19
|
defaultLocale?: string;
|
|
20
|
+
apiBaseUrl?: string;
|
|
20
21
|
translationDir?: string;
|
|
21
22
|
autoDetectLanguage?: boolean;
|
|
22
23
|
autoDetectPath?: string;
|
|
@@ -34,6 +35,7 @@ interface ModuleOptionsExtend extends ModuleOptions {
|
|
|
34
35
|
dateBuild: number;
|
|
35
36
|
baseURL: string;
|
|
36
37
|
hashMode: boolean;
|
|
38
|
+
apiBaseUrl: string;
|
|
37
39
|
}
|
|
38
40
|
interface ModulePrivateOptionsExtend extends ModuleOptions {
|
|
39
41
|
rootDir: string;
|
package/dist/module.d.ts
CHANGED
|
@@ -17,6 +17,7 @@ interface ModuleOptions {
|
|
|
17
17
|
metaBaseUrl?: string;
|
|
18
18
|
define?: boolean;
|
|
19
19
|
defaultLocale?: string;
|
|
20
|
+
apiBaseUrl?: string;
|
|
20
21
|
translationDir?: string;
|
|
21
22
|
autoDetectLanguage?: boolean;
|
|
22
23
|
autoDetectPath?: string;
|
|
@@ -34,6 +35,7 @@ interface ModuleOptionsExtend extends ModuleOptions {
|
|
|
34
35
|
dateBuild: number;
|
|
35
36
|
baseURL: string;
|
|
36
37
|
hashMode: boolean;
|
|
38
|
+
apiBaseUrl: string;
|
|
37
39
|
}
|
|
38
40
|
interface ModulePrivateOptionsExtend extends ModuleOptions {
|
|
39
41
|
rootDir: string;
|
package/dist/module.json
CHANGED
package/dist/module.mjs
CHANGED
|
@@ -391,6 +391,7 @@ const module = defineNuxtModule({
|
|
|
391
391
|
includeDefaultLocaleRoute: false,
|
|
392
392
|
fallbackLocale: void 0,
|
|
393
393
|
localeCookie: "user-locale",
|
|
394
|
+
apiBaseUrl: "_locales",
|
|
394
395
|
routesLocaleLinks: {},
|
|
395
396
|
globalLocaleRoutes: {},
|
|
396
397
|
plural: (key, count, _locale, getTranslation) => {
|
|
@@ -418,6 +419,7 @@ const module = defineNuxtModule({
|
|
|
418
419
|
let plural = options.plural;
|
|
419
420
|
if (typeof plural !== "string")
|
|
420
421
|
plural = plural.toString();
|
|
422
|
+
const apiBaseUrl = (options.apiBaseUrl ?? "_locales").replace(/^\/+/, "");
|
|
421
423
|
nuxt.options.runtimeConfig.public.i18nConfig = {
|
|
422
424
|
plural,
|
|
423
425
|
locales: localeManager.locales ?? [],
|
|
@@ -436,7 +438,8 @@ const module = defineNuxtModule({
|
|
|
436
438
|
dateBuild: Date.now(),
|
|
437
439
|
baseURL: nuxt.options.app.baseURL,
|
|
438
440
|
hashMode: nuxt.options?.router?.options?.hashMode ?? false,
|
|
439
|
-
globalLocaleRoutes: void 0
|
|
441
|
+
globalLocaleRoutes: void 0,
|
|
442
|
+
apiBaseUrl
|
|
440
443
|
};
|
|
441
444
|
nuxt.options.runtimeConfig.i18nConfig = {
|
|
442
445
|
rootDir: nuxt.options.rootDir,
|
|
@@ -467,7 +470,7 @@ const module = defineNuxtModule({
|
|
|
467
470
|
}
|
|
468
471
|
addImportsDir(resolver.resolve("./runtime/composables"));
|
|
469
472
|
addServerHandler({
|
|
470
|
-
route:
|
|
473
|
+
route: `/${apiBaseUrl}/:page/:locale/data.json`,
|
|
471
474
|
handler: resolver.resolve("./runtime/server/middleware/i18n-loader")
|
|
472
475
|
});
|
|
473
476
|
await addComponentsDir({
|
|
@@ -486,10 +489,10 @@ const module = defineNuxtModule({
|
|
|
486
489
|
localeManager.locales.forEach((locale) => {
|
|
487
490
|
if (!options.disablePageLocales) {
|
|
488
491
|
pagesNames.forEach((name) => {
|
|
489
|
-
prerenderRoutes.push(
|
|
492
|
+
prerenderRoutes.push(`/${apiBaseUrl}/${name}/${locale.code}/data.json`);
|
|
490
493
|
});
|
|
491
494
|
}
|
|
492
|
-
prerenderRoutes.push(
|
|
495
|
+
prerenderRoutes.push(`/${apiBaseUrl}/general/${locale.code}/data.json`);
|
|
493
496
|
});
|
|
494
497
|
if (isCloudflarePages) {
|
|
495
498
|
const processPageWithChildren = (page, parentPath = "") => {
|
|
@@ -527,7 +530,9 @@ const module = defineNuxtModule({
|
|
|
527
530
|
localeManager.locales.forEach((locale) => {
|
|
528
531
|
if (locale.code !== options.defaultLocale || options.includeDefaultLocaleRoute) {
|
|
529
532
|
pages.forEach((page) => {
|
|
530
|
-
|
|
533
|
+
if (!/\.[a-z0-9]+$/i.test(page) || page.startsWith(`/${apiBaseUrl}`)) {
|
|
534
|
+
routes.push(`/${locale.code}${page}`);
|
|
535
|
+
}
|
|
531
536
|
});
|
|
532
537
|
}
|
|
533
538
|
});
|
|
@@ -554,15 +559,17 @@ const module = defineNuxtModule({
|
|
|
554
559
|
const routesSet = prerenderRoutes.routes;
|
|
555
560
|
const additionalRoutes = /* @__PURE__ */ new Set();
|
|
556
561
|
routesSet.forEach((route) => {
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
if (
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
562
|
+
if (!/\.[a-z0-9]+$/i.test(route) || route.startsWith(`/${apiBaseUrl}`)) {
|
|
563
|
+
localeManager.locales.forEach((locale) => {
|
|
564
|
+
if (locale.code !== options.defaultLocale) {
|
|
565
|
+
if (route === "/") {
|
|
566
|
+
additionalRoutes.add(`/${locale.code}`);
|
|
567
|
+
} else {
|
|
568
|
+
additionalRoutes.add(`/${locale.code}${route}`);
|
|
569
|
+
}
|
|
563
570
|
}
|
|
564
|
-
}
|
|
565
|
-
}
|
|
571
|
+
});
|
|
572
|
+
}
|
|
566
573
|
});
|
|
567
574
|
additionalRoutes.forEach((route) => routesSet.add(route));
|
|
568
575
|
});
|
|
@@ -66,19 +66,3 @@ export interface PluginsInjections {
|
|
|
66
66
|
$loadPageTranslations: (locale: string, routeName: string) => Promise<void>;
|
|
67
67
|
$setI18nRouteParams: (value: I18nRouteParams) => I18nRouteParams;
|
|
68
68
|
}
|
|
69
|
-
declare module '#app' {
|
|
70
|
-
interface NuxtApp extends PluginsInjections {
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
declare module '@vue/runtime-core' {
|
|
74
|
-
interface ComponentCustomProperties extends PluginsInjections {
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
declare module 'vue' {
|
|
78
|
-
interface ComponentCustomProperties extends PluginsInjections {
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
declare module '#app/nuxt' {
|
|
82
|
-
interface NuxtApp extends PluginsInjections {
|
|
83
|
-
}
|
|
84
|
-
}
|
|
@@ -121,6 +121,7 @@ export default defineNuxtPlugin(async (nuxtApp) => {
|
|
|
121
121
|
const config = useRuntimeConfig();
|
|
122
122
|
const i18nConfig = config.public.i18nConfig;
|
|
123
123
|
const plural = new Function("return " + i18nConfig.plural.toString())();
|
|
124
|
+
const apiBaseUrl = i18nConfig.apiBaseUrl ?? "_locales";
|
|
124
125
|
const loadTranslationsIfNeeded = async (locale, routeName) => {
|
|
125
126
|
try {
|
|
126
127
|
if (!i18nHelper.hasPageTranslation(locale, routeName)) {
|
|
@@ -128,7 +129,7 @@ export default defineNuxtPlugin(async (nuxtApp) => {
|
|
|
128
129
|
if (i18nConfig.routesLocaleLinks && i18nConfig.routesLocaleLinks[fRouteName]) {
|
|
129
130
|
fRouteName = i18nConfig.routesLocaleLinks[fRouteName];
|
|
130
131
|
}
|
|
131
|
-
const data = await $fetch(
|
|
132
|
+
const data = await $fetch(`/${apiBaseUrl}/${fRouteName}/${locale}/data.json?v=${i18nConfig.dateBuild}`, { baseURL: i18nConfig.baseURL });
|
|
132
133
|
await i18nHelper.loadPageTranslations(locale, routeName, data ?? {});
|
|
133
134
|
}
|
|
134
135
|
} catch (_error) {
|
|
@@ -138,7 +139,7 @@ export default defineNuxtPlugin(async (nuxtApp) => {
|
|
|
138
139
|
const hashLocale2 = i18nConfig.hashMode ? nuxtApp.runWithContext(() => (useCookie("hash-locale").value ?? i18nConfig.defaultLocale).toString()).toString() : null;
|
|
139
140
|
const locale = getCurrentLocale(to, i18nConfig, hashLocale2);
|
|
140
141
|
if (!i18nHelper.hasGeneralTranslation(locale)) {
|
|
141
|
-
const data = await $fetch(
|
|
142
|
+
const data = await $fetch(`/${apiBaseUrl}/general/${locale}/data.json?v=${i18nConfig.dateBuild}`, { baseURL: i18nConfig.baseURL });
|
|
142
143
|
await i18nHelper.loadTranslations(locale, data ?? {});
|
|
143
144
|
}
|
|
144
145
|
if (!i18nConfig.disablePageLocales) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nuxt-i18n-micro",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.22.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",
|
|
@@ -90,7 +90,7 @@
|
|
|
90
90
|
"workspaces": [
|
|
91
91
|
"client",
|
|
92
92
|
"playground",
|
|
93
|
-
"test/
|
|
93
|
+
"test/fixtures/**/*"
|
|
94
94
|
],
|
|
95
95
|
"packageManager": "yarn@3.7.0+sha256.7bf0c78a106332886ea4e59641fd819b1af953edcd72c4d93a32b1c71000ee67"
|
|
96
96
|
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"id":"5beda9dc-b03a-48eb-9130-880c63a71b4a","timestamp":1727883245976,"matcher":{"static":{},"wildcard":{},"dynamic":{}},"prerendered":[]}
|