nuxt-i18n-micro 2.1.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 +3 -0
- package/dist/runtime/composables/useLocaleHead.js +36 -3
- package/package.json +2 -2
- package/dist/client/_nuxt/builds/meta/df79903a-9996-4527-8269-e47de875a594.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
|
@@ -787,6 +787,9 @@ const module = defineNuxtModule({
|
|
|
787
787
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
788
788
|
// @ts-ignore
|
|
789
789
|
routeDisableMeta,
|
|
790
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
791
|
+
// @ts-ignore
|
|
792
|
+
globalLocaleRoutes: mergedGlobalLocaleRoutes,
|
|
790
793
|
experimental: {
|
|
791
794
|
i18nPreviousPageFallback: options.experimental?.i18nPreviousPageFallback ?? false,
|
|
792
795
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
@@ -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}`,
|
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,7 +61,7 @@
|
|
|
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.
|
|
64
|
+
"nuxt-i18n-micro-core": "1.0.22",
|
|
65
65
|
"nuxt-i18n-micro-test-utils": "1.0.7",
|
|
66
66
|
"nuxt-i18n-micro-types": "1.0.12"
|
|
67
67
|
},
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"id":"df79903a-9996-4527-8269-e47de875a594","timestamp":1761933265840,"matcher":{"static":{},"wildcard":{},"dynamic":{}},"prerendered":[]}
|