nuxt-i18n-micro 1.101.2 → 1.102.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/3b71a52e-40e0-4913-a13a-e722e382d06d.json +1 -0
- package/dist/client/index.html +2 -2
- package/dist/module.json +1 -1
- package/dist/module.mjs +19 -30
- package/dist/runtime/plugins/02.meta.js +8 -2
- package/dist/runtime/plugins/03.define.d.ts +3 -10
- package/dist/runtime/utils/route-utils.d.ts +9 -0
- package/dist/runtime/utils/route-utils.js +33 -0
- package/package.json +2 -2
- package/dist/client/_nuxt/builds/meta/48c4fe22-ef0c-4134-a6f0-f5d3d316c514.json +0 -1
package/dist/client/200.html
CHANGED
|
@@ -8,5 +8,5 @@
|
|
|
8
8
|
<link rel="prefetch" as="script" crossorigin href="/__NUXT_DEVTOOLS_I18N_BASE__/_nuxt/T7szCJDf.js">
|
|
9
9
|
<link rel="prefetch" as="style" crossorigin href="/__NUXT_DEVTOOLS_I18N_BASE__/_nuxt/error-500.DGwSTbEi.css">
|
|
10
10
|
<link rel="prefetch" as="script" crossorigin href="/__NUXT_DEVTOOLS_I18N_BASE__/_nuxt/DTIY11lm.js">
|
|
11
|
-
<script type="module" src="/__NUXT_DEVTOOLS_I18N_BASE__/_nuxt/s7GTWWQo.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_DEVTOOLS_I18N_BASE__/",buildId:"
|
|
11
|
+
<script type="module" src="/__NUXT_DEVTOOLS_I18N_BASE__/_nuxt/s7GTWWQo.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},1760083218234,false]</script>
|
|
12
|
+
<script>window.__NUXT__={};window.__NUXT__.config={public:{},app:{baseURL:"/__NUXT_DEVTOOLS_I18N_BASE__/",buildId:"3b71a52e-40e0-4913-a13a-e722e382d06d",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_DEVTOOLS_I18N_BASE__/_nuxt/T7szCJDf.js">
|
|
9
9
|
<link rel="prefetch" as="style" crossorigin href="/__NUXT_DEVTOOLS_I18N_BASE__/_nuxt/error-500.DGwSTbEi.css">
|
|
10
10
|
<link rel="prefetch" as="script" crossorigin href="/__NUXT_DEVTOOLS_I18N_BASE__/_nuxt/DTIY11lm.js">
|
|
11
|
-
<script type="module" src="/__NUXT_DEVTOOLS_I18N_BASE__/_nuxt/s7GTWWQo.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_DEVTOOLS_I18N_BASE__/",buildId:"
|
|
11
|
+
<script type="module" src="/__NUXT_DEVTOOLS_I18N_BASE__/_nuxt/s7GTWWQo.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},1760083218234,false]</script>
|
|
12
|
+
<script>window.__NUXT__={};window.__NUXT__.config={public:{},app:{baseURL:"/__NUXT_DEVTOOLS_I18N_BASE__/",buildId:"3b71a52e-40e0-4913-a13a-e722e382d06d",buildAssetsDir:"/_nuxt/",cdnURL:""}}</script></body></html>
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"id":"
|
|
1
|
+
{"id":"3b71a52e-40e0-4913-a13a-e722e382d06d","timestamp":1760083211792}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"id":"3b71a52e-40e0-4913-a13a-e722e382d06d","timestamp":1760083211792,"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_DEVTOOLS_I18N_BASE__/_nuxt/T7szCJDf.js">
|
|
9
9
|
<link rel="prefetch" as="style" crossorigin href="/__NUXT_DEVTOOLS_I18N_BASE__/_nuxt/error-500.DGwSTbEi.css">
|
|
10
10
|
<link rel="prefetch" as="script" crossorigin href="/__NUXT_DEVTOOLS_I18N_BASE__/_nuxt/DTIY11lm.js">
|
|
11
|
-
<script type="module" src="/__NUXT_DEVTOOLS_I18N_BASE__/_nuxt/s7GTWWQo.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_DEVTOOLS_I18N_BASE__/",buildId:"
|
|
11
|
+
<script type="module" src="/__NUXT_DEVTOOLS_I18N_BASE__/_nuxt/s7GTWWQo.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},1760083218234,false]</script>
|
|
12
|
+
<script>window.__NUXT__={};window.__NUXT__.config={public:{},app:{baseURL:"/__NUXT_DEVTOOLS_I18N_BASE__/",buildId:"3b71a52e-40e0-4913-a13a-e722e382d06d",buildAssetsDir:"/_nuxt/",cdnURL:""}}</script></body></html>
|
package/dist/module.json
CHANGED
package/dist/module.mjs
CHANGED
|
@@ -189,39 +189,15 @@ function extractDefineI18nRouteData(content, _filePath) {
|
|
|
189
189
|
try {
|
|
190
190
|
const scriptContent = extractScriptContent(content);
|
|
191
191
|
if (!scriptContent) {
|
|
192
|
-
return
|
|
192
|
+
return null;
|
|
193
193
|
}
|
|
194
194
|
const configObject = findDefineI18nRouteConfig(scriptContent);
|
|
195
195
|
if (!configObject) {
|
|
196
|
-
return
|
|
197
|
-
}
|
|
198
|
-
let locales = null;
|
|
199
|
-
if (configObject.locales) {
|
|
200
|
-
if (Array.isArray(configObject.locales)) {
|
|
201
|
-
locales = configObject.locales.map((item) => {
|
|
202
|
-
if (typeof item === "string") {
|
|
203
|
-
return item;
|
|
204
|
-
} else if (typeof item === "object" && item !== null && item.code) {
|
|
205
|
-
return item.code;
|
|
206
|
-
}
|
|
207
|
-
return null;
|
|
208
|
-
}).filter((item) => item !== null);
|
|
209
|
-
} else if (typeof configObject.locales === "object") {
|
|
210
|
-
locales = Object.keys(configObject.locales).filter(
|
|
211
|
-
(key) => key !== "meta" && key !== "path" && key !== "title" && key !== "description"
|
|
212
|
-
);
|
|
213
|
-
}
|
|
214
|
-
}
|
|
215
|
-
let localeRoutes = null;
|
|
216
|
-
if (configObject.localeRoutes && typeof configObject.localeRoutes === "object") {
|
|
217
|
-
const isValid = Object.values(configObject.localeRoutes).every((value) => typeof value === "string");
|
|
218
|
-
if (isValid) {
|
|
219
|
-
localeRoutes = configObject.localeRoutes;
|
|
220
|
-
}
|
|
196
|
+
return null;
|
|
221
197
|
}
|
|
222
|
-
return
|
|
198
|
+
return configObject;
|
|
223
199
|
} catch {
|
|
224
|
-
return
|
|
200
|
+
return null;
|
|
225
201
|
}
|
|
226
202
|
}
|
|
227
203
|
const normalizePath = (routePath) => {
|
|
@@ -749,19 +725,29 @@ const module = defineNuxtModule({
|
|
|
749
725
|
const localeManager = new LocaleManager(options, rootDirs);
|
|
750
726
|
const routeLocales = {};
|
|
751
727
|
const globalLocaleRoutes = {};
|
|
728
|
+
const routeDisableMeta = {};
|
|
752
729
|
const pageFiles = await globby("pages/**/*.vue", { cwd: nuxt.options.rootDir });
|
|
753
730
|
for (const pageFile of pageFiles) {
|
|
754
731
|
const fullPath = join(nuxt.options.rootDir, pageFile);
|
|
755
732
|
try {
|
|
756
733
|
const fileContent = readFileSync(fullPath, "utf-8");
|
|
757
|
-
const
|
|
734
|
+
const config = extractDefineI18nRouteData(fileContent, fullPath);
|
|
735
|
+
if (!config) continue;
|
|
736
|
+
const { locales: extractedLocales, localeRoutes, disableMeta } = config;
|
|
758
737
|
const routePath = pageFile.replace(/^pages\//, "/").replace(/\/index\.vue$/, "").replace(/\.vue$/, "").replace(/\/$/, "") || "/";
|
|
759
738
|
if (extractedLocales) {
|
|
760
|
-
|
|
739
|
+
if (Array.isArray(extractedLocales)) {
|
|
740
|
+
routeLocales[routePath] = extractedLocales;
|
|
741
|
+
} else if (typeof extractedLocales === "object") {
|
|
742
|
+
routeLocales[routePath] = Object.keys(extractedLocales);
|
|
743
|
+
}
|
|
761
744
|
}
|
|
762
745
|
if (localeRoutes) {
|
|
763
746
|
globalLocaleRoutes[routePath] = localeRoutes;
|
|
764
747
|
}
|
|
748
|
+
if (disableMeta !== void 0) {
|
|
749
|
+
routeDisableMeta[routePath] = disableMeta;
|
|
750
|
+
}
|
|
765
751
|
} catch {
|
|
766
752
|
}
|
|
767
753
|
}
|
|
@@ -795,6 +781,9 @@ const module = defineNuxtModule({
|
|
|
795
781
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
796
782
|
// @ts-ignore
|
|
797
783
|
routeLocales,
|
|
784
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
785
|
+
// @ts-ignore
|
|
786
|
+
routeDisableMeta,
|
|
798
787
|
experimental: {
|
|
799
788
|
i18nPreviousPageFallback: options.experimental?.i18nPreviousPageFallback ?? false
|
|
800
789
|
}
|
|
@@ -1,10 +1,16 @@
|
|
|
1
1
|
import { useLocaleHead } from "../composables/useLocaleHead.js";
|
|
2
|
-
import { useRequestURL, useHead, defineNuxtPlugin, useRuntimeConfig } from "#imports";
|
|
2
|
+
import { useRequestURL, useHead, defineNuxtPlugin, useRuntimeConfig, useRoute } from "#imports";
|
|
3
|
+
import { isMetaDisabledForRoute } from "../utils/route-utils.js";
|
|
3
4
|
const host = process.env.HOST ?? "localhost";
|
|
4
5
|
const port = process.env.PORT ?? "host";
|
|
5
|
-
export default defineNuxtPlugin((
|
|
6
|
+
export default defineNuxtPlugin((nuxtApp) => {
|
|
6
7
|
const config = useRuntimeConfig();
|
|
8
|
+
const route = useRoute();
|
|
7
9
|
const i18nConfig = config.public.i18nConfig;
|
|
10
|
+
const currentLocale = nuxtApp.$getLocale?.();
|
|
11
|
+
if (isMetaDisabledForRoute(route, i18nConfig.routeDisableMeta, currentLocale)) {
|
|
12
|
+
return;
|
|
13
|
+
}
|
|
8
14
|
const schema = port === "443" ? "https" : "http";
|
|
9
15
|
const defaultUrl = port === "80" || port === "443" ? `${schema}://${host}` : `${schema}://${host}:${port}`;
|
|
10
16
|
const url = useRequestURL();
|
|
@@ -1,14 +1,7 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
type LocalesObject = Record<string, Translations>;
|
|
1
|
+
import type { DefineI18nRouteConfig } from 'nuxt-i18n-micro-types';
|
|
3
2
|
declare const _default: import("nuxt/app").Plugin<{
|
|
4
|
-
defineI18nRoute: (routeDefinition:
|
|
5
|
-
locales?: string[] | LocalesObject;
|
|
6
|
-
localeRoutes?: Record<string, string>;
|
|
7
|
-
}) => Promise<void>;
|
|
3
|
+
defineI18nRoute: (routeDefinition: DefineI18nRouteConfig) => Promise<void>;
|
|
8
4
|
}> & import("nuxt/app").ObjectPlugin<{
|
|
9
|
-
defineI18nRoute: (routeDefinition:
|
|
10
|
-
locales?: string[] | LocalesObject;
|
|
11
|
-
localeRoutes?: Record<string, string>;
|
|
12
|
-
}) => Promise<void>;
|
|
5
|
+
defineI18nRoute: (routeDefinition: DefineI18nRouteConfig) => Promise<void>;
|
|
13
6
|
}>;
|
|
14
7
|
export default _default;
|
|
@@ -20,3 +20,12 @@ export declare function extractBaseRoutePattern(matchedPath: string): string;
|
|
|
20
20
|
* @returns Array of allowed locale codes or null if no restrictions
|
|
21
21
|
*/
|
|
22
22
|
export declare function findAllowedLocalesForRoute(route: RouteLocationNormalizedLoaded, routeLocales: Record<string, string[]> | undefined): string[] | null;
|
|
23
|
+
/**
|
|
24
|
+
* Checks if meta tags should be disabled for a route
|
|
25
|
+
*
|
|
26
|
+
* @param route - The route object
|
|
27
|
+
* @param routeDisableMeta - The routeDisableMeta configuration object
|
|
28
|
+
* @param currentLocale - The current locale code
|
|
29
|
+
* @returns True if meta tags should be disabled, false otherwise
|
|
30
|
+
*/
|
|
31
|
+
export declare function isMetaDisabledForRoute(route: RouteLocationNormalizedLoaded, routeDisableMeta: Record<string, boolean | string[]> | undefined, currentLocale?: string): boolean;
|
|
@@ -17,3 +17,36 @@ export function findAllowedLocalesForRoute(route, routeLocales) {
|
|
|
17
17
|
}
|
|
18
18
|
return allowedLocales || null;
|
|
19
19
|
}
|
|
20
|
+
export function isMetaDisabledForRoute(route, routeDisableMeta, currentLocale) {
|
|
21
|
+
if (!routeDisableMeta) {
|
|
22
|
+
return false;
|
|
23
|
+
}
|
|
24
|
+
const routePath = route.path;
|
|
25
|
+
const routeName = route.name?.toString();
|
|
26
|
+
const normalizedRouteName = routeName?.replace("localized-", "");
|
|
27
|
+
const normalizedRoutePath = normalizedRouteName ? `/${normalizedRouteName}` : void 0;
|
|
28
|
+
const checkDisableMeta = (disableMetaValue) => {
|
|
29
|
+
if (disableMetaValue === void 0) {
|
|
30
|
+
return false;
|
|
31
|
+
}
|
|
32
|
+
if (typeof disableMetaValue === "boolean") {
|
|
33
|
+
return disableMetaValue;
|
|
34
|
+
}
|
|
35
|
+
if (Array.isArray(disableMetaValue)) {
|
|
36
|
+
return currentLocale ? disableMetaValue.includes(currentLocale) : false;
|
|
37
|
+
}
|
|
38
|
+
return false;
|
|
39
|
+
};
|
|
40
|
+
if (checkDisableMeta(routeDisableMeta[routePath]) || routeName && checkDisableMeta(routeDisableMeta[routeName]) || normalizedRouteName && checkDisableMeta(routeDisableMeta[normalizedRouteName]) || normalizedRoutePath && checkDisableMeta(routeDisableMeta[normalizedRoutePath])) {
|
|
41
|
+
return true;
|
|
42
|
+
}
|
|
43
|
+
if (route.matched && route.matched.length > 0) {
|
|
44
|
+
const matchedRoute = route.matched[0];
|
|
45
|
+
const matchedPath = matchedRoute.path;
|
|
46
|
+
const baseRoutePattern = extractBaseRoutePattern(matchedPath);
|
|
47
|
+
if (checkDisableMeta(routeDisableMeta[baseRoutePattern])) {
|
|
48
|
+
return true;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
return false;
|
|
52
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nuxt-i18n-micro",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.102.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",
|
|
@@ -61,8 +61,8 @@
|
|
|
61
61
|
"globby": "^14.1.0",
|
|
62
62
|
"sirv": "^2.0.4",
|
|
63
63
|
"ufo": "^1.5.4",
|
|
64
|
+
"nuxt-i18n-micro-types": "1.0.10",
|
|
64
65
|
"nuxt-i18n-micro-core": "1.0.18",
|
|
65
|
-
"nuxt-i18n-micro-types": "1.0.9",
|
|
66
66
|
"nuxt-i18n-micro-test-utils": "1.0.6"
|
|
67
67
|
},
|
|
68
68
|
"devDependencies": {
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"id":"48c4fe22-ef0c-4134-a6f0-f5d3d316c514","timestamp":1759992972613,"matcher":{"static":{},"wildcard":{},"dynamic":{}},"prerendered":[]}
|