nuxt-i18n-micro 1.32.1 → 1.32.2
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 +6 -6
- package/dist/client/404.html +6 -6
- package/dist/client/_nuxt/{C4eGGOXV.js → CL71IQiy.js} +1 -1
- package/dist/client/_nuxt/{BARbCa2g.js → Cwq8qovn.js} +1 -1
- package/dist/client/_nuxt/{DwKyf7FR.js → DDIvEkjZ.js} +1 -1
- package/dist/client/_nuxt/De2IYGEm.js +98 -0
- package/dist/client/_nuxt/builds/latest.json +1 -1
- package/dist/client/_nuxt/builds/meta/e22a2afa-23e9-4d8d-9d9a-796ce96339fd.json +1 -0
- package/dist/client/index.html +6 -6
- package/dist/module.json +1 -1
- package/dist/module.mjs +4 -0
- package/dist/runtime/plugins/01.plugin.js +43 -31
- package/package.json +1 -1
- package/dist/client/_nuxt/CTiMIQCz.js +0 -98
- package/dist/client/_nuxt/builds/meta/f1354573-fd79-4f4c-9c07-5367d8c22fba.json +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"id":"
|
|
1
|
+
{"id":"e22a2afa-23e9-4d8d-9d9a-796ce96339fd","timestamp":1731570174097}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"id":"e22a2afa-23e9-4d8d-9d9a-796ce96339fd","timestamp":1731570174097,"matcher":{"static":{},"wildcard":{},"dynamic":{}},"prerendered":[]}
|
package/dist/client/index.html
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
<!DOCTYPE html><html data-capo=""><head><meta charset="utf-8">
|
|
2
2
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
3
3
|
<link rel="stylesheet" href="/__nuxt-i18n-micro/_nuxt/entry.BqOlM4b6.css">
|
|
4
|
-
<link rel="modulepreload" as="script" crossorigin href="/__nuxt-i18n-micro/_nuxt/
|
|
4
|
+
<link rel="modulepreload" as="script" crossorigin href="/__nuxt-i18n-micro/_nuxt/De2IYGEm.js">
|
|
5
5
|
<link rel="prefetch" as="script" crossorigin href="/__nuxt-i18n-micro/_nuxt/B6E6ObS_.js">
|
|
6
6
|
<link rel="prefetch" as="style" crossorigin href="/__nuxt-i18n-micro/_nuxt/error-404.C_4C5G96.css">
|
|
7
|
-
<link rel="prefetch" as="script" crossorigin href="/__nuxt-i18n-micro/_nuxt/
|
|
8
|
-
<link rel="prefetch" as="script" crossorigin href="/__nuxt-i18n-micro/_nuxt/
|
|
7
|
+
<link rel="prefetch" as="script" crossorigin href="/__nuxt-i18n-micro/_nuxt/DDIvEkjZ.js">
|
|
8
|
+
<link rel="prefetch" as="script" crossorigin href="/__nuxt-i18n-micro/_nuxt/CL71IQiy.js">
|
|
9
9
|
<link rel="prefetch" as="style" crossorigin href="/__nuxt-i18n-micro/_nuxt/error-500.CBAEdpZV.css">
|
|
10
|
-
<link rel="prefetch" as="script" crossorigin href="/__nuxt-i18n-micro/_nuxt/
|
|
11
|
-
<script type="module" src="/__nuxt-i18n-micro/_nuxt/
|
|
12
|
-
<script>window.__NUXT__={};window.__NUXT__.config={public:{},app:{baseURL:"/__nuxt-i18n-micro",buildId:"
|
|
10
|
+
<link rel="prefetch" as="script" crossorigin href="/__nuxt-i18n-micro/_nuxt/Cwq8qovn.js">
|
|
11
|
+
<script type="module" src="/__nuxt-i18n-micro/_nuxt/De2IYGEm.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},1731570187038,false]</script>
|
|
12
|
+
<script>window.__NUXT__={};window.__NUXT__.config={public:{},app:{baseURL:"/__nuxt-i18n-micro",buildId:"e22a2afa-23e9-4d8d-9d9a-796ce96339fd",buildAssetsDir:"/_nuxt/",cdnURL:""}}</script></body></html>
|
package/dist/module.json
CHANGED
package/dist/module.mjs
CHANGED
|
@@ -495,17 +495,20 @@ const module = defineNuxtModule({
|
|
|
495
495
|
};
|
|
496
496
|
addPlugin({
|
|
497
497
|
src: resolver.resolve("./runtime/plugins/01.plugin"),
|
|
498
|
+
name: "i18n-plugin-loader",
|
|
498
499
|
order: 0
|
|
499
500
|
});
|
|
500
501
|
if (options.meta) {
|
|
501
502
|
addPlugin({
|
|
502
503
|
src: resolver.resolve("./runtime/plugins/02.meta"),
|
|
504
|
+
name: "i18n-plugin-meta",
|
|
503
505
|
order: 2
|
|
504
506
|
});
|
|
505
507
|
}
|
|
506
508
|
if (options.define) {
|
|
507
509
|
addPlugin({
|
|
508
510
|
src: resolver.resolve("./runtime/plugins/03.define"),
|
|
511
|
+
name: "i18n-plugin-define",
|
|
509
512
|
order: 3
|
|
510
513
|
});
|
|
511
514
|
}
|
|
@@ -513,6 +516,7 @@ const module = defineNuxtModule({
|
|
|
513
516
|
addPlugin({
|
|
514
517
|
src: resolver.resolve("./runtime/plugins/04.auto-detect"),
|
|
515
518
|
mode: "server",
|
|
519
|
+
name: "i18n-plugin-auto-detect",
|
|
516
520
|
order: 4
|
|
517
521
|
});
|
|
518
522
|
}
|
|
@@ -204,14 +204,14 @@ export default defineNuxtPlugin(async (nuxtApp) => {
|
|
|
204
204
|
console.warn(`[nuxt-i18n-next] The page name is missing in the path: ${path}. Please ensure that definePageMeta({ name: 'pageName' }) is set.`);
|
|
205
205
|
return;
|
|
206
206
|
}
|
|
207
|
-
const
|
|
208
|
-
const data = await $fetch(
|
|
207
|
+
const route2 = `/${apiBaseUrl}/${fRouteName}/${locale}/data.json?v=${i18nConfig.dateBuild}`.replace(/\/{2,}/g, "/");
|
|
208
|
+
const data = await $fetch(route2, { baseURL: runtimeConfig.app.baseURL });
|
|
209
209
|
await i18nHelper.loadPageTranslations(locale, routeName, data ?? {});
|
|
210
210
|
}
|
|
211
211
|
} catch (_error) {
|
|
212
212
|
}
|
|
213
213
|
};
|
|
214
|
-
|
|
214
|
+
async function loadTranslationsForRoute(to, next) {
|
|
215
215
|
const hashLocale2 = i18nConfig.hashMode ? nuxtApp.runWithContext(() => (useCookie("hash-locale").value ?? i18nConfig.defaultLocale).toString()).toString() : null;
|
|
216
216
|
const locale = getCurrentLocale(to, i18nConfig, hashLocale2);
|
|
217
217
|
if (!i18nHelper.hasGeneralTranslation(locale)) {
|
|
@@ -229,12 +229,21 @@ export default defineNuxtPlugin(async (nuxtApp) => {
|
|
|
229
229
|
if (next) {
|
|
230
230
|
next();
|
|
231
231
|
}
|
|
232
|
+
}
|
|
233
|
+
useRouter().beforeEach(async (to, from, next) => {
|
|
234
|
+
if (to.path !== from.path) {
|
|
235
|
+
await loadTranslationsForRoute(to, next);
|
|
236
|
+
}
|
|
237
|
+
next();
|
|
232
238
|
});
|
|
239
|
+
const route = useRoute();
|
|
240
|
+
await loadTranslationsForRoute(route);
|
|
233
241
|
const getTranslation = (key, params, defaultValue) => {
|
|
234
242
|
if (!key) return "";
|
|
243
|
+
const route2 = useRoute();
|
|
235
244
|
const hashLocale2 = i18nConfig.hashMode ? (useCookie("hash-locale").value ?? i18nConfig.defaultLocale).toString() : null;
|
|
236
|
-
const locale = getCurrentLocale(
|
|
237
|
-
const routeName = getRouteName(
|
|
245
|
+
const locale = getCurrentLocale(route2, i18nConfig, hashLocale2);
|
|
246
|
+
const routeName = getRouteName(route2, locale);
|
|
238
247
|
let value = i18nHelper.getTranslation(locale, routeName, key);
|
|
239
248
|
if (!value) {
|
|
240
249
|
if (isDev && import.meta.client) {
|
|
@@ -259,9 +268,9 @@ export default defineNuxtPlugin(async (nuxtApp) => {
|
|
|
259
268
|
getLocaleName: () => getCurrentName(useRoute(), i18nConfig, hashLocale),
|
|
260
269
|
defaultLocale: () => i18nConfig.defaultLocale,
|
|
261
270
|
getLocales: () => i18nConfig.locales || [],
|
|
262
|
-
getRouteName: (
|
|
271
|
+
getRouteName: (route2, locale) => {
|
|
263
272
|
const selectedLocale = locale ?? getCurrentLocale(useRoute(), i18nConfig, hashLocale);
|
|
264
|
-
const selectedRoute =
|
|
273
|
+
const selectedRoute = route2 ?? useRoute();
|
|
265
274
|
return getRouteName(selectedRoute, selectedLocale);
|
|
266
275
|
},
|
|
267
276
|
t: getTranslation,
|
|
@@ -270,43 +279,46 @@ export default defineNuxtPlugin(async (nuxtApp) => {
|
|
|
270
279
|
return value?.toString() ?? defaultValue ?? key;
|
|
271
280
|
},
|
|
272
281
|
tc: (key, count, defaultValue) => {
|
|
273
|
-
const
|
|
282
|
+
const route2 = useRoute();
|
|
283
|
+
const currentLocale = getCurrentLocale(route2, i18nConfig, hashLocale);
|
|
274
284
|
return plural(key, count, currentLocale, getTranslation) ?? defaultValue ?? key;
|
|
275
285
|
},
|
|
276
286
|
tn: (value, options) => {
|
|
277
|
-
const
|
|
287
|
+
const route2 = useRoute();
|
|
288
|
+
const locale = getCurrentLocale(route2, i18nConfig, hashLocale);
|
|
278
289
|
return formatNumber(value, locale, options);
|
|
279
290
|
},
|
|
280
291
|
td: (value, options) => {
|
|
281
|
-
const
|
|
292
|
+
const route2 = useRoute();
|
|
293
|
+
const locale = getCurrentLocale(route2, i18nConfig, hashLocale);
|
|
282
294
|
return formatDate(value, locale, options);
|
|
283
295
|
},
|
|
284
296
|
has: (key) => {
|
|
285
297
|
return !!getTranslation(key);
|
|
286
298
|
},
|
|
287
299
|
mergeTranslations: (newTranslations) => {
|
|
288
|
-
const
|
|
289
|
-
const locale = getCurrentLocale(
|
|
290
|
-
const routeName = getRouteName(
|
|
300
|
+
const route2 = useRoute();
|
|
301
|
+
const locale = getCurrentLocale(route2, i18nConfig, hashLocale);
|
|
302
|
+
const routeName = getRouteName(route2, locale);
|
|
291
303
|
i18nHelper.mergeTranslation(locale, routeName, newTranslations);
|
|
292
304
|
},
|
|
293
305
|
switchLocaleRoute: (toLocale) => {
|
|
294
306
|
const router = useRouter();
|
|
295
|
-
const
|
|
296
|
-
const fromLocale = getCurrentLocale(
|
|
307
|
+
const route2 = useRoute();
|
|
308
|
+
const fromLocale = getCurrentLocale(route2, i18nConfig, hashLocale);
|
|
297
309
|
if (i18nConfig.hashMode) {
|
|
298
310
|
hashLocale = toLocale;
|
|
299
311
|
}
|
|
300
|
-
return switchLocaleRoute(fromLocale, toLocale,
|
|
312
|
+
return switchLocaleRoute(fromLocale, toLocale, route2, router, i18nConfig, i18nRouteParams.value);
|
|
301
313
|
},
|
|
302
314
|
switchLocalePath: (toLocale) => {
|
|
303
315
|
const router = useRouter();
|
|
304
|
-
const
|
|
305
|
-
const fromLocale = getCurrentLocale(
|
|
316
|
+
const route2 = useRoute();
|
|
317
|
+
const fromLocale = getCurrentLocale(route2, i18nConfig, hashLocale);
|
|
306
318
|
if (i18nConfig.hashMode) {
|
|
307
319
|
hashLocale = toLocale;
|
|
308
320
|
}
|
|
309
|
-
const localeRoute = switchLocaleRoute(fromLocale, toLocale,
|
|
321
|
+
const localeRoute = switchLocaleRoute(fromLocale, toLocale, route2, router, i18nConfig, i18nRouteParams.value);
|
|
310
322
|
if (typeof localeRoute === "string") {
|
|
311
323
|
return localeRoute;
|
|
312
324
|
}
|
|
@@ -317,33 +329,33 @@ export default defineNuxtPlugin(async (nuxtApp) => {
|
|
|
317
329
|
},
|
|
318
330
|
switchLocale: (toLocale) => {
|
|
319
331
|
const router = useRouter();
|
|
320
|
-
const
|
|
321
|
-
const fromLocale = getCurrentLocale(
|
|
332
|
+
const route2 = useRoute();
|
|
333
|
+
const fromLocale = getCurrentLocale(route2, i18nConfig, hashLocale);
|
|
322
334
|
if (i18nConfig.hashMode) {
|
|
323
335
|
hashLocale = toLocale;
|
|
324
336
|
}
|
|
325
|
-
switchLocale(fromLocale, toLocale,
|
|
337
|
+
switchLocale(fromLocale, toLocale, route2, router, i18nConfig, i18nRouteParams.value);
|
|
326
338
|
},
|
|
327
|
-
switchRoute: (
|
|
339
|
+
switchRoute: (route2, toLocale) => {
|
|
328
340
|
const router = useRouter();
|
|
329
|
-
if (typeof
|
|
330
|
-
|
|
341
|
+
if (typeof route2 === "string") {
|
|
342
|
+
route2 = router.resolve(route2);
|
|
331
343
|
}
|
|
332
|
-
const fromLocale = getCurrentLocale(
|
|
344
|
+
const fromLocale = getCurrentLocale(route2, i18nConfig, hashLocale);
|
|
333
345
|
if (i18nConfig.hashMode) {
|
|
334
346
|
hashLocale = toLocale ?? fromLocale;
|
|
335
347
|
}
|
|
336
|
-
switchLocale(fromLocale, toLocale ?? fromLocale,
|
|
348
|
+
switchLocale(fromLocale, toLocale ?? fromLocale, route2, router, i18nConfig, i18nRouteParams.value);
|
|
337
349
|
},
|
|
338
350
|
localeRoute: (to, locale) => {
|
|
339
351
|
const router = useRouter();
|
|
340
|
-
const
|
|
341
|
-
return getLocalizedRoute(to, router,
|
|
352
|
+
const route2 = useRoute();
|
|
353
|
+
return getLocalizedRoute(to, router, route2, i18nConfig, locale, hashLocale);
|
|
342
354
|
},
|
|
343
355
|
localePath: (to, locale) => {
|
|
344
356
|
const router = useRouter();
|
|
345
|
-
const
|
|
346
|
-
const localeRoute = getLocalizedRoute(to, router,
|
|
357
|
+
const route2 = useRoute();
|
|
358
|
+
const localeRoute = getLocalizedRoute(to, router, route2, i18nConfig, locale, hashLocale);
|
|
347
359
|
if (typeof localeRoute === "string") {
|
|
348
360
|
return localeRoute;
|
|
349
361
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nuxt-i18n-micro",
|
|
3
|
-
"version": "1.32.
|
|
3
|
+
"version": "1.32.2",
|
|
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",
|