nuxt-i18n-micro 3.20.1 → 3.21.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.
@@ -1 +1 @@
1
- <!DOCTYPE html><html><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1"><link rel="stylesheet" href="/__NUXT_DEVTOOLS_I18N_BASE__/_nuxt/entry.Kj_DYE7z.css" crossorigin><link rel="modulepreload" as="script" crossorigin href="/__NUXT_DEVTOOLS_I18N_BASE__/_nuxt/SDQMalAT.js"><script type="module" src="/__NUXT_DEVTOOLS_I18N_BASE__/_nuxt/SDQMalAT.js" crossorigin></script><link rel="prefetch" as="style" crossorigin href="/__NUXT_DEVTOOLS_I18N_BASE__/_nuxt/error-404.CyBDSRXN.css"><link rel="prefetch" as="script" crossorigin href="/__NUXT_DEVTOOLS_I18N_BASE__/_nuxt/Dx6dmpFi.js"><link rel="prefetch" as="script" crossorigin href="/__NUXT_DEVTOOLS_I18N_BASE__/_nuxt/BA2bGsrZ.js"><link rel="prefetch" as="style" crossorigin href="/__NUXT_DEVTOOLS_I18N_BASE__/_nuxt/error-500.DJtCwW7w.css"><link rel="prefetch" as="script" crossorigin href="/__NUXT_DEVTOOLS_I18N_BASE__/_nuxt/C_HK2snF.js"></head><body><div id="__nuxt"></div><div id="teleports"></div><script>window.__NUXT__={};window.__NUXT__.config={public:{},app:{baseURL:"/__NUXT_DEVTOOLS_I18N_BASE__/",buildId:"2289c85d-a41f-4749-a560-b569969d6394",buildAssetsDir:"/_nuxt/",cdnURL:""}}</script><script type="application/json" data-nuxt-data="nuxt-app" data-ssr="false" id="__NUXT_DATA__">[{"prerenderedAt":1,"serverRendered":2},1782220045639,false]</script></body></html>
1
+ <!DOCTYPE html><html><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1"><link rel="stylesheet" href="/__NUXT_DEVTOOLS_I18N_BASE__/_nuxt/entry.Kj_DYE7z.css" crossorigin><link rel="modulepreload" as="script" crossorigin href="/__NUXT_DEVTOOLS_I18N_BASE__/_nuxt/SDQMalAT.js"><script type="module" src="/__NUXT_DEVTOOLS_I18N_BASE__/_nuxt/SDQMalAT.js" crossorigin></script><link rel="prefetch" as="style" crossorigin href="/__NUXT_DEVTOOLS_I18N_BASE__/_nuxt/error-404.CyBDSRXN.css"><link rel="prefetch" as="script" crossorigin href="/__NUXT_DEVTOOLS_I18N_BASE__/_nuxt/Dx6dmpFi.js"><link rel="prefetch" as="script" crossorigin href="/__NUXT_DEVTOOLS_I18N_BASE__/_nuxt/BA2bGsrZ.js"><link rel="prefetch" as="style" crossorigin href="/__NUXT_DEVTOOLS_I18N_BASE__/_nuxt/error-500.DJtCwW7w.css"><link rel="prefetch" as="script" crossorigin href="/__NUXT_DEVTOOLS_I18N_BASE__/_nuxt/C_HK2snF.js"></head><body><div id="__nuxt"></div><div id="teleports"></div><script>window.__NUXT__={};window.__NUXT__.config={public:{},app:{baseURL:"/__NUXT_DEVTOOLS_I18N_BASE__/",buildId:"0792ea61-cd2b-4714-91c8-a8e7805549a8",buildAssetsDir:"/_nuxt/",cdnURL:""}}</script><script type="application/json" data-nuxt-data="nuxt-app" data-ssr="false" id="__NUXT_DATA__">[{"prerenderedAt":1,"serverRendered":2},1782394434395,false]</script></body></html>
@@ -1 +1 @@
1
- <!DOCTYPE html><html><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1"><link rel="stylesheet" href="/__NUXT_DEVTOOLS_I18N_BASE__/_nuxt/entry.Kj_DYE7z.css" crossorigin><link rel="modulepreload" as="script" crossorigin href="/__NUXT_DEVTOOLS_I18N_BASE__/_nuxt/SDQMalAT.js"><script type="module" src="/__NUXT_DEVTOOLS_I18N_BASE__/_nuxt/SDQMalAT.js" crossorigin></script><link rel="prefetch" as="style" crossorigin href="/__NUXT_DEVTOOLS_I18N_BASE__/_nuxt/error-404.CyBDSRXN.css"><link rel="prefetch" as="script" crossorigin href="/__NUXT_DEVTOOLS_I18N_BASE__/_nuxt/Dx6dmpFi.js"><link rel="prefetch" as="script" crossorigin href="/__NUXT_DEVTOOLS_I18N_BASE__/_nuxt/BA2bGsrZ.js"><link rel="prefetch" as="style" crossorigin href="/__NUXT_DEVTOOLS_I18N_BASE__/_nuxt/error-500.DJtCwW7w.css"><link rel="prefetch" as="script" crossorigin href="/__NUXT_DEVTOOLS_I18N_BASE__/_nuxt/C_HK2snF.js"></head><body><div id="__nuxt"></div><div id="teleports"></div><script>window.__NUXT__={};window.__NUXT__.config={public:{},app:{baseURL:"/__NUXT_DEVTOOLS_I18N_BASE__/",buildId:"2289c85d-a41f-4749-a560-b569969d6394",buildAssetsDir:"/_nuxt/",cdnURL:""}}</script><script type="application/json" data-nuxt-data="nuxt-app" data-ssr="false" id="__NUXT_DATA__">[{"prerenderedAt":1,"serverRendered":2},1782220045639,false]</script></body></html>
1
+ <!DOCTYPE html><html><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1"><link rel="stylesheet" href="/__NUXT_DEVTOOLS_I18N_BASE__/_nuxt/entry.Kj_DYE7z.css" crossorigin><link rel="modulepreload" as="script" crossorigin href="/__NUXT_DEVTOOLS_I18N_BASE__/_nuxt/SDQMalAT.js"><script type="module" src="/__NUXT_DEVTOOLS_I18N_BASE__/_nuxt/SDQMalAT.js" crossorigin></script><link rel="prefetch" as="style" crossorigin href="/__NUXT_DEVTOOLS_I18N_BASE__/_nuxt/error-404.CyBDSRXN.css"><link rel="prefetch" as="script" crossorigin href="/__NUXT_DEVTOOLS_I18N_BASE__/_nuxt/Dx6dmpFi.js"><link rel="prefetch" as="script" crossorigin href="/__NUXT_DEVTOOLS_I18N_BASE__/_nuxt/BA2bGsrZ.js"><link rel="prefetch" as="style" crossorigin href="/__NUXT_DEVTOOLS_I18N_BASE__/_nuxt/error-500.DJtCwW7w.css"><link rel="prefetch" as="script" crossorigin href="/__NUXT_DEVTOOLS_I18N_BASE__/_nuxt/C_HK2snF.js"></head><body><div id="__nuxt"></div><div id="teleports"></div><script>window.__NUXT__={};window.__NUXT__.config={public:{},app:{baseURL:"/__NUXT_DEVTOOLS_I18N_BASE__/",buildId:"0792ea61-cd2b-4714-91c8-a8e7805549a8",buildAssetsDir:"/_nuxt/",cdnURL:""}}</script><script type="application/json" data-nuxt-data="nuxt-app" data-ssr="false" id="__NUXT_DATA__">[{"prerenderedAt":1,"serverRendered":2},1782394434396,false]</script></body></html>
@@ -1 +1 @@
1
- {"id":"2289c85d-a41f-4749-a560-b569969d6394","timestamp":1782220041934}
1
+ {"id":"0792ea61-cd2b-4714-91c8-a8e7805549a8","timestamp":1782394431420}
@@ -0,0 +1 @@
1
+ {"id":"0792ea61-cd2b-4714-91c8-a8e7805549a8","timestamp":1782394431420,"matcher":{"static":{},"wildcard":{},"dynamic":{}},"prerendered":[]}
@@ -1 +1 @@
1
- <!DOCTYPE html><html><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1"><link rel="stylesheet" href="/__NUXT_DEVTOOLS_I18N_BASE__/_nuxt/entry.Kj_DYE7z.css" crossorigin><link rel="modulepreload" as="script" crossorigin href="/__NUXT_DEVTOOLS_I18N_BASE__/_nuxt/SDQMalAT.js"><script type="module" src="/__NUXT_DEVTOOLS_I18N_BASE__/_nuxt/SDQMalAT.js" crossorigin></script><link rel="prefetch" as="style" crossorigin href="/__NUXT_DEVTOOLS_I18N_BASE__/_nuxt/error-404.CyBDSRXN.css"><link rel="prefetch" as="script" crossorigin href="/__NUXT_DEVTOOLS_I18N_BASE__/_nuxt/Dx6dmpFi.js"><link rel="prefetch" as="script" crossorigin href="/__NUXT_DEVTOOLS_I18N_BASE__/_nuxt/BA2bGsrZ.js"><link rel="prefetch" as="style" crossorigin href="/__NUXT_DEVTOOLS_I18N_BASE__/_nuxt/error-500.DJtCwW7w.css"><link rel="prefetch" as="script" crossorigin href="/__NUXT_DEVTOOLS_I18N_BASE__/_nuxt/C_HK2snF.js"></head><body><div id="__nuxt"></div><div id="teleports"></div><script>window.__NUXT__={};window.__NUXT__.config={public:{},app:{baseURL:"/__NUXT_DEVTOOLS_I18N_BASE__/",buildId:"2289c85d-a41f-4749-a560-b569969d6394",buildAssetsDir:"/_nuxt/",cdnURL:""}}</script><script type="application/json" data-nuxt-data="nuxt-app" data-ssr="false" id="__NUXT_DATA__">[{"prerenderedAt":1,"serverRendered":2},1782220045640,false]</script></body></html>
1
+ <!DOCTYPE html><html><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1"><link rel="stylesheet" href="/__NUXT_DEVTOOLS_I18N_BASE__/_nuxt/entry.Kj_DYE7z.css" crossorigin><link rel="modulepreload" as="script" crossorigin href="/__NUXT_DEVTOOLS_I18N_BASE__/_nuxt/SDQMalAT.js"><script type="module" src="/__NUXT_DEVTOOLS_I18N_BASE__/_nuxt/SDQMalAT.js" crossorigin></script><link rel="prefetch" as="style" crossorigin href="/__NUXT_DEVTOOLS_I18N_BASE__/_nuxt/error-404.CyBDSRXN.css"><link rel="prefetch" as="script" crossorigin href="/__NUXT_DEVTOOLS_I18N_BASE__/_nuxt/Dx6dmpFi.js"><link rel="prefetch" as="script" crossorigin href="/__NUXT_DEVTOOLS_I18N_BASE__/_nuxt/BA2bGsrZ.js"><link rel="prefetch" as="style" crossorigin href="/__NUXT_DEVTOOLS_I18N_BASE__/_nuxt/error-500.DJtCwW7w.css"><link rel="prefetch" as="script" crossorigin href="/__NUXT_DEVTOOLS_I18N_BASE__/_nuxt/C_HK2snF.js"></head><body><div id="__nuxt"></div><div id="teleports"></div><script>window.__NUXT__={};window.__NUXT__.config={public:{},app:{baseURL:"/__NUXT_DEVTOOLS_I18N_BASE__/",buildId:"0792ea61-cd2b-4714-91c8-a8e7805549a8",buildAssetsDir:"/_nuxt/",cdnURL:""}}</script><script type="application/json" data-nuxt-data="nuxt-app" data-ssr="false" id="__NUXT_DATA__">[{"prerenderedAt":1,"serverRendered":2},1782394434396,false]</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": "3.20.1",
4
+ "version": "3.21.0",
5
5
  "builder": {
6
6
  "@nuxt/module-builder": "1.0.2",
7
7
  "unbuild": "3.6.1"
package/dist/module.mjs CHANGED
@@ -319,6 +319,14 @@ function collectDefineI18nRouteMetaFromFiles(pageFiles, rootDirs) {
319
319
  }
320
320
 
321
321
  const DEFAULT_CANONICAL_QUERY_WHITELIST = ["page", "sort", "filter", "search", "q", "query", "tag"];
322
+ const moduleRequire = createRequire(import.meta.url);
323
+ const I18N_MICRO_NITRO_TRACE_ENTRIES = [
324
+ "@i18n-micro/utils/route",
325
+ "@i18n-micro/core",
326
+ "@i18n-micro/route-strategy",
327
+ "@i18n-micro/path-strategy",
328
+ "@i18n-micro/hmr/cache-keys"
329
+ ];
322
330
  function generateI18nTypes() {
323
331
  return `
324
332
  import type {PluginsInjections} from "nuxt-i18n-micro";
@@ -761,6 +769,17 @@ declare module '#i18n-internal/plural' {
761
769
  nitroConfig.alias["#i18n-internal/plural"] = pluralTemplate.dst;
762
770
  nitroConfig.alias["#i18n-internal/strategy"] = strategyTemplate.dst;
763
771
  nitroConfig.alias["#i18n-internal/config"] = configTemplate.dst;
772
+ nitroConfig.externals = nitroConfig.externals || {};
773
+ nitroConfig.externals.traceInclude = nitroConfig.externals.traceInclude || [];
774
+ for (const entry of I18N_MICRO_NITRO_TRACE_ENTRIES) {
775
+ try {
776
+ const resolved = moduleRequire.resolve(entry);
777
+ if (!nitroConfig.externals.traceInclude.includes(resolved)) {
778
+ nitroConfig.externals.traceInclude.push(resolved);
779
+ }
780
+ } catch {
781
+ }
782
+ }
764
783
  if (translationPayloads.serverAssets) {
765
784
  nitroConfig.serverAssets = nitroConfig.serverAssets || [];
766
785
  nitroConfig.serverAssets.push({
@@ -0,0 +1,10 @@
1
+ import type { I18nHeadInput } from '@i18n-micro/types';
2
+ import type { MaybeRefOrGetter } from 'vue';
3
+ /**
4
+ * Register page-level overrides for i18n SEO head tags.
5
+ * Merged on top of `useLocaleHead` output by the `02.meta` plugin.
6
+ */
7
+ export declare function useI18nHead(input?: MaybeRefOrGetter<I18nHeadInput | null>): {
8
+ pageHead: import("vue").Ref<I18nHeadInput | null, I18nHeadInput | null>;
9
+ resetPageHead: () => void;
10
+ };
@@ -0,0 +1,18 @@
1
+ import { toValue, watch } from "vue";
2
+ import { useState } from "#app";
3
+ export function useI18nHead(input) {
4
+ const pageHead = useState("i18n-head-page", () => null);
5
+ const resetPageHead = () => {
6
+ pageHead.value = null;
7
+ };
8
+ if (input !== void 0) {
9
+ watch(
10
+ () => toValue(input),
11
+ (value) => {
12
+ pageHead.value = value ?? null;
13
+ },
14
+ { immediate: true, deep: true }
15
+ );
16
+ }
17
+ return { pageHead, resetPageHead };
18
+ }
@@ -84,7 +84,7 @@ export interface PluginsInjections {
84
84
  $tc: (key: string, params: number | Params, defaultValue?: string) => string;
85
85
  $tn: (value: number, options?: Intl.NumberFormatOptions) => string;
86
86
  $td: (value: Date | number | string, options?: Intl.DateTimeFormatOptions) => string;
87
- $tdr: (value: Date | number | string, options?: Intl.DateTimeFormatOptions) => string;
87
+ $tdr: (value: Date | number | string, options?: Intl.RelativeTimeFormatOptions) => string;
88
88
  $has: (key: string) => boolean;
89
89
  $mergeTranslations: (newTranslations: Translations) => void;
90
90
  $switchLocaleRoute: (locale: string) => RouteLocationRaw;
@@ -4,6 +4,7 @@ import { useState } from "#app";
4
4
  import { plural } from "#build/i18n.plural.mjs";
5
5
  import { createI18nStrategy, getI18nConfig } from "#build/i18n.strategy.mjs";
6
6
  import { createError, defineNuxtPlugin, navigateTo, useRouter, useRuntimeConfig } from "#imports";
7
+ import { useI18nHead } from "../composables/useI18nHead.js";
7
8
  import { useI18nLocale } from "../composables/useI18nLocale.js";
8
9
  import { createNuxtI18nPluginApi, NuxtI18n, NuxtTranslationLoader } from "../utils/nuxt-i18n.js";
9
10
  import { translationStorage } from "../utils/storage.js";
@@ -22,6 +23,7 @@ export default defineNuxtPlugin(async (nuxtApp) => {
22
23
  });
23
24
  const { locale: localeState, setLocale, getLocale, getEffectiveLocale, resolveInitialLocale, isValidLocale } = useI18nLocale();
24
25
  const i18nRouteParams = useState("i18n-route-params", () => ({}));
26
+ const { resetPageHead } = useI18nHead();
25
27
  const customMissingHandler = useState("i18n-missing-handler", () => null);
26
28
  const ssrChunks = useState("i18n-ssr-chunks", () => ({}));
27
29
  const i18n = new NuxtI18n({
@@ -109,6 +111,7 @@ export default defineNuxtPlugin(async (nuxtApp) => {
109
111
  router.beforeEach(async (to, from) => {
110
112
  if (to.name !== from.name) {
111
113
  i18nRouteParams.value = {};
114
+ resetPageHead();
112
115
  }
113
116
  const shouldSwitchContext = to.path !== from.path || isNoPrefixStrategy(i18nConfig.strategy);
114
117
  if (!shouldSwitchContext) {
@@ -1,12 +1,15 @@
1
+ import { mergeI18nHead } from "@i18n-micro/utils/merge-i18n-head";
1
2
  import { isMetaDisabledForRoute } from "@i18n-micro/utils/route";
2
3
  import { resolveI18nConfigWithRuntimeOverrides } from "@i18n-micro/utils/runtime-config";
3
- import { watch } from "vue";
4
+ import { computed, watch } from "vue";
4
5
  import { getI18nConfig } from "#build/i18n.strategy.mjs";
5
6
  import { defineNuxtPlugin, useHead, useRequestURL, useRoute, useState } from "#imports";
7
+ import { useI18nHead } from "../composables/useI18nHead.js";
6
8
  import { useLocaleHead } from "../composables/useLocaleHead.js";
7
9
  export default defineNuxtPlugin((nuxtApp) => {
8
10
  const route = useRoute();
9
11
  const i18nRouteParams = useState("i18n-route-params", () => ({}));
12
+ const { pageHead } = useI18nHead();
10
13
  const getRuntimeConfig = nuxtApp.$getI18nConfig;
11
14
  const i18nConfig = resolveI18nConfigWithRuntimeOverrides(
12
15
  typeof getRuntimeConfig === "function" ? getRuntimeConfig() : getI18nConfig()
@@ -27,7 +30,17 @@ export default defineNuxtPlugin((nuxtApp) => {
27
30
  baseUrl,
28
31
  autoUpdate: false
29
32
  });
30
- useHead(metaObject);
33
+ const mergedHead = computed(() => {
34
+ const { $getLocales, $getLocale } = nuxtApp;
35
+ const allLocales = $getLocales?.() ?? i18nConfig.locales ?? [];
36
+ const locale = $getLocale?.() || i18nConfig.defaultLocale || "en";
37
+ return mergeI18nHead(metaObject.value, pageHead.value, {
38
+ identifierAttribute: "id",
39
+ locales: allLocales,
40
+ currentLocale: locale
41
+ });
42
+ });
43
+ useHead(mergedHead);
31
44
  const refreshMeta = () => updateMeta();
32
45
  if (import.meta.server) {
33
46
  nuxtApp.hook("app:rendered", refreshMeta);
@@ -35,14 +48,7 @@ export default defineNuxtPlugin((nuxtApp) => {
35
48
  refreshMeta();
36
49
  nuxtApp.hook("page:finish", refreshMeta);
37
50
  }
38
- watch(
39
- () => i18nRouteParams.value,
40
- refreshMeta,
41
- { deep: true, flush: "post" }
42
- );
43
- watch(
44
- () => [route.fullPath, route.name, route.matched.length],
45
- refreshMeta,
46
- { flush: "post" }
47
- );
51
+ watch(() => i18nRouteParams.value, refreshMeta, { deep: true, flush: "post" });
52
+ watch(() => [route.fullPath, route.name, route.matched.length], refreshMeta, { flush: "post" });
53
+ watch(pageHead, refreshMeta, { deep: true, flush: "post" });
48
54
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nuxt-i18n-micro",
3
- "version": "3.20.1",
3
+ "version": "3.21.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",
@@ -76,13 +76,13 @@
76
76
  "ufo": "^1.5.4",
77
77
  "unplugin": "^1.16.1",
78
78
  "@vue/compiler-sfc": "^3.5.25",
79
- "@i18n-micro/hmr": "1.0.1",
80
- "@i18n-micro/route-strategy": "1.1.8",
81
79
  "@i18n-micro/core": "1.3.2",
80
+ "@i18n-micro/route-strategy": "1.1.8",
81
+ "@i18n-micro/path-strategy": "1.3.3",
82
+ "@i18n-micro/types": "1.2.6",
83
+ "@i18n-micro/utils": "1.0.3",
82
84
  "@i18n-micro/test-utils": "1.2.2",
83
- "@i18n-micro/types": "1.2.5",
84
- "@i18n-micro/utils": "1.0.2",
85
- "@i18n-micro/path-strategy": "1.3.3"
85
+ "@i18n-micro/hmr": "1.0.1"
86
86
  },
87
87
  "devDependencies": {
88
88
  "oxfmt": "^0.43.0",
@@ -1 +0,0 @@
1
- {"id":"2289c85d-a41f-4749-a560-b569969d6394","timestamp":1782220041934,"matcher":{"static":{},"wildcard":{},"dynamic":{}},"prerendered":[]}