nuxt-i18n-micro 1.29.4 → 1.29.6
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/66d7665e-5819-42e7-bffd-4eea374483d8.json +1 -0
- package/dist/client/index.html +2 -2
- package/dist/module.json +1 -1
- package/dist/module.mjs +7 -5
- package/dist/runtime/plugins/01.plugin.js +20 -3
- package/package.json +1 -1
- package/dist/client/_nuxt/builds/meta/1d2bb48d-d8b2-43ed-82ce-c5dcf5a0446d.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},1729592519748,false]</script>
|
|
12
|
+
<script>window.__NUXT__={};window.__NUXT__.config={public:{},app:{baseURL:"/__nuxt-i18n-micro",buildId:"66d7665e-5819-42e7-bffd-4eea374483d8",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},1729592519749,false]</script>
|
|
12
|
+
<script>window.__NUXT__={};window.__NUXT__.config={public:{},app:{baseURL:"/__nuxt-i18n-micro",buildId:"66d7665e-5819-42e7-bffd-4eea374483d8",buildAssetsDir:"/_nuxt/",cdnURL:""}}</script></body></html>
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"id":"
|
|
1
|
+
{"id":"66d7665e-5819-42e7-bffd-4eea374483d8","timestamp":1729592509211}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"id":"66d7665e-5819-42e7-bffd-4eea374483d8","timestamp":1729592509211,"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},1729592519749,false]</script>
|
|
12
|
+
<script>window.__NUXT__={};window.__NUXT__.config={public:{},app:{baseURL:"/__nuxt-i18n-micro",buildId:"66d7665e-5819-42e7-bffd-4eea374483d8",buildAssetsDir:"/_nuxt/",cdnURL:""}}</script></body></html>
|
package/dist/module.json
CHANGED
package/dist/module.mjs
CHANGED
|
@@ -139,6 +139,9 @@ const normalizeRegex = (toNorm) => {
|
|
|
139
139
|
return toNorm.startsWith("/") && toNorm.endsWith("/") ? toNorm?.slice(1, -1) : toNorm;
|
|
140
140
|
};
|
|
141
141
|
|
|
142
|
+
const buildRouteNameFromRoute = (name, path2) => {
|
|
143
|
+
return name ?? (path2 ?? "").replace(/[^a-z0-9]/gi, "-").replace(/^-+|-+$/g, "");
|
|
144
|
+
};
|
|
142
145
|
class PageManager {
|
|
143
146
|
locales;
|
|
144
147
|
defaultLocale;
|
|
@@ -165,7 +168,6 @@ class PageManager {
|
|
|
165
168
|
pages.forEach((page) => {
|
|
166
169
|
if (!page.name) {
|
|
167
170
|
console.warn(`[nuxt-i18n-next] Page name is missing for the file: ${page.file}`);
|
|
168
|
-
return;
|
|
169
171
|
}
|
|
170
172
|
const customRoute = this.globalLocaleRoutes[page.name ?? ""] ?? null;
|
|
171
173
|
if (customRoute === false) {
|
|
@@ -182,7 +184,7 @@ class PageManager {
|
|
|
182
184
|
extractLocalizedPaths(pages, rootDir, parentPath = "") {
|
|
183
185
|
const localizedPaths = {};
|
|
184
186
|
pages.forEach((page) => {
|
|
185
|
-
const pageName = page.name
|
|
187
|
+
const pageName = buildRouteNameFromRoute(page.name, page.path);
|
|
186
188
|
const globalLocalePath = this.globalLocaleRoutes[pageName];
|
|
187
189
|
if (!globalLocalePath) {
|
|
188
190
|
if (page.file) {
|
|
@@ -240,7 +242,7 @@ class PageManager {
|
|
|
240
242
|
}
|
|
241
243
|
const currentChildren = page.children ? [...page.children] : [];
|
|
242
244
|
if (originalChildren.length) {
|
|
243
|
-
const newName = normalizePath(path.join("/", page.name
|
|
245
|
+
const newName = normalizePath(path.join("/", buildRouteNameFromRoute(page.name, page.path)));
|
|
244
246
|
const localizedChildren = this.mergeChildren(originalChildren, newName, [this.defaultLocale.code]);
|
|
245
247
|
const childrenMap = new Map(currentChildren.map((child) => [child.name, child]));
|
|
246
248
|
localizedChildren.forEach((localizedChild) => {
|
|
@@ -285,7 +287,7 @@ class PageManager {
|
|
|
285
287
|
}
|
|
286
288
|
createLocalizedRoute(page, localeCodes, originalChildren, isCustom, customPath = "", customRegex) {
|
|
287
289
|
const routePath = this.buildRoutePath(localeCodes, page.path, customPath, isCustom, customRegex);
|
|
288
|
-
const routeName = buildRouteName(page.name
|
|
290
|
+
const routeName = buildRouteName(buildRouteNameFromRoute(page.name, page.path), localeCodes[0], isCustom);
|
|
289
291
|
return {
|
|
290
292
|
...page,
|
|
291
293
|
children: this.createLocalizedChildren(originalChildren, page.path, localeCodes, true),
|
|
@@ -295,7 +297,7 @@ class PageManager {
|
|
|
295
297
|
}
|
|
296
298
|
createLocalizedChildRoute(route, routePath, locale, customLocalePaths, children, modifyName, addLocalePrefix) {
|
|
297
299
|
const finalPath = this.buildLocalizedRoutePath(routePath, locale, customLocalePaths, addLocalePrefix);
|
|
298
|
-
const routeName = this.buildLocalizedRouteName(route.name
|
|
300
|
+
const routeName = this.buildLocalizedRouteName(buildRouteNameFromRoute(route.name, route.path), locale, modifyName);
|
|
299
301
|
return {
|
|
300
302
|
...route,
|
|
301
303
|
name: routeName,
|
|
@@ -83,6 +83,18 @@ function getLocalizedRoute(to, router, route, i18nConfig, locale, hashLocale) {
|
|
|
83
83
|
}
|
|
84
84
|
return params;
|
|
85
85
|
};
|
|
86
|
+
if (!routeName || routeName === "") {
|
|
87
|
+
const resolved = router.resolve(to);
|
|
88
|
+
let url = resolved.path.replace(new RegExp(`^/${currentLocale}/`), "/");
|
|
89
|
+
if (currentLocale !== i18nConfig.defaultLocale || i18nConfig.includeDefaultLocaleRoute) {
|
|
90
|
+
url = "/" + currentLocale + url;
|
|
91
|
+
}
|
|
92
|
+
return router.resolve({
|
|
93
|
+
path: url,
|
|
94
|
+
query: selectRoute.query,
|
|
95
|
+
hash: selectRoute.hash
|
|
96
|
+
});
|
|
97
|
+
}
|
|
86
98
|
if (router.hasRoute(`localized-${routeName}-${currentLocale}`)) {
|
|
87
99
|
const newParams2 = resolveParams(selectRoute);
|
|
88
100
|
newParams2.locale = currentLocale;
|
|
@@ -131,14 +143,19 @@ export default defineNuxtPlugin(async (nuxtApp) => {
|
|
|
131
143
|
const plural = new Function("return " + i18nConfig.plural.toString())();
|
|
132
144
|
const apiBaseUrl = i18nConfig.apiBaseUrl ?? "_locales";
|
|
133
145
|
const runtimeConfig = useRuntimeConfig();
|
|
134
|
-
const loadTranslationsIfNeeded = async (locale, routeName) => {
|
|
146
|
+
const loadTranslationsIfNeeded = async (locale, routeName, path) => {
|
|
135
147
|
try {
|
|
136
148
|
if (!i18nHelper.hasPageTranslation(locale, routeName)) {
|
|
137
149
|
let fRouteName = routeName;
|
|
138
150
|
if (i18nConfig.routesLocaleLinks && i18nConfig.routesLocaleLinks[fRouteName]) {
|
|
139
151
|
fRouteName = i18nConfig.routesLocaleLinks[fRouteName];
|
|
140
152
|
}
|
|
141
|
-
|
|
153
|
+
if (!fRouteName || fRouteName === "") {
|
|
154
|
+
console.warn(`[nuxt-i18n-next] The page name is missing in the path: ${path}. Please ensure that definePageMeta({ name: 'pageName' }) is set.`);
|
|
155
|
+
return;
|
|
156
|
+
}
|
|
157
|
+
const route = `/${apiBaseUrl}/${fRouteName}/${locale}/data.json?v=${i18nConfig.dateBuild}`.replace(/\/{2,}/g, "/");
|
|
158
|
+
const data = await $fetch(route, { baseURL: runtimeConfig.app.baseURL });
|
|
142
159
|
await i18nHelper.loadPageTranslations(locale, routeName, data ?? {});
|
|
143
160
|
}
|
|
144
161
|
} catch (_error) {
|
|
@@ -153,7 +170,7 @@ export default defineNuxtPlugin(async (nuxtApp) => {
|
|
|
153
170
|
}
|
|
154
171
|
if (!i18nConfig.disablePageLocales) {
|
|
155
172
|
const routeName = getRouteName(to, locale);
|
|
156
|
-
await loadTranslationsIfNeeded(locale, routeName);
|
|
173
|
+
await loadTranslationsIfNeeded(locale, routeName, to.fullPath);
|
|
157
174
|
}
|
|
158
175
|
await nuxtApp.callHook("i18n:register", (translations, selectedLocale) => {
|
|
159
176
|
const routeName = getRouteName(to, locale);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nuxt-i18n-micro",
|
|
3
|
-
"version": "1.29.
|
|
3
|
+
"version": "1.29.6",
|
|
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":"1d2bb48d-d8b2-43ed-82ce-c5dcf5a0446d","timestamp":1729515371381,"matcher":{"static":{},"wildcard":{},"dynamic":{}},"prerendered":[]}
|