nuxt-i18n-micro 2.10.0 → 2.12.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/CBxwnKtU.js">
9
9
  <link rel="prefetch" as="style" crossorigin href="/__NUXT_DEVTOOLS_I18N_BASE__/_nuxt/error-500.BqKd8Zt-.css">
10
10
  <link rel="prefetch" as="script" crossorigin href="/__NUXT_DEVTOOLS_I18N_BASE__/_nuxt/BYEpoBUk.js">
11
- <script type="module" src="/__NUXT_DEVTOOLS_I18N_BASE__/_nuxt/XZXfxmri.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},1763631493448,false]</script>
12
- <script>window.__NUXT__={};window.__NUXT__.config={public:{},app:{baseURL:"/__NUXT_DEVTOOLS_I18N_BASE__/",buildId:"4d50402d-b49e-486b-8691-1920eff342d2",buildAssetsDir:"/_nuxt/",cdnURL:""}}</script></body></html>
11
+ <script type="module" src="/__NUXT_DEVTOOLS_I18N_BASE__/_nuxt/XZXfxmri.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},1763994971266,false]</script>
12
+ <script>window.__NUXT__={};window.__NUXT__.config={public:{},app:{baseURL:"/__NUXT_DEVTOOLS_I18N_BASE__/",buildId:"01201220-c0fd-464a-8476-6d05efe648a4",buildAssetsDir:"/_nuxt/",cdnURL:""}}</script></body></html>
@@ -8,5 +8,5 @@
8
8
  <link rel="prefetch" as="script" crossorigin href="/__NUXT_DEVTOOLS_I18N_BASE__/_nuxt/CBxwnKtU.js">
9
9
  <link rel="prefetch" as="style" crossorigin href="/__NUXT_DEVTOOLS_I18N_BASE__/_nuxt/error-500.BqKd8Zt-.css">
10
10
  <link rel="prefetch" as="script" crossorigin href="/__NUXT_DEVTOOLS_I18N_BASE__/_nuxt/BYEpoBUk.js">
11
- <script type="module" src="/__NUXT_DEVTOOLS_I18N_BASE__/_nuxt/XZXfxmri.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},1763631493448,false]</script>
12
- <script>window.__NUXT__={};window.__NUXT__.config={public:{},app:{baseURL:"/__NUXT_DEVTOOLS_I18N_BASE__/",buildId:"4d50402d-b49e-486b-8691-1920eff342d2",buildAssetsDir:"/_nuxt/",cdnURL:""}}</script></body></html>
11
+ <script type="module" src="/__NUXT_DEVTOOLS_I18N_BASE__/_nuxt/XZXfxmri.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},1763994971267,false]</script>
12
+ <script>window.__NUXT__={};window.__NUXT__.config={public:{},app:{baseURL:"/__NUXT_DEVTOOLS_I18N_BASE__/",buildId:"01201220-c0fd-464a-8476-6d05efe648a4",buildAssetsDir:"/_nuxt/",cdnURL:""}}</script></body></html>
@@ -1 +1 @@
1
- {"id":"4d50402d-b49e-486b-8691-1920eff342d2","timestamp":1763631487169}
1
+ {"id":"01201220-c0fd-464a-8476-6d05efe648a4","timestamp":1763994964382}
@@ -0,0 +1 @@
1
+ {"id":"01201220-c0fd-464a-8476-6d05efe648a4","timestamp":1763994964382,"matcher":{"static":{},"wildcard":{},"dynamic":{}},"prerendered":[]}
@@ -8,5 +8,5 @@
8
8
  <link rel="prefetch" as="script" crossorigin href="/__NUXT_DEVTOOLS_I18N_BASE__/_nuxt/CBxwnKtU.js">
9
9
  <link rel="prefetch" as="style" crossorigin href="/__NUXT_DEVTOOLS_I18N_BASE__/_nuxt/error-500.BqKd8Zt-.css">
10
10
  <link rel="prefetch" as="script" crossorigin href="/__NUXT_DEVTOOLS_I18N_BASE__/_nuxt/BYEpoBUk.js">
