nuxt-i18n-micro 1.60.0 → 1.61.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/EwNUkbJF.js">
9
9
  <link rel="prefetch" as="style" crossorigin href="/__NUXT_DEVTOOLS_I18N_BASE__/_nuxt/error-500.C2JGrgZX.css">
10
10
  <link rel="prefetch" as="script" crossorigin href="/__NUXT_DEVTOOLS_I18N_BASE__/_nuxt/DuZjM2Ym.js">
11
- <script type="module" src="/__NUXT_DEVTOOLS_I18N_BASE__/_nuxt/C9njAg9E.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},1736853592172,false]</script>
12
- <script>window.__NUXT__={};window.__NUXT__.config={public:{},app:{baseURL:"/__NUXT_DEVTOOLS_I18N_BASE__/",buildId:"1bc37d11-ac0a-4cf4-9f49-6f1123ca70df",buildAssetsDir:"/_nuxt/",cdnURL:""}}</script></body></html>
11
+ <script type="module" src="/__NUXT_DEVTOOLS_I18N_BASE__/_nuxt/C9njAg9E.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},1736953870972,false]</script>
12
+ <script>window.__NUXT__={};window.__NUXT__.config={public:{},app:{baseURL:"/__NUXT_DEVTOOLS_I18N_BASE__/",buildId:"019df560-5b4f-4d25-8ca1-a8cad935e3d2",buildAssetsDir:"/_nuxt/",cdnURL:""}}</script></body></html>
@@ -8,5 +8,5 @@
8
8
  <link rel="prefetch" as="script" crossorigin href="/__NUXT_DEVTOOLS_I18N_BASE__/_nuxt/EwNUkbJF.js">
9
9
  <link rel="prefetch" as="style" crossorigin href="/__NUXT_DEVTOOLS_I18N_BASE__/_nuxt/error-500.C2JGrgZX.css">
10
10
  <link rel="prefetch" as="script" crossorigin href="/__NUXT_DEVTOOLS_I18N_BASE__/_nuxt/DuZjM2Ym.js">
11
- <script type="module" src="/__NUXT_DEVTOOLS_I18N_BASE__/_nuxt/C9njAg9E.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},1736853592173,false]</script>
12
- <script>window.__NUXT__={};window.__NUXT__.config={public:{},app:{baseURL:"/__NUXT_DEVTOOLS_I18N_BASE__/",buildId:"1bc37d11-ac0a-4cf4-9f49-6f1123ca70df",buildAssetsDir:"/_nuxt/",cdnURL:""}}</script></body></html>
11
+ <script type="module" src="/__NUXT_DEVTOOLS_I18N_BASE__/_nuxt/C9njAg9E.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},1736953870973,false]</script>
12
+ <script>window.__NUXT__={};window.__NUXT__.config={public:{},app:{baseURL:"/__NUXT_DEVTOOLS_I18N_BASE__/",buildId:"019df560-5b4f-4d25-8ca1-a8cad935e3d2",buildAssetsDir:"/_nuxt/",cdnURL:""}}</script></body></html>
@@ -1 +1 @@
1
- {"id":"1bc37d11-ac0a-4cf4-9f49-6f1123ca70df","timestamp":1736853586767}
1
+ {"id":"019df560-5b4f-4d25-8ca1-a8cad935e3d2","timestamp":1736953866014}
@@ -0,0 +1 @@
1
+ {"id":"019df560-5b4f-4d25-8ca1-a8cad935e3d2","timestamp":1736953866014,"matcher":{"static":{},"wildcard":{},"dynamic":{}},"prerendered":[]}
@@ -8,5 +8,5 @@
8
8
  <link rel="prefetch" as="script" crossorigin href="/__NUXT_DEVTOOLS_I18N_BASE__/_nuxt/EwNUkbJF.js">
9
9
  <link rel="prefetch" as="style" crossorigin href="/__NUXT_DEVTOOLS_I18N_BASE__/_nuxt/error-500.C2JGrgZX.css">
10
10
  <link rel="prefetch" as="script" crossorigin href="/__NUXT_DEVTOOLS_I18N_BASE__/_nuxt/DuZjM2Ym.js">
