nuxt-i18n-micro 1.19.1 → 1.20.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 +6 -6
- package/dist/client/404.html +6 -6
- package/dist/client/_nuxt/{CnNUpwZL.js → Cyk_K70X.js} +1 -1
- package/dist/client/_nuxt/KRXZLT2z.js +98 -0
- package/dist/client/_nuxt/builds/latest.json +1 -1
- package/dist/client/_nuxt/builds/meta/93fa43e4-d906-4eb9-8c5d-ff7ca632f7d7.json +1 -0
- package/dist/client/_nuxt/{BKcmVa-6.js → knEmOwlw.js} +1 -1
- package/dist/client/_nuxt/{ftQz2Awu.js → xINE4AoZ.js} +1 -1
- package/dist/client/index.html +6 -6
- package/dist/module.d.mts +2 -0
- package/dist/module.d.ts +2 -0
- package/dist/module.json +1 -1
- package/dist/module.mjs +53 -10
- package/package.json +1 -1
- package/dist/client/_nuxt/CeFL7aT9.js +0 -98
- package/dist/client/_nuxt/builds/meta/4b4d2b81-4ced-42fa-866c-4d6ade4d7385.json +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"id":"
|
|
1
|
+
{"id":"93fa43e4-d906-4eb9-8c5d-ff7ca632f7d7","timestamp":1727388589496}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"id":"93fa43e4-d906-4eb9-8c5d-ff7ca632f7d7","timestamp":1727388589496,"matcher":{"static":{},"wildcard":{},"dynamic":{}},"prerendered":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{_ as s,o as a,c as i,a as e,t as o}from"./
|
|
1
|
+
import{_ as s,o as a,c as i,a as e,t as o}from"./KRXZLT2z.js";import{u}from"./Cyk_K70X.js";const l={class:"antialiased bg-white dark:bg-black dark:text-white font-sans grid min-h-screen overflow-hidden place-content-center text-black"},c={class:"max-w-520px text-center"},d=["textContent"],p=["textContent"],f={__name:"error-500",props:{appName:{type:String,default:"Nuxt"},version:{type:String,default:""},statusCode:{type:Number,default:500},statusMessage:{type:String,default:"Server error"},description:{type:String,default:"This page is temporarily unavailable."}},setup(t){const r=t;return u({title:`${r.statusCode} - ${r.statusMessage} | ${r.appName}`,script:[{children:`!function(){const e=document.createElement("link").relList;if(!(e&&e.supports&&e.supports("modulepreload"))){for(const e of document.querySelectorAll('link[rel="modulepreload"]'))r(e);new MutationObserver((e=>{for(const o of e)if("childList"===o.type)for(const e of o.addedNodes)"LINK"===e.tagName&&"modulepreload"===e.rel&&r(e)})).observe(document,{childList:!0,subtree:!0})}function r(e){if(e.ep)return;e.ep=!0;const r=function(e){const r={};return e.integrity&&(r.integrity=e.integrity),e.referrerPolicy&&(r.referrerPolicy=e.referrerPolicy),"use-credentials"===e.crossOrigin?r.credentials="include":"anonymous"===e.crossOrigin?r.credentials="omit":r.credentials="same-origin",r}(e);fetch(e.href,r)}}();`}],style:[{children:'*,:after,:before{border-color:var(--un-default-border-color,#e5e7eb);border-style:solid;border-width:0;box-sizing:border-box}:after,:before{--un-content:""}html{line-height:1.5;-webkit-text-size-adjust:100%;font-family:ui-sans-serif,system-ui,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji;font-feature-settings:normal;font-variation-settings:normal;-moz-tab-size:4;tab-size:4;-webkit-tap-highlight-color:transparent}body{line-height:inherit;margin:0}h1{font-size:inherit;font-weight:inherit}h1,p{margin:0}*,:after,:before{--un-rotate:0;--un-rotate-x:0;--un-rotate-y:0;--un-rotate-z:0;--un-scale-x:1;--un-scale-y:1;--un-scale-z:1;--un-skew-x:0;--un-skew-y:0;--un-translate-x:0;--un-translate-y:0;--un-translate-z:0;--un-pan-x: ;--un-pan-y: ;--un-pinch-zoom: ;--un-scroll-snap-strictness:proximity;--un-ordinal: ;--un-slashed-zero: ;--un-numeric-figure: ;--un-numeric-spacing: ;--un-numeric-fraction: ;--un-border-spacing-x:0;--un-border-spacing-y:0;--un-ring-offset-shadow:0 0 transparent;--un-ring-shadow:0 0 transparent;--un-shadow-inset: ;--un-shadow:0 0 transparent;--un-ring-inset: ;--un-ring-offset-width:0px;--un-ring-offset-color:#fff;--un-ring-width:0px;--un-ring-color:rgba(147,197,253,.5);--un-blur: ;--un-brightness: ;--un-contrast: ;--un-drop-shadow: ;--un-grayscale: ;--un-hue-rotate: ;--un-invert: ;--un-saturate: ;--un-sepia: ;--un-backdrop-blur: ;--un-backdrop-brightness: ;--un-backdrop-contrast: ;--un-backdrop-grayscale: ;--un-backdrop-hue-rotate: ;--un-backdrop-invert: ;--un-backdrop-opacity: ;--un-backdrop-saturate: ;--un-backdrop-sepia: }'}]}),(g,n)=>(a(),i("div",l,[n[0]||(n[0]=e("div",{class:"-bottom-1/2 fixed h-1/2 left-0 right-0 spotlight"},null,-1)),e("div",c,[e("h1",{class:"font-medium mb-8 sm:text-10xl text-8xl",textContent:o(t.statusCode)},null,8,d),e("p",{class:"font-light leading-tight mb-16 px-8 sm:px-0 sm:text-4xl text-xl",textContent:o(t.description)},null,8,p)])]))}},b=s(f,[["__scopeId","data-v-d6cbdfc0"]]);export{b as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{_ as a,o as i,c as u,a as e,t as r,b as c,w as l,d,e as p}from"./
|
|
1
|
+
import{_ as a,o as i,c as u,a as e,t as r,b as c,w as l,d,e as p}from"./KRXZLT2z.js";import{u as f}from"./Cyk_K70X.js";const m={class:"antialiased bg-white dark:bg-black dark:text-white font-sans grid min-h-screen overflow-hidden place-content-center text-black"},g={class:"max-w-520px text-center z-20"},h=["textContent"],b=["textContent"],x={class:"flex items-center justify-center w-full"},y={__name:"error-404",props:{appName:{type:String,default:"Nuxt"},version:{type:String,default:""},statusCode:{type:Number,default:404},statusMessage:{type:String,default:"Not Found"},description:{type:String,default:"Sorry, the page you are looking for could not be found."},backHome:{type:String,default:"Go back home"}},setup(t){const n=t;return f({title:`${n.statusCode} - ${n.statusMessage} | ${n.appName}`,script:[{children:`!function(){const e=document.createElement("link").relList;if(!(e&&e.supports&&e.supports("modulepreload"))){for(const e of document.querySelectorAll('link[rel="modulepreload"]'))r(e);new MutationObserver((e=>{for(const o of e)if("childList"===o.type)for(const e of o.addedNodes)"LINK"===e.tagName&&"modulepreload"===e.rel&&r(e)})).observe(document,{childList:!0,subtree:!0})}function r(e){if(e.ep)return;e.ep=!0;const r=function(e){const r={};return e.integrity&&(r.integrity=e.integrity),e.referrerPolicy&&(r.referrerPolicy=e.referrerPolicy),"use-credentials"===e.crossOrigin?r.credentials="include":"anonymous"===e.crossOrigin?r.credentials="omit":r.credentials="same-origin",r}(e);fetch(e.href,r)}}();`}],style:[{children:'*,:after,:before{border-color:var(--un-default-border-color,#e5e7eb);border-style:solid;border-width:0;box-sizing:border-box}:after,:before{--un-content:""}html{line-height:1.5;-webkit-text-size-adjust:100%;font-family:ui-sans-serif,system-ui,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji;font-feature-settings:normal;font-variation-settings:normal;-moz-tab-size:4;tab-size:4;-webkit-tap-highlight-color:transparent}body{line-height:inherit;margin:0}h1{font-size:inherit;font-weight:inherit}a{color:inherit;text-decoration:inherit}h1,p{margin:0}*,:after,:before{--un-rotate:0;--un-rotate-x:0;--un-rotate-y:0;--un-rotate-z:0;--un-scale-x:1;--un-scale-y:1;--un-scale-z:1;--un-skew-x:0;--un-skew-y:0;--un-translate-x:0;--un-translate-y:0;--un-translate-z:0;--un-pan-x: ;--un-pan-y: ;--un-pinch-zoom: ;--un-scroll-snap-strictness:proximity;--un-ordinal: ;--un-slashed-zero: ;--un-numeric-figure: ;--un-numeric-spacing: ;--un-numeric-fraction: ;--un-border-spacing-x:0;--un-border-spacing-y:0;--un-ring-offset-shadow:0 0 transparent;--un-ring-shadow:0 0 transparent;--un-shadow-inset: ;--un-shadow:0 0 transparent;--un-ring-inset: ;--un-ring-offset-width:0px;--un-ring-offset-color:#fff;--un-ring-width:0px;--un-ring-color:rgba(147,197,253,.5);--un-blur: ;--un-brightness: ;--un-contrast: ;--un-drop-shadow: ;--un-grayscale: ;--un-hue-rotate: ;--un-invert: ;--un-saturate: ;--un-sepia: ;--un-backdrop-blur: ;--un-backdrop-brightness: ;--un-backdrop-contrast: ;--un-backdrop-grayscale: ;--un-backdrop-hue-rotate: ;--un-backdrop-invert: ;--un-backdrop-opacity: ;--un-backdrop-saturate: ;--un-backdrop-sepia: }'}]}),(k,o)=>{const s=p;return i(),u("div",m,[o[0]||(o[0]=e("div",{class:"fixed left-0 right-0 spotlight z-10"},null,-1)),e("div",g,[e("h1",{class:"font-medium mb-8 sm:text-10xl text-8xl",textContent:r(t.statusCode)},null,8,h),e("p",{class:"font-light leading-tight mb-16 px-8 sm:px-0 sm:text-4xl text-xl",textContent:r(t.description)},null,8,b),e("div",x,[c(s,{to:"/",class:"cursor-pointer gradient-border px-4 py-2 sm:px-6 sm:py-3 sm:text-xl text-md"},{default:l(()=>[d(r(t.backHome),1)]),_:1})])])])}}},v=a(y,[["__scopeId","data-v-28c488d2"]]);export{v as default};
|
package/dist/client/index.html
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
<!DOCTYPE html><html data-capo=""><head><meta charset="utf-8">
|
|
2
2
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
3
3
|
<link rel="stylesheet" href="/__nuxt-i18n-micro/_nuxt/entry.DjxsrOxm.css">
|
|
4
|
-
<link rel="modulepreload" as="script" crossorigin href="/__nuxt-i18n-micro/_nuxt/
|
|
4
|
+
<link rel="modulepreload" as="script" crossorigin href="/__nuxt-i18n-micro/_nuxt/KRXZLT2z.js">
|
|
5
5
|
<link rel="prefetch" as="script" crossorigin href="/__nuxt-i18n-micro/_nuxt/B6E6ObS_.js">
|
|
6
6
|
<link rel="prefetch" as="style" crossorigin href="/__nuxt-i18n-micro/_nuxt/error-404.C_4C5G96.css">
|
|
7
|
-
<link rel="prefetch" as="script" crossorigin href="/__nuxt-i18n-micro/_nuxt/
|
|
8
|
-
<link rel="prefetch" as="script" crossorigin href="/__nuxt-i18n-micro/_nuxt/
|
|
7
|
+
<link rel="prefetch" as="script" crossorigin href="/__nuxt-i18n-micro/_nuxt/xINE4AoZ.js">
|
|
8
|
+
<link rel="prefetch" as="script" crossorigin href="/__nuxt-i18n-micro/_nuxt/Cyk_K70X.js">
|
|
9
9
|
<link rel="prefetch" as="style" crossorigin href="/__nuxt-i18n-micro/_nuxt/error-500.CBAEdpZV.css">
|
|
10
|
-
<link rel="prefetch" as="script" crossorigin href="/__nuxt-i18n-micro/_nuxt/
|
|
11
|
-
<script type="module" src="/__nuxt-i18n-micro/_nuxt/
|
|
12
|
-
<script>window.__NUXT__={};window.__NUXT__.config={public:{},app:{baseURL:"/__nuxt-i18n-micro",buildId:"
|
|
10
|
+
<link rel="prefetch" as="script" crossorigin href="/__nuxt-i18n-micro/_nuxt/knEmOwlw.js">
|
|
11
|
+
<script type="module" src="/__nuxt-i18n-micro/_nuxt/KRXZLT2z.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},1727388601538,false]</script>
|
|
12
|
+
<script>window.__NUXT__={};window.__NUXT__.config={public:{},app:{baseURL:"/__nuxt-i18n-micro",buildId:"93fa43e4-d906-4eb9-8c5d-ff7ca632f7d7",buildAssetsDir:"/_nuxt/",cdnURL:""}}</script></body></html>
|
package/dist/module.d.mts
CHANGED
|
@@ -9,6 +9,7 @@ interface Locale {
|
|
|
9
9
|
}
|
|
10
10
|
type Getter = (key: string, params?: Record<string, string | number | boolean>, defaultValue?: string) => unknown;
|
|
11
11
|
type PluralFunc = (key: string, count: number, locale: string, getter: Getter) => string | null;
|
|
12
|
+
type GlobalLocaleRoutes = Record<string, Record<string, string> | false | boolean> | null | undefined;
|
|
12
13
|
interface ModuleOptions {
|
|
13
14
|
locales?: Locale[];
|
|
14
15
|
meta?: boolean;
|
|
@@ -25,6 +26,7 @@ interface ModuleOptions {
|
|
|
25
26
|
disablePageLocales?: boolean;
|
|
26
27
|
fallbackLocale?: string;
|
|
27
28
|
localeCookie?: string;
|
|
29
|
+
globalLocaleRoutes?: GlobalLocaleRoutes;
|
|
28
30
|
}
|
|
29
31
|
interface ModuleOptionsExtend extends ModuleOptions {
|
|
30
32
|
plural: string;
|
package/dist/module.d.ts
CHANGED
|
@@ -9,6 +9,7 @@ interface Locale {
|
|
|
9
9
|
}
|
|
10
10
|
type Getter = (key: string, params?: Record<string, string | number | boolean>, defaultValue?: string) => unknown;
|
|
11
11
|
type PluralFunc = (key: string, count: number, locale: string, getter: Getter) => string | null;
|
|
12
|
+
type GlobalLocaleRoutes = Record<string, Record<string, string> | false | boolean> | null | undefined;
|
|
12
13
|
interface ModuleOptions {
|
|
13
14
|
locales?: Locale[];
|
|
14
15
|
meta?: boolean;
|
|
@@ -25,6 +26,7 @@ interface ModuleOptions {
|
|
|
25
26
|
disablePageLocales?: boolean;
|
|
26
27
|
fallbackLocale?: string;
|
|
27
28
|
localeCookie?: string;
|
|
29
|
+
globalLocaleRoutes?: GlobalLocaleRoutes;
|
|
28
30
|
}
|
|
29
31
|
interface ModuleOptionsExtend extends ModuleOptions {
|
|
30
32
|
plural: string;
|
package/dist/module.json
CHANGED
package/dist/module.mjs
CHANGED
|
@@ -88,11 +88,21 @@ function setupDevToolsUI(options, resolve) {
|
|
|
88
88
|
});
|
|
89
89
|
}
|
|
90
90
|
|
|
91
|
+
function normalizeLocales(localesArray) {
|
|
92
|
+
const localesObject = {};
|
|
93
|
+
for (const locale of localesArray) {
|
|
94
|
+
localesObject[locale] = {};
|
|
95
|
+
}
|
|
96
|
+
return localesObject;
|
|
97
|
+
}
|
|
91
98
|
function extractDefineI18nRouteConfig(content, filePath) {
|
|
92
99
|
const match = content.match(/^[ \t]*\$defineI18nRoute\((\{[\s\S]*?\})\)/m);
|
|
93
100
|
if (match && match[1]) {
|
|
94
101
|
try {
|
|
95
102
|
const parsedObject = Function('"use strict";return (' + match[1] + ")")();
|
|
103
|
+
if (parsedObject.locales && Array.isArray(parsedObject.locales)) {
|
|
104
|
+
parsedObject.locales = normalizeLocales(parsedObject.locales);
|
|
105
|
+
}
|
|
96
106
|
if (validateDefineI18nRouteConfig(parsedObject)) {
|
|
97
107
|
return parsedObject;
|
|
98
108
|
} else {
|
|
@@ -147,11 +157,13 @@ class PageManager {
|
|
|
147
157
|
includeDefaultLocaleRoute;
|
|
148
158
|
localizedPaths = {};
|
|
149
159
|
activeLocaleCodes;
|
|
150
|
-
|
|
160
|
+
globalLocaleRoutes;
|
|
161
|
+
constructor(locales, defaultLocaleCode, includeDefaultLocaleRoute, globalLocaleRoutes) {
|
|
151
162
|
this.locales = locales;
|
|
152
163
|
this.defaultLocale = this.findLocaleByCode(defaultLocaleCode) || { code: defaultLocaleCode };
|
|
153
164
|
this.includeDefaultLocaleRoute = includeDefaultLocaleRoute;
|
|
154
165
|
this.activeLocaleCodes = this.computeActiveLocaleCodes();
|
|
166
|
+
this.globalLocaleRoutes = globalLocaleRoutes || {};
|
|
155
167
|
}
|
|
156
168
|
findLocaleByCode(code) {
|
|
157
169
|
return this.locales.find((locale) => locale.code === code);
|
|
@@ -162,20 +174,37 @@ class PageManager {
|
|
|
162
174
|
extendPages(pages, rootDir) {
|
|
163
175
|
this.localizedPaths = this.extractLocalizedPaths(pages, rootDir);
|
|
164
176
|
const additionalRoutes = [];
|
|
165
|
-
pages.forEach((page) =>
|
|
177
|
+
pages.forEach((page) => {
|
|
178
|
+
const customRoute = this.globalLocaleRoutes[page.name ?? ""] ?? null;
|
|
179
|
+
if (customRoute === false) {
|
|
180
|
+
return;
|
|
181
|
+
}
|
|
182
|
+
if (customRoute && typeof customRoute === "object") {
|
|
183
|
+
this.addCustomGlobalLocalizedRoutes(page, customRoute, additionalRoutes);
|
|
184
|
+
} else {
|
|
185
|
+
this.localizePage(page, additionalRoutes);
|
|
186
|
+
}
|
|
187
|
+
});
|
|
166
188
|
pages.push(...additionalRoutes);
|
|
167
189
|
}
|
|
168
190
|
extractLocalizedPaths(pages, rootDir, parentPath = "") {
|
|
169
191
|
const localizedPaths = {};
|
|
170
192
|
pages.forEach((page) => {
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
const
|
|
177
|
-
|
|
193
|
+
const pageName = page.name ?? "";
|
|
194
|
+
const globalLocalePath = this.globalLocaleRoutes[pageName];
|
|
195
|
+
if (!globalLocalePath) {
|
|
196
|
+
if (page.file) {
|
|
197
|
+
const filePath = path.resolve(rootDir, page.file);
|
|
198
|
+
const fileContent = readFileSync(filePath, "utf-8");
|
|
199
|
+
const i18nRouteConfig = extractDefineI18nRouteConfig(fileContent, filePath);
|
|
200
|
+
if (i18nRouteConfig?.localeRoutes) {
|
|
201
|
+
const normalizedFullPath = normalizePath(path.join(parentPath, page.path));
|
|
202
|
+
localizedPaths[normalizedFullPath] = i18nRouteConfig.localeRoutes;
|
|
203
|
+
}
|
|
178
204
|
}
|
|
205
|
+
} else if (typeof globalLocalePath === "object") {
|
|
206
|
+
const normalizedFullPath = normalizePath(path.join(parentPath, page.path));
|
|
207
|
+
localizedPaths[normalizedFullPath] = globalLocalePath;
|
|
179
208
|
}
|
|
180
209
|
if (page.children?.length) {
|
|
181
210
|
const parentFullPath = normalizePath(path.join(parentPath, page.path));
|
|
@@ -184,6 +213,19 @@ class PageManager {
|
|
|
184
213
|
});
|
|
185
214
|
return localizedPaths;
|
|
186
215
|
}
|
|
216
|
+
addCustomGlobalLocalizedRoutes(page, customRoutePaths, additionalRoutes) {
|
|
217
|
+
this.locales.forEach((locale) => {
|
|
218
|
+
const customPath = customRoutePaths[locale.code];
|
|
219
|
+
if (!customPath)
|
|
220
|
+
return;
|
|
221
|
+
const isDefaultLocale = isLocaleDefault(locale, this.defaultLocale, this.includeDefaultLocaleRoute);
|
|
222
|
+
if (isDefaultLocale) {
|
|
223
|
+
page.path = normalizePath(customPath);
|
|
224
|
+
} else {
|
|
225
|
+
additionalRoutes.push(this.createLocalizedRoute(page, [locale.code], page.children ?? [], true, customPath));
|
|
226
|
+
}
|
|
227
|
+
});
|
|
228
|
+
}
|
|
187
229
|
localizePage(page, additionalRoutes) {
|
|
188
230
|
if (isPageRedirectOnly(page))
|
|
189
231
|
return;
|
|
@@ -350,6 +392,7 @@ const module = defineNuxtModule({
|
|
|
350
392
|
fallbackLocale: void 0,
|
|
351
393
|
localeCookie: "user-locale",
|
|
352
394
|
routesLocaleLinks: {},
|
|
395
|
+
globalLocaleRoutes: {},
|
|
353
396
|
plural: (key, count, _locale, getTranslation) => {
|
|
354
397
|
const translation = getTranslation(key, {});
|
|
355
398
|
if (!translation) {
|
|
@@ -371,7 +414,7 @@ const module = defineNuxtModule({
|
|
|
371
414
|
const resolver = createResolver(import.meta.url);
|
|
372
415
|
const rootDirs = nuxt.options._layers.map((layer) => layer.config.rootDir).reverse();
|
|
373
416
|
const localeManager = new LocaleManager(options, rootDirs);
|
|
374
|
-
const pageManager = new PageManager(localeManager.locales, options.defaultLocale, options.includeDefaultLocaleRoute);
|
|
417
|
+
const pageManager = new PageManager(localeManager.locales, options.defaultLocale, options.includeDefaultLocaleRoute, options.globalLocaleRoutes);
|
|
375
418
|
let plural = options.plural;
|
|
376
419
|
if (typeof plural !== "string")
|
|
377
420
|
plural = plural.toString();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nuxt-i18n-micro",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.20.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",
|