11
- <script type="module" src="/__NUXT_DEVTOOLS_I18N_BASE__/_nuxt/XZXfxmri.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},1763631493448,false]</script>
12
- <script>window.__NUXT__={};window.__NUXT__.config={public:{},app:{baseURL:"/__NUXT_DEVTOOLS_I18N_BASE__/",buildId:"4d50402d-b49e-486b-8691-1920eff342d2",buildAssetsDir:"/_nuxt/",cdnURL:""}}</script></body></html>
11
+ <script type="module" src="/__NUXT_DEVTOOLS_I18N_BASE__/_nuxt/XZXfxmri.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},1763994971267,false]</script>
12
+ <script>window.__NUXT__={};window.__NUXT__.config={public:{},app:{baseURL:"/__NUXT_DEVTOOLS_I18N_BASE__/",buildId:"01201220-c0fd-464a-8476-6d05efe648a4",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": "2.10.0",
4
+ "version": "2.12.0",
5
5
  "builder": {
6
6
  "@nuxt/module-builder": "1.0.2",
7
7
  "unbuild": "3.6.1"
package/dist/module.mjs CHANGED
@@ -844,7 +844,8 @@ const module = defineNuxtModule({
844
844
  return selectedForm.trim().replace("{count}", count.toString());
845
845
  },
846
846
  customRegexMatcher: void 0,
847
- excludePatterns: void 0
847
+ excludePatterns: void 0,
848
+ missingWarn: true
848
849
  },
849
850
  async setup(options, nuxt) {
850
851
  const defaultLocale = process.env.DEFAULT_LOCALE ?? options.defaultLocale ?? "en";
@@ -937,6 +938,7 @@ const module = defineNuxtModule({
937
938
  // eslint-disable-next-line @typescript-eslint/ban-ts-comment
938
939
  // @ts-ignore
939
940
  globalLocaleRoutes: mergedGlobalLocaleRoutes,
941
+ missingWarn: options.missingWarn ?? true,
940
942
  experimental: {
941
943
  i18nPreviousPageFallback: options.experimental?.i18nPreviousPageFallback ?? false,
942
944
  // eslint-disable-next-line @typescript-eslint/ban-ts-comment
@@ -23,7 +23,8 @@ export function useI18n() {
23
23
  $switchRoute: nuxtApp.$switchRoute,
24
24
  $localeRoute: nuxtApp.$localeRoute,
25
25
  $localePath: nuxtApp.$localePath,
26
- $loadPageTranslations: nuxtApp.$loadPageTranslations
26
+ $loadPageTranslations: nuxtApp.$loadPageTranslations,
27
+ $setMissingHandler: nuxtApp.$setMissingHandler
27
28
  };
28
29
  const noDollarInjections = Object.fromEntries(
29
30
  Object.entries(injections).map(([key, value]) => [key.slice(1), value])
@@ -1,6 +1,6 @@
1
1
  import type { RouteLocationNormalizedLoaded, RouteLocationRaw, RouteLocationResolved, RouteLocationResolvedGeneric, RouteLocationNamedRaw } from 'vue-router';
2
2
  import { useTranslationHelper } from 'nuxt-i18n-micro-core';
3
- import type { Locale, I18nRouteParams, Params, Translations, CleanTranslation } from 'nuxt-i18n-micro-types';
3
+ import type { Locale, I18nRouteParams, Params, Translations, CleanTranslation, MissingHandler } from 'nuxt-i18n-micro-types';
4
4
  declare const _default: import("nuxt/app").Plugin<{
5
5
  i18n: undefined;
6
6
  __micro: boolean;
@@ -29,6 +29,7 @@ declare const _default: import("nuxt/app").Plugin<{
29
29
  localePath: (to: RouteLocationNamedRaw | RouteLocationResolvedGeneric | string, locale?: string) => string;
30
30
  setI18nRouteParams: (value: I18nRouteParams) => I18nRouteParams;
31
31
  loadPageTranslations: (locale: string, routeName: string, translations: Translations) => Promise<void>;
32
+ setMissingHandler: (handler: MissingHandler | null) => void;
32
33
  helper: {
33
34
  hasCache(locale: string, page: string): boolean;
34
35
  getCache(locale: string, routeName: string): Map<string, unknown> | undefined;
@@ -71,6 +72,7 @@ declare const _default: import("nuxt/app").Plugin<{
71
72
  localePath: (to: RouteLocationNamedRaw | RouteLocationResolvedGeneric | string, locale?: string) => string;
72
73
  setI18nRouteParams: (value: I18nRouteParams) => I18nRouteParams;
73
74
  loadPageTranslations: (locale: string, routeName: string, translations: Translations) => Promise<void>;
75
+ setMissingHandler: (handler: MissingHandler | null) => void;
74
76
  helper: {
75
77
  hasCache(locale: string, page: string): boolean;
76
78
  getCache(locale: string, routeName: string): Map<string, unknown> | undefined;
@@ -112,5 +114,6 @@ export interface PluginsInjections {
112
114
  $localePath: (to: RouteLocationNamedRaw | RouteLocationResolvedGeneric | string, locale?: string) => string;
113
115
  $setI18nRouteParams: (value: I18nRouteParams) => I18nRouteParams;
114
116
  $loadPageTranslations: (locale: string, routeName: string, translations: Translations) => Promise<void>;
117
+ $setMissingHandler: (handler: MissingHandler | null) => void;
115
118
  helper: ReturnType<typeof useTranslationHelper>;
116
119
  }
@@ -54,6 +54,8 @@ export default defineNuxtPlugin(async (nuxtApp) => {
54
54
  const i18nRouteParams = useState("i18n-route-params", () => ({}));
55
55
  const previousPageInfo = useState("i18n-previous-page", () => null);
56
56
  const enablePreviousPageFallback = i18nConfig.experimental?.i18nPreviousPageFallback ?? false;
57
+ const missingWarn = i18nConfig.missingWarn ?? true;
58
+ const customMissingHandler = useState("i18n-missing-handler", () => null);
57
59
  nuxtApp.hook("page:finish", () => {
58
60
  if (import.meta.client) {
59
61
  previousPageInfo.value = null;
@@ -142,7 +144,9 @@ export default defineNuxtPlugin(async (nuxtApp) => {
142
144
  }
143
145
  }
144
146
  if (!value) {
145
- if (isDev && import.meta.client) {
147
+ if (customMissingHandler.value) {
148
+ customMissingHandler.value(locale, key, routeName);
149
+ } else if (missingWarn && isDev && import.meta.client) {
146
150
  console.warn(`Not found '${key}' key in '${locale}' locale messages for route '${routeName}'.`);
147
151
  }
148
152
  value = defaultValue === void 0 ? key : defaultValue;
@@ -248,6 +252,9 @@ export default defineNuxtPlugin(async (nuxtApp) => {
248
252
  loadPageTranslations: async (locale, routeName, translations) => {
249
253
  await i18nHelper.loadPageTranslations(locale, routeName, translations);
250
254
  },
255
+ setMissingHandler: (handler) => {
256
+ customMissingHandler.value = handler;
257
+ },
251
258
  helper: i18nHelper
252
259
  // Оставляем helper, он может быть полезен для продвинутых пользователей
253
260
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nuxt-i18n-micro",
3
- "version": "2.10.0",
3
+ "version": "2.12.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",
@@ -62,8 +62,8 @@
62
62
  "sirv": "^2.0.4",
63
63
  "ufo": "^1.5.4",
64
64
  "nuxt-i18n-micro-core": "1.0.25",
65
- "nuxt-i18n-micro-types": "1.0.14",
66
- "nuxt-i18n-micro-test-utils": "1.0.7"
65
+ "nuxt-i18n-micro-test-utils": "1.0.7",
66
+ "nuxt-i18n-micro-types": "1.0.15"
67
67
  },
68
68
  "devDependencies": {
69
69
  "@nuxt/devtools": "^2.6.3",
@@ -1 +0,0 @@
1
- {"id":"4d50402d-b49e-486b-8691-1920eff342d2","timestamp":1763631487169,"matcher":{"static":{},"wildcard":{},"dynamic":{}},"prerendered":[]}