nuxt-i18n-micro 1.20.5 → 1.21.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.
- 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/a2c375f4-a7c7-4cfd-b7bb-b80cf6c29638.json +1 -0
- package/dist/client/index.html +2 -2
- package/dist/module.d.mts +3 -2
- package/dist/module.d.ts +3 -2
- package/dist/module.json +1 -1
- package/dist/runtime/composables/useI18n.js +5 -0
- package/dist/runtime/plugins/01.plugin.d.ts +17 -5
- package/dist/runtime/plugins/01.plugin.js +87 -19
- package/package.json +1 -5
- package/dist/client/_nuxt/builds/meta/83a84051-55cf-4ecf-bbe3-e92d06f718d6.json +0 -1
package/dist/client/200.html
CHANGED
|
@@ -8,5 +8,5 @@
|
|
|
8
8
|
<link rel="prefetch" as="script" crossorigin href="/__nuxt-i18n-micro/_nuxt/CnNUpwZL.js">
|
|
9
9
|
<link rel="prefetch" as="style" crossorigin href="/__nuxt-i18n-micro/_nuxt/error-500.CBAEdpZV.css">
|
|
10
10
|
<link rel="prefetch" as="script" crossorigin href="/__nuxt-i18n-micro/_nuxt/BKcmVa-6.js">
|
|
11
|
-
<script type="module" src="/__nuxt-i18n-micro/_nuxt/CeFL7aT9.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-i18n-micro",buildId:"
|
|
11
|
+
<script type="module" src="/__nuxt-i18n-micro/_nuxt/CeFL7aT9.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},1727601837089,false]</script>
|
|
12
|
+
<script>window.__NUXT__={};window.__NUXT__.config={public:{},app:{baseURL:"/__nuxt-i18n-micro",buildId:"a2c375f4-a7c7-4cfd-b7bb-b80cf6c29638",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-i18n-micro/_nuxt/CnNUpwZL.js">
|
|
9
9
|
<link rel="prefetch" as="style" crossorigin href="/__nuxt-i18n-micro/_nuxt/error-500.CBAEdpZV.css">
|
|
10
10
|
<link rel="prefetch" as="script" crossorigin href="/__nuxt-i18n-micro/_nuxt/BKcmVa-6.js">
|
|
11
|
-
<script type="module" src="/__nuxt-i18n-micro/_nuxt/CeFL7aT9.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-i18n-micro",buildId:"
|
|
11
|
+
<script type="module" src="/__nuxt-i18n-micro/_nuxt/CeFL7aT9.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},1727601837089,false]</script>
|
|
12
|
+
<script>window.__NUXT__={};window.__NUXT__.config={public:{},app:{baseURL:"/__nuxt-i18n-micro",buildId:"a2c375f4-a7c7-4cfd-b7bb-b80cf6c29638",buildAssetsDir:"/_nuxt/",cdnURL:""}}</script></body></html>
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"id":"
|
|
1
|
+
{"id":"a2c375f4-a7c7-4cfd-b7bb-b80cf6c29638","timestamp":1727601826771}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"id":"a2c375f4-a7c7-4cfd-b7bb-b80cf6c29638","timestamp":1727601826771,"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-i18n-micro/_nuxt/CnNUpwZL.js">
|
|
9
9
|
<link rel="prefetch" as="style" crossorigin href="/__nuxt-i18n-micro/_nuxt/error-500.CBAEdpZV.css">
|
|
10
10
|
<link rel="prefetch" as="script" crossorigin href="/__nuxt-i18n-micro/_nuxt/BKcmVa-6.js">
|
|
11
|
-
<script type="module" src="/__nuxt-i18n-micro/_nuxt/CeFL7aT9.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-i18n-micro",buildId:"
|
|
11
|
+
<script type="module" src="/__nuxt-i18n-micro/_nuxt/CeFL7aT9.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},1727601837089,false]</script>
|
|
12
|
+
<script>window.__NUXT__={};window.__NUXT__.config={public:{},app:{baseURL:"/__nuxt-i18n-micro",buildId:"a2c375f4-a7c7-4cfd-b7bb-b80cf6c29638",buildAssetsDir:"/_nuxt/",cdnURL:""}}</script></body></html>
|
package/dist/module.d.mts
CHANGED
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
import * as _nuxt_schema from '@nuxt/schema';
|
|
2
2
|
import { HookResult } from '@nuxt/schema';
|
|
3
3
|
|
|
4
|
+
type LocaleCode = string;
|
|
4
5
|
interface Locale {
|
|
5
|
-
code:
|
|
6
|
+
code: LocaleCode;
|
|
6
7
|
disabled?: boolean;
|
|
7
8
|
iso?: string;
|
|
8
9
|
dir?: 'ltr' | 'rtl' | 'auto';
|
|
9
10
|
}
|
|
10
11
|
type Getter = (key: string, params?: Record<string, string | number | boolean>, defaultValue?: string) => unknown;
|
|
11
12
|
type PluralFunc = (key: string, count: number, locale: string, getter: Getter) => string | null;
|
|
12
|
-
type GlobalLocaleRoutes = Record<string, Record<
|
|
13
|
+
type GlobalLocaleRoutes = Record<string, Record<LocaleCode, string> | false | boolean> | null | undefined;
|
|
13
14
|
interface ModuleOptions {
|
|
14
15
|
locales?: Locale[];
|
|
15
16
|
meta?: boolean;
|
package/dist/module.d.ts
CHANGED
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
import * as _nuxt_schema from '@nuxt/schema';
|
|
2
2
|
import { HookResult } from '@nuxt/schema';
|
|
3
3
|
|
|
4
|
+
type LocaleCode = string;
|
|
4
5
|
interface Locale {
|
|
5
|
-
code:
|
|
6
|
+
code: LocaleCode;
|
|
6
7
|
disabled?: boolean;
|
|
7
8
|
iso?: string;
|
|
8
9
|
dir?: 'ltr' | 'rtl' | 'auto';
|
|
9
10
|
}
|
|
10
11
|
type Getter = (key: string, params?: Record<string, string | number | boolean>, defaultValue?: string) => unknown;
|
|
11
12
|
type PluralFunc = (key: string, count: number, locale: string, getter: Getter) => string | null;
|
|
12
|
-
type GlobalLocaleRoutes = Record<string, Record<
|
|
13
|
+
type GlobalLocaleRoutes = Record<string, Record<LocaleCode, string> | false | boolean> | null | undefined;
|
|
13
14
|
interface ModuleOptions {
|
|
14
15
|
locales?: Locale[];
|
|
15
16
|
meta?: boolean;
|
package/dist/module.json
CHANGED
|
@@ -2,6 +2,7 @@ import { useNuxtApp } from "#imports";
|
|
|
2
2
|
export function useI18n() {
|
|
3
3
|
const nuxtApp = useNuxtApp();
|
|
4
4
|
return {
|
|
5
|
+
$defaultLocale: nuxtApp.$defaultLocale,
|
|
5
6
|
$getLocale: nuxtApp.$getLocale,
|
|
6
7
|
$getLocales: nuxtApp.$getLocales,
|
|
7
8
|
$getRouteName: nuxtApp.$getRouteName,
|
|
@@ -11,8 +12,12 @@ export function useI18n() {
|
|
|
11
12
|
$has: nuxtApp.$has,
|
|
12
13
|
$tc: nuxtApp.$tc,
|
|
13
14
|
$mergeTranslations: nuxtApp.$mergeTranslations,
|
|
15
|
+
$setI18nRouteParams: nuxtApp.$setI18nRouteParams,
|
|
16
|
+
$switchLocaleRoute: nuxtApp.$switchLocaleRoute,
|
|
17
|
+
$switchLocalePath: nuxtApp.$switchLocalePath,
|
|
14
18
|
$switchLocale: nuxtApp.$switchLocale,
|
|
15
19
|
$localeRoute: nuxtApp.$localeRoute,
|
|
20
|
+
$localePath: nuxtApp.$localePath,
|
|
16
21
|
$loadPageTranslations: nuxtApp.$loadPageTranslations
|
|
17
22
|
};
|
|
18
23
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { RouteLocationNormalizedLoaded, RouteLocationRaw, RouteLocationResolvedGeneric } from 'vue-router';
|
|
2
|
-
import type { Locale } from '../../types.js';
|
|
1
|
+
import type { RouteLocationNormalizedLoaded, RouteLocationRaw, RouteLocationResolved, RouteLocationResolvedGeneric } from 'vue-router';
|
|
2
|
+
import type { Locale, I18nRouteParams } from '../../types.js';
|
|
3
3
|
export interface Translations {
|
|
4
4
|
[key: string]: string | number | boolean | Translations | PluralTranslations | unknown[] | null;
|
|
5
5
|
}
|
|
@@ -20,8 +20,12 @@ declare const _default: import("#app").Plugin<{
|
|
|
20
20
|
td: (value: Date | number | string, options?: Intl.DateTimeFormatOptions) => string;
|
|
21
21
|
has: (key: string) => boolean;
|
|
22
22
|
mergeTranslations: (newTranslations: Translations) => void;
|
|
23
|
+
switchLocaleRoute: (toLocale: string) => string | import("vue-router").RouteLocationAsRelativeGeneric | import("vue-router").RouteLocationAsPathGeneric;
|
|
24
|
+
switchLocalePath: (toLocale: string) => string;
|
|
23
25
|
switchLocale: (toLocale: string) => void;
|
|
24
|
-
localeRoute: (to: RouteLocationRaw, locale?: string) =>
|
|
26
|
+
localeRoute: (to: RouteLocationRaw, locale?: string) => RouteLocationResolved;
|
|
27
|
+
localePath: (to: RouteLocationRaw, locale?: string) => string;
|
|
28
|
+
setI18nRouteParams: (value: I18nRouteParams) => I18nRouteParams;
|
|
25
29
|
}> & import("#app").ObjectPlugin<{
|
|
26
30
|
i18n: undefined;
|
|
27
31
|
__micro: boolean;
|
|
@@ -35,8 +39,12 @@ declare const _default: import("#app").Plugin<{
|
|
|
35
39
|
td: (value: Date | number | string, options?: Intl.DateTimeFormatOptions) => string;
|
|
36
40
|
has: (key: string) => boolean;
|
|
37
41
|
mergeTranslations: (newTranslations: Translations) => void;
|
|
42
|
+
switchLocaleRoute: (toLocale: string) => string | import("vue-router").RouteLocationAsRelativeGeneric | import("vue-router").RouteLocationAsPathGeneric;
|
|
43
|
+
switchLocalePath: (toLocale: string) => string;
|
|
38
44
|
switchLocale: (toLocale: string) => void;
|
|
39
|
-
localeRoute: (to: RouteLocationRaw, locale?: string) =>
|
|
45
|
+
localeRoute: (to: RouteLocationRaw, locale?: string) => RouteLocationResolved;
|
|
46
|
+
localePath: (to: RouteLocationRaw, locale?: string) => string;
|
|
47
|
+
setI18nRouteParams: (value: I18nRouteParams) => I18nRouteParams;
|
|
40
48
|
}>;
|
|
41
49
|
export default _default;
|
|
42
50
|
export interface PluginsInjections {
|
|
@@ -50,9 +58,13 @@ export interface PluginsInjections {
|
|
|
50
58
|
$td: (value: Date | number | string, options?: Intl.DateTimeFormatOptions) => string;
|
|
51
59
|
$has: (key: string) => boolean;
|
|
52
60
|
$mergeTranslations: (newTranslations: Translations) => void;
|
|
61
|
+
$switchLocaleRoute: (locale: string) => RouteLocationRaw;
|
|
62
|
+
$switchLocalePath: (locale: string) => string;
|
|
53
63
|
$switchLocale: (locale: string) => void;
|
|
54
|
-
$localeRoute: (to: RouteLocationRaw, locale?: string) =>
|
|
64
|
+
$localeRoute: (to: RouteLocationRaw, locale?: string) => RouteLocationResolved;
|
|
65
|
+
$localePath: (to: RouteLocationRaw, locale?: string) => string;
|
|
55
66
|
$loadPageTranslations: (locale: string, routeName: string) => Promise<void>;
|
|
67
|
+
$setI18nRouteParams: (value: I18nRouteParams) => I18nRouteParams;
|
|
56
68
|
}
|
|
57
69
|
declare module '#app' {
|
|
58
70
|
interface NuxtApp extends PluginsInjections {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { useTranslationHelper } from "../translationHelper.js";
|
|
2
2
|
import { defineNuxtPlugin, useRuntimeConfig } from "#app";
|
|
3
|
-
import { useRoute, useRouter, useCookie } from "#imports";
|
|
3
|
+
import { useRoute, useRouter, useCookie, useState } from "#imports";
|
|
4
4
|
const i18nHelper = useTranslationHelper();
|
|
5
5
|
const isDev = process.env.NODE_ENV !== "production";
|
|
6
6
|
function interpolate(template, params) {
|
|
@@ -19,27 +19,22 @@ function getCurrentLocale(route, i18nConfig, hashLocale) {
|
|
|
19
19
|
function getRouteName(route, locale) {
|
|
20
20
|
return (route?.name ?? "").toString().replace("localized-", "").replace(new RegExp(`-${locale}$`), "");
|
|
21
21
|
}
|
|
22
|
-
function
|
|
23
|
-
const checkLocale = i18nConfig.locales?.find((l) => l.code === toLocale);
|
|
24
|
-
if (!checkLocale) {
|
|
25
|
-
console.warn(`Locale ${toLocale} is not available`);
|
|
26
|
-
return Promise.reject(`Locale ${toLocale} is not available`);
|
|
27
|
-
}
|
|
22
|
+
function switchLocaleRoute(fromLocale, toLocale, route, router, i18nConfig, i18nRouteParams) {
|
|
28
23
|
const routeName = getRouteName(route, fromLocale);
|
|
29
24
|
if (router.hasRoute(`localized-${routeName}-${toLocale}`)) {
|
|
30
|
-
const newParams2 = { ...route.params };
|
|
25
|
+
const newParams2 = { ...route.params, ...i18nRouteParams?.[toLocale] };
|
|
31
26
|
newParams2.locale = toLocale;
|
|
32
27
|
if (i18nConfig.hashMode) {
|
|
33
28
|
const userLocaleCookie = useCookie("hash-locale");
|
|
34
29
|
userLocaleCookie.value = toLocale;
|
|
35
30
|
}
|
|
36
|
-
return
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
}
|
|
31
|
+
return {
|
|
32
|
+
name: `localized-${routeName}-${toLocale}`,
|
|
33
|
+
params: newParams2
|
|
34
|
+
};
|
|
40
35
|
}
|
|
41
36
|
const newRouteName = toLocale !== i18nConfig.defaultLocale || i18nConfig.includeDefaultLocaleRoute ? `localized-${routeName}` : routeName;
|
|
42
|
-
const newParams = { ...route.params };
|
|
37
|
+
const newParams = { ...route.params, ...i18nRouteParams?.[toLocale] };
|
|
43
38
|
delete newParams.locale;
|
|
44
39
|
if (toLocale !== i18nConfig.defaultLocale || i18nConfig.includeDefaultLocaleRoute) {
|
|
45
40
|
newParams.locale = toLocale;
|
|
@@ -48,7 +43,23 @@ function switchLocale(fromLocale, toLocale, route, router, i18nConfig) {
|
|
|
48
43
|
const userLocaleCookie = useCookie("hash-locale");
|
|
49
44
|
userLocaleCookie.value = toLocale;
|
|
50
45
|
}
|
|
51
|
-
return
|
|
46
|
+
return { name: newRouteName, params: newParams };
|
|
47
|
+
}
|
|
48
|
+
function switchLocale(fromLocale, toLocale, route, router, i18nConfig, i18nRouteParams) {
|
|
49
|
+
const checkLocale = i18nConfig.locales?.find((l) => l.code === toLocale);
|
|
50
|
+
if (!checkLocale) {
|
|
51
|
+
console.warn(`Locale ${toLocale} is not available`);
|
|
52
|
+
return Promise.reject(`Locale ${toLocale} is not available`);
|
|
53
|
+
}
|
|
54
|
+
const switchedRoute = switchLocaleRoute(
|
|
55
|
+
fromLocale,
|
|
56
|
+
toLocale,
|
|
57
|
+
route,
|
|
58
|
+
router,
|
|
59
|
+
i18nConfig,
|
|
60
|
+
i18nRouteParams
|
|
61
|
+
);
|
|
62
|
+
return router.push(switchedRoute);
|
|
52
63
|
}
|
|
53
64
|
function getLocalizedRoute(to, router, route, i18nConfig, locale, hashLocale) {
|
|
54
65
|
const currentLocale = locale || getCurrentLocale(route, i18nConfig, hashLocale);
|
|
@@ -65,25 +76,37 @@ function getLocalizedRoute(to, router, route, i18nConfig, locale, hashLocale) {
|
|
|
65
76
|
return params;
|
|
66
77
|
};
|
|
67
78
|
if (router.hasRoute(`localized-${routeName}-${currentLocale}`)) {
|
|
68
|
-
const newParams2 = resolveParams(
|
|
79
|
+
const newParams2 = resolveParams(selectRoute);
|
|
69
80
|
newParams2.locale = currentLocale;
|
|
70
81
|
return router.resolve({
|
|
82
|
+
name: `localized-${routeName}-${currentLocale}`,
|
|
71
83
|
params: newParams2,
|
|
72
|
-
|
|
84
|
+
query: selectRoute.query,
|
|
85
|
+
hash: selectRoute.hash
|
|
73
86
|
});
|
|
74
87
|
}
|
|
75
88
|
const newRouteName = currentLocale !== i18nConfig.defaultLocale || i18nConfig.includeDefaultLocaleRoute ? `localized-${routeName}` : routeName;
|
|
76
89
|
if (!router.hasRoute(newRouteName)) {
|
|
77
90
|
const newParams2 = resolveParams(to);
|
|
78
91
|
delete newParams2.locale;
|
|
79
|
-
return router.resolve({
|
|
92
|
+
return router.resolve({
|
|
93
|
+
name: routeName,
|
|
94
|
+
params: newParams2,
|
|
95
|
+
query: selectRoute.query,
|
|
96
|
+
hash: selectRoute.hash
|
|
97
|
+
});
|
|
80
98
|
}
|
|
81
99
|
const newParams = resolveParams(to);
|
|
82
100
|
delete newParams.locale;
|
|
83
101
|
if (currentLocale !== i18nConfig.defaultLocale || i18nConfig.includeDefaultLocaleRoute) {
|
|
84
102
|
newParams.locale = currentLocale;
|
|
85
103
|
}
|
|
86
|
-
return router.resolve({
|
|
104
|
+
return router.resolve({
|
|
105
|
+
name: newRouteName,
|
|
106
|
+
params: newParams,
|
|
107
|
+
query: selectRoute.query,
|
|
108
|
+
hash: selectRoute.hash
|
|
109
|
+
});
|
|
87
110
|
}
|
|
88
111
|
function formatNumber(value, locale, options) {
|
|
89
112
|
return new Intl.NumberFormat(locale, options).format(value);
|
|
@@ -146,6 +169,10 @@ export default defineNuxtPlugin(async (nuxtApp) => {
|
|
|
146
169
|
if (i18nConfig.hashMode) {
|
|
147
170
|
hashLocale = useCookie("hash-locale").value ?? i18nConfig.defaultLocale;
|
|
148
171
|
}
|
|
172
|
+
const i18nRouteParams = useState("i18n-route-params");
|
|
173
|
+
nuxtApp.hook("page:start", () => {
|
|
174
|
+
i18nRouteParams.value = null;
|
|
175
|
+
});
|
|
149
176
|
const provideData = {
|
|
150
177
|
i18n: void 0,
|
|
151
178
|
__micro: true,
|
|
@@ -179,6 +206,31 @@ export default defineNuxtPlugin(async (nuxtApp) => {
|
|
|
179
206
|
const routeName = getRouteName(route, locale);
|
|
180
207
|
i18nHelper.mergeTranslation(locale, routeName, newTranslations);
|
|
181
208
|
},
|
|
209
|
+
switchLocaleRoute: (toLocale) => {
|
|
210
|
+
const router = useRouter();
|
|
211
|
+
const route = useRoute();
|
|
212
|
+
const fromLocale = getCurrentLocale(route, i18nConfig, hashLocale);
|
|
213
|
+
if (i18nConfig.hashMode) {
|
|
214
|
+
hashLocale = toLocale;
|
|
215
|
+
}
|
|
216
|
+
return switchLocaleRoute(fromLocale, toLocale, route, router, i18nConfig, i18nRouteParams.value);
|
|
217
|
+
},
|
|
218
|
+
switchLocalePath: (toLocale) => {
|
|
219
|
+
const router = useRouter();
|
|
220
|
+
const route = useRoute();
|
|
221
|
+
const fromLocale = getCurrentLocale(route, i18nConfig, hashLocale);
|
|
222
|
+
if (i18nConfig.hashMode) {
|
|
223
|
+
hashLocale = toLocale;
|
|
224
|
+
}
|
|
225
|
+
const localeRoute = switchLocaleRoute(fromLocale, toLocale, route, router, i18nConfig, i18nRouteParams.value);
|
|
226
|
+
if (typeof localeRoute === "string") {
|
|
227
|
+
return localeRoute;
|
|
228
|
+
}
|
|
229
|
+
if ("fullPath" in localeRoute) {
|
|
230
|
+
return localeRoute.fullPath;
|
|
231
|
+
}
|
|
232
|
+
return "";
|
|
233
|
+
},
|
|
182
234
|
switchLocale: (toLocale) => {
|
|
183
235
|
const router = useRouter();
|
|
184
236
|
const route = useRoute();
|
|
@@ -186,12 +238,28 @@ export default defineNuxtPlugin(async (nuxtApp) => {
|
|
|
186
238
|
if (i18nConfig.hashMode) {
|
|
187
239
|
hashLocale = toLocale;
|
|
188
240
|
}
|
|
189
|
-
switchLocale(fromLocale, toLocale, route, router, i18nConfig);
|
|
241
|
+
switchLocale(fromLocale, toLocale, route, router, i18nConfig, i18nRouteParams.value);
|
|
190
242
|
},
|
|
191
243
|
localeRoute: (to, locale) => {
|
|
192
244
|
const router = useRouter();
|
|
193
245
|
const route = useRoute();
|
|
194
246
|
return getLocalizedRoute(to, router, route, i18nConfig, locale, hashLocale);
|
|
247
|
+
},
|
|
248
|
+
localePath: (to, locale) => {
|
|
249
|
+
const router = useRouter();
|
|
250
|
+
const route = useRoute();
|
|
251
|
+
const localeRoute = getLocalizedRoute(to, router, route, i18nConfig, locale, hashLocale);
|
|
252
|
+
if (typeof localeRoute === "string") {
|
|
253
|
+
return localeRoute;
|
|
254
|
+
}
|
|
255
|
+
if ("fullPath" in localeRoute) {
|
|
256
|
+
return localeRoute.fullPath;
|
|
257
|
+
}
|
|
258
|
+
return "";
|
|
259
|
+
},
|
|
260
|
+
setI18nRouteParams: (value) => {
|
|
261
|
+
i18nRouteParams.value = value;
|
|
262
|
+
return i18nRouteParams.value;
|
|
195
263
|
}
|
|
196
264
|
};
|
|
197
265
|
provideData.i18n = provideData;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nuxt-i18n-micro",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.21.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",
|
|
@@ -63,7 +63,6 @@
|
|
|
63
63
|
"@nuxt/devtools-kit": "^1.4.2",
|
|
64
64
|
"@nuxt/kit": "^3.13.1",
|
|
65
65
|
"chokidar": "^3.6.0",
|
|
66
|
-
"ps-node": "^0.1.6",
|
|
67
66
|
"sirv": "^2.0.4",
|
|
68
67
|
"ufo": "^1.5.4"
|
|
69
68
|
},
|
|
@@ -76,13 +75,10 @@
|
|
|
76
75
|
"@nuxt/test-utils": "^3.14.2",
|
|
77
76
|
"@playwright/test": "^1.47.0",
|
|
78
77
|
"@types/node": "^20.14.11",
|
|
79
|
-
"@types/pidusage": "^2.0.5",
|
|
80
|
-
"@types/ps-node": "^0.1.3",
|
|
81
78
|
"changelogen": "^0.5.5",
|
|
82
79
|
"eslint": "^8.56.0",
|
|
83
80
|
"execa": "^9.3.1",
|
|
84
81
|
"nuxt": "^3.13.1",
|
|
85
|
-
"pidusage": "^3.0.2",
|
|
86
82
|
"typescript": "5.5.4",
|
|
87
83
|
"vitepress": "^1.3.4",
|
|
88
84
|
"vitest": "^2.0.5",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"id":"83a84051-55cf-4ecf-bbe3-e92d06f718d6","timestamp":1727446621097,"matcher":{"static":{},"wildcard":{},"dynamic":{}},"prerendered":[]}
|