nuxt-i18n-micro 1.76.3 → 1.78.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/d269d831-d8f8-4ce1-bd15-d7a192ce3723.json +1 -0
- package/dist/client/index.html +2 -2
- package/dist/module.json +1 -1
- package/dist/module.mjs +11 -3
- package/dist/runtime/plugins/01.plugin.d.ts +10 -4
- package/dist/runtime/plugins/01.plugin.js +14 -4
- package/package.json +2 -2
- package/dist/client/_nuxt/builds/meta/55e592f8-59f1-4957-b408-ca556fa24e88.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/BBbCCCx2.js">
|
|
9
9
|
<link rel="prefetch" as="style" crossorigin href="/__NUXT_DEVTOOLS_I18N_BASE__/_nuxt/error-500.BRj5A2lo.css">
|
|
10
10
|
<link rel="prefetch" as="script" crossorigin href="/__NUXT_DEVTOOLS_I18N_BASE__/_nuxt/CfVvufsh.js">
|
|
11
|
-
<script type="module" src="/__NUXT_DEVTOOLS_I18N_BASE__/_nuxt/MjlAM4Ld.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/MjlAM4Ld.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},1741805954061,false]</script>
|
|
12
|
+
<script>window.__NUXT__={};window.__NUXT__.config={public:{},app:{baseURL:"/__NUXT_DEVTOOLS_I18N_BASE__/",buildId:"d269d831-d8f8-4ce1-bd15-d7a192ce3723",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/BBbCCCx2.js">
|
|
9
9
|
<link rel="prefetch" as="style" crossorigin href="/__NUXT_DEVTOOLS_I18N_BASE__/_nuxt/error-500.BRj5A2lo.css">
|
|
10
10
|
<link rel="prefetch" as="script" crossorigin href="/__NUXT_DEVTOOLS_I18N_BASE__/_nuxt/CfVvufsh.js">
|
|
11
|
-
<script type="module" src="/__NUXT_DEVTOOLS_I18N_BASE__/_nuxt/MjlAM4Ld.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/MjlAM4Ld.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},1741805954062,false]</script>
|
|
12
|
+
<script>window.__NUXT__={};window.__NUXT__.config={public:{},app:{baseURL:"/__NUXT_DEVTOOLS_I18N_BASE__/",buildId:"d269d831-d8f8-4ce1-bd15-d7a192ce3723",buildAssetsDir:"/_nuxt/",cdnURL:""}}</script></body></html>
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"id":"
|
|
1
|
+
{"id":"d269d831-d8f8-4ce1-bd15-d7a192ce3723","timestamp":1741805947958}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"id":"d269d831-d8f8-4ce1-bd15-d7a192ce3723","timestamp":1741805947958,"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/BBbCCCx2.js">
|
|
9
9
|
<link rel="prefetch" as="style" crossorigin href="/__NUXT_DEVTOOLS_I18N_BASE__/_nuxt/error-500.BRj5A2lo.css">
|
|
10
10
|
<link rel="prefetch" as="script" crossorigin href="/__NUXT_DEVTOOLS_I18N_BASE__/_nuxt/CfVvufsh.js">
|
|
11
|
-
<script type="module" src="/__NUXT_DEVTOOLS_I18N_BASE__/_nuxt/MjlAM4Ld.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/MjlAM4Ld.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},1741805954062,false]</script>
|
|
12
|
+
<script>window.__NUXT__={};window.__NUXT__.config={public:{},app:{baseURL:"/__NUXT_DEVTOOLS_I18N_BASE__/",buildId:"d269d831-d8f8-4ce1-bd15-d7a192ce3723",buildAssetsDir:"/_nuxt/",cdnURL:""}}</script></body></html>
|
package/dist/module.json
CHANGED
package/dist/module.mjs
CHANGED
|
@@ -120,10 +120,12 @@ class PageManager {
|
|
|
120
120
|
localizedPaths = {};
|
|
121
121
|
activeLocaleCodes;
|
|
122
122
|
globalLocaleRoutes;
|
|
123
|
-
|
|
123
|
+
noPrefixRedirect;
|
|
124
|
+
constructor(locales, defaultLocaleCode, strategy, globalLocaleRoutes, noPrefixRedirect) {
|
|
124
125
|
this.locales = locales;
|
|
125
126
|
this.defaultLocale = this.findLocaleByCode(defaultLocaleCode) || { code: defaultLocaleCode };
|
|
126
127
|
this.strategy = strategy;
|
|
128
|
+
this.noPrefixRedirect = noPrefixRedirect;
|
|
127
129
|
this.activeLocaleCodes = this.computeActiveLocaleCodes();
|
|
128
130
|
this.globalLocaleRoutes = globalLocaleRoutes || {};
|
|
129
131
|
}
|
|
@@ -197,8 +199,11 @@ class PageManager {
|
|
|
197
199
|
const isDefaultLocale = isLocaleDefault(locale, this.defaultLocale, isPrefixStrategy(this.strategy));
|
|
198
200
|
if (isNoPrefixStrategy(this.strategy)) {
|
|
199
201
|
const newRoute = this.createLocalizedRoute(page, [locale.code], page.children ?? [], true, customPath, customRegex);
|
|
200
|
-
if (newRoute)
|
|
202
|
+
if (newRoute) {
|
|
201
203
|
additionalRoutes.push(newRoute);
|
|
204
|
+
if (this.noPrefixRedirect && isNoPrefixStrategy(this.strategy))
|
|
205
|
+
page.redirect = newRoute.path;
|
|
206
|
+
}
|
|
202
207
|
} else {
|
|
203
208
|
if (isDefaultLocale) {
|
|
204
209
|
page.path = normalizePath(customPath);
|
|
@@ -271,6 +276,8 @@ class PageManager {
|
|
|
271
276
|
const newRoute = this.createLocalizedRoute(page, [locale.code], originalChildren, true, customPath, customRegex);
|
|
272
277
|
if (newRoute)
|
|
273
278
|
additionalRoutes.push(newRoute);
|
|
279
|
+
if (this.noPrefixRedirect && isNoPrefixStrategy(this.strategy) && newRoute)
|
|
280
|
+
page.redirect = newRoute.path;
|
|
274
281
|
}
|
|
275
282
|
if (isPrefixAndDefaultStrategy(this.strategy) && locale === this.defaultLocale) {
|
|
276
283
|
const newRoute = this.createLocalizedRoute(page, [locale.code], originalChildren, true, customPath, customRegex, true);
|
|
@@ -416,6 +423,7 @@ const module = defineNuxtModule({
|
|
|
416
423
|
disablePageLocales: false,
|
|
417
424
|
disableWatcher: false,
|
|
418
425
|
disableUpdater: false,
|
|
426
|
+
noPrefixRedirect: false,
|
|
419
427
|
includeDefaultLocaleRoute: void 0,
|
|
420
428
|
fallbackLocale: void 0,
|
|
421
429
|
localeCookie: "user-locale",
|
|
@@ -448,7 +456,7 @@ const module = defineNuxtModule({
|
|
|
448
456
|
const resolver = createResolver(import.meta.url);
|
|
449
457
|
const rootDirs = nuxt.options._layers.map((layer) => layer.config.rootDir).reverse();
|
|
450
458
|
const localeManager = new LocaleManager(options, rootDirs);
|
|
451
|
-
const pageManager = new PageManager(localeManager.locales, defaultLocale, options.strategy, options.globalLocaleRoutes);
|
|
459
|
+
const pageManager = new PageManager(localeManager.locales, defaultLocale, options.strategy, options.globalLocaleRoutes, options.noPrefixRedirect);
|
|
452
460
|
addTemplate({
|
|
453
461
|
filename: "i18n.plural.mjs",
|
|
454
462
|
write: true,
|
|
@@ -8,8 +8,10 @@ declare const _default: import("nuxt/app").Plugin<{
|
|
|
8
8
|
defaultLocale: () => string | undefined;
|
|
9
9
|
getLocales: () => Locale[];
|
|
10
10
|
getRouteName: (route?: RouteLocationNormalizedLoaded | RouteLocationResolvedGeneric, locale?: string) => string;
|
|
11
|
-
t: (key: string, params?: Params, defaultValue?: string | null) => Translation;
|
|
12
|
-
ts: (key: string, params?: Params, defaultValue?: string) => string;
|
|
11
|
+
t: (key: string, params?: Params, defaultValue?: string | null, route?: RouteLocationNormalizedLoaded) => Translation;
|
|
12
|
+
ts: (key: string, params?: Params, defaultValue?: string, route?: RouteLocationNormalizedLoaded) => string;
|
|
13
|
+
_t: (route: RouteLocationNormalizedLoaded) => (key: string, params?: Params, defaultValue?: string | null) => Translation;
|
|
14
|
+
_ts: (route: RouteLocationNormalizedLoaded) => (key: string, params?: Params, defaultValue?: string) => string;
|
|
13
15
|
tc: (key: string, params: number | Params, defaultValue?: string) => string;
|
|
14
16
|
tn: (value: number, options?: Intl.NumberFormatOptions) => string;
|
|
15
17
|
td: (value: Date | number | string, options?: Intl.DateTimeFormatOptions) => string;
|
|
@@ -32,8 +34,10 @@ declare const _default: import("nuxt/app").Plugin<{
|
|
|
32
34
|
defaultLocale: () => string | undefined;
|
|
33
35
|
getLocales: () => Locale[];
|
|
34
36
|
getRouteName: (route?: RouteLocationNormalizedLoaded | RouteLocationResolvedGeneric, locale?: string) => string;
|
|
35
|
-
t: (key: string, params?: Params, defaultValue?: string | null) => Translation;
|
|
36
|
-
ts: (key: string, params?: Params, defaultValue?: string) => string;
|
|
37
|
+
t: (key: string, params?: Params, defaultValue?: string | null, route?: RouteLocationNormalizedLoaded) => Translation;
|
|
38
|
+
ts: (key: string, params?: Params, defaultValue?: string, route?: RouteLocationNormalizedLoaded) => string;
|
|
39
|
+
_t: (route: RouteLocationNormalizedLoaded) => (key: string, params?: Params, defaultValue?: string | null) => Translation;
|
|
40
|
+
_ts: (route: RouteLocationNormalizedLoaded) => (key: string, params?: Params, defaultValue?: string) => string;
|
|
37
41
|
tc: (key: string, params: number | Params, defaultValue?: string) => string;
|
|
38
42
|
tn: (value: number, options?: Intl.NumberFormatOptions) => string;
|
|
39
43
|
td: (value: Date | number | string, options?: Intl.DateTimeFormatOptions) => string;
|
|
@@ -57,7 +61,9 @@ export interface PluginsInjections {
|
|
|
57
61
|
$defaultLocale: () => string | undefined;
|
|
58
62
|
$getRouteName: (route?: RouteLocationNamedRaw | RouteLocationResolvedGeneric, locale?: string) => string;
|
|
59
63
|
$t: (key: string, params?: Params, defaultValue?: string | null) => Translation;
|
|
64
|
+
$_t: (route: RouteLocationNormalizedLoaded) => (key: string, params?: Params, defaultValue?: string | null) => Translation;
|
|
60
65
|
$ts: (key: string, params?: Params, defaultValue?: string) => string;
|
|
66
|
+
$_ts: (route: RouteLocationNormalizedLoaded) => (key: string, params?: Params, defaultValue?: string | null) => Translation;
|
|
61
67
|
$tc: (key: string, params: number | Params, defaultValue?: string) => string;
|
|
62
68
|
$tn: (value: number, options?: Intl.NumberFormatOptions) => string;
|
|
63
69
|
$td: (value: Date | number | string, options?: Intl.DateTimeFormatOptions) => string;
|
|
@@ -106,9 +106,9 @@ export default defineNuxtPlugin(async (nuxtApp) => {
|
|
|
106
106
|
const selectedRoute = route ?? routeService.getCurrentRoute();
|
|
107
107
|
return routeService.getRouteName(selectedRoute, selectedLocale);
|
|
108
108
|
},
|
|
109
|
-
t: (key, params, defaultValue) => {
|
|
109
|
+
t: (key, params, defaultValue, route) => {
|
|
110
110
|
if (!key) return "";
|
|
111
|
-
|
|
111
|
+
route = route ?? routeService.getCurrentRoute();
|
|
112
112
|
const locale = routeService.getCurrentLocale();
|
|
113
113
|
const routeName = routeService.getRouteName(route, locale);
|
|
114
114
|
let value = i18nHelper.getTranslation(locale, routeName, key);
|
|
@@ -120,10 +120,20 @@ export default defineNuxtPlugin(async (nuxtApp) => {
|
|
|
120
120
|
}
|
|
121
121
|
return typeof value === "string" && params ? interpolate(value, params) : value;
|
|
122
122
|
},
|
|
123
|
-
ts: (key, params, defaultValue) => {
|
|
124
|
-
const value = provideData.t(key, params, defaultValue);
|
|
123
|
+
ts: (key, params, defaultValue, route) => {
|
|
124
|
+
const value = provideData.t(key, params, defaultValue, route);
|
|
125
125
|
return value?.toString() ?? defaultValue ?? key;
|
|
126
126
|
},
|
|
127
|
+
_t: (route) => {
|
|
128
|
+
return (key, params, defaultValue) => {
|
|
129
|
+
return provideData.t(key, params, defaultValue, route);
|
|
130
|
+
};
|
|
131
|
+
},
|
|
132
|
+
_ts: (route) => {
|
|
133
|
+
return (key, params, defaultValue) => {
|
|
134
|
+
return provideData.ts(key, params, defaultValue, route);
|
|
135
|
+
};
|
|
136
|
+
},
|
|
127
137
|
tc: (key, params, defaultValue) => {
|
|
128
138
|
const currentLocale = routeService.getCurrentLocale();
|
|
129
139
|
const { count, ..._params } = typeof params === "number" ? { count: params } : params;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nuxt-i18n-micro",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.78.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,7 +61,7 @@
|
|
|
61
61
|
"ufo": "^1.5.4",
|
|
62
62
|
"nuxt-i18n-micro-core": "1.0.17",
|
|
63
63
|
"nuxt-i18n-micro-test-utils": "1.0.6",
|
|
64
|
-
"nuxt-i18n-micro-types": "1.0.
|
|
64
|
+
"nuxt-i18n-micro-types": "1.0.2"
|
|
65
65
|
},
|
|
66
66
|
"devDependencies": {
|
|
67
67
|
"@nuxt/devtools": "^2.1.0",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"id":"55e592f8-59f1-4957-b408-ca556fa24e88","timestamp":1740323195533,"matcher":{"static":{},"wildcard":{},"dynamic":{}},"prerendered":[]}
|