11
- <script type="module" src="/__NUXT_DEVTOOLS_I18N_BASE__/_nuxt/C9njAg9E.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},1736853592173,false]</script>
12
- <script>window.__NUXT__={};window.__NUXT__.config={public:{},app:{baseURL:"/__NUXT_DEVTOOLS_I18N_BASE__/",buildId:"1bc37d11-ac0a-4cf4-9f49-6f1123ca70df",buildAssetsDir:"/_nuxt/",cdnURL:""}}</script></body></html>
11
+ <script type="module" src="/__NUXT_DEVTOOLS_I18N_BASE__/_nuxt/C9njAg9E.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},1736953870973,false]</script>
12
+ <script>window.__NUXT__={};window.__NUXT__.config={public:{},app:{baseURL:"/__NUXT_DEVTOOLS_I18N_BASE__/",buildId:"019df560-5b4f-4d25-8ca1-a8cad935e3d2",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.60.0",
4
+ "version": "1.61.0",
5
5
  "builder": {
6
6
  "@nuxt/module-builder": "0.8.4",
7
7
  "unbuild": "2.0.0"
package/dist/module.mjs CHANGED
@@ -134,8 +134,8 @@ class PageManager {
134
134
  computeActiveLocaleCodes() {
135
135
  return this.locales.filter((locale) => locale.code !== this.defaultLocale.code || isPrefixAndDefaultStrategy(this.strategy) || isPrefixStrategy(this.strategy)).map((locale) => locale.code);
136
136
  }
137
- extendPages(pages, rootDir, customRegex, isCloudflarePages) {
138
- this.localizedPaths = this.extractLocalizedPaths(pages, rootDir);
137
+ extendPages(pages, customRegex, isCloudflarePages) {
138
+ this.localizedPaths = this.extractLocalizedPaths(pages);
139
139
  const additionalRoutes = [];
140
140
  pages.forEach((page) => {
141
141
  if (!page.name) {
@@ -165,16 +165,15 @@ class PageManager {
165
165
  }
166
166
  pages.push(...additionalRoutes);
167
167
  }
168
- extractLocalizedPaths(pages, rootDir, parentPath = "") {
168
+ extractLocalizedPaths(pages, parentPath = "") {
169
169
  const localizedPaths = {};
170
170
  pages.forEach((page) => {
171
171
  const pageName = buildRouteNameFromRoute(page.name, page.path);
172
172
  const globalLocalePath = this.globalLocaleRoutes[pageName];
173
173
  if (!globalLocalePath) {
174
174
  if (page.file) {
175
- const filePath = path.resolve(rootDir, page.file);
176
- const fileContent = readFileSync(filePath, "utf-8");
177
- const localeRoutes = extractLocaleRoutes(fileContent, filePath);
175
+ const fileContent = readFileSync(page.file, "utf-8");
176
+ const localeRoutes = extractLocaleRoutes(fileContent, page.file);
178
177
  if (localeRoutes) {
179
178
  const normalizedFullPath = normalizePath(path.join(parentPath, page.path));
180
179
  localizedPaths[normalizedFullPath] = localeRoutes;
@@ -186,7 +185,7 @@ class PageManager {
186
185
  }
187
186
  if (page.children?.length) {
188
187
  const parentFullPath = normalizePath(path.join(parentPath, page.path));
189
- Object.assign(localizedPaths, this.extractLocalizedPaths(page.children, rootDir, parentFullPath));
188
+ Object.assign(localizedPaths, this.extractLocalizedPaths(page.children, parentFullPath));
190
189
  }
191
190
  });
192
191
  return localizedPaths;
@@ -527,7 +526,7 @@ const module = defineNuxtModule({
527
526
  if (!options.disableWatcher) {
528
527
  localeManager.ensureTranslationFilesExist(pagesNames, options.translationDir, nuxt.options.rootDir);
529
528
  }
530
- pageManager.extendPages(pages, nuxt.options.rootDir, options.customRegexMatcher, isCloudflarePages);
529
+ pageManager.extendPages(pages, options.customRegexMatcher, isCloudflarePages);
531
530
  if (isPrefixStrategy(options.strategy) && !isCloudflarePages) {
532
531
  const fallbackRoute = {
533
532
  path: "/:pathMatch(.*)*",
@@ -15,6 +15,7 @@ export function useI18n() {
15
15
  $has: nuxtApp.$has,
16
16
  $tc: nuxtApp.$tc,
17
17
  $mergeTranslations: nuxtApp.$mergeTranslations,
18
+ $mergeGlobalTranslations: nuxtApp.$mergeGlobalTranslations,
18
19
  $setI18nRouteParams: nuxtApp.$setI18nRouteParams,
19
20
  $switchLocaleRoute: nuxtApp.$switchLocaleRoute,
20
21
  $switchLocalePath: nuxtApp.$switchLocalePath,
@@ -17,6 +17,7 @@ declare const _default: import("nuxt/app").Plugin<{
17
17
  tdr(value: Date | number | string, options?: Intl.RelativeTimeFormatOptions): string;
18
18
  has: (key: string) => boolean;
19
19
  mergeTranslations: (newTranslations: Translations) => void;
20
+ mergeGlobalTranslations: (newTranslations: Translations) => void;
20
21
  switchLocaleRoute: (toLocale: string) => string | import("vue-router").RouteLocationAsRelativeGeneric | import("vue-router").RouteLocationAsPathGeneric;
21
22
  switchLocalePath: (toLocale: string) => string;
22
23
  switchLocale: (toLocale: string) => void;
@@ -40,6 +41,7 @@ declare const _default: import("nuxt/app").Plugin<{
40
41
  tdr(value: Date | number | string, options?: Intl.RelativeTimeFormatOptions): string;
41
42
  has: (key: string) => boolean;
42
43
  mergeTranslations: (newTranslations: Translations) => void;
44
+ mergeGlobalTranslations: (newTranslations: Translations) => void;
43
45
  switchLocaleRoute: (toLocale: string) => string | import("vue-router").RouteLocationAsRelativeGeneric | import("vue-router").RouteLocationAsPathGeneric;
44
46
  switchLocalePath: (toLocale: string) => string;
45
47
  switchLocale: (toLocale: string) => void;
@@ -63,6 +65,7 @@ export interface PluginsInjections {
63
65
  $tdr: (value: Date | number | string, options?: Intl.DateTimeFormatOptions) => string;
64
66
  $has: (key: string) => boolean;
65
67
  $mergeTranslations: (newTranslations: Translations) => void;
68
+ $mergeGlobalTranslations: (newTranslations: Translations) => void;
66
69
  $switchLocaleRoute: (locale: string) => RouteLocationRaw;
67
70
  $switchLocalePath: (locale: string) => string;
68
71
  $switchLocale: (locale: string) => void;
@@ -355,6 +355,9 @@ export default defineNuxtPlugin(async (nuxtApp) => {
355
355
  const routeName = getRouteName(route2, locale);
356
356
  i18nHelper.mergeTranslation(routeName, newTranslations);
357
357
  },
358
+ mergeGlobalTranslations: (newTranslations) => {
359
+ i18nHelper.mergeGlobalTranslation(newTranslations, true);
360
+ },
358
361
  switchLocaleRoute: (toLocale) => {
359
362
  const route2 = router.currentRoute.value;
360
363
  return switchLocaleRoute(i18nHelper.getLocale(), toLocale, route2, router, i18nConfig, i18nRouteParams.value);
@@ -54,8 +54,8 @@ export default defineNuxtPlugin(async (_nuxtApp) => {
54
54
  if (Object.values(normalizedLocales).length) {
55
55
  if (normalizedLocales[currentLocale]) {
56
56
  const translation = normalizedLocales[currentLocale];
57
- const { $mergeTranslations } = useNuxtApp();
58
- $mergeTranslations(translation);
57
+ const { $mergeGlobalTranslations } = useNuxtApp();
58
+ $mergeGlobalTranslations(translation);
59
59
  }
60
60
  if (!normalizedLocales[currentLocale]) {
61
61
  let defaultRouteName = route.name?.toString().replace("localized-", "").replace(new RegExp(`-${currentLocale}$`), "");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nuxt-i18n-micro",
3
- "version": "1.60.0",
3
+ "version": "1.61.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",
@@ -1 +0,0 @@
1
- {"id":"1bc37d11-ac0a-4cf4-9f49-6f1123ca70df","timestamp":1736853586767,"matcher":{"static":{},"wildcard":{},"dynamic":{}},"prerendered":[]}