nuxt-i18n-micro 2.3.0 → 2.5.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.
- package/dist/client/200.html +2 -2
- package/dist/client/404.html +2 -2
- package/dist/client/_nuxt/builds/latest.json +1 -1
- package/dist/client/_nuxt/builds/meta/dc8ec25f-2f2b-41cd-9ff1-ce2de81f36ea.json +1 -0
- package/dist/client/index.html +2 -2
- package/dist/module.json +1 -1
- package/dist/module.mjs +61 -13
- package/dist/runtime/components/i18n-link.vue +2 -1
- package/dist/runtime/composables/useLocaleHead.js +15 -6
- package/dist/runtime/plugins/01.plugin.js +4 -3
- package/dist/runtime/plugins/02.meta.js +2 -1
- package/dist/runtime/plugins/03.define.js +2 -1
- package/dist/runtime/translation-server-middleware.js +3 -1
- package/package.json +4 -4
- package/dist/client/_nuxt/builds/meta/1f0be1c2-48e6-40e6-8faf-6f8e0f051970.json +0 -1
package/dist/client/200.html
CHANGED
|
@@ -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},
|
|
12
|
-
<script>window.__NUXT__={};window.__NUXT__.config={public:{},app:{baseURL:"/__NUXT_DEVTOOLS_I18N_BASE__/",buildId:"
|
|
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},1762356606888,false]</script>
|
|
12
|
+
<script>window.__NUXT__={};window.__NUXT__.config={public:{},app:{baseURL:"/__NUXT_DEVTOOLS_I18N_BASE__/",buildId:"dc8ec25f-2f2b-41cd-9ff1-ce2de81f36ea",buildAssetsDir:"/_nuxt/",cdnURL:""}}</script></body></html>
|
package/dist/client/404.html
CHANGED
|
@@ -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},
|
|
12
|
-
<script>window.__NUXT__={};window.__NUXT__.config={public:{},app:{baseURL:"/__NUXT_DEVTOOLS_I18N_BASE__/",buildId:"
|
|
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},1762356606889,false]</script>
|
|
12
|
+
<script>window.__NUXT__={};window.__NUXT__.config={public:{},app:{baseURL:"/__NUXT_DEVTOOLS_I18N_BASE__/",buildId:"dc8ec25f-2f2b-41cd-9ff1-ce2de81f36ea",buildAssetsDir:"/_nuxt/",cdnURL:""}}</script></body></html>
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"id":"
|
|
1
|
+
{"id":"dc8ec25f-2f2b-41cd-9ff1-ce2de81f36ea","timestamp":1762356596622}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"id":"dc8ec25f-2f2b-41cd-9ff1-ce2de81f36ea","timestamp":1762356596622,"matcher":{"static":{},"wildcard":{},"dynamic":{}},"prerendered":[]}
|
package/dist/client/index.html
CHANGED
|
@@ -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},
|
|
12
|
-
<script>window.__NUXT__={};window.__NUXT__.config={public:{},app:{baseURL:"/__NUXT_DEVTOOLS_I18N_BASE__/",buildId:"
|
|
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},1762356606889,false]</script>
|
|
12
|
+
<script>window.__NUXT__={};window.__NUXT__.config={public:{},app:{baseURL:"/__NUXT_DEVTOOLS_I18N_BASE__/",buildId:"dc8ec25f-2f2b-41cd-9ff1-ce2de81f36ea",buildAssetsDir:"/_nuxt/",cdnURL:""}}</script></body></html>
|
package/dist/module.json
CHANGED
package/dist/module.mjs
CHANGED
|
@@ -194,6 +194,34 @@ function extractDefineI18nRouteData(content, _filePath) {
|
|
|
194
194
|
if (!configObject) {
|
|
195
195
|
return null;
|
|
196
196
|
}
|
|
197
|
+
if (configObject.locales && typeof configObject.locales === "object" && !Array.isArray(configObject.locales)) {
|
|
198
|
+
const localesObj = configObject.locales;
|
|
199
|
+
const normalizedLocales = [];
|
|
200
|
+
const normalizedLocaleRoutes = {};
|
|
201
|
+
for (const [locale, value] of Object.entries(localesObj)) {
|
|
202
|
+
normalizedLocales.push(locale);
|
|
203
|
+
if (value && typeof value === "object" && "path" in value && typeof value.path === "string") {
|
|
204
|
+
normalizedLocaleRoutes[locale] = value.path;
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
return {
|
|
208
|
+
...configObject,
|
|
209
|
+
locales: normalizedLocales,
|
|
210
|
+
localeRoutes: configObject.localeRoutes || Object.keys(normalizedLocaleRoutes).length > 0 ? { ...configObject.localeRoutes, ...normalizedLocaleRoutes } : void 0
|
|
211
|
+
};
|
|
212
|
+
}
|
|
213
|
+
if (Array.isArray(configObject.locales) && configObject.locales.length > 0 && typeof configObject.locales[0] === "object") {
|
|
214
|
+
const normalizedLocales = configObject.locales.map((item) => {
|
|
215
|
+
if (item && typeof item === "object" && "code" in item) {
|
|
216
|
+
return item.code;
|
|
217
|
+
}
|
|
218
|
+
return String(item);
|
|
219
|
+
});
|
|
220
|
+
return {
|
|
221
|
+
...configObject,
|
|
222
|
+
locales: normalizedLocales
|
|
223
|
+
};
|
|
224
|
+
}
|
|
197
225
|
return configObject;
|
|
198
226
|
} catch {
|
|
199
227
|
return null;
|
|
@@ -363,8 +391,16 @@ class PageManager {
|
|
|
363
391
|
if (customPaths) {
|
|
364
392
|
localesToGenerate.forEach((locale) => {
|
|
365
393
|
if (customPaths[locale.code]) {
|
|
366
|
-
|
|
367
|
-
|
|
394
|
+
if (isPrefixAndDefaultStrategy(this.strategy) && locale.code === defaultLocaleCode) {
|
|
395
|
+
const nonPrefixedRoute = this.createLocalizedRoute(page, [locale.code], originalChildren, true, customPaths[locale.code], customRegex, false, locale.code, originalPath);
|
|
396
|
+
if (nonPrefixedRoute) additionalRoutes.push(nonPrefixedRoute);
|
|
397
|
+
const prefixedRoute = this.createLocalizedRoute(page, [locale.code], originalChildren, true, customPaths[locale.code], customRegex, true, locale.code, originalPath);
|
|
398
|
+
if (prefixedRoute) additionalRoutes.push(prefixedRoute);
|
|
399
|
+
} else {
|
|
400
|
+
const shouldAddPrefix = isPrefixAndDefaultStrategy(this.strategy) && locale.code === defaultLocaleCode;
|
|
401
|
+
const newRoute = this.createLocalizedRoute(page, [locale.code], originalChildren, true, customPaths[locale.code], customRegex, shouldAddPrefix, locale.code, originalPath);
|
|
402
|
+
if (newRoute) additionalRoutes.push(newRoute);
|
|
403
|
+
}
|
|
368
404
|
} else {
|
|
369
405
|
const newRoute = this.createLocalizedRoute(page, [locale.code], originalChildren, false, "", customRegex, false, locale.code, originalPath);
|
|
370
406
|
if (newRoute) additionalRoutes.push(newRoute);
|
|
@@ -495,6 +531,9 @@ class PageManager {
|
|
|
495
531
|
if (isNoPrefixStrategy(this.strategy)) {
|
|
496
532
|
return;
|
|
497
533
|
}
|
|
534
|
+
if (isPrefixAndDefaultStrategy(this.strategy)) {
|
|
535
|
+
return;
|
|
536
|
+
}
|
|
498
537
|
const defaultLocalePath = this.localizedPaths[page.path]?.[this.defaultLocale.code];
|
|
499
538
|
if (defaultLocalePath) {
|
|
500
539
|
page.path = normalizePath(defaultLocalePath);
|
|
@@ -533,16 +572,22 @@ class PageManager {
|
|
|
533
572
|
if (isDefaultLocale && isPrefixExceptDefaultStrategy(this.strategy)) {
|
|
534
573
|
page.path = normalizePath(customPath);
|
|
535
574
|
page.children = this.createLocalizedChildren(originalChildren, "", [locale.code], false, false, false, { [locale.code]: customPath });
|
|
575
|
+
} else if (isPrefixAndDefaultStrategy(this.strategy) && locale === this.defaultLocale) {
|
|
576
|
+
const nonPrefixedRoute = this.createLocalizedRoute(page, [locale.code], originalChildren, true, customPath, customRegex, false, locale.code);
|
|
577
|
+
if (nonPrefixedRoute) {
|
|
578
|
+
additionalRoutes.push(nonPrefixedRoute);
|
|
579
|
+
}
|
|
580
|
+
const prefixedRoute = this.createLocalizedRoute(page, [locale.code], originalChildren, true, customPath, customRegex, true, locale.code);
|
|
581
|
+
if (prefixedRoute) {
|
|
582
|
+
additionalRoutes.push(prefixedRoute);
|
|
583
|
+
}
|
|
536
584
|
} else {
|
|
537
|
-
const
|
|
585
|
+
const shouldAddPrefix = !isDefaultLocale;
|
|
586
|
+
const newRoute = this.createLocalizedRoute(page, [locale.code], originalChildren, true, customPath, customRegex, shouldAddPrefix, locale.code);
|
|
538
587
|
if (newRoute) {
|
|
539
588
|
additionalRoutes.push(newRoute);
|
|
540
589
|
}
|
|
541
590
|
}
|
|
542
|
-
if (isPrefixAndDefaultStrategy(this.strategy) && locale === this.defaultLocale) {
|
|
543
|
-
const newRoute = this.createLocalizedRoute(page, [locale.code], originalChildren, true, customPath, customRegex, true, locale.code);
|
|
544
|
-
if (newRoute) additionalRoutes.push(newRoute);
|
|
545
|
-
}
|
|
546
591
|
});
|
|
547
592
|
}
|
|
548
593
|
createLocalizedChildren(routes, parentPath, localeCodes, modifyName = true, addLocalePrefix = false, parentLocale = false, localizedParentPaths = {}) {
|
|
@@ -649,7 +694,8 @@ class PageManager {
|
|
|
649
694
|
}
|
|
650
695
|
createLocalizedRoute(page, localeCodes, originalChildren, isCustom, customPath = "", customRegex, force = false, parentLocale = false, originalPagePath) {
|
|
651
696
|
const routePath = this.buildRoutePath(localeCodes, page.path, encodeURI(customPath), isCustom, customRegex, force);
|
|
652
|
-
|
|
697
|
+
const isPrefixAndDefaultWithCustomPath = isPrefixAndDefaultStrategy(this.strategy) && isCustom && customPath;
|
|
698
|
+
if (!routePath || !isPrefixAndDefaultWithCustomPath && routePath === page.path) return null;
|
|
653
699
|
if (localeCodes.length === 0) return null;
|
|
654
700
|
const firstLocale = localeCodes[0];
|
|
655
701
|
if (!firstLocale) return null;
|
|
@@ -682,7 +728,8 @@ class PageManager {
|
|
|
682
728
|
return buildFullPathNoPrefix(isCustom ? customPath : originalPath);
|
|
683
729
|
}
|
|
684
730
|
if (isCustom) {
|
|
685
|
-
|
|
731
|
+
const shouldAddPrefix = force || isPrefixStrategy(this.strategy) || isPrefixAndDefaultStrategy(this.strategy) && !localeCodes.includes(this.defaultLocale.code) || !localeCodes.includes(this.defaultLocale.code);
|
|
732
|
+
return shouldAddPrefix ? buildFullPath(localeCodes, customPath, customRegex) : normalizePath(customPath);
|
|
686
733
|
}
|
|
687
734
|
return buildFullPath(localeCodes, originalPath, customRegex);
|
|
688
735
|
}
|
|
@@ -848,7 +895,8 @@ const module = defineNuxtModule({
|
|
|
848
895
|
write: true,
|
|
849
896
|
getContents: () => `export const plural = ${options.plural.toString()};`
|
|
850
897
|
});
|
|
851
|
-
const
|
|
898
|
+
const rawUrl = process.env.NUXT_I18N_APP_BASE_URL ?? options.apiBaseUrl ?? "_locales";
|
|
899
|
+
const apiBaseUrl = rawUrl.startsWith("http://") || rawUrl.startsWith("https://") ? rawUrl : "/" + rawUrl.replace(/^\/+|\/+$|\/{2,}/, "");
|
|
852
900
|
nuxt.options.runtimeConfig.public.i18nConfig = {
|
|
853
901
|
locales: localeManager.locales ?? [],
|
|
854
902
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
@@ -950,7 +998,7 @@ const module = defineNuxtModule({
|
|
|
950
998
|
});
|
|
951
999
|
}
|
|
952
1000
|
addServerHandler({
|
|
953
|
-
route:
|
|
1001
|
+
route: `${apiBaseUrl}/:page/:locale/data.json`,
|
|
954
1002
|
handler: resolver.resolve("./runtime/server/routes/get")
|
|
955
1003
|
});
|
|
956
1004
|
addComponentsDir({
|
|
@@ -1025,10 +1073,10 @@ ${accepts}
|
|
|
1025
1073
|
localeManager.locales.forEach((locale) => {
|
|
1026
1074
|
if (!options.disablePageLocales) {
|
|
1027
1075
|
pagesNames.forEach((name) => {
|
|
1028
|
-
prerenderRoutes.push(
|
|
1076
|
+
prerenderRoutes.push(`${apiBaseUrl}/${name}/${locale.code}/data.json`);
|
|
1029
1077
|
});
|
|
1030
1078
|
}
|
|
1031
|
-
prerenderRoutes.push(
|
|
1079
|
+
prerenderRoutes.push(`${apiBaseUrl}/general/${locale.code}/data.json`);
|
|
1032
1080
|
});
|
|
1033
1081
|
if (!options.disableWatcher) {
|
|
1034
1082
|
localeManager.ensureTranslationFilesExist(pagesNames, options.translationDir, nuxt.options.rootDir);
|
|
@@ -19,7 +19,8 @@
|
|
|
19
19
|
</template>
|
|
20
20
|
|
|
21
21
|
<script setup>
|
|
22
|
-
import { useNuxtApp,
|
|
22
|
+
import { useNuxtApp, useRoute, useRouter } from "#imports";
|
|
23
|
+
import { computed } from "vue";
|
|
23
24
|
const { $localeRoute } = useNuxtApp();
|
|
24
25
|
const props = defineProps({
|
|
25
26
|
to: { type: [Object, String], required: true },
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { joinURL, parseURL, withQuery } from "ufo";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
2
|
+
import { isNoPrefixStrategy } from "nuxt-i18n-micro-core";
|
|
3
|
+
import { useRoute, useRuntimeConfig, useNuxtApp } from "#imports";
|
|
4
4
|
import { findAllowedLocalesForRoute } from "../utils/route-utils.js";
|
|
5
|
+
import { ref, unref } from "vue";
|
|
5
6
|
export const useLocaleHead = ({ addDirAttribute = true, identifierAttribute = "id", addSeoAttributes = true, baseUrl = "/" } = {}) => {
|
|
6
7
|
const metaObject = ref({
|
|
7
8
|
htmlAttrs: {},
|
|
@@ -20,8 +21,8 @@ export const useLocaleHead = ({ addDirAttribute = true, identifierAttribute = "i
|
|
|
20
21
|
return withQuery(pathname, filtered);
|
|
21
22
|
}
|
|
22
23
|
function updateMeta() {
|
|
23
|
-
const {
|
|
24
|
-
const { $getLocales, $getLocale } = useNuxtApp();
|
|
24
|
+
const { strategy, canonicalQueryWhitelist, routeLocales } = useRuntimeConfig().public.i18nConfig;
|
|
25
|
+
const { $getLocales, $getLocale, $switchLocalePath } = useNuxtApp();
|
|
25
26
|
if (!$getLocale || !$getLocales) return;
|
|
26
27
|
const route = useRoute();
|
|
27
28
|
const locale = unref($getLocale());
|
|
@@ -80,8 +81,16 @@ export const useLocaleHead = ({ addDirAttribute = true, identifierAttribute = "i
|
|
|
80
81
|
href: ogUrl
|
|
81
82
|
};
|
|
82
83
|
const alternateLinks = isNoPrefixStrategy(strategy) ? [] : alternateLocales.flatMap((loc) => {
|
|
83
|
-
const
|
|
84
|
-
|
|
84
|
+
const switchedPath = $switchLocalePath(loc.code);
|
|
85
|
+
if (!switchedPath) {
|
|
86
|
+
return [];
|
|
87
|
+
}
|
|
88
|
+
let href;
|
|
89
|
+
if (switchedPath.startsWith("http://") || switchedPath.startsWith("https://")) {
|
|
90
|
+
href = switchedPath;
|
|
91
|
+
} else {
|
|
92
|
+
href = joinURL(unref(baseUrl), switchedPath.startsWith("/") ? switchedPath : `/${switchedPath}`);
|
|
93
|
+
}
|
|
85
94
|
const links = [{
|
|
86
95
|
[identifierAttribute]: `i18n-alternate-${loc.code}`,
|
|
87
96
|
rel: "alternate",
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import { useTranslationHelper, interpolate, isNoPrefixStrategy, RouteService, FormatService } from "nuxt-i18n-micro-core";
|
|
2
|
-
import { useRouter, useCookie,
|
|
2
|
+
import { useRouter, useCookie, navigateTo, defineNuxtPlugin, useRuntimeConfig, createError } from "#imports";
|
|
3
|
+
import { unref } from "vue";
|
|
3
4
|
import { useState } from "#app";
|
|
4
5
|
import { plural } from "#build/i18n.plural.mjs";
|
|
5
6
|
const isDev = process.env.NODE_ENV !== "production";
|
|
6
7
|
export default defineNuxtPlugin(async (nuxtApp) => {
|
|
7
8
|
const config = useRuntimeConfig();
|
|
8
9
|
const i18nConfig = config.public.i18nConfig;
|
|
9
|
-
const apiBaseUrl = i18nConfig.apiBaseUrl ?? "_locales";
|
|
10
|
+
const apiBaseUrl = i18nConfig.apiBaseUrl ?? "/_locales";
|
|
10
11
|
const router = useRouter();
|
|
11
12
|
const runtimeConfig = useRuntimeConfig();
|
|
12
13
|
const generalLocaleCache = useState("i18n-general-cache", () => ({}));
|
|
@@ -67,7 +68,7 @@ export default defineNuxtPlugin(async (nuxtApp) => {
|
|
|
67
68
|
}
|
|
68
69
|
return;
|
|
69
70
|
}
|
|
70
|
-
const url =
|
|
71
|
+
const url = `${apiBaseUrl}/${routeName}/${locale}/data.json`.replace(/\/{2,}/g, "/");
|
|
71
72
|
try {
|
|
72
73
|
const data = await $fetch(url, {
|
|
73
74
|
baseURL: runtimeConfig.app.baseURL,
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { useLocaleHead } from "../composables/useLocaleHead.js";
|
|
2
|
-
import { useRequestURL, useHead, defineNuxtPlugin, useRuntimeConfig, useRoute
|
|
2
|
+
import { useRequestURL, useHead, defineNuxtPlugin, useRuntimeConfig, useRoute } from "#imports";
|
|
3
|
+
import { watch } from "vue";
|
|
3
4
|
import { isMetaDisabledForRoute } from "../utils/route-utils.js";
|
|
4
5
|
const host = process.env.HOST ?? "localhost";
|
|
5
6
|
const port = process.env.PORT ?? "host";
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { defineNuxtPlugin, useNuxtApp
|
|
1
|
+
import { defineNuxtPlugin, useNuxtApp } from "#imports";
|
|
2
|
+
import { watch, unref, computed, onUnmounted } from "vue";
|
|
2
3
|
const normalizeLocales = (locales) => {
|
|
3
4
|
if (Array.isArray(locales)) {
|
|
4
5
|
return locales.reduce((acc, locale) => {
|
|
@@ -4,7 +4,9 @@ import { useRuntimeConfig } from "#imports";
|
|
|
4
4
|
const I18N_CONTEXT_KEY = "__i18n_cache__";
|
|
5
5
|
async function fetchTranslations(locale) {
|
|
6
6
|
try {
|
|
7
|
-
const
|
|
7
|
+
const config = useRuntimeConfig();
|
|
8
|
+
const apiBaseUrl = config.public.i18nConfig?.apiBaseUrl ?? "/_locales";
|
|
9
|
+
const translations = await $fetch(`${apiBaseUrl}/general/${locale}/data.json`);
|
|
8
10
|
return translations;
|
|
9
11
|
} catch (error) {
|
|
10
12
|
console.error(`Error loading translation for locale "${locale}":`, error);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nuxt-i18n-micro",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.5.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",
|
|
@@ -61,9 +61,9 @@
|
|
|
61
61
|
"globby": "^14.1.0",
|
|
62
62
|
"sirv": "^2.0.4",
|
|
63
63
|
"ufo": "^1.5.4",
|
|
64
|
-
"nuxt-i18n-micro-
|
|
64
|
+
"nuxt-i18n-micro-types": "1.0.12",
|
|
65
65
|
"nuxt-i18n-micro-test-utils": "1.0.7",
|
|
66
|
-
"nuxt-i18n-micro-
|
|
66
|
+
"nuxt-i18n-micro-core": "1.0.23"
|
|
67
67
|
},
|
|
68
68
|
"devDependencies": {
|
|
69
69
|
"@nuxt/devtools": "^2.6.3",
|
|
@@ -100,7 +100,7 @@
|
|
|
100
100
|
"dev:build": "nuxi build playground",
|
|
101
101
|
"dev:prepare": "nuxt-module-build build --stub && nuxt-module-build prepare && nuxi prepare playground",
|
|
102
102
|
"dev:generate": "nuxi generate playground",
|
|
103
|
-
"release": "pnpm run lint && pnpm run typecheck && pnpm run test:types && pnpm run test && pnpm run test:workspaces && pnpm run prepack && changelogen --release && pnpm publish -r && git push --follow-tags",
|
|
103
|
+
"release": "pnpm run lint && pnpm run typecheck && pnpm run test:types && pnpm run test && pnpm run test:vitest && pnpm run test:workspaces && pnpm run prepack && changelogen --release && pnpm publish -r && git push --follow-tags",
|
|
104
104
|
"lint": "eslint .",
|
|
105
105
|
"lint:fix": "eslint . --fix",
|
|
106
106
|
"test": "playwright test",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"id":"1f0be1c2-48e6-40e6-8faf-6f8e0f051970","timestamp":1762281055061,"matcher":{"static":{},"wildcard":{},"dynamic":{}},"prerendered":[]}
|