@uipkge/nuxt 0.1.16 → 0.1.17

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.
package/dist/module.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "compatibility": {
5
5
  "nuxt": ">=3.0.0"
6
6
  },
7
- "version": "0.1.16",
7
+ "version": "0.1.17",
8
8
  "builder": {
9
9
  "@nuxt/module-builder": "1.0.2",
10
10
  "unbuild": "unknown"
@@ -107,7 +107,13 @@ export default defineNuxtPlugin(async (nuxtApp) => {
107
107
  }
108
108
  }
109
109
  }
110
- await loadLocale(locale);
110
+ let currentLocale = locale;
111
+ const ssrKeys = nuxtApp.payload.i18nowCdnKeys;
112
+ if (ssrKeys && ssrKeys.length > 0) {
113
+ syncer.setExistingKeys(ssrKeys);
114
+ } else {
115
+ await loadLocale(locale);
116
+ }
111
117
  const originalGlobalT = nuxtApp.vueApp.config.globalProperties.$t;
112
118
  if (originalGlobalT) {
113
119
  nuxtApp.vueApp.config.globalProperties.$t = function(key, defaultValue, ...rest) {
@@ -120,6 +126,8 @@ export default defineNuxtPlugin(async (nuxtApp) => {
120
126
  };
121
127
  }
122
128
  nuxtApp.hook("i18n:beforeLocaleSwitch", async ({ newLocale }) => {
129
+ if (newLocale === currentLocale) return;
130
+ currentLocale = newLocale;
123
131
  await loadLocale(newLocale);
124
132
  });
125
133
  return {
@@ -24,6 +24,7 @@ export default defineNuxtPlugin(async (nuxtApp) => {
24
24
  }
25
25
  const messages = data;
26
26
  if (i18n) i18n.setLocaleMessage(locale, messages);
27
+ nuxtApp.payload.i18nowCdnKeys = Object.keys(messages);
27
28
  } catch (err) {
28
29
  if (import.meta.dev) {
29
30
  console.warn(`[i18now] Failed to load locale '${locale}' from CDN:`, err);
@@ -31,8 +32,11 @@ export default defineNuxtPlugin(async (nuxtApp) => {
31
32
  }
32
33
  }
33
34
  const currentLocale = i18n?.locale?.value ?? i18n?.locale ?? configLocale;
35
+ let activeLocale = currentLocale;
34
36
  await loadLocale(currentLocale);
35
37
  nuxtApp.hook("i18n:beforeLocaleSwitch", async ({ newLocale }) => {
38
+ if (newLocale === activeLocale) return;
39
+ activeLocale = newLocale;
36
40
  await loadLocale(newLocale);
37
41
  });
38
42
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@uipkge/nuxt",
3
- "version": "0.1.16",
3
+ "version": "0.1.17",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "exports": {