nuxt-i18n-micro 1.75.0 → 1.76.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},1739876373759,false]</script>
12
- <script>window.__NUXT__={};window.__NUXT__.config={public:{},app:{baseURL:"/__NUXT_DEVTOOLS_I18N_BASE__/",buildId:"6e721518-e515-4ebe-94b1-8e87429f4025",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},1739981286478,false]</script>
12
+ <script>window.__NUXT__={};window.__NUXT__.config={public:{},app:{baseURL:"/__NUXT_DEVTOOLS_I18N_BASE__/",buildId:"38589fcc-d716-4bad-b71f-acbb6a83596c",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},1739876373759,false]</script>
12
- <script>window.__NUXT__={};window.__NUXT__.config={public:{},app:{baseURL:"/__NUXT_DEVTOOLS_I18N_BASE__/",buildId:"6e721518-e515-4ebe-94b1-8e87429f4025",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},1739981286479,false]</script>
12
+ <script>window.__NUXT__={};window.__NUXT__.config={public:{},app:{baseURL:"/__NUXT_DEVTOOLS_I18N_BASE__/",buildId:"38589fcc-d716-4bad-b71f-acbb6a83596c",buildAssetsDir:"/_nuxt/",cdnURL:""}}</script></body></html>
@@ -1 +1 @@
1
- {"id":"6e721518-e515-4ebe-94b1-8e87429f4025","timestamp":1739876368439}
1
+ {"id":"38589fcc-d716-4bad-b71f-acbb6a83596c","timestamp":1739981280984}
@@ -0,0 +1 @@
1
+ {"id":"38589fcc-d716-4bad-b71f-acbb6a83596c","timestamp":1739981280984,"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},1739876373760,false]</script>
12
- <script>window.__NUXT__={};window.__NUXT__.config={public:{},app:{baseURL:"/__NUXT_DEVTOOLS_I18N_BASE__/",buildId:"6e721518-e515-4ebe-94b1-8e87429f4025",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},1739981286479,false]</script>
12
+ <script>window.__NUXT__={};window.__NUXT__.config={public:{},app:{baseURL:"/__NUXT_DEVTOOLS_I18N_BASE__/",buildId:"38589fcc-d716-4bad-b71f-acbb6a83596c",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.75.0",
4
+ "version": "1.76.0",
5
5
  "builder": {
6
6
  "@nuxt/module-builder": "0.8.4",
7
7
  "unbuild": "2.0.0"
package/dist/module.mjs CHANGED
@@ -3,7 +3,7 @@ import * as fs from 'node:fs';
3
3
  import fs__default, { readFileSync, existsSync, mkdirSync, writeFileSync } from 'node:fs';
4
4
  import { useNuxt, defineNuxtModule, useLogger, createResolver, addTemplate, addImportsDir, addPlugin, addServerHandler, addComponentsDir, addTypeTemplate, extendPages, addPrerenderRoutes } from '@nuxt/kit';
5
5
  import { watch } from 'chokidar';
6
- import { isPrefixAndDefaultStrategy, isPrefixStrategy, isNoPrefixStrategy, withPrefixStrategy } from 'nuxt-i18n-micro-core';
6
+ import { isPrefixAndDefaultStrategy, isPrefixStrategy, isNoPrefixStrategy, isPrefixExceptDefaultStrategy, withPrefixStrategy } from 'nuxt-i18n-micro-core';
7
7
  import { fileURLToPath } from 'node:url';
8
8
  import { onDevToolsInitialized, extendServerRpc } from '@nuxt/devtools-kit';
9
9
  import sirv from 'sirv';
@@ -463,7 +463,7 @@ const module = defineNuxtModule({
463
463
  defaultLocale,
464
464
  localeCookie: options.localeCookie ?? "user-locale",
465
465
  autoDetectPath: options.autoDetectPath ?? "/",
466
- strategy: options.strategy ?? "no_prefix",
466
+ strategy: options.strategy ?? "prefix_except_default",
467
467
  // eslint-disable-next-line @typescript-eslint/ban-ts-comment
468
468
  // @ts-ignore
469
469
  routesLocaleLinks: options.routesLocaleLinks ?? {},
@@ -532,7 +532,7 @@ const module = defineNuxtModule({
532
532
  route: `/${apiBaseUrl}/:page/:locale/data.json`,
533
533
  handler: resolver.resolve("./runtime/server/routes/get")
534
534
  });
535
- await addComponentsDir({
535
+ addComponentsDir({
536
536
  path: resolver.resolve("./runtime/components"),
537
537
  pathPrefix: false,
538
538
  extensions: ["vue"]
@@ -609,6 +609,34 @@ const module = defineNuxtModule({
609
609
  imports: ["useTranslationServerMiddleware"]
610
610
  });
611
611
  }
612
+ const routeRules = nuxt.options.routeRules || {};
613
+ const strategy = options.strategy;
614
+ if (routeRules && Object.keys(routeRules).length && !isNoPrefixStrategy(strategy)) {
615
+ nitroConfig.routeRules = nitroConfig.routeRules || {};
616
+ for (const [originalPath, ruleValue] of Object.entries(routeRules)) {
617
+ if (originalPath.startsWith("/api"))
618
+ continue;
619
+ localeManager.locales.forEach((localeObj) => {
620
+ const localeCode = localeObj.code;
621
+ const isDefaultLocale = localeCode === defaultLocale;
622
+ const skip = (isPrefixExceptDefaultStrategy(strategy) || isPrefixAndDefaultStrategy(strategy)) && isDefaultLocale;
623
+ if (skip) {
624
+ return;
625
+ }
626
+ const suffix = originalPath === "/" ? "" : originalPath;
627
+ const localizedPath = `/${localeCode}${suffix}`;
628
+ nitroConfig.routeRules = nitroConfig.routeRules || {};
629
+ nitroConfig.routeRules[localizedPath] = {
630
+ ...nitroConfig.routeRules[localizedPath],
631
+ ...ruleValue
632
+ };
633
+ if (typeof ruleValue.redirect === "string") {
634
+ nitroConfig.routeRules[localizedPath].redirect = `/${localeCode}${ruleValue.redirect}`;
635
+ }
636
+ logger.debug(`Replicated routeRule for ${localizedPath}: ${JSON.stringify(ruleValue)}`);
637
+ });
638
+ }
639
+ }
612
640
  if (isNoPrefixStrategy(options.strategy)) {
613
641
  return;
614
642
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nuxt-i18n-micro",
3
- "version": "1.75.0",
3
+ "version": "1.76.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",
@@ -60,8 +60,8 @@
60
60
  "sirv": "^2.0.4",
61
61
  "ufo": "^1.5.4",
62
62
  "nuxt-i18n-micro-core": "1.0.17",
63
- "nuxt-i18n-micro-test-utils": "1.0.6",
64
- "nuxt-i18n-micro-types": "1.0.1"
63
+ "nuxt-i18n-micro-types": "1.0.1",
64
+ "nuxt-i18n-micro-test-utils": "1.0.6"
65
65
  },
66
66
  "devDependencies": {
67
67
  "@nuxt/devtools": "^2.1.0",
@@ -1 +0,0 @@
1
- {"id":"6e721518-e515-4ebe-94b1-8e87429f4025","timestamp":1739876368439,"matcher":{"static":{},"wildcard":{},"dynamic":{}},"prerendered":[]}