nuxt-i18n-micro 1.19.2 → 1.20.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 +6 -6
- package/dist/client/404.html +6 -6
- package/dist/client/_nuxt/{CnNUpwZL.js → B148pa4t.js} +1 -1
- package/dist/client/_nuxt/BCYq0FKk.js +98 -0
- package/dist/client/_nuxt/{BKcmVa-6.js → C6gwlnea.js} +1 -1
- package/dist/client/_nuxt/{ftQz2Awu.js → CNnq3hGv.js} +1 -1
- package/dist/client/_nuxt/builds/latest.json +1 -1
- package/dist/client/_nuxt/builds/meta/bb6d2b1a-9d63-4276-ae80-21dfa9b85ca3.json +1 -0
- 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 +43 -10
- package/dist/runtime/plugins/01.plugin.d.ts +2 -0
- package/dist/runtime/plugins/01.plugin.js +47 -45
- package/package.json +1 -1
- package/dist/client/_nuxt/CeFL7aT9.js +0 -98
- package/dist/client/_nuxt/builds/meta/74119d58-be1e-4be5-a7fe-d3487dd8d646.json +0 -1
|
@@ -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"./BCYq0FKk.js";import{u}from"./B148pa4t.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"./BCYq0FKk.js";import{u as f}from"./B148pa4t.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};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"id":"
|
|
1
|
+
{"id":"bb6d2b1a-9d63-4276-ae80-21dfa9b85ca3","timestamp":1727429794281}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"id":"bb6d2b1a-9d63-4276-ae80-21dfa9b85ca3","timestamp":1727429794281,"matcher":{"static":{},"wildcard":{},"dynamic":{}},"prerendered":[]}
|
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/BCYq0FKk.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/CNnq3hGv.js">
|
|
8
|
+
<link rel="prefetch" as="script" crossorigin href="/__nuxt-i18n-micro/_nuxt/B148pa4t.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/C6gwlnea.js">
|
|
11
|
+
<script type="module" src="/__nuxt-i18n-micro/_nuxt/BCYq0FKk.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},1727429805769,false]</script>
|
|
12
|
+
<script>window.__NUXT__={};window.__NUXT__.config={public:{},app:{baseURL:"/__nuxt-i18n-micro",buildId:"bb6d2b1a-9d63-4276-ae80-21dfa9b85ca3",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
|
@@ -157,11 +157,13 @@ class PageManager {
|
|
|
157
157
|
includeDefaultLocaleRoute;
|
|
158
158
|
localizedPaths = {};
|
|
159
159
|
activeLocaleCodes;
|
|
160
|
-
|
|
160
|
+
globalLocaleRoutes;
|
|
161
|
+
constructor(locales, defaultLocaleCode, includeDefaultLocaleRoute, globalLocaleRoutes) {
|
|
161
162
|
this.locales = locales;
|
|
162
163
|
this.defaultLocale = this.findLocaleByCode(defaultLocaleCode) || { code: defaultLocaleCode };
|
|
163
164
|
this.includeDefaultLocaleRoute = includeDefaultLocaleRoute;
|
|
164
165
|
this.activeLocaleCodes = this.computeActiveLocaleCodes();
|
|
166
|
+
this.globalLocaleRoutes = globalLocaleRoutes || {};
|
|
165
167
|
}
|
|
166
168
|
findLocaleByCode(code) {
|
|
167
169
|
return this.locales.find((locale) => locale.code === code);
|
|
@@ -172,20 +174,37 @@ class PageManager {
|
|
|
172
174
|
extendPages(pages, rootDir) {
|
|
173
175
|
this.localizedPaths = this.extractLocalizedPaths(pages, rootDir);
|
|
174
176
|
const additionalRoutes = [];
|
|
175
|
-
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
|
+
});
|
|
176
188
|
pages.push(...additionalRoutes);
|
|
177
189
|
}
|
|
178
190
|
extractLocalizedPaths(pages, rootDir, parentPath = "") {
|
|
179
191
|
const localizedPaths = {};
|
|
180
192
|
pages.forEach((page) => {
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
const
|
|
187
|
-
|
|
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
|
+
}
|
|
188
204
|
}
|
|
205
|
+
} else if (typeof globalLocalePath === "object") {
|
|
206
|
+
const normalizedFullPath = normalizePath(path.join(parentPath, page.path));
|
|
207
|
+
localizedPaths[normalizedFullPath] = globalLocalePath;
|
|
189
208
|
}
|
|
190
209
|
if (page.children?.length) {
|
|
191
210
|
const parentFullPath = normalizePath(path.join(parentPath, page.path));
|
|
@@ -194,6 +213,19 @@ class PageManager {
|
|
|
194
213
|
});
|
|
195
214
|
return localizedPaths;
|
|
196
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
|
+
}
|
|
197
229
|
localizePage(page, additionalRoutes) {
|
|
198
230
|
if (isPageRedirectOnly(page))
|
|
199
231
|
return;
|
|
@@ -360,6 +392,7 @@ const module = defineNuxtModule({
|
|
|
360
392
|
fallbackLocale: void 0,
|
|
361
393
|
localeCookie: "user-locale",
|
|
362
394
|
routesLocaleLinks: {},
|
|
395
|
+
globalLocaleRoutes: {},
|
|
363
396
|
plural: (key, count, _locale, getTranslation) => {
|
|
364
397
|
const translation = getTranslation(key, {});
|
|
365
398
|
if (!translation) {
|
|
@@ -381,7 +414,7 @@ const module = defineNuxtModule({
|
|
|
381
414
|
const resolver = createResolver(import.meta.url);
|
|
382
415
|
const rootDirs = nuxt.options._layers.map((layer) => layer.config.rootDir).reverse();
|
|
383
416
|
const localeManager = new LocaleManager(options, rootDirs);
|
|
384
|
-
const pageManager = new PageManager(localeManager.locales, options.defaultLocale, options.includeDefaultLocaleRoute);
|
|
417
|
+
const pageManager = new PageManager(localeManager.locales, options.defaultLocale, options.includeDefaultLocaleRoute, options.globalLocaleRoutes);
|
|
385
418
|
let plural = options.plural;
|
|
386
419
|
if (typeof plural !== "string")
|
|
387
420
|
plural = plural.toString();
|
|
@@ -8,6 +8,7 @@ interface PluralTranslations {
|
|
|
8
8
|
plural: string;
|
|
9
9
|
}
|
|
10
10
|
declare const _default: import("#app").Plugin<{
|
|
11
|
+
i18n: undefined;
|
|
11
12
|
getLocale: () => string;
|
|
12
13
|
getLocales: () => Locale[];
|
|
13
14
|
getRouteName: (route?: RouteLocationNormalizedLoaded | RouteLocationResolvedGeneric, locale?: string) => string;
|
|
@@ -20,6 +21,7 @@ declare const _default: import("#app").Plugin<{
|
|
|
20
21
|
switchLocale: (toLocale: string) => void;
|
|
21
22
|
localeRoute: (to: RouteLocationRaw, locale?: string) => RouteLocationRaw;
|
|
22
23
|
}> & import("#app").ObjectPlugin<{
|
|
24
|
+
i18n: undefined;
|
|
23
25
|
getLocale: () => string;
|
|
24
26
|
getLocales: () => Locale[];
|
|
25
27
|
getRouteName: (route?: RouteLocationNormalizedLoaded | RouteLocationResolvedGeneric, locale?: string) => string;
|
|
@@ -138,52 +138,54 @@ export default defineNuxtPlugin(async (nuxtApp) => {
|
|
|
138
138
|
if (i18nConfig.hashMode) {
|
|
139
139
|
hashLocale = useCookie("hash-locale").value ?? i18nConfig.defaultLocale;
|
|
140
140
|
}
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
hashLocale = toLocale;
|
|
179
|
-
}
|
|
180
|
-
switchLocale(fromLocale, toLocale, route, router, i18nConfig);
|
|
181
|
-
},
|
|
182
|
-
localeRoute: (to, locale) => {
|
|
183
|
-
const router = useRouter();
|
|
184
|
-
const route = useRoute();
|
|
185
|
-
return getLocalizedRoute(to, router, route, i18nConfig, locale, hashLocale);
|
|
141
|
+
const provideData = {
|
|
142
|
+
i18n: void 0,
|
|
143
|
+
getLocale: () => getCurrentLocale(useRoute(), i18nConfig, hashLocale),
|
|
144
|
+
getLocales: () => i18nConfig.locales || [],
|
|
145
|
+
getRouteName: (route, locale) => {
|
|
146
|
+
const selectedLocale = locale ?? getCurrentLocale(useRoute(), i18nConfig, hashLocale);
|
|
147
|
+
const selectedRoute = route ?? useRoute();
|
|
148
|
+
return getRouteName(selectedRoute, selectedLocale);
|
|
149
|
+
},
|
|
150
|
+
t: getTranslation,
|
|
151
|
+
tc: (key, count, defaultValue) => {
|
|
152
|
+
const currentLocale = getCurrentLocale(useRoute(), i18nConfig, hashLocale);
|
|
153
|
+
return plural(key, count, currentLocale, getTranslation) ?? defaultValue ?? key;
|
|
154
|
+
},
|
|
155
|
+
tn: (value, options) => {
|
|
156
|
+
const locale = getCurrentLocale(useRoute(), i18nConfig, hashLocale);
|
|
157
|
+
return formatNumber(value, locale, options);
|
|
158
|
+
},
|
|
159
|
+
td: (value, options) => {
|
|
160
|
+
const locale = getCurrentLocale(useRoute(), i18nConfig, hashLocale);
|
|
161
|
+
return formatDate(value, locale, options);
|
|
162
|
+
},
|
|
163
|
+
has: (key) => {
|
|
164
|
+
return !!getTranslation(key);
|
|
165
|
+
},
|
|
166
|
+
mergeTranslations: (newTranslations) => {
|
|
167
|
+
const route = useRoute();
|
|
168
|
+
const locale = getCurrentLocale(route, i18nConfig, hashLocale);
|
|
169
|
+
const routeName = getRouteName(route, locale);
|
|
170
|
+
i18nHelper.mergeTranslation(locale, routeName, newTranslations);
|
|
171
|
+
},
|
|
172
|
+
switchLocale: (toLocale) => {
|
|
173
|
+
const router = useRouter();
|
|
174
|
+
const route = useRoute();
|
|
175
|
+
const fromLocale = getCurrentLocale(route, i18nConfig, hashLocale);
|
|
176
|
+
if (i18nConfig.hashMode) {
|
|
177
|
+
hashLocale = toLocale;
|
|
186
178
|
}
|
|
179
|
+
switchLocale(fromLocale, toLocale, route, router, i18nConfig);
|
|
180
|
+
},
|
|
181
|
+
localeRoute: (to, locale) => {
|
|
182
|
+
const router = useRouter();
|
|
183
|
+
const route = useRoute();
|
|
184
|
+
return getLocalizedRoute(to, router, route, i18nConfig, locale, hashLocale);
|
|
187
185
|
}
|
|
188
186
|
};
|
|
187
|
+
provideData.i18n = provideData;
|
|
188
|
+
return {
|
|
189
|
+
provide: provideData
|
|
190
|
+
};
|
|
189
191
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nuxt-i18n-micro",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.20.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",
|