nuxt-i18n-micro 2.4.0 → 2.6.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/119cca13-ae84-4b8a-b244-c16eb4a6ed9f.json +1 -0
- package/dist/client/index.html +2 -2
- package/dist/module.json +1 -1
- package/dist/module.mjs +7 -5
- package/dist/runtime/plugins/01.plugin.js +7 -7
- package/dist/runtime/translation-server-middleware.js +4 -1
- package/package.json +3 -3
- package/dist/client/_nuxt/builds/meta/2d4fb144-8539-4f7d-a7d3-5dedb810c640.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},1762414713405,false]</script>
|
|
12
|
+
<script>window.__NUXT__={};window.__NUXT__.config={public:{},app:{baseURL:"/__NUXT_DEVTOOLS_I18N_BASE__/",buildId:"119cca13-ae84-4b8a-b244-c16eb4a6ed9f",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},1762414713405,false]</script>
|
|
12
|
+
<script>window.__NUXT__={};window.__NUXT__.config={public:{},app:{baseURL:"/__NUXT_DEVTOOLS_I18N_BASE__/",buildId:"119cca13-ae84-4b8a-b244-c16eb4a6ed9f",buildAssetsDir:"/_nuxt/",cdnURL:""}}</script></body></html>
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"id":"
|
|
1
|
+
{"id":"119cca13-ae84-4b8a-b244-c16eb4a6ed9f","timestamp":1762414707440}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"id":"119cca13-ae84-4b8a-b244-c16eb4a6ed9f","timestamp":1762414707440,"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},1762414713405,false]</script>
|
|
12
|
+
<script>window.__NUXT__={};window.__NUXT__.config={public:{},app:{baseURL:"/__NUXT_DEVTOOLS_I18N_BASE__/",buildId:"119cca13-ae84-4b8a-b244-c16eb4a6ed9f",buildAssetsDir:"/_nuxt/",cdnURL:""}}</script></body></html>
|
package/dist/module.json
CHANGED
package/dist/module.mjs
CHANGED
|
@@ -895,7 +895,8 @@ const module = defineNuxtModule({
|
|
|
895
895
|
write: true,
|
|
896
896
|
getContents: () => `export const plural = ${options.plural.toString()};`
|
|
897
897
|
});
|
|
898
|
-
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,}/, "");
|
|
899
900
|
nuxt.options.runtimeConfig.public.i18nConfig = {
|
|
900
901
|
locales: localeManager.locales ?? [],
|
|
901
902
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
@@ -945,7 +946,8 @@ const module = defineNuxtModule({
|
|
|
945
946
|
customRegexMatcher: options.customRegexMatcher,
|
|
946
947
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
947
948
|
// @ts-ignore
|
|
948
|
-
routesLocaleLinks: options.routesLocaleLinks ?? {}
|
|
949
|
+
routesLocaleLinks: options.routesLocaleLinks ?? {},
|
|
950
|
+
apiBaseUrl
|
|
949
951
|
};
|
|
950
952
|
addImportsDir(resolver.resolve("./runtime/composables"));
|
|
951
953
|
if (process.env && process.env.TEST) {
|
|
@@ -997,7 +999,7 @@ const module = defineNuxtModule({
|
|
|
997
999
|
});
|
|
998
1000
|
}
|
|
999
1001
|
addServerHandler({
|
|
1000
|
-
route:
|
|
1002
|
+
route: `${apiBaseUrl}/:page/:locale/data.json`,
|
|
1001
1003
|
handler: resolver.resolve("./runtime/server/routes/get")
|
|
1002
1004
|
});
|
|
1003
1005
|
addComponentsDir({
|
|
@@ -1072,10 +1074,10 @@ ${accepts}
|
|
|
1072
1074
|
localeManager.locales.forEach((locale) => {
|
|
1073
1075
|
if (!options.disablePageLocales) {
|
|
1074
1076
|
pagesNames.forEach((name) => {
|
|
1075
|
-
prerenderRoutes.push(
|
|
1077
|
+
prerenderRoutes.push(`${apiBaseUrl}/${name}/${locale.code}/data.json`);
|
|
1076
1078
|
});
|
|
1077
1079
|
}
|
|
1078
|
-
prerenderRoutes.push(
|
|
1080
|
+
prerenderRoutes.push(`${apiBaseUrl}/general/${locale.code}/data.json`);
|
|
1079
1081
|
});
|
|
1080
1082
|
if (!options.disableWatcher) {
|
|
1081
1083
|
localeManager.ensureTranslationFilesExist(pagesNames, options.translationDir, nuxt.options.rootDir);
|
|
@@ -7,7 +7,7 @@ const isDev = process.env.NODE_ENV !== "production";
|
|
|
7
7
|
export default defineNuxtPlugin(async (nuxtApp) => {
|
|
8
8
|
const config = useRuntimeConfig();
|
|
9
9
|
const i18nConfig = config.public.i18nConfig;
|
|
10
|
-
const apiBaseUrl = i18nConfig.apiBaseUrl ?? "_locales";
|
|
10
|
+
const apiBaseUrl = i18nConfig.apiBaseUrl ?? "/_locales";
|
|
11
11
|
const router = useRouter();
|
|
12
12
|
const runtimeConfig = useRuntimeConfig();
|
|
13
13
|
const generalLocaleCache = useState("i18n-general-cache", () => ({}));
|
|
@@ -58,7 +58,7 @@ export default defineNuxtPlugin(async (nuxtApp) => {
|
|
|
58
58
|
if (isNoPrefixStrategy(i18nConfig.strategy)) {
|
|
59
59
|
locale = await nuxtApp.runWithContext(() => useCookie("no-prefix-locale", { default: () => locale }).value);
|
|
60
60
|
}
|
|
61
|
-
const routeName = routeService.
|
|
61
|
+
const routeName = routeService.getPluginRouteName(to, locale);
|
|
62
62
|
if (!routeName) {
|
|
63
63
|
return;
|
|
64
64
|
}
|
|
@@ -68,7 +68,7 @@ export default defineNuxtPlugin(async (nuxtApp) => {
|
|
|
68
68
|
}
|
|
69
69
|
return;
|
|
70
70
|
}
|
|
71
|
-
const url =
|
|
71
|
+
const url = `${apiBaseUrl}/${routeName}/${locale}/data.json`.replace(/\/{2,}/g, "/");
|
|
72
72
|
try {
|
|
73
73
|
const data = await $fetch(url, {
|
|
74
74
|
baseURL: runtimeConfig.app.baseURL,
|
|
@@ -92,7 +92,7 @@ export default defineNuxtPlugin(async (nuxtApp) => {
|
|
|
92
92
|
}
|
|
93
93
|
if (import.meta.client && enablePreviousPageFallback) {
|
|
94
94
|
const fromLocale = routeService.getCurrentLocale(from);
|
|
95
|
-
const fromRouteName = routeService.
|
|
95
|
+
const fromRouteName = routeService.getPluginRouteName(from, fromLocale);
|
|
96
96
|
previousPageInfo.value = { locale: fromLocale, routeName: fromRouteName };
|
|
97
97
|
}
|
|
98
98
|
try {
|
|
@@ -119,7 +119,7 @@ export default defineNuxtPlugin(async (nuxtApp) => {
|
|
|
119
119
|
if (!key) return "";
|
|
120
120
|
route = route ?? routeService.getCurrentRoute();
|
|
121
121
|
const locale = routeService.getCurrentLocale();
|
|
122
|
-
const routeName = routeService.
|
|
122
|
+
const routeName = routeService.getPluginRouteName(route, locale);
|
|
123
123
|
let value = i18nHelper.getTranslation(locale, routeName, key);
|
|
124
124
|
if (!value && previousPageInfo.value && enablePreviousPageFallback) {
|
|
125
125
|
const prev = previousPageInfo.value;
|
|
@@ -172,13 +172,13 @@ export default defineNuxtPlugin(async (nuxtApp) => {
|
|
|
172
172
|
has: (key, route) => {
|
|
173
173
|
route = route ?? routeService.getCurrentRoute();
|
|
174
174
|
const locale = routeService.getCurrentLocale();
|
|
175
|
-
const routeName = routeService.
|
|
175
|
+
const routeName = routeService.getPluginRouteName(route, locale);
|
|
176
176
|
return !!i18nHelper.getTranslation(locale, routeName, key);
|
|
177
177
|
},
|
|
178
178
|
mergeTranslations: (newTranslations) => {
|
|
179
179
|
const route = routeService.getCurrentRoute();
|
|
180
180
|
const locale = routeService.getCurrentLocale(route);
|
|
181
|
-
const routeName = routeService.
|
|
181
|
+
const routeName = routeService.getPluginRouteName(route, locale);
|
|
182
182
|
i18nHelper.mergeTranslation(locale, routeName, newTranslations);
|
|
183
183
|
},
|
|
184
184
|
mergeGlobalTranslations: (newTranslations) => {
|
|
@@ -4,7 +4,10 @@ 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 i18nConfig = config.i18nConfig;
|
|
9
|
+
const apiBaseUrl = i18nConfig?.apiBaseUrl ?? "/_locales";
|
|
10
|
+
const translations = await $fetch(`${apiBaseUrl}/general/${locale}/data.json`);
|
|
8
11
|
return translations;
|
|
9
12
|
} catch (error) {
|
|
10
13
|
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.6.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-types": "1.0.12",
|
|
65
64
|
"nuxt-i18n-micro-test-utils": "1.0.7",
|
|
66
|
-
"nuxt-i18n-micro-
|
|
65
|
+
"nuxt-i18n-micro-types": "1.0.13",
|
|
66
|
+
"nuxt-i18n-micro-core": "1.0.24"
|
|
67
67
|
},
|
|
68
68
|
"devDependencies": {
|
|
69
69
|
"@nuxt/devtools": "^2.6.3",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"id":"2d4fb144-8539-4f7d-a7d3-5dedb810c640","timestamp":1762341830059,"matcher":{"static":{},"wildcard":{},"dynamic":{}},"prerendered":[]}
|