nuxt-i18n-micro 3.20.0 → 3.20.1

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:"5a55317c-1ad8-41ca-a7f6-2fe58e16b2f6",buildAssetsDir:"/_nuxt/",cdnURL:""}}</script><script type="application/json" data-nuxt-data="nuxt-app" data-ssr="false" id="__NUXT_DATA__">[{"prerenderedAt":1,"serverRendered":2},1781512938774,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:"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 +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:"5a55317c-1ad8-41ca-a7f6-2fe58e16b2f6",buildAssetsDir:"/_nuxt/",cdnURL:""}}</script><script type="application/json" data-nuxt-data="nuxt-app" data-ssr="false" id="__NUXT_DATA__">[{"prerenderedAt":1,"serverRendered":2},1781512938774,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:"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 +1 @@
1
- {"id":"5a55317c-1ad8-41ca-a7f6-2fe58e16b2f6","timestamp":1781512935536}
1
+ {"id":"2289c85d-a41f-4749-a560-b569969d6394","timestamp":1782220041934}
@@ -0,0 +1 @@
1
+ {"id":"2289c85d-a41f-4749-a560-b569969d6394","timestamp":1782220041934,"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:"5a55317c-1ad8-41ca-a7f6-2fe58e16b2f6",buildAssetsDir:"/_nuxt/",cdnURL:""}}</script><script type="application/json" data-nuxt-data="nuxt-app" data-ssr="false" id="__NUXT_DATA__">[{"prerenderedAt":1,"serverRendered":2},1781512938774,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:"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>
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.0",
4
+ "version": "3.20.1",
5
5
  "builder": {
6
6
  "@nuxt/module-builder": "1.0.2",
7
7
  "unbuild": "3.6.1"
@@ -1,5 +1,6 @@
1
1
  import { isNoPrefixStrategy } from "@i18n-micro/core";
2
2
  import { findAllowedLocalesForRoute } from "@i18n-micro/utils/route";
3
+ import { resolveOgLocale, warnUnresolvedOgLocale } from "@i18n-micro/utils/resolve-og-locale";
3
4
  import { joinURL, parseURL, withQuery } from "ufo";
4
5
  import { ref, unref, watch } from "vue";
5
6
  import { useNuxtApp, useRoute } from "#app";
@@ -59,7 +60,8 @@ export const useLocaleHead = ({
59
60
  const enabledLocales = allLocales.filter((loc) => !loc.disabled);
60
61
  const locales = currentRouteLocales ? enabledLocales.filter((loc) => currentRouteLocales.includes(loc.code)) : enabledLocales;
61
62
  const currentIso = currentLocale.iso || locale;
62
- const currentOg = currentLocale.og || currentIso;
63
+ const currentOg = resolveOgLocale(currentLocale);
64
+ const missingWarn = i18nConfig.missingWarn ?? true;
63
65
  const currentDir = currentLocale.dir || "auto";
64
66
  let fullPath = unref(route.fullPath);
65
67
  if (!fullPath.startsWith("/")) {
@@ -77,34 +79,40 @@ export const useLocaleHead = ({
77
79
  canonicalPath = filterQuery(fullPath, canonicalQueryWhitelist ?? []);
78
80
  ogUrl = joinURL(unref(baseUrl), canonicalPath);
79
81
  }
80
- metaObject.value = {
81
- htmlAttrs: {
82
- lang: currentIso,
83
- ...addDirAttribute ? { dir: currentDir } : {}
84
- },
85
- link: [],
86
- meta: []
82
+ const htmlAttrs = {
83
+ lang: currentIso,
84
+ ...addDirAttribute ? { dir: currentDir } : {}
87
85
  };
88
- if (!addSeoAttributes) return;
86
+ if (!addSeoAttributes) {
87
+ metaObject.value = { htmlAttrs, link: [], meta: [] };
88
+ return;
89
+ }
89
90
  const localesForSeo = locales.filter((loc) => loc.seo !== false);
90
- const ogLocaleMeta = {
91
+ if (!currentOg) {
92
+ warnUnresolvedOgLocale(currentLocale, { missingWarn, tag: "og:locale" });
93
+ }
94
+ const ogLocaleMeta = currentOg ? {
91
95
  [identifierAttribute]: "i18n-og",
92
96
  property: "og:locale",
93
- content: unref(currentOg)
94
- };
97
+ content: currentOg
98
+ } : null;
95
99
  const ogUrlMeta = {
96
100
  [identifierAttribute]: "i18n-og-url",
97
101
  property: "og:url",
98
102
  content: ogUrl
99
103
  };
100
104
  const alternateOgLocalesMeta = localesForSeo.filter((loc) => loc.code !== locale).map((loc) => {
101
- const ogAlt = loc.og || loc.iso || loc.code;
105
+ const ogAlt = resolveOgLocale(loc);
106
+ if (!ogAlt) {
107
+ warnUnresolvedOgLocale(loc, { missingWarn, tag: "og:locale:alternate" });
108
+ return null;
109
+ }
102
110
  return {
103
111
  [identifierAttribute]: `i18n-og-alt-${ogAlt}`,
104
112
  property: "og:locale:alternate",
105
- content: unref(ogAlt)
113
+ content: ogAlt
106
114
  };
107
- });
115
+ }).filter((meta) => meta !== null);
108
116
  const canonicalLink = {
109
117
  [identifierAttribute]: "i18n-can",
110
118
  rel: "canonical",
@@ -162,8 +170,11 @@ export const useLocaleHead = ({
162
170
  };
163
171
  }
164
172
  }
165
- metaObject.value.meta = [ogLocaleMeta, ogUrlMeta, ...alternateOgLocalesMeta];
166
- metaObject.value.link = [canonicalLink, ...alternateLinks, ...xDefaultLink ? [xDefaultLink] : []];
173
+ metaObject.value = {
174
+ htmlAttrs,
175
+ meta: [...ogLocaleMeta ? [ogLocaleMeta] : [], ogUrlMeta, ...alternateOgLocalesMeta],
176
+ link: [canonicalLink, ...alternateLinks, ...xDefaultLink ? [xDefaultLink] : []]
177
+ };
167
178
  }
168
179
  if (autoUpdate) {
169
180
  watch(
@@ -2,10 +2,11 @@ import { isMetaDisabledForRoute } from "@i18n-micro/utils/route";
2
2
  import { resolveI18nConfigWithRuntimeOverrides } from "@i18n-micro/utils/runtime-config";
3
3
  import { watch } from "vue";
4
4
  import { getI18nConfig } from "#build/i18n.strategy.mjs";
5
- import { defineNuxtPlugin, useHead, useRequestURL, useRoute } from "#imports";
5
+ import { defineNuxtPlugin, useHead, useRequestURL, useRoute, useState } from "#imports";
6
6
  import { useLocaleHead } from "../composables/useLocaleHead.js";
7
7
  export default defineNuxtPlugin((nuxtApp) => {
8
8
  const route = useRoute();
9
+ const i18nRouteParams = useState("i18n-route-params", () => ({}));
9
10
  const getRuntimeConfig = nuxtApp.$getI18nConfig;
10
11
  const i18nConfig = resolveI18nConfigWithRuntimeOverrides(
11
12
  typeof getRuntimeConfig === "function" ? getRuntimeConfig() : getI18nConfig()
@@ -27,13 +28,21 @@ export default defineNuxtPlugin((nuxtApp) => {
27
28
  autoUpdate: false
28
29
  });
29
30
  useHead(metaObject);
31
+ const refreshMeta = () => updateMeta();
30
32
  if (import.meta.server) {
31
- updateMeta();
32
- } else if (import.meta.client) {
33
- watch(
34
- () => route.fullPath,
35
- () => updateMeta(),
36
- { immediate: true }
37
- );
33
+ nuxtApp.hook("app:rendered", refreshMeta);
34
+ } else {
35
+ refreshMeta();
36
+ nuxtApp.hook("page:finish", refreshMeta);
38
37
  }
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
+ );
39
48
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nuxt-i18n-micro",
3
- "version": "3.20.0",
3
+ "version": "3.20.1",
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",
@@ -77,12 +77,12 @@
77
77
  "unplugin": "^1.16.1",
78
78
  "@vue/compiler-sfc": "^3.5.25",
79
79
  "@i18n-micro/hmr": "1.0.1",
80
+ "@i18n-micro/route-strategy": "1.1.8",
80
81
  "@i18n-micro/core": "1.3.2",
81
- "@i18n-micro/path-strategy": "1.3.3",
82
- "@i18n-micro/types": "1.2.4",
83
82
  "@i18n-micro/test-utils": "1.2.2",
84
- "@i18n-micro/route-strategy": "1.1.8",
85
- "@i18n-micro/utils": "1.0.1"
83
+ "@i18n-micro/types": "1.2.5",
84
+ "@i18n-micro/utils": "1.0.2",
85
+ "@i18n-micro/path-strategy": "1.3.3"
86
86
  },
87
87
  "devDependencies": {
88
88
  "oxfmt": "^0.43.0",
@@ -1 +0,0 @@
1
- {"id":"5a55317c-1ad8-41ca-a7f6-2fe58e16b2f6","timestamp":1781512935536,"matcher":{"static":{},"wildcard":{},"dynamic":{}},"prerendered":[]}