nuxt-i18n-micro 1.13.1 → 1.13.2
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 +1 -1
- package/dist/client/404.html +1 -1
- package/dist/client/_nuxt/builds/latest.json +1 -1
- package/dist/client/_nuxt/builds/meta/1f40d9d0-1d86-4ceb-b98c-da56e66c6bdb.json +1 -0
- package/dist/client/index.html +1 -1
- package/dist/module.json +1 -1
- package/dist/runtime/plugins/01.plugin.d.ts +1 -1
- package/dist/runtime/plugins/01.plugin.js +2 -2
- package/dist/runtime/plugins/03.define.d.ts +2 -2
- package/dist/runtime/plugins/03.define.js +21 -18
- package/package.json +1 -1
- package/dist/client/_nuxt/builds/meta/5324e7e7-92a1-4e32-b4c3-4ce4f77f2934.json +0 -1
package/dist/client/200.html
CHANGED
|
@@ -9,4 +9,4 @@
|
|
|
9
9
|
<link rel="prefetch" as="style" href="/__nuxt-i18n-micro/_nuxt/error-500.21ZDxC33.css">
|
|
10
10
|
<link rel="prefetch" as="script" crossorigin href="/__nuxt-i18n-micro/_nuxt/DzdJBprQ.js">
|
|
11
11
|
<script type="module" src="/__nuxt-i18n-micro/_nuxt/D1fvHJQV.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__">[{"serverRendered":1},false]</script>
|
|
12
|
-
<script>window.__NUXT__={};window.__NUXT__.config={public:{},app:{baseURL:"/__nuxt-i18n-micro",buildId:"
|
|
12
|
+
<script>window.__NUXT__={};window.__NUXT__.config={public:{},app:{baseURL:"/__nuxt-i18n-micro",buildId:"1f40d9d0-1d86-4ceb-b98c-da56e66c6bdb",buildAssetsDir:"/_nuxt/",cdnURL:""}}</script></body></html>
|
package/dist/client/404.html
CHANGED
|
@@ -9,4 +9,4 @@
|
|
|
9
9
|
<link rel="prefetch" as="style" href="/__nuxt-i18n-micro/_nuxt/error-500.21ZDxC33.css">
|
|
10
10
|
<link rel="prefetch" as="script" crossorigin href="/__nuxt-i18n-micro/_nuxt/DzdJBprQ.js">
|
|
11
11
|
<script type="module" src="/__nuxt-i18n-micro/_nuxt/D1fvHJQV.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__">[{"serverRendered":1},false]</script>
|
|
12
|
-
<script>window.__NUXT__={};window.__NUXT__.config={public:{},app:{baseURL:"/__nuxt-i18n-micro",buildId:"
|
|
12
|
+
<script>window.__NUXT__={};window.__NUXT__.config={public:{},app:{baseURL:"/__nuxt-i18n-micro",buildId:"1f40d9d0-1d86-4ceb-b98c-da56e66c6bdb",buildAssetsDir:"/_nuxt/",cdnURL:""}}</script></body></html>
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"id":"
|
|
1
|
+
{"id":"1f40d9d0-1d86-4ceb-b98c-da56e66c6bdb","timestamp":1725460561569}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"id":"1f40d9d0-1d86-4ceb-b98c-da56e66c6bdb","timestamp":1725460561569,"matcher":{"static":{},"wildcard":{},"dynamic":{}},"prerendered":[]}
|
package/dist/client/index.html
CHANGED
|
@@ -9,4 +9,4 @@
|
|
|
9
9
|
<link rel="prefetch" as="style" href="/__nuxt-i18n-micro/_nuxt/error-500.21ZDxC33.css">
|
|
10
10
|
<link rel="prefetch" as="script" crossorigin href="/__nuxt-i18n-micro/_nuxt/DzdJBprQ.js">
|
|
11
11
|
<script type="module" src="/__nuxt-i18n-micro/_nuxt/D1fvHJQV.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__">[{"serverRendered":1},false]</script>
|
|
12
|
-
<script>window.__NUXT__={};window.__NUXT__.config={public:{},app:{baseURL:"/__nuxt-i18n-micro",buildId:"
|
|
12
|
+
<script>window.__NUXT__={};window.__NUXT__.config={public:{},app:{baseURL:"/__nuxt-i18n-micro",buildId:"1f40d9d0-1d86-4ceb-b98c-da56e66c6bdb",buildAssetsDir:"/_nuxt/",cdnURL:""}}</script></body></html>
|
package/dist/module.json
CHANGED
|
@@ -36,7 +36,7 @@ export default _default;
|
|
|
36
36
|
export interface PluginsInjections {
|
|
37
37
|
$getLocale: () => string;
|
|
38
38
|
$getLocales: () => Locale[];
|
|
39
|
-
$getRouteName: (route?:
|
|
39
|
+
$getRouteName: (route?: RouteLocationRaw, locale?: string) => string;
|
|
40
40
|
$t: <T extends Record<string, string | number | boolean>>(key: string, params?: T, defaultValue?: string) => string | number | boolean | Translations | PluralTranslations | unknown[] | unknown | null;
|
|
41
41
|
$tc: (key: string, count: number, defaultValue?: string) => string;
|
|
42
42
|
$tn: (value: number, options?: Intl.NumberFormatOptions) => string;
|
|
@@ -40,7 +40,7 @@ function getLocalizedRoute(to, router, route, i18nConfig, locale) {
|
|
|
40
40
|
const selectRoute = router.resolve(to);
|
|
41
41
|
const routeName = getRouteName(selectRoute, currentLocale);
|
|
42
42
|
if (router.hasRoute(`localized-${routeName}-${currentLocale}`)) {
|
|
43
|
-
const newParams2 = { ...
|
|
43
|
+
const newParams2 = typeof to === "object" && "params" in to && typeof to.params === "object" ? { ...to.params } : {};
|
|
44
44
|
newParams2.locale = currentLocale;
|
|
45
45
|
return router.resolve({
|
|
46
46
|
params: newParams2,
|
|
@@ -48,7 +48,7 @@ function getLocalizedRoute(to, router, route, i18nConfig, locale) {
|
|
|
48
48
|
});
|
|
49
49
|
}
|
|
50
50
|
const newRouteName = currentLocale !== i18nConfig.defaultLocale || i18nConfig.includeDefaultLocaleRoute ? `localized-${routeName}` : routeName;
|
|
51
|
-
const newParams = { ...
|
|
51
|
+
const newParams = typeof to === "object" && "params" in to && typeof to.params === "object" ? { ...to.params } : {};
|
|
52
52
|
delete newParams.locale;
|
|
53
53
|
if (currentLocale !== i18nConfig.defaultLocale || i18nConfig.includeDefaultLocaleRoute) {
|
|
54
54
|
newParams.locale = currentLocale;
|
|
@@ -2,11 +2,11 @@ declare const _default: import("#app").Plugin<{
|
|
|
2
2
|
defineI18nRoute: (routeDefinition: {
|
|
3
3
|
locales?: string[] | Record<string, Record<string, string>>;
|
|
4
4
|
localeRoutes?: Record<string, string>;
|
|
5
|
-
}) => Promise<void
|
|
5
|
+
}) => Promise<void>;
|
|
6
6
|
}> & import("#app").ObjectPlugin<{
|
|
7
7
|
defineI18nRoute: (routeDefinition: {
|
|
8
8
|
locales?: string[] | Record<string, Record<string, string>>;
|
|
9
9
|
localeRoutes?: Record<string, string>;
|
|
10
|
-
}) => Promise<void
|
|
10
|
+
}) => Promise<void>;
|
|
11
11
|
}>;
|
|
12
12
|
export default _default;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { defineNuxtPlugin, useNuxtApp, useRuntimeConfig } from "#app";
|
|
1
|
+
import { defineNuxtPlugin, navigateTo, useNuxtApp, useRuntimeConfig } from "#app";
|
|
2
2
|
import { useRoute, useRouter } from "#imports";
|
|
3
3
|
export default defineNuxtPlugin((_nuxtApp) => {
|
|
4
4
|
const config = useRuntimeConfig();
|
|
@@ -16,29 +16,32 @@ export default defineNuxtPlugin((_nuxtApp) => {
|
|
|
16
16
|
}
|
|
17
17
|
return {};
|
|
18
18
|
};
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
if (!Object.values(normalizedLocales).length || normalizedLocales[currentLocale]) {
|
|
24
|
-
const translation = normalizedLocales[currentLocale];
|
|
25
|
-
const nuxtApp = useNuxtApp();
|
|
26
|
-
nuxtApp.$mergeTranslations(translation);
|
|
27
|
-
} else {
|
|
19
|
+
useRouter().beforeEach(async (to, from, next) => {
|
|
20
|
+
if (i18nConfig.includeDefaultLocaleRoute) {
|
|
21
|
+
const currentLocale = (to.params.locale || i18nConfig.defaultLocale).toString();
|
|
22
|
+
const { name } = to;
|
|
28
23
|
let defaultRouteName = name?.toString().replace("localized-", "").replace(new RegExp(`-${currentLocale}$`), "");
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
if (i18nConfig.includeDefaultLocaleRoute) {
|
|
33
|
-
if (router.hasRoute(`localized-${defaultRouteName}-${currentLocale}`)) {
|
|
34
|
-
defaultRouteName = `localized-${defaultRouteName}-${currentLocale}`;
|
|
24
|
+
if (!to.params.locale) {
|
|
25
|
+
if (router.hasRoute(`localized-${to.name?.toString()}-${currentLocale}`)) {
|
|
26
|
+
defaultRouteName = `localized-${to.name?.toString()}-${currentLocale}`;
|
|
35
27
|
} else {
|
|
36
|
-
defaultRouteName = `localized-${
|
|
28
|
+
defaultRouteName = `localized-${to.name?.toString()}`;
|
|
37
29
|
}
|
|
30
|
+
const newParams = { ...to.params };
|
|
38
31
|
newParams.locale = i18nConfig.defaultLocale;
|
|
39
32
|
newParams.name = defaultRouteName;
|
|
33
|
+
await navigateTo({ name: defaultRouteName, params: newParams }, { redirectCode: 301, external: true });
|
|
40
34
|
}
|
|
41
|
-
|
|
35
|
+
}
|
|
36
|
+
next();
|
|
37
|
+
});
|
|
38
|
+
const defineI18nRoute = async (routeDefinition) => {
|
|
39
|
+
const currentLocale = (route.params.locale || i18nConfig.defaultLocale).toString();
|
|
40
|
+
const normalizedLocales = normalizeLocales(routeDefinition.locales);
|
|
41
|
+
if (!Object.values(normalizedLocales).length || normalizedLocales[currentLocale]) {
|
|
42
|
+
const translation = normalizedLocales[currentLocale];
|
|
43
|
+
const nuxtApp = useNuxtApp();
|
|
44
|
+
nuxtApp.$mergeTranslations(translation);
|
|
42
45
|
}
|
|
43
46
|
};
|
|
44
47
|
return {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nuxt-i18n-micro",
|
|
3
|
-
"version": "1.13.
|
|
3
|
+
"version": "1.13.2",
|
|
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",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"id":"5324e7e7-92a1-4e32-b4c3-4ce4f77f2934","timestamp":1725449582814,"matcher":{"static":{},"wildcard":{},"dynamic":{}},"prerendered":[]}
|