nuxt-i18n-micro 1.59.1 → 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},1736852822644,false]</script>
12
- <script>window.__NUXT__={};window.__NUXT__.config={public:{},app:{baseURL:"/__NUXT_DEVTOOLS_I18N_BASE__/",buildId:"569329fc-a258-4243-a57f-6857e7d94336",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},1736852822644,false]</script>
12
- <script>window.__NUXT__={};window.__NUXT__.config={public:{},app:{baseURL:"/__NUXT_DEVTOOLS_I18N_BASE__/",buildId:"569329fc-a258-4243-a57f-6857e7d94336",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":"569329fc-a258-4243-a57f-6857e7d94336","timestamp":1736852817464}
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},1736852822644,false]</script>
12
- <script>window.__NUXT__={};window.__NUXT__.config={public:{},app:{baseURL:"/__NUXT_DEVTOOLS_I18N_BASE__/",buildId:"569329fc-a258-4243-a57f-6857e7d94336",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.d.mts CHANGED
@@ -1,7 +1,7 @@
1
1
  import * as _nuxt_schema from '@nuxt/schema';
2
2
  import { HookResult } from '@nuxt/schema';
3
- import { M as ModulePrivateOptionsExtend, b as ModuleOptionsExtend, c as ModuleOptions } from './shared/nuxt-i18n-micro.4444721d.mjs';
4
- export { d as Getter, G as GlobalLocaleRoutes, a as Locale, L as LocaleCode, P as PluralFunc } from './shared/nuxt-i18n-micro.4444721d.mjs';
3
+ import { M as ModulePrivateOptionsExtend, b as ModuleOptionsExtend, c as ModuleOptions } from './shared/nuxt-i18n-micro.4b19b717.mjs';
4
+ export { d as Getter, G as GlobalLocaleRoutes, a as Locale, L as LocaleCode, P as PluralFunc } from './shared/nuxt-i18n-micro.4b19b717.mjs';
5
5
  export { PluginsInjections } from '../dist/runtime/plugins/01.plugin.js';
6
6
 
7
7
  declare const _default: _nuxt_schema.NuxtModule<ModuleOptions, ModuleOptions, false>;
package/dist/module.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import * as _nuxt_schema from '@nuxt/schema';
2
2
  import { HookResult } from '@nuxt/schema';
3
- import { M as ModulePrivateOptionsExtend, b as ModuleOptionsExtend, c as ModuleOptions } from './shared/nuxt-i18n-micro.4444721d.js';
4
- export { d as Getter, G as GlobalLocaleRoutes, a as Locale, L as LocaleCode, P as PluralFunc } from './shared/nuxt-i18n-micro.4444721d.js';
3
+ import { M as ModulePrivateOptionsExtend, b as ModuleOptionsExtend, c as ModuleOptions } from './shared/nuxt-i18n-micro.4b19b717.js';
4
+ export { d as Getter, G as GlobalLocaleRoutes, a as Locale, L as LocaleCode, P as PluralFunc } from './shared/nuxt-i18n-micro.4b19b717.js';
5
5
  export { PluginsInjections } from '../dist/runtime/plugins/01.plugin.js';
6
6
 
7
7
  declare const _default: _nuxt_schema.NuxtModule<ModuleOptions, ModuleOptions, false>;
package/dist/module.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "nuxt-i18n-micro",
3
3
  "configKey": "i18n",
4
- "version": "1.59.1",
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;
@@ -395,6 +394,7 @@ const module = defineNuxtModule({
395
394
  autoDetectLanguage: true,
396
395
  disablePageLocales: false,
397
396
  disableWatcher: false,
397
+ disableUpdater: false,
398
398
  includeDefaultLocaleRoute: void 0,
399
399
  fallbackLocale: void 0,
400
400
  localeCookie: "user-locale",
@@ -440,6 +440,7 @@ const module = defineNuxtModule({
440
440
  metaBaseUrl: options.metaBaseUrl ?? void 0,
441
441
  define: options.define ?? true,
442
442
  disableWatcher: options.disableWatcher ?? false,
443
+ disableUpdater: options.disableUpdater ?? false,
443
444
  defaultLocale: options.defaultLocale ?? "en",
444
445
  translationDir: options.translationDir ?? "locales",
445
446
  localeCookie: options.localeCookie ?? "user-locale",
@@ -525,7 +526,7 @@ const module = defineNuxtModule({
525
526
  if (!options.disableWatcher) {
526
527
  localeManager.ensureTranslationFilesExist(pagesNames, options.translationDir, nuxt.options.rootDir);
527
528
  }
528
- pageManager.extendPages(pages, nuxt.options.rootDir, options.customRegexMatcher, isCloudflarePages);
529
+ pageManager.extendPages(pages, options.customRegexMatcher, isCloudflarePages);
529
530
  if (isPrefixStrategy(options.strategy) && !isCloudflarePages) {
530
531
  const fallbackRoute = {
531
532
  path: "/:pathMatch(.*)*",
@@ -615,22 +616,24 @@ const module = defineNuxtModule({
615
616
  }
616
617
  }
617
618
  });
618
- nuxt.hook("nitro:build:before", async (_nitro) => {
619
- const isProd = nuxt.options.dev === false;
620
- if (!isProd) {
621
- const translationPath = path.resolve(nuxt.options.rootDir, options.translationDir);
622
- logger.log("\u2139 add file watcher: " + translationPath);
623
- const watcherEvent = async (path2) => {
624
- watcher.close();
625
- logger.log("\u21BB update store item: " + path2);
626
- nuxt.callHook("restart");
627
- };
628
- const watcher = watch(translationPath, { depth: 2, persistent: true }).on("change", watcherEvent);
629
- nuxt.hook("close", () => {
630
- watcher.close();
631
- });
632
- }
633
- });
619
+ if (!options.disableUpdater) {
620
+ nuxt.hook("nitro:build:before", async (_nitro) => {
621
+ const isProd = nuxt.options.dev === false;
622
+ if (!isProd) {
623
+ const translationPath = path.resolve(nuxt.options.rootDir, options.translationDir);
624
+ logger.log("\u2139 add file watcher: " + translationPath);
625
+ const watcherEvent = async (path2) => {
626
+ watcher.close();
627
+ logger.log("\u21BB update store item: " + path2);
628
+ nuxt.callHook("restart");
629
+ };
630
+ const watcher = watch(translationPath, { depth: 2, persistent: true }).on("change", watcherEvent);
631
+ nuxt.hook("close", () => {
632
+ watcher.close();
633
+ });
634
+ }
635
+ });
636
+ }
634
637
  nuxt.hook("prerender:routes", async (prerenderRoutes) => {
635
638
  if (isNoPrefixStrategy(options.strategy)) {
636
639
  return;
@@ -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}$`), "");
@@ -27,6 +27,7 @@ interface ModuleOptions {
27
27
  autoDetectLanguage?: boolean;
28
28
  autoDetectPath?: string;
29
29
  disableWatcher?: boolean;
30
+ disableUpdater?: boolean;
30
31
  types?: boolean;
31
32
  includeDefaultLocaleRoute?: boolean;
32
33
  routesLocaleLinks?: {
@@ -27,6 +27,7 @@ interface ModuleOptions {
27
27
  autoDetectLanguage?: boolean;
28
28
  autoDetectPath?: string;
29
29
  disableWatcher?: boolean;
30
+ disableUpdater?: boolean;
30
31
  types?: boolean;
31
32
  includeDefaultLocaleRoute?: boolean;
32
33
  routesLocaleLinks?: {
package/dist/utils.d.mts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { NuxtPage } from '@nuxt/schema';
2
- import { L as LocaleCode, a as Locale } from './shared/nuxt-i18n-micro.4444721d.mjs';
2
+ import { L as LocaleCode, a as Locale } from './shared/nuxt-i18n-micro.4b19b717.mjs';
3
3
 
4
4
  declare function extractLocaleRoutes(content: string, filePath: string): Record<string, string> | null;
5
5
  declare function validateDefineI18nRouteConfig(obj: Record<LocaleCode, Record<string, string>>): boolean;
package/dist/utils.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { NuxtPage } from '@nuxt/schema';
2
- import { L as LocaleCode, a as Locale } from './shared/nuxt-i18n-micro.4444721d.js';
2
+ import { L as LocaleCode, a as Locale } from './shared/nuxt-i18n-micro.4b19b717.js';
3
3
 
4
4
  declare function extractLocaleRoutes(content: string, filePath: string): Record<string, string> | null;
5
5
  declare function validateDefineI18nRouteConfig(obj: Record<LocaleCode, Record<string, string>>): boolean;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nuxt-i18n-micro",
3
- "version": "1.59.1",
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":"569329fc-a258-4243-a57f-6857e7d94336","timestamp":1736852817464,"matcher":{"static":{},"wildcard":{},"dynamic":{}},"prerendered":[]}