nuxt-i18n-micro 3.29.2 → 3.29.4
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/7a8cab88-a568-460d-8a67-5955e9b3c5ff.json +1 -0
- package/dist/client/index.html +1 -1
- package/dist/module.json +1 -1
- package/dist/module.mjs +1 -0
- package/dist/runtime/components/i18n-t.d.vue.ts +1 -1
- package/dist/runtime/components/i18n-t.vue.d.ts +1 -1
- package/dist/runtime/composables/useI18nHead.d.ts +1 -1
- package/dist/runtime/composables/useI18nLocale.d.ts +7 -3
- package/dist/runtime/composables/useLocaleHead.js +17 -10
- package/dist/runtime/middleware/i18n-redirect.global.d.ts +1 -1
- package/dist/runtime/plugins/01.plugin.d.ts +88 -2
- package/dist/runtime/plugins/02.meta.d.ts +1 -1
- package/dist/runtime/plugins/03.define.d.ts +6 -1
- package/dist/runtime/plugins/04.vue-devtools.d.ts +1 -1
- package/dist/runtime/plugins/05.hooks.d.ts +1 -1
- package/dist/runtime/plugins/06.redirect.d.ts +1 -1
- package/dist/runtime/utils/nuxt-i18n.js +3 -2
- package/dist/runtime/utils/trailing-slash.d.ts +5 -0
- package/dist/runtime/utils/trailing-slash.js +6 -0
- package/package.json +8 -8
- package/dist/client/_nuxt/builds/meta/2cbcc7b6-c485-462c-ae54-c91d34888fbe.json +0 -1
package/dist/client/200.html
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
<!DOCTYPE html><html><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1"><script type="importmap">{"imports":{"#entry":"/__nuxt-i18n-micro/_nuxt/CZxMDymS.js"}}</script><link rel="stylesheet" href="/__nuxt-i18n-micro/_nuxt/entry.CJGrD2VA.css" crossorigin><link rel="modulepreload" as="script" crossorigin href="/__nuxt-i18n-micro/_nuxt/CZxMDymS.js"><link rel="modulepreload" as="script" crossorigin href="/__nuxt-i18n-micro/_nuxt/BAu8wLxk.js"><script type="module" src="/__nuxt-i18n-micro/_nuxt/CZxMDymS.js" crossorigin></script><link rel="prefetch" as="style" crossorigin href="/__nuxt-i18n-micro/_nuxt/error-404.BRCCa7jH.css"><link rel="prefetch" as="script" crossorigin href="/__nuxt-i18n-micro/_nuxt/BlsWt_np.js"><link rel="prefetch" as="script" crossorigin href="/__nuxt-i18n-micro/_nuxt/Bo5omLnI.js"><link rel="prefetch" as="style" crossorigin href="/__nuxt-i18n-micro/_nuxt/error-500.C7JgQlK0.css"><link rel="prefetch" as="script" crossorigin href="/__nuxt-i18n-micro/_nuxt/CSbZDNyO.js"></head><body><div id="__nuxt"></div><div id="teleports"></div><script>window.__NUXT__={};window.__NUXT__.config={public:{},app:{baseURL:"/__nuxt-i18n-micro",buildId:"
|
|
1
|
+
<!DOCTYPE html><html><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1"><script type="importmap">{"imports":{"#entry":"/__nuxt-i18n-micro/_nuxt/CZxMDymS.js"}}</script><link rel="stylesheet" href="/__nuxt-i18n-micro/_nuxt/entry.CJGrD2VA.css" crossorigin><link rel="modulepreload" as="script" crossorigin href="/__nuxt-i18n-micro/_nuxt/CZxMDymS.js"><link rel="modulepreload" as="script" crossorigin href="/__nuxt-i18n-micro/_nuxt/BAu8wLxk.js"><script type="module" src="/__nuxt-i18n-micro/_nuxt/CZxMDymS.js" crossorigin></script><link rel="prefetch" as="style" crossorigin href="/__nuxt-i18n-micro/_nuxt/error-404.BRCCa7jH.css"><link rel="prefetch" as="script" crossorigin href="/__nuxt-i18n-micro/_nuxt/BlsWt_np.js"><link rel="prefetch" as="script" crossorigin href="/__nuxt-i18n-micro/_nuxt/Bo5omLnI.js"><link rel="prefetch" as="style" crossorigin href="/__nuxt-i18n-micro/_nuxt/error-500.C7JgQlK0.css"><link rel="prefetch" as="script" crossorigin href="/__nuxt-i18n-micro/_nuxt/CSbZDNyO.js"></head><body><div id="__nuxt"></div><div id="teleports"></div><script>window.__NUXT__={};window.__NUXT__.config={public:{},app:{baseURL:"/__nuxt-i18n-micro",buildId:"7a8cab88-a568-460d-8a67-5955e9b3c5ff",buildAssetsDir:"/_nuxt/",cdnURL:""}}</script><script type="application/json" data-nuxt-data="nuxt-app" data-ssr="false" id="__NUXT_DATA__">[{"prerenderedAt":1,"serverRendered":2},1789393266818,false]</script></body></html>
|
package/dist/client/404.html
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
<!DOCTYPE html><html><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1"><script type="importmap">{"imports":{"#entry":"/__nuxt-i18n-micro/_nuxt/CZxMDymS.js"}}</script><link rel="stylesheet" href="/__nuxt-i18n-micro/_nuxt/entry.CJGrD2VA.css" crossorigin><link rel="modulepreload" as="script" crossorigin href="/__nuxt-i18n-micro/_nuxt/CZxMDymS.js"><link rel="modulepreload" as="script" crossorigin href="/__nuxt-i18n-micro/_nuxt/BAu8wLxk.js"><script type="module" src="/__nuxt-i18n-micro/_nuxt/CZxMDymS.js" crossorigin></script><link rel="prefetch" as="style" crossorigin href="/__nuxt-i18n-micro/_nuxt/error-404.BRCCa7jH.css"><link rel="prefetch" as="script" crossorigin href="/__nuxt-i18n-micro/_nuxt/BlsWt_np.js"><link rel="prefetch" as="script" crossorigin href="/__nuxt-i18n-micro/_nuxt/Bo5omLnI.js"><link rel="prefetch" as="style" crossorigin href="/__nuxt-i18n-micro/_nuxt/error-500.C7JgQlK0.css"><link rel="prefetch" as="script" crossorigin href="/__nuxt-i18n-micro/_nuxt/CSbZDNyO.js"></head><body><div id="__nuxt"></div><div id="teleports"></div><script>window.__NUXT__={};window.__NUXT__.config={public:{},app:{baseURL:"/__nuxt-i18n-micro",buildId:"
|
|
1
|
+
<!DOCTYPE html><html><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1"><script type="importmap">{"imports":{"#entry":"/__nuxt-i18n-micro/_nuxt/CZxMDymS.js"}}</script><link rel="stylesheet" href="/__nuxt-i18n-micro/_nuxt/entry.CJGrD2VA.css" crossorigin><link rel="modulepreload" as="script" crossorigin href="/__nuxt-i18n-micro/_nuxt/CZxMDymS.js"><link rel="modulepreload" as="script" crossorigin href="/__nuxt-i18n-micro/_nuxt/BAu8wLxk.js"><script type="module" src="/__nuxt-i18n-micro/_nuxt/CZxMDymS.js" crossorigin></script><link rel="prefetch" as="style" crossorigin href="/__nuxt-i18n-micro/_nuxt/error-404.BRCCa7jH.css"><link rel="prefetch" as="script" crossorigin href="/__nuxt-i18n-micro/_nuxt/BlsWt_np.js"><link rel="prefetch" as="script" crossorigin href="/__nuxt-i18n-micro/_nuxt/Bo5omLnI.js"><link rel="prefetch" as="style" crossorigin href="/__nuxt-i18n-micro/_nuxt/error-500.C7JgQlK0.css"><link rel="prefetch" as="script" crossorigin href="/__nuxt-i18n-micro/_nuxt/CSbZDNyO.js"></head><body><div id="__nuxt"></div><div id="teleports"></div><script>window.__NUXT__={};window.__NUXT__.config={public:{},app:{baseURL:"/__nuxt-i18n-micro",buildId:"7a8cab88-a568-460d-8a67-5955e9b3c5ff",buildAssetsDir:"/_nuxt/",cdnURL:""}}</script><script type="application/json" data-nuxt-data="nuxt-app" data-ssr="false" id="__NUXT_DATA__">[{"prerenderedAt":1,"serverRendered":2},1789393266819,false]</script></body></html>
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"id":"
|
|
1
|
+
{"id":"7a8cab88-a568-460d-8a67-5955e9b3c5ff","timestamp":1789393262923}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"id":"7a8cab88-a568-460d-8a67-5955e9b3c5ff","timestamp":1789393262923,"prerendered":[]}
|
package/dist/client/index.html
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
<!DOCTYPE html><html><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1"><script type="importmap">{"imports":{"#entry":"/__nuxt-i18n-micro/_nuxt/CZxMDymS.js"}}</script><link rel="stylesheet" href="/__nuxt-i18n-micro/_nuxt/entry.CJGrD2VA.css" crossorigin><link rel="modulepreload" as="script" crossorigin href="/__nuxt-i18n-micro/_nuxt/CZxMDymS.js"><link rel="modulepreload" as="script" crossorigin href="/__nuxt-i18n-micro/_nuxt/BAu8wLxk.js"><script type="module" src="/__nuxt-i18n-micro/_nuxt/CZxMDymS.js" crossorigin></script><link rel="prefetch" as="style" crossorigin href="/__nuxt-i18n-micro/_nuxt/error-404.BRCCa7jH.css"><link rel="prefetch" as="script" crossorigin href="/__nuxt-i18n-micro/_nuxt/BlsWt_np.js"><link rel="prefetch" as="script" crossorigin href="/__nuxt-i18n-micro/_nuxt/Bo5omLnI.js"><link rel="prefetch" as="style" crossorigin href="/__nuxt-i18n-micro/_nuxt/error-500.C7JgQlK0.css"><link rel="prefetch" as="script" crossorigin href="/__nuxt-i18n-micro/_nuxt/CSbZDNyO.js"></head><body><div id="__nuxt"></div><div id="teleports"></div><script>window.__NUXT__={};window.__NUXT__.config={public:{},app:{baseURL:"/__nuxt-i18n-micro",buildId:"
|
|
1
|
+
<!DOCTYPE html><html><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1"><script type="importmap">{"imports":{"#entry":"/__nuxt-i18n-micro/_nuxt/CZxMDymS.js"}}</script><link rel="stylesheet" href="/__nuxt-i18n-micro/_nuxt/entry.CJGrD2VA.css" crossorigin><link rel="modulepreload" as="script" crossorigin href="/__nuxt-i18n-micro/_nuxt/CZxMDymS.js"><link rel="modulepreload" as="script" crossorigin href="/__nuxt-i18n-micro/_nuxt/BAu8wLxk.js"><script type="module" src="/__nuxt-i18n-micro/_nuxt/CZxMDymS.js" crossorigin></script><link rel="prefetch" as="style" crossorigin href="/__nuxt-i18n-micro/_nuxt/error-404.BRCCa7jH.css"><link rel="prefetch" as="script" crossorigin href="/__nuxt-i18n-micro/_nuxt/BlsWt_np.js"><link rel="prefetch" as="script" crossorigin href="/__nuxt-i18n-micro/_nuxt/Bo5omLnI.js"><link rel="prefetch" as="style" crossorigin href="/__nuxt-i18n-micro/_nuxt/error-500.C7JgQlK0.css"><link rel="prefetch" as="script" crossorigin href="/__nuxt-i18n-micro/_nuxt/CSbZDNyO.js"></head><body><div id="__nuxt"></div><div id="teleports"></div><script>window.__NUXT__={};window.__NUXT__.config={public:{},app:{baseURL:"/__nuxt-i18n-micro",buildId:"7a8cab88-a568-460d-8a67-5955e9b3c5ff",buildAssetsDir:"/_nuxt/",cdnURL:""}}</script><script type="application/json" data-nuxt-data="nuxt-app" data-ssr="false" id="__NUXT_DATA__">[{"prerenderedAt":1,"serverRendered":2},1789393266819,false]</script></body></html>
|
package/dist/module.json
CHANGED
package/dist/module.mjs
CHANGED
|
@@ -539,6 +539,7 @@ function buildFullConfig(params) {
|
|
|
539
539
|
strategy: options.strategy ?? "prefix_except_default",
|
|
540
540
|
dateBuild,
|
|
541
541
|
hashMode: nuxt.options?.router?.options?.hashMode ?? false,
|
|
542
|
+
trailingSlash: options.trailingSlash ?? nuxt.options.experimental?.defaults?.nuxtLink?.trailingSlash,
|
|
542
543
|
apiBaseUrl: apiConfig.apiBaseUrl,
|
|
543
544
|
apiBaseClientHost: apiConfig.apiBaseClientHost,
|
|
544
545
|
isSSG,
|
|
@@ -119,9 +119,9 @@ declare const __VLS_export: import("vue").DefineComponent<import("vue").ExtractP
|
|
|
119
119
|
type: PropType<Date | string | number>;
|
|
120
120
|
};
|
|
121
121
|
}>> & Readonly<{}>, {
|
|
122
|
-
html: boolean;
|
|
123
122
|
params: Record<string, string | number | boolean>;
|
|
124
123
|
tag: string;
|
|
124
|
+
html: boolean;
|
|
125
125
|
defaultValue: string;
|
|
126
126
|
hideIfEmpty: boolean;
|
|
127
127
|
customPluralRule: PluralFunc;
|
|
@@ -119,9 +119,9 @@ declare const __VLS_export: import("vue").DefineComponent<import("vue").ExtractP
|
|
|
119
119
|
type: PropType<Date | string | number>;
|
|
120
120
|
};
|
|
121
121
|
}>> & Readonly<{}>, {
|
|
122
|
-
html: boolean;
|
|
123
122
|
params: Record<string, string | number | boolean>;
|
|
124
123
|
tag: string;
|
|
124
|
+
html: boolean;
|
|
125
125
|
defaultValue: string;
|
|
126
126
|
hideIfEmpty: boolean;
|
|
127
127
|
customPluralRule: PluralFunc;
|
|
@@ -8,6 +8,6 @@ import type { MaybeRefOrGetter } from 'vue';
|
|
|
8
8
|
* re-resolve on locale change. A plain object is evaluated once and stays frozen.
|
|
9
9
|
*/
|
|
10
10
|
export declare function useI18nHead(input?: MaybeRefOrGetter<I18nHeadInput | null>): {
|
|
11
|
-
pageHead:
|
|
11
|
+
pageHead: import("vue").Ref<I18nHeadInput | null, I18nHeadInput | null>;
|
|
12
12
|
resetPageHead: () => void;
|
|
13
13
|
};
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
type CookieRef = {
|
|
2
|
+
value: string | null;
|
|
3
|
+
};
|
|
1
4
|
/** Callback to get locale from route (RouteService.getCurrentLocale) */
|
|
2
5
|
export type GetLocaleFromRoute = (route?: unknown) => string;
|
|
3
6
|
export interface ResolveInitialLocaleOptions {
|
|
@@ -10,9 +13,9 @@ export interface ResolveInitialLocaleOptions {
|
|
|
10
13
|
* Combines useState('i18n-locale'), locale cookie, and sync utilities.
|
|
11
14
|
*/
|
|
12
15
|
export declare function useI18nLocale(): {
|
|
13
|
-
locale:
|
|
14
|
-
localeCookie:
|
|
15
|
-
hashCookie:
|
|
16
|
+
locale: import("vue").Ref<string | null, string | null>;
|
|
17
|
+
localeCookie: CookieRef;
|
|
18
|
+
hashCookie: CookieRef;
|
|
16
19
|
getPreferredLocale: () => string | null;
|
|
17
20
|
getLocale: () => string | null;
|
|
18
21
|
getLocaleWithServerFallback: (serverLocale?: string | null) => string | null;
|
|
@@ -23,3 +26,4 @@ export declare function useI18nLocale(): {
|
|
|
23
26
|
isValidLocale: (locale: string | null | undefined) => locale is string;
|
|
24
27
|
validLocales: string[];
|
|
25
28
|
};
|
|
29
|
+
export {};
|
|
@@ -74,17 +74,25 @@ export const useLocaleHead = ({
|
|
|
74
74
|
if (!fullPath.startsWith("/")) {
|
|
75
75
|
fullPath = `/${fullPath}`;
|
|
76
76
|
}
|
|
77
|
-
const
|
|
78
|
-
|
|
77
|
+
const whitelist = canonicalQueryWhitelist ?? [];
|
|
78
|
+
const currentSwitchedPath = switchLocalePath(locale);
|
|
79
79
|
let ogUrl;
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
80
|
+
if (currentSwitchedPath) {
|
|
81
|
+
if (currentSwitchedPath.startsWith("http://") || currentSwitchedPath.startsWith("https://")) {
|
|
82
|
+
ogUrl = filterLocalizedHref(currentSwitchedPath, whitelist);
|
|
83
|
+
} else {
|
|
84
|
+
const filteredPath = filterLocalizedHref(currentSwitchedPath, whitelist);
|
|
85
|
+
ogUrl = joinURL(unref(baseUrl), filteredPath.startsWith("/") ? filteredPath : `/${filteredPath}`);
|
|
86
|
+
}
|
|
85
87
|
} else {
|
|
86
|
-
|
|
87
|
-
|
|
88
|
+
const matchedLocale = [...locales].sort((a, b) => b.code.length - a.code.length).find((localeItem) => fullPath.startsWith(`/${localeItem.code}`));
|
|
89
|
+
let localizedPath = fullPath;
|
|
90
|
+
if (routeName.startsWith(localizedRouteNamePrefixResolved) && matchedLocale) {
|
|
91
|
+
localizedPath = fullPath.slice(matchedLocale.code.length + 1);
|
|
92
|
+
ogUrl = joinURL(unref(baseUrl), locale, filterQuery(localizedPath, whitelist));
|
|
93
|
+
} else {
|
|
94
|
+
ogUrl = joinURL(unref(baseUrl), filterQuery(fullPath, whitelist));
|
|
95
|
+
}
|
|
88
96
|
}
|
|
89
97
|
const htmlAttrs = {
|
|
90
98
|
lang: currentIso,
|
|
@@ -127,7 +135,6 @@ export const useLocaleHead = ({
|
|
|
127
135
|
};
|
|
128
136
|
const defaultLocale = i18nConfig.defaultLocale || "en";
|
|
129
137
|
const defaultLocaleObj = allLocales.find((loc) => loc.code === defaultLocale);
|
|
130
|
-
const whitelist = canonicalQueryWhitelist ?? [];
|
|
131
138
|
const alternateLinks = isNoPrefixStrategy(strategy) ? [] : (() => {
|
|
132
139
|
const hrefByCode = /* @__PURE__ */ new Map();
|
|
133
140
|
for (const loc of localesForSeo) {
|
|
@@ -1,7 +1,93 @@
|
|
|
1
1
|
import type { PathStrategy } from '@i18n-micro/path-strategy';
|
|
2
2
|
import type { CleanTranslation, DefineI18nRouteConfig, I18nRouteParams, Locale, MissingHandler, ModuleOptionsExtend, Params, Translations, TranslationKey } from '@i18n-micro/types';
|
|
3
3
|
import type { RouteLocationNamedRaw, RouteLocationNormalizedLoaded, RouteLocationRaw, RouteLocationResolved, RouteLocationResolvedGeneric } from 'vue-router';
|
|
4
|
-
declare const _default:
|
|
4
|
+
declare const _default: import("nuxt/app").Plugin<{
|
|
5
|
+
getI18nConfig: () => ModuleOptionsExtend;
|
|
6
|
+
helper: {
|
|
7
|
+
mergeTranslation(locale: string, routeName: string, newTranslations: Translations, _force?: boolean): Promise<void>;
|
|
8
|
+
};
|
|
9
|
+
i18n: unknown;
|
|
10
|
+
__micro: boolean;
|
|
11
|
+
i18nStrategy: PathStrategy;
|
|
12
|
+
getLocale: (route?: RouteLocationNormalizedLoaded | RouteLocationResolvedGeneric) => string;
|
|
13
|
+
getLocaleName: () => string | null;
|
|
14
|
+
defaultLocale: () => string | undefined;
|
|
15
|
+
getLocales: () => Locale[];
|
|
16
|
+
getRouteName: (route?: RouteLocationNormalizedLoaded | RouteLocationResolvedGeneric, locale?: string) => string;
|
|
17
|
+
t: (key: TranslationKey, params?: Params, defaultValue?: string | null, routeContext?: unknown) => CleanTranslation;
|
|
18
|
+
ts: (key: string, params?: Params, defaultValue?: string, route?: RouteLocationNormalizedLoaded) => string;
|
|
19
|
+
_t: (route: RouteLocationNormalizedLoaded) => (key: string, params?: Params, defaultValue?: string | null) => CleanTranslation;
|
|
20
|
+
_ts: (route: RouteLocationNormalizedLoaded) => (key: string, params?: Params, defaultValue?: string) => string;
|
|
21
|
+
tc: (key: TranslationKey, count: number | Params, defaultValue?: string) => string;
|
|
22
|
+
tn: {
|
|
23
|
+
(value: number, options?: Intl.NumberFormatOptions): string;
|
|
24
|
+
(value: number, key: string, overrides?: Intl.NumberFormatOptions): string;
|
|
25
|
+
(value: number, key: string, locale: string, overrides?: Intl.NumberFormatOptions): string;
|
|
26
|
+
};
|
|
27
|
+
td: {
|
|
28
|
+
(value: Date | number | string, options?: Intl.DateTimeFormatOptions): string;
|
|
29
|
+
(value: Date | number | string, key: string, overrides?: Intl.DateTimeFormatOptions): string;
|
|
30
|
+
(value: Date | number | string, key: string, locale: string, overrides?: Intl.DateTimeFormatOptions): string;
|
|
31
|
+
};
|
|
32
|
+
tdr: (value: Date | number | string, options?: Intl.RelativeTimeFormatOptions) => string;
|
|
33
|
+
has: (key: TranslationKey, routeContext?: unknown) => boolean;
|
|
34
|
+
resolveTranslations: (routeContext?: unknown) => Translations;
|
|
35
|
+
setTranslation: (key: TranslationKey, value: unknown) => void;
|
|
36
|
+
mergeTranslations: (newTranslations: Translations) => void;
|
|
37
|
+
switchLocaleRoute: (toLocale: string) => RouteLocationRaw;
|
|
38
|
+
clearCache: () => void;
|
|
39
|
+
switchLocalePath: (toLocale: string) => string;
|
|
40
|
+
switchLocale: (toLocale: string) => Promise<unknown>;
|
|
41
|
+
switchRoute: (route: RouteLocationNamedRaw | RouteLocationResolvedGeneric | string, toLocale?: string) => unknown;
|
|
42
|
+
localeRoute(to: RouteLocationNamedRaw | RouteLocationResolvedGeneric | string, locale?: string): RouteLocationResolved;
|
|
43
|
+
localePath(to: RouteLocationNamedRaw | RouteLocationResolvedGeneric | string, locale?: string): string;
|
|
44
|
+
setI18nRouteParams: (value: I18nRouteParams) => I18nRouteParams;
|
|
45
|
+
loadPageTranslations: (locale: string, routeName: string, translations: Translations) => Promise<void>;
|
|
46
|
+
setMissingHandler: (handler: MissingHandler | null) => void;
|
|
47
|
+
}> & import("nuxt/app").ObjectPlugin<{
|
|
48
|
+
getI18nConfig: () => ModuleOptionsExtend;
|
|
49
|
+
helper: {
|
|
50
|
+
mergeTranslation(locale: string, routeName: string, newTranslations: Translations, _force?: boolean): Promise<void>;
|
|
51
|
+
};
|
|
52
|
+
i18n: unknown;
|
|
53
|
+
__micro: boolean;
|
|
54
|
+
i18nStrategy: PathStrategy;
|
|
55
|
+
getLocale: (route?: RouteLocationNormalizedLoaded | RouteLocationResolvedGeneric) => string;
|
|
56
|
+
getLocaleName: () => string | null;
|
|
57
|
+
defaultLocale: () => string | undefined;
|
|
58
|
+
getLocales: () => Locale[];
|
|
59
|
+
getRouteName: (route?: RouteLocationNormalizedLoaded | RouteLocationResolvedGeneric, locale?: string) => string;
|
|
60
|
+
t: (key: TranslationKey, params?: Params, defaultValue?: string | null, routeContext?: unknown) => CleanTranslation;
|
|
61
|
+
ts: (key: string, params?: Params, defaultValue?: string, route?: RouteLocationNormalizedLoaded) => string;
|
|
62
|
+
_t: (route: RouteLocationNormalizedLoaded) => (key: string, params?: Params, defaultValue?: string | null) => CleanTranslation;
|
|
63
|
+
_ts: (route: RouteLocationNormalizedLoaded) => (key: string, params?: Params, defaultValue?: string) => string;
|
|
64
|
+
tc: (key: TranslationKey, count: number | Params, defaultValue?: string) => string;
|
|
65
|
+
tn: {
|
|
66
|
+
(value: number, options?: Intl.NumberFormatOptions): string;
|
|
67
|
+
(value: number, key: string, overrides?: Intl.NumberFormatOptions): string;
|
|
68
|
+
(value: number, key: string, locale: string, overrides?: Intl.NumberFormatOptions): string;
|
|
69
|
+
};
|
|
70
|
+
td: {
|
|
71
|
+
(value: Date | number | string, options?: Intl.DateTimeFormatOptions): string;
|
|
72
|
+
(value: Date | number | string, key: string, overrides?: Intl.DateTimeFormatOptions): string;
|
|
73
|
+
(value: Date | number | string, key: string, locale: string, overrides?: Intl.DateTimeFormatOptions): string;
|
|
74
|
+
};
|
|
75
|
+
tdr: (value: Date | number | string, options?: Intl.RelativeTimeFormatOptions) => string;
|
|
76
|
+
has: (key: TranslationKey, routeContext?: unknown) => boolean;
|
|
77
|
+
resolveTranslations: (routeContext?: unknown) => Translations;
|
|
78
|
+
setTranslation: (key: TranslationKey, value: unknown) => void;
|
|
79
|
+
mergeTranslations: (newTranslations: Translations) => void;
|
|
80
|
+
switchLocaleRoute: (toLocale: string) => RouteLocationRaw;
|
|
81
|
+
clearCache: () => void;
|
|
82
|
+
switchLocalePath: (toLocale: string) => string;
|
|
83
|
+
switchLocale: (toLocale: string) => Promise<unknown>;
|
|
84
|
+
switchRoute: (route: RouteLocationNamedRaw | RouteLocationResolvedGeneric | string, toLocale?: string) => unknown;
|
|
85
|
+
localeRoute(to: RouteLocationNamedRaw | RouteLocationResolvedGeneric | string, locale?: string): RouteLocationResolved;
|
|
86
|
+
localePath(to: RouteLocationNamedRaw | RouteLocationResolvedGeneric | string, locale?: string): string;
|
|
87
|
+
setI18nRouteParams: (value: I18nRouteParams) => I18nRouteParams;
|
|
88
|
+
loadPageTranslations: (locale: string, routeName: string, translations: Translations) => Promise<void>;
|
|
89
|
+
setMissingHandler: (handler: MissingHandler | null) => void;
|
|
90
|
+
}>;
|
|
5
91
|
export default _default;
|
|
6
92
|
export type TranslationFn<T extends CleanTranslation> = (key: TranslationKey, params?: Params, defaultValue?: string | null) => T;
|
|
7
93
|
export interface PluginsInjections {
|
|
@@ -18,7 +104,7 @@ export interface PluginsInjections {
|
|
|
18
104
|
/** Every configured locale, with its metadata. */
|
|
19
105
|
$getLocales: () => Locale[];
|
|
20
106
|
/** Route name with the locale prefix stripped — the name translations are keyed by. */
|
|
21
|
-
$getRouteName: (route?:
|
|
107
|
+
$getRouteName: (route?: RouteLocationNormalizedLoaded | RouteLocationResolvedGeneric, locale?: string) => string;
|
|
22
108
|
/**
|
|
23
109
|
* Translate a key, interpolating `params` into it. Returns `defaultValue` when the key is
|
|
24
110
|
* missing, or the key itself when no default is given.
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
declare const _default:
|
|
1
|
+
declare const _default: import("nuxt/app").Plugin<Record<string, unknown>> & import("nuxt/app").ObjectPlugin<Record<string, unknown>>;
|
|
2
2
|
export default _default;
|
|
@@ -1,2 +1,7 @@
|
|
|
1
|
-
|
|
1
|
+
import type { DefineI18nRouteConfig } from '@i18n-micro/types';
|
|
2
|
+
declare const _default: import("nuxt/app").Plugin<{
|
|
3
|
+
defineI18nRoute: (routeDefinition: DefineI18nRouteConfig) => Promise<void>;
|
|
4
|
+
}> & import("nuxt/app").ObjectPlugin<{
|
|
5
|
+
defineI18nRoute: (routeDefinition: DefineI18nRouteConfig) => Promise<void>;
|
|
6
|
+
}>;
|
|
2
7
|
export default _default;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
declare const _default:
|
|
1
|
+
declare const _default: import("nuxt/app").Plugin<Record<string, unknown>> & import("nuxt/app").ObjectPlugin<Record<string, unknown>>;
|
|
2
2
|
export default _default;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
declare const _default:
|
|
1
|
+
declare const _default: import("nuxt/app").Plugin<Record<string, unknown>> & import("nuxt/app").ObjectPlugin<Record<string, unknown>>;
|
|
2
2
|
export default _default;
|
|
@@ -3,5 +3,5 @@
|
|
|
3
3
|
* Handles locale detection, 404 checks, and redirects.
|
|
4
4
|
* Client SPA redirects are handled by i18n-redirect route middleware.
|
|
5
5
|
*/
|
|
6
|
-
declare const _default:
|
|
6
|
+
declare const _default: import("nuxt/app").Plugin<Record<string, unknown>> & import("nuxt/app").ObjectPlugin<Record<string, unknown>>;
|
|
7
7
|
export default _default;
|
|
@@ -9,6 +9,7 @@ import {
|
|
|
9
9
|
import { deepMergeTranslationsRecursive } from "@i18n-micro/utils/deep-merge";
|
|
10
10
|
import { shallowRef, triggerRef, unref } from "vue";
|
|
11
11
|
import { translationStorage } from "./storage.js";
|
|
12
|
+
import { applyTrailingSlash } from "./trailing-slash.js";
|
|
12
13
|
function toRouteLocationResolved(result) {
|
|
13
14
|
const fullPath = result.fullPath ?? result.path ?? "";
|
|
14
15
|
const path = result.path ?? fullPath.split("?")[0]?.split("#")[0] ?? fullPath;
|
|
@@ -438,7 +439,7 @@ export function createNuxtI18nPluginApi(deps) {
|
|
|
438
439
|
const route = router.currentRoute.value;
|
|
439
440
|
const fromLocale = getCurrentLocale(route);
|
|
440
441
|
const switched = i18nStrategy.switchLocaleRoute(fromLocale, toLocale, route, { i18nRouteParams: unref(i18nRouteParams.value) });
|
|
441
|
-
return extractSwitchLocalePath(switched, router);
|
|
442
|
+
return applyTrailingSlash(extractSwitchLocalePath(switched, router), i18nConfig.trailingSlash);
|
|
442
443
|
},
|
|
443
444
|
switchLocale: async (toLocale) => {
|
|
444
445
|
if (!isValidLocale(toLocale)) {
|
|
@@ -465,7 +466,7 @@ export function createNuxtI18nPluginApi(deps) {
|
|
|
465
466
|
localePath(to, locale) {
|
|
466
467
|
const targetLocale = locale !== void 0 && locale !== "" ? String(locale) : getCurrentLocale();
|
|
467
468
|
const result = i18nStrategy.localeRoute(targetLocale, to, router.currentRoute.value);
|
|
468
|
-
return result.fullPath ?? result.path ?? "";
|
|
469
|
+
return applyTrailingSlash(result.fullPath ?? result.path ?? "", i18nConfig.trailingSlash);
|
|
469
470
|
},
|
|
470
471
|
setI18nRouteParams: (value) => {
|
|
471
472
|
i18nRouteParams.value = value;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { hasProtocol, withTrailingSlash, withoutTrailingSlash } from "ufo";
|
|
2
|
+
export function applyTrailingSlash(to, trailingSlash) {
|
|
3
|
+
if (trailingSlash !== "append" && trailingSlash !== "remove") return to;
|
|
4
|
+
if (hasProtocol(to) && !to.startsWith("http")) return to;
|
|
5
|
+
return (trailingSlash === "append" ? withTrailingSlash : withoutTrailingSlash)(to, true);
|
|
6
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nuxt-i18n-micro",
|
|
3
|
-
"version": "3.29.
|
|
3
|
+
"version": "3.29.4",
|
|
4
4
|
"description": "Fast, lightweight i18n for Nuxt with strategy-based routing and minimal overhead.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"i18n",
|
|
@@ -82,13 +82,13 @@
|
|
|
82
82
|
"sirv": "^2.0.3",
|
|
83
83
|
"ufo": "^1.6.4",
|
|
84
84
|
"unplugin": "^1.16.1 || ^2.0.0 || ^3.3.0",
|
|
85
|
-
"@i18n-micro/
|
|
86
|
-
"@i18n-micro/
|
|
87
|
-
"@i18n-micro/
|
|
88
|
-
"@i18n-micro/
|
|
89
|
-
"@i18n-micro/
|
|
90
|
-
"@i18n-micro/
|
|
91
|
-
"@i18n-micro/utils": "^1.0.
|
|
85
|
+
"@i18n-micro/hmr": "^1.0.15",
|
|
86
|
+
"@i18n-micro/core": "^1.3.18",
|
|
87
|
+
"@i18n-micro/path-strategy": "^1.3.17",
|
|
88
|
+
"@i18n-micro/test-utils": "^1.2.15",
|
|
89
|
+
"@i18n-micro/route-strategy": "^1.1.25",
|
|
90
|
+
"@i18n-micro/types": "^1.2.15",
|
|
91
|
+
"@i18n-micro/utils": "^1.0.23"
|
|
92
92
|
},
|
|
93
93
|
"devDependencies": {
|
|
94
94
|
"@nuxt/devtools": "^3.4.2",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"id":"2cbcc7b6-c485-462c-ae54-c91d34888fbe","timestamp":1789036570204,"prerendered":[]}
|