nuxt-i18n-micro 1.76.2 → 1.77.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.
@@ -8,5 +8,5 @@
8
8
  <link rel="prefetch" as="script" crossorigin href="/__NUXT_DEVTOOLS_I18N_BASE__/_nuxt/BBbCCCx2.js">
9
9
  <link rel="prefetch" as="style" crossorigin href="/__NUXT_DEVTOOLS_I18N_BASE__/_nuxt/error-500.BRj5A2lo.css">
10
10
  <link rel="prefetch" as="script" crossorigin href="/__NUXT_DEVTOOLS_I18N_BASE__/_nuxt/CfVvufsh.js">
11
- <script type="module" src="/__NUXT_DEVTOOLS_I18N_BASE__/_nuxt/MjlAM4Ld.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},1740125086428,false]</script>
12
- <script>window.__NUXT__={};window.__NUXT__.config={public:{},app:{baseURL:"/__NUXT_DEVTOOLS_I18N_BASE__/",buildId:"2a345ec3-0b90-4491-9f47-af97b802c9e1",buildAssetsDir:"/_nuxt/",cdnURL:""}}</script></body></html>
11
+ <script type="module" src="/__NUXT_DEVTOOLS_I18N_BASE__/_nuxt/MjlAM4Ld.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},1740841447828,false]</script>
12
+ <script>window.__NUXT__={};window.__NUXT__.config={public:{},app:{baseURL:"/__NUXT_DEVTOOLS_I18N_BASE__/",buildId:"dfc609ef-3316-44b5-8bc8-dfbef0eb51b8",buildAssetsDir:"/_nuxt/",cdnURL:""}}</script></body></html>
@@ -8,5 +8,5 @@
8
8
  <link rel="prefetch" as="script" crossorigin href="/__NUXT_DEVTOOLS_I18N_BASE__/_nuxt/BBbCCCx2.js">
9
9
  <link rel="prefetch" as="style" crossorigin href="/__NUXT_DEVTOOLS_I18N_BASE__/_nuxt/error-500.BRj5A2lo.css">
10
10
  <link rel="prefetch" as="script" crossorigin href="/__NUXT_DEVTOOLS_I18N_BASE__/_nuxt/CfVvufsh.js">
11
- <script type="module" src="/__NUXT_DEVTOOLS_I18N_BASE__/_nuxt/MjlAM4Ld.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},1740125086428,false]</script>
12
- <script>window.__NUXT__={};window.__NUXT__.config={public:{},app:{baseURL:"/__NUXT_DEVTOOLS_I18N_BASE__/",buildId:"2a345ec3-0b90-4491-9f47-af97b802c9e1",buildAssetsDir:"/_nuxt/",cdnURL:""}}</script></body></html>
11
+ <script type="module" src="/__NUXT_DEVTOOLS_I18N_BASE__/_nuxt/MjlAM4Ld.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},1740841447828,false]</script>
12
+ <script>window.__NUXT__={};window.__NUXT__.config={public:{},app:{baseURL:"/__NUXT_DEVTOOLS_I18N_BASE__/",buildId:"dfc609ef-3316-44b5-8bc8-dfbef0eb51b8",buildAssetsDir:"/_nuxt/",cdnURL:""}}</script></body></html>
@@ -1 +1 @@
1
- {"id":"2a345ec3-0b90-4491-9f47-af97b802c9e1","timestamp":1740125077860}
1
+ {"id":"dfc609ef-3316-44b5-8bc8-dfbef0eb51b8","timestamp":1740841440158}
@@ -0,0 +1 @@
1
+ {"id":"dfc609ef-3316-44b5-8bc8-dfbef0eb51b8","timestamp":1740841440158,"matcher":{"static":{},"wildcard":{},"dynamic":{}},"prerendered":[]}
@@ -8,5 +8,5 @@
8
8
  <link rel="prefetch" as="script" crossorigin href="/__NUXT_DEVTOOLS_I18N_BASE__/_nuxt/BBbCCCx2.js">
9
9
  <link rel="prefetch" as="style" crossorigin href="/__NUXT_DEVTOOLS_I18N_BASE__/_nuxt/error-500.BRj5A2lo.css">
10
10
  <link rel="prefetch" as="script" crossorigin href="/__NUXT_DEVTOOLS_I18N_BASE__/_nuxt/CfVvufsh.js">
11
- <script type="module" src="/__NUXT_DEVTOOLS_I18N_BASE__/_nuxt/MjlAM4Ld.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},1740125086428,false]</script>
12
- <script>window.__NUXT__={};window.__NUXT__.config={public:{},app:{baseURL:"/__NUXT_DEVTOOLS_I18N_BASE__/",buildId:"2a345ec3-0b90-4491-9f47-af97b802c9e1",buildAssetsDir:"/_nuxt/",cdnURL:""}}</script></body></html>
11
+ <script type="module" src="/__NUXT_DEVTOOLS_I18N_BASE__/_nuxt/MjlAM4Ld.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},1740841447828,false]</script>
12
+ <script>window.__NUXT__={};window.__NUXT__.config={public:{},app:{baseURL:"/__NUXT_DEVTOOLS_I18N_BASE__/",buildId:"dfc609ef-3316-44b5-8bc8-dfbef0eb51b8",buildAssetsDir:"/_nuxt/",cdnURL:""}}</script></body></html>
package/dist/module.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "nuxt-i18n-micro",
3
3
  "configKey": "i18n",
