nuxt-i18n-micro 1.10.0 → 1.11.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/{Bp0c0hHs.js → 5O6Zkut2.js} +1 -1
- package/dist/client/_nuxt/CX2tGbR4.js +119 -0
- package/dist/client/_nuxt/{B3v0hbsS.js → DulLifOC.js} +1 -1
- package/dist/client/_nuxt/builds/latest.json +1 -1
- package/dist/client/_nuxt/builds/meta/188e6c4c-cf5a-4166-a467-e82e4c5b743c.json +1 -0
- package/dist/client/_nuxt/{Pz-9CgbY.js → hsW9SqPc.js} +1 -1
- package/dist/client/index.html +6 -6
- package/dist/module.json +1 -1
- package/dist/module.mjs +35 -5
- package/dist/runtime/composables/useI18n.js +2 -0
- package/dist/runtime/plugins/01.plugin.d.ts +6 -0
- package/dist/runtime/plugins/01.plugin.js +14 -0
- package/package.json +1 -1
- package/dist/client/_nuxt/DBV-AMiz.js +0 -119
- package/dist/client/_nuxt/builds/meta/8416eff3-e660-4b21-9228-1117e80ad39a.json +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{i as o,r as u,g as f,h as d,j as v,k as l,l as i,m as h,n as m}from"./
|
|
1
|
+
import{i as o,r as u,g as f,h as d,j as v,k as l,l as i,m as h,n as m}from"./CX2tGbR4.js";function U(t,a={}){const e=a.head||o();if(e)return e.ssr?e.push(t,a):p(e,t,a)}function p(t,a,e={}){const s=u(!1),n=u({});f(()=>{n.value=s.value?{}:d(a)});const r=t.push(n.value,e);return v(n,c=>{r.patch(c)}),m()&&(l(()=>{r.dispose()}),i(()=>{s.value=!0}),h(()=>{s.value=!1})),r}export{U as u};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"id":"
|
|
1
|
+
{"id":"188e6c4c-cf5a-4166-a467-e82e4c5b743c","timestamp":1725090966238}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"id":"188e6c4c-cf5a-4166-a467-e82e4c5b743c","timestamp":1725090966238,"matcher":{"static":{},"wildcard":{},"dynamic":{}},"prerendered":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{u as o}from"./
|
|
1
|
+
import{u as o}from"./DulLifOC.js";import{_ as a,o as s,c as i,a as e,t as r,p as u,f as l}from"./CX2tGbR4.js";const c=t=>(u("data-v-b63e9691"),t=t(),l(),t),d={class:"font-sans antialiased bg-white dark:bg-black text-black dark:text-white grid min-h-screen place-content-center overflow-hidden"},p=c(()=>e("div",{class:"fixed -bottom-1/2 left-0 right-0 h-1/2 spotlight"},null,-1)),h={class:"max-w-520px text-center"},b=["textContent"],g=["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 n=t;return o({title:`${n.statusCode} - ${n.statusMessage} | ${n.appName}`,script:[],style:[{children:'*,:before,:after{box-sizing:border-box;border-width:0;border-style:solid;border-color:var(--un-default-border-color, #e5e7eb)}:before,:after{--un-content:""}html{line-height:1.5;-webkit-text-size-adjust:100%;-moz-tab-size:4;tab-size:4;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;-webkit-tap-highlight-color:transparent}body{margin:0;line-height:inherit}h1{font-size:inherit;font-weight:inherit}h1,p{margin:0}*,:before,:after{--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 rgb(0 0 0 / 0);--un-ring-shadow:0 0 rgb(0 0 0 / 0);--un-shadow-inset: ;--un-shadow:0 0 rgb(0 0 0 / 0);--un-ring-inset: ;--un-ring-offset-width:0px;--un-ring-offset-color:#fff;--un-ring-width:0px;--un-ring-color:rgb(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: }'}]}),(m,x)=>(s(),i("div",d,[p,e("div",h,[e("h1",{class:"text-8xl sm:text-10xl font-medium mb-8",textContent:r(t.statusCode)},null,8,b),e("p",{class:"text-xl px-8 sm:px-0 sm:text-4xl font-light mb-16 leading-tight",textContent:r(t.description)},null,8,g)])]))}},w=a(f,[["__scopeId","data-v-b63e9691"]]);export{w 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/CX2tGbR4.js">
|
|
5
5
|
<link rel="prefetch" as="script" crossorigin href="/__nuxt-i18n-micro/_nuxt/B6E6ObS_.js">
|
|
6
6
|
<link rel="prefetch" as="style" href="/__nuxt-i18n-micro/_nuxt/error-404.D-AvUzLt.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/5O6Zkut2.js">
|
|
8
|
+
<link rel="prefetch" as="script" crossorigin href="/__nuxt-i18n-micro/_nuxt/DulLifOC.js">
|
|
9
9
|
<link rel="prefetch" as="style" href="/__nuxt-i18n-micro/_nuxt/error-500.21ZDxC33.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/hsW9SqPc.js">
|
|
11
|
+
<script type="module" src="/__nuxt-i18n-micro/_nuxt/CX2tGbR4.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:"188e6c4c-cf5a-4166-a467-e82e4c5b743c",buildAssetsDir:"/_nuxt/",cdnURL:""}}</script></body></html>
|
package/dist/module.json
CHANGED
package/dist/module.mjs
CHANGED
|
@@ -190,7 +190,7 @@ const module = defineNuxtModule({
|
|
|
190
190
|
if (page.file) {
|
|
191
191
|
const filePath = path.resolve(nuxt.options.rootDir, page.file);
|
|
192
192
|
const fileContent = readFileSync(filePath, "utf-8");
|
|
193
|
-
const i18nRouteConfig = extractDefineI18nRouteConfig(fileContent);
|
|
193
|
+
const i18nRouteConfig = extractDefineI18nRouteConfig(fileContent, filePath);
|
|
194
194
|
if (i18nRouteConfig && i18nRouteConfig.localeRoutes) {
|
|
195
195
|
customPaths[page.path] = i18nRouteConfig.localeRoutes;
|
|
196
196
|
}
|
|
@@ -300,23 +300,53 @@ const module = defineNuxtModule({
|
|
|
300
300
|
});
|
|
301
301
|
}
|
|
302
302
|
});
|
|
303
|
+
nuxt.hook("prerender:routes", async (prerenderRoutes) => {
|
|
304
|
+
const routesSet = prerenderRoutes.routes;
|
|
305
|
+
const additionalRoutes = /* @__PURE__ */ new Set();
|
|
306
|
+
routesSet.forEach((route) => {
|
|
307
|
+
options.locales.forEach((locale) => {
|
|
308
|
+
if (locale.code !== options.defaultLocale) {
|
|
309
|
+
if (route === "/") {
|
|
310
|
+
additionalRoutes.add(`/${locale.code}`);
|
|
311
|
+
} else {
|
|
312
|
+
additionalRoutes.add(`/${locale.code}${route}`);
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
});
|
|
316
|
+
});
|
|
317
|
+
additionalRoutes.forEach((route) => routesSet.add(route));
|
|
318
|
+
});
|
|
303
319
|
if (nuxt.options.dev) {
|
|
304
320
|
setupDevToolsUI(options, resolver.resolve);
|
|
305
321
|
}
|
|
306
322
|
}
|
|
307
323
|
});
|
|
308
|
-
function
|
|
324
|
+
function cleanObjectString(objectString) {
|
|
325
|
+
let cleanedString = objectString.replace(/'/g, '"');
|
|
326
|
+
cleanedString = cleanedString.replace(/([{,]\s*)(\w+)(\s*:)/g, '$1"$2"$3');
|
|
327
|
+
cleanedString = cleanedString.replace(/,(\s*[}\]])/g, "$1");
|
|
328
|
+
cleanedString = cleanedString.replace(/,+/g, ",");
|
|
329
|
+
cleanedString = cleanedString.replace(/(\{|\[)\s*,/g, "$1");
|
|
330
|
+
cleanedString = cleanedString.replace(/,(\s*[}\]])/g, "$1");
|
|
331
|
+
cleanedString = cleanedString.trim();
|
|
332
|
+
if (!cleanedString.startsWith("{") || !cleanedString.endsWith("}")) {
|
|
333
|
+
throw new Error("Invalid object format after cleaning");
|
|
334
|
+
}
|
|
335
|
+
return cleanedString;
|
|
336
|
+
}
|
|
337
|
+
function extractDefineI18nRouteConfig(content, path2) {
|
|
309
338
|
const match = content.match(/\$defineI18nRoute\((\{[\s\S]*?\})\)/);
|
|
310
339
|
if (match && match[1]) {
|
|
311
340
|
try {
|
|
312
|
-
const
|
|
341
|
+
const cleanedString = cleanObjectString(match[1]);
|
|
342
|
+
const configObject = JSON.parse(cleanedString);
|
|
313
343
|
if (validateDefineI18nRouteConfig(configObject)) {
|
|
314
344
|
return configObject;
|
|
315
345
|
} else {
|
|
316
|
-
console.error("Invalid defineI18nRoute configuration format:", configObject);
|
|
346
|
+
console.error("Invalid defineI18nRoute configuration format:", configObject, "in file: ", path2);
|
|
317
347
|
}
|
|
318
348
|
} catch (error) {
|
|
319
|
-
console.error("Failed to parse defineI18nRoute configuration:", error);
|
|
349
|
+
console.error("Failed to parse defineI18nRoute configuration:", error, "in file: ", path2);
|
|
320
350
|
}
|
|
321
351
|
}
|
|
322
352
|
return null;
|
|
@@ -12,6 +12,8 @@ declare const _default: import("#app").Plugin<{
|
|
|
12
12
|
getLocales: () => Locale[];
|
|
13
13
|
t: (key: string, params?: Record<string, string | number | boolean>, defaultValue?: string) => unknown;
|
|
14
14
|
tc: (key: string, count: number, defaultValue?: string) => string;
|
|
15
|
+
tn: (value: number, options?: Intl.NumberFormatOptions) => string;
|
|
16
|
+
td: (value: Date | number | string, options?: Intl.DateTimeFormatOptions) => string;
|
|
15
17
|
has: (key: string) => boolean;
|
|
16
18
|
mergeTranslations: (newTranslations: Translations) => void;
|
|
17
19
|
switchLocale: (locale: string) => void;
|
|
@@ -21,6 +23,8 @@ declare const _default: import("#app").Plugin<{
|
|
|
21
23
|
getLocales: () => Locale[];
|
|
22
24
|
t: (key: string, params?: Record<string, string | number | boolean>, defaultValue?: string) => unknown;
|
|
23
25
|
tc: (key: string, count: number, defaultValue?: string) => string;
|
|
26
|
+
tn: (value: number, options?: Intl.NumberFormatOptions) => string;
|
|
27
|
+
td: (value: Date | number | string, options?: Intl.DateTimeFormatOptions) => string;
|
|
24
28
|
has: (key: string) => boolean;
|
|
25
29
|
mergeTranslations: (newTranslations: Translations) => void;
|
|
26
30
|
switchLocale: (locale: string) => void;
|
|
@@ -32,6 +36,8 @@ export interface PluginsInjections {
|
|
|
32
36
|
$getLocales: () => Locale[];
|
|
33
37
|
$t: <T extends Record<string, string | number | boolean>>(key: string, params?: T, defaultValue?: string) => string | number | boolean | Translations | PluralTranslations | unknown[] | unknown | null;
|
|
34
38
|
$tc: (key: string, count: number, defaultValue?: string) => string;
|
|
39
|
+
$tn: (value: number, options?: Intl.NumberFormatOptions) => string;
|
|
40
|
+
$td: (value: Date | number | string, options?: Intl.DateTimeFormatOptions) => string;
|
|
35
41
|
$has: (key: string) => boolean;
|
|
36
42
|
$mergeTranslations: (newTranslations: Translations) => void;
|
|
37
43
|
$switchLocale: (locale: string) => void;
|
|
@@ -55,6 +55,12 @@ function getLocalizedRoute(to, router, route, i18nConfig, locale) {
|
|
|
55
55
|
}
|
|
56
56
|
return router.resolve({ name: newRouteName, params: newParams });
|
|
57
57
|
}
|
|
58
|
+
function formatNumber(value, locale, options) {
|
|
59
|
+
return new Intl.NumberFormat(locale, options).format(value);
|
|
60
|
+
}
|
|
61
|
+
function formatDate(value, locale, options) {
|
|
62
|
+
return new Intl.DateTimeFormat(locale, options).format(new Date(value));
|
|
63
|
+
}
|
|
58
64
|
export default defineNuxtPlugin(async (nuxtApp) => {
|
|
59
65
|
const registerI18nModule = (translations, locale) => {
|
|
60
66
|
i18nHelper.mergeGlobalTranslation(locale, translations);
|
|
@@ -117,6 +123,14 @@ export default defineNuxtPlugin(async (nuxtApp) => {
|
|
|
117
123
|
const translation = getTranslation(key, {}, defaultValue);
|
|
118
124
|
return plural(translation?.toString(), count, getCurrentLocale(useRoute(), i18nConfig));
|
|
119
125
|
},
|
|
126
|
+
tn: (value, options) => {
|
|
127
|
+
const locale = getCurrentLocale(useRoute(), i18nConfig);
|
|
128
|
+
return formatNumber(value, locale, options);
|
|
129
|
+
},
|
|
130
|
+
td: (value, options) => {
|
|
131
|
+
const locale = getCurrentLocale(useRoute(), i18nConfig);
|
|
132
|
+
return formatDate(value, locale, options);
|
|
133
|
+
},
|
|
120
134
|
has: (key) => {
|
|
121
135
|
return !!getTranslation(key);
|
|
122
136
|
},
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nuxt-i18n-micro",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.11.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",
|