nuxt-i18n-micro 2.0.0 → 2.2.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/761c8107-0390-4ed8-9b33-a10824c775b2.json +1 -0
- package/dist/client/index.html +2 -2
- package/dist/module.json +1 -1
- package/dist/module.mjs +6 -4
- package/dist/runtime/composables/useLocaleHead.js +36 -3
- package/dist/runtime/server/plugins/watcher.dev.js +1 -1
- package/package.json +3 -3
- package/dist/client/_nuxt/builds/meta/9577efa7-2d15-4fca-9d0d-3cd305cdd931.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/CBxwnKtU.js">
|
|
9
9
|
<link rel="prefetch" as="style" crossorigin href="/__NUXT_DEVTOOLS_I18N_BASE__/_nuxt/error-500.BqKd8Zt-.css">
|
|
10
10
|
<link rel="prefetch" as="script" crossorigin href="/__NUXT_DEVTOOLS_I18N_BASE__/_nuxt/BYEpoBUk.js">
|
|
11
|
-
<script type="module" src="/__NUXT_DEVTOOLS_I18N_BASE__/_nuxt/XZXfxmri.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/XZXfxmri.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},1762153620044,false]</script>
|
|
12
|
+
<script>window.__NUXT__={};window.__NUXT__.config={public:{},app:{baseURL:"/__NUXT_DEVTOOLS_I18N_BASE__/",buildId:"761c8107-0390-4ed8-9b33-a10824c775b2",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/CBxwnKtU.js">
|
|
9
9
|
<link rel="prefetch" as="style" crossorigin href="/__NUXT_DEVTOOLS_I18N_BASE__/_nuxt/error-500.BqKd8Zt-.css">
|
|
10
10
|
<link rel="prefetch" as="script" crossorigin href="/__NUXT_DEVTOOLS_I18N_BASE__/_nuxt/BYEpoBUk.js">
|
|
11
|
-
<script type="module" src="/__NUXT_DEVTOOLS_I18N_BASE__/_nuxt/XZXfxmri.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/XZXfxmri.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},1762153620044,false]</script>
|
|
12
|
+
<script>window.__NUXT__={};window.__NUXT__.config={public:{},app:{baseURL:"/__NUXT_DEVTOOLS_I18N_BASE__/",buildId:"761c8107-0390-4ed8-9b33-a10824c775b2",buildAssetsDir:"/_nuxt/",cdnURL:""}}</script></body></html>
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"id":"
|
|
1
|
+
{"id":"761c8107-0390-4ed8-9b33-a10824c775b2","timestamp":1762153612543}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"id":"761c8107-0390-4ed8-9b33-a10824c775b2","timestamp":1762153612543,"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/CBxwnKtU.js">
|
|
9
9
|
<link rel="prefetch" as="style" crossorigin href="/__NUXT_DEVTOOLS_I18N_BASE__/_nuxt/error-500.BqKd8Zt-.css">
|
|
10
10
|
<link rel="prefetch" as="script" crossorigin href="/__NUXT_DEVTOOLS_I18N_BASE__/_nuxt/BYEpoBUk.js">
|
|
11
|
-
<script type="module" src="/__NUXT_DEVTOOLS_I18N_BASE__/_nuxt/XZXfxmri.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/XZXfxmri.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},1762153620045,false]</script>
|
|
12
|
+
<script>window.__NUXT__={};window.__NUXT__.config={public:{},app:{baseURL:"/__NUXT_DEVTOOLS_I18N_BASE__/",buildId:"761c8107-0390-4ed8-9b33-a10824c775b2",buildAssetsDir:"/_nuxt/",cdnURL:""}}</script></body></html>
|
package/dist/module.json
CHANGED
package/dist/module.mjs
CHANGED
|
@@ -690,7 +690,6 @@ const module = defineNuxtModule({
|
|
|
690
690
|
autoDetectLanguage: true,
|
|
691
691
|
disablePageLocales: false,
|
|
692
692
|
disableWatcher: false,
|
|
693
|
-
disableUpdater: false,
|
|
694
693
|
// experimental kept in runtimeConfig only to avoid type drift here
|
|
695
694
|
noPrefixRedirect: false,
|
|
696
695
|
includeDefaultLocaleRoute: void 0,
|
|
@@ -733,7 +732,7 @@ const module = defineNuxtModule({
|
|
|
733
732
|
const routeLocales = {};
|
|
734
733
|
const globalLocaleRoutes = {};
|
|
735
734
|
const routeDisableMeta = {};
|
|
736
|
-
const pageFiles = await globby("pages/**/*.vue", { cwd: nuxt.options.rootDir });
|
|
735
|
+
const pageFiles = await globby(["pages/**/*.vue", "app/pages/**/*.vue"], { cwd: nuxt.options.rootDir });
|
|
737
736
|
for (const pageFile of pageFiles) {
|
|
738
737
|
const fullPath = join(nuxt.options.rootDir, pageFile);
|
|
739
738
|
try {
|
|
@@ -741,7 +740,7 @@ const module = defineNuxtModule({
|
|
|
741
740
|
const config = extractDefineI18nRouteData(fileContent, fullPath);
|
|
742
741
|
if (!config) continue;
|
|
743
742
|
const { locales: extractedLocales, localeRoutes, disableMeta } = config;
|
|
744
|
-
const routePath = pageFile.replace(/^pages\//, "/").replace(/\/index\.vue$/, "").replace(/\.vue$/, "").replace(/\/$/, "") || "/";
|
|
743
|
+
const routePath = pageFile.replace(/^(app\/)?pages\//, "/").replace(/\/index\.vue$/, "").replace(/\.vue$/, "").replace(/\/$/, "") || "/";
|
|
745
744
|
if (extractedLocales) {
|
|
746
745
|
if (Array.isArray(extractedLocales)) {
|
|
747
746
|
routeLocales[routePath] = extractedLocales;
|
|
@@ -788,6 +787,9 @@ const module = defineNuxtModule({
|
|
|
788
787
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
789
788
|
// @ts-ignore
|
|
790
789
|
routeDisableMeta,
|
|
790
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
791
|
+
// @ts-ignore
|
|
792
|
+
globalLocaleRoutes: mergedGlobalLocaleRoutes,
|
|
791
793
|
experimental: {
|
|
792
794
|
i18nPreviousPageFallback: options.experimental?.i18nPreviousPageFallback ?? false,
|
|
793
795
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
@@ -1089,7 +1091,7 @@ ${accepts}
|
|
|
1089
1091
|
}
|
|
1090
1092
|
});
|
|
1091
1093
|
nuxt.hook("nitro:config", (nitroConfig) => {
|
|
1092
|
-
if (nuxt.options.dev && (options.experimental?.hmr ?? true)
|
|
1094
|
+
if (nuxt.options.dev && (options.experimental?.hmr ?? true)) {
|
|
1093
1095
|
nitroConfig.plugins = nitroConfig.plugins || [];
|
|
1094
1096
|
nitroConfig.plugins.push(resolver.resolve("./runtime/server/plugins/watcher.dev"));
|
|
1095
1097
|
}
|
|
@@ -20,8 +20,8 @@ export const useLocaleHead = ({ addDirAttribute = true, identifierAttribute = "i
|
|
|
20
20
|
return withQuery(pathname, filtered);
|
|
21
21
|
}
|
|
22
22
|
function updateMeta() {
|
|
23
|
-
const { defaultLocale, strategy, canonicalQueryWhitelist, routeLocales } = useRuntimeConfig().public.i18nConfig;
|
|
24
|
-
const { $getLocales, $getLocale } = useNuxtApp();
|
|
23
|
+
const { defaultLocale, strategy, canonicalQueryWhitelist, routeLocales, globalLocaleRoutes } = useRuntimeConfig().public.i18nConfig;
|
|
24
|
+
const { $getLocales, $getLocale, $getRouteName } = useNuxtApp();
|
|
25
25
|
if (!$getLocale || !$getLocales) return;
|
|
26
26
|
const route = useRoute();
|
|
27
27
|
const locale = unref($getLocale());
|
|
@@ -38,6 +38,17 @@ export const useLocaleHead = ({ addDirAttribute = true, identifierAttribute = "i
|
|
|
38
38
|
fullPath = `/${fullPath}`;
|
|
39
39
|
}
|
|
40
40
|
const matchedLocale = locales.find((locale2) => fullPath.startsWith(`/${locale2.code}`));
|
|
41
|
+
const baseRouteName = $getRouteName ? unref($getRouteName(route, locale)) : routeName.replace(/^localized-/, "").replace(new RegExp(`-${locale}$`), "").replace(new RegExp(`-${defaultLocale}$`), "");
|
|
42
|
+
let normalizedPath = route.path;
|
|
43
|
+
if (matchedLocale && normalizedPath.startsWith(`/${matchedLocale.code}`)) {
|
|
44
|
+
normalizedPath = normalizedPath.slice(matchedLocale.code.length + 1);
|
|
45
|
+
}
|
|
46
|
+
if (!normalizedPath.startsWith("/")) {
|
|
47
|
+
normalizedPath = `/${normalizedPath}`;
|
|
48
|
+
}
|
|
49
|
+
if (normalizedPath !== "/" && normalizedPath.endsWith("/")) {
|
|
50
|
+
normalizedPath = normalizedPath.slice(0, -1);
|
|
51
|
+
}
|
|
41
52
|
let localizedPath = fullPath;
|
|
42
53
|
let ogUrl;
|
|
43
54
|
let canonicalPath;
|
|
@@ -49,6 +60,22 @@ export const useLocaleHead = ({ addDirAttribute = true, identifierAttribute = "i
|
|
|
49
60
|
canonicalPath = filterQuery(fullPath, canonicalQueryWhitelist ?? []);
|
|
50
61
|
ogUrl = joinURL(unref(baseUrl), canonicalPath);
|
|
51
62
|
}
|
|
63
|
+
let routeLocalizedPaths = globalLocaleRoutes?.[baseRouteName] || globalLocaleRoutes?.[normalizedPath] || null;
|
|
64
|
+
if (!routeLocalizedPaths && globalLocaleRoutes) {
|
|
65
|
+
for (const [, localizedPaths] of Object.entries(globalLocaleRoutes)) {
|
|
66
|
+
if (typeof localizedPaths === "object" && localizedPaths !== null) {
|
|
67
|
+
const normalizedCurrentPath = canonicalPath.replace(/^\/+/, "/");
|
|
68
|
+
const matchingLocale = Object.entries(localizedPaths).find(([_, localizedPathValue]) => {
|
|
69
|
+
const normalizedLocalizedPath = String(localizedPathValue).replace(/^\/+/, "/");
|
|
70
|
+
return normalizedCurrentPath === normalizedLocalizedPath || matchedLocale && normalizedCurrentPath === `/${matchedLocale.code}/${normalizedLocalizedPath}`;
|
|
71
|
+
});
|
|
72
|
+
if (matchingLocale) {
|
|
73
|
+
routeLocalizedPaths = localizedPaths;
|
|
74
|
+
break;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
}
|
|
52
79
|
metaObject.value = {
|
|
53
80
|
htmlAttrs: {
|
|
54
81
|
lang: currentIso,
|
|
@@ -80,7 +107,13 @@ export const useLocaleHead = ({ addDirAttribute = true, identifierAttribute = "i
|
|
|
80
107
|
href: ogUrl
|
|
81
108
|
};
|
|
82
109
|
const alternateLinks = isNoPrefixStrategy(strategy) ? [] : alternateLocales.flatMap((loc) => {
|
|
83
|
-
|
|
110
|
+
let pathForLocale;
|
|
111
|
+
if (routeLocalizedPaths && routeLocalizedPaths[loc.code]) {
|
|
112
|
+
pathForLocale = routeLocalizedPaths[loc.code];
|
|
113
|
+
} else {
|
|
114
|
+
pathForLocale = defaultLocale === loc.code && isPrefixExceptDefaultStrategy(strategy) ? canonicalPath : canonicalPath;
|
|
115
|
+
}
|
|
116
|
+
const localizedPath2 = defaultLocale === loc.code && isPrefixExceptDefaultStrategy(strategy) ? pathForLocale : joinURL(loc.code, pathForLocale);
|
|
84
117
|
const href = joinURL(unref(baseUrl), localizedPath2);
|
|
85
118
|
const links = [{
|
|
86
119
|
[identifierAttribute]: `i18n-alternate-${loc.code}`,
|
|
@@ -8,7 +8,7 @@ export default defineNitroPlugin((nitroApp) => {
|
|
|
8
8
|
}
|
|
9
9
|
const config = useRuntimeConfig();
|
|
10
10
|
const i18nConfig = config.i18nConfig;
|
|
11
|
-
if (!i18nConfig ||
|
|
11
|
+
if (!i18nConfig || process.env.NODE_ENV !== "development") {
|
|
12
12
|
return;
|
|
13
13
|
}
|
|
14
14
|
const log = (...args) => i18nConfig.debug && console.log("[i18n-hmr]", ...args);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nuxt-i18n-micro",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.2.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,9 +61,9 @@
|
|
|
61
61
|
"globby": "^14.1.0",
|
|
62
62
|
"sirv": "^2.0.4",
|
|
63
63
|
"ufo": "^1.5.4",
|
|
64
|
+
"nuxt-i18n-micro-core": "1.0.22",
|
|
64
65
|
"nuxt-i18n-micro-test-utils": "1.0.7",
|
|
65
|
-
"nuxt-i18n-micro-types": "1.0.
|
|
66
|
-
"nuxt-i18n-micro-core": "1.0.20"
|
|
66
|
+
"nuxt-i18n-micro-types": "1.0.12"
|
|
67
67
|
},
|
|
68
68
|
"devDependencies": {
|
|
69
69
|
"@nuxt/devtools": "^2.6.3",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"id":"9577efa7-2d15-4fca-9d0d-3cd305cdd931","timestamp":1761831387055,"matcher":{"static":{},"wildcard":{},"dynamic":{}},"prerendered":[]}
|