4
- "version": "1.76.2",
4
+ "version": "1.77.0",
5
5
  "builder": {
6
6
  "@nuxt/module-builder": "0.8.4",
7
7
  "unbuild": "2.0.0"
package/dist/module.mjs CHANGED
@@ -120,10 +120,12 @@ class PageManager {
120
120
  localizedPaths = {};
121
121
  activeLocaleCodes;
122
122
  globalLocaleRoutes;
123
- constructor(locales, defaultLocaleCode, strategy, globalLocaleRoutes) {
123
+ noPrefixRedirect;
124
+ constructor(locales, defaultLocaleCode, strategy, globalLocaleRoutes, noPrefixRedirect) {
124
125
  this.locales = locales;
125
126
  this.defaultLocale = this.findLocaleByCode(defaultLocaleCode) || { code: defaultLocaleCode };
126
127
  this.strategy = strategy;
128
+ this.noPrefixRedirect = noPrefixRedirect;
127
129
  this.activeLocaleCodes = this.computeActiveLocaleCodes();
128
130
  this.globalLocaleRoutes = globalLocaleRoutes || {};
129
131
  }
@@ -197,8 +199,11 @@ class PageManager {
197
199
  const isDefaultLocale = isLocaleDefault(locale, this.defaultLocale, isPrefixStrategy(this.strategy));
198
200
  if (isNoPrefixStrategy(this.strategy)) {
199
201
  const newRoute = this.createLocalizedRoute(page, [locale.code], page.children ?? [], true, customPath, customRegex);
200
- if (newRoute)
202
+ if (newRoute) {
201
203
  additionalRoutes.push(newRoute);
204
+ if (this.noPrefixRedirect && isNoPrefixStrategy(this.strategy))
205
+ page.redirect = newRoute.path;
206
+ }
202
207
  } else {
203
208
  if (isDefaultLocale) {
204
209
  page.path = normalizePath(customPath);
@@ -271,6 +276,8 @@ class PageManager {
271
276
  const newRoute = this.createLocalizedRoute(page, [locale.code], originalChildren, true, customPath, customRegex);
272
277
  if (newRoute)
273
278
  additionalRoutes.push(newRoute);
279
+ if (this.noPrefixRedirect && isNoPrefixStrategy(this.strategy) && newRoute)
280
+ page.redirect = newRoute.path;
274
281
  }
275
282
  if (isPrefixAndDefaultStrategy(this.strategy) && locale === this.defaultLocale) {
276
283
  const newRoute = this.createLocalizedRoute(page, [locale.code], originalChildren, true, customPath, customRegex, true);
@@ -416,6 +423,7 @@ const module = defineNuxtModule({
416
423
  disablePageLocales: false,
417
424
  disableWatcher: false,
418
425
  disableUpdater: false,
426
+ noPrefixRedirect: false,
419
427
  includeDefaultLocaleRoute: void 0,
420
428
  fallbackLocale: void 0,
421
429
  localeCookie: "user-locale",
@@ -448,7 +456,7 @@ const module = defineNuxtModule({
448
456
  const resolver = createResolver(import.meta.url);
449
457
  const rootDirs = nuxt.options._layers.map((layer) => layer.config.rootDir).reverse();
450
458
  const localeManager = new LocaleManager(options, rootDirs);
451
- const pageManager = new PageManager(localeManager.locales, defaultLocale, options.strategy, options.globalLocaleRoutes);
459
+ const pageManager = new PageManager(localeManager.locales, defaultLocale, options.strategy, options.globalLocaleRoutes, options.noPrefixRedirect);
452
460
  addTemplate({
453
461
  filename: "i18n.plural.mjs",
454
462
  write: true,
@@ -166,9 +166,14 @@ export default defineNuxtPlugin(async (nuxtApp) => {
166
166
  if (typeof localeRoute === "string") {
167
167
  return localeRoute;
168
168
  }
169
- if ("fullPath" in localeRoute) {
169
+ if ("fullPath" in localeRoute && localeRoute.fullPath) {
170
170
  return localeRoute.fullPath;
171
171
  }
172
+ if ("name" in localeRoute && localeRoute.name) {
173
+ if (router.hasRoute(localeRoute.name)) {
174
+ return router.resolve(localeRoute).fullPath;
175
+ }
176
+ }
172
177
  return "";
173
178
  },
174
179
  switchLocale: (toLocale) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nuxt-i18n-micro",
3
- "version": "1.76.2",
3
+ "version": "1.77.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",
@@ -59,9 +59,9 @@
59
59
  "globby": "^14.1.0",
60
60
  "sirv": "^2.0.4",
61
61
  "ufo": "^1.5.4",
62
+ "nuxt-i18n-micro-test-utils": "1.0.6",
62
63
  "nuxt-i18n-micro-core": "1.0.17",
63
- "nuxt-i18n-micro-types": "1.0.1",
64
- "nuxt-i18n-micro-test-utils": "1.0.6"
64
+ "nuxt-i18n-micro-types": "1.0.2"
65
65
  },
66
66
  "devDependencies": {
67
67
  "@nuxt/devtools": "^2.1.0",
@@ -1 +0,0 @@
1
- {"id":"2a345ec3-0b90-4491-9f47-af97b802c9e1","timestamp":1740125077860,"matcher":{"static":{},"wildcard":{},"dynamic":{}},"prerendered":[]}