nuxt-i18n-micro 1.32.3 → 1.33.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.
@@ -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"./BqvPetMk.js";import{u as f}from"./DKpok9-G.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
+ 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"./CTiMIQCz.js";import{u as f}from"./C4eGGOXV.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":"97407185-9c30-415a-a770-7c7fbf00a393","timestamp":1731570644540}
1
+ {"id":"8d5393e1-c8f1-4429-89a7-5f4d8a44ada2","timestamp":1732182352920}
@@ -0,0 +1 @@
1
+ {"id":"8d5393e1-c8f1-4429-89a7-5f4d8a44ada2","timestamp":1732182352920,"matcher":{"static":{},"wildcard":{},"dynamic":{}},"prerendered":[]}
@@ -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.BqOlM4b6.css">
4
- <link rel="modulepreload" as="script" crossorigin href="/__nuxt-i18n-micro/_nuxt/BqvPetMk.js">
4
+ <link rel="modulepreload" as="script" crossorigin href="/__nuxt-i18n-micro/_nuxt/CTiMIQCz.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/Dh7ThpBa.js">
8
- <link rel="prefetch" as="script" crossorigin href="/__nuxt-i18n-micro/_nuxt/DKpok9-G.js">
7
+ <link rel="prefetch" as="script" crossorigin href="/__nuxt-i18n-micro/_nuxt/DwKyf7FR.js">
8
+ <link rel="prefetch" as="script" crossorigin href="/__nuxt-i18n-micro/_nuxt/C4eGGOXV.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/DyPN9pGe.js">
11
- <script type="module" src="/__nuxt-i18n-micro/_nuxt/BqvPetMk.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},1731570657853,false]</script>
12
- <script>window.__NUXT__={};window.__NUXT__.config={public:{},app:{baseURL:"/__nuxt-i18n-micro",buildId:"97407185-9c30-415a-a770-7c7fbf00a393",buildAssetsDir:"/_nuxt/",cdnURL:""}}</script></body></html>
10
+ <link rel="prefetch" as="script" crossorigin href="/__nuxt-i18n-micro/_nuxt/BARbCa2g.js">
11
+ <script type="module" src="/__nuxt-i18n-micro/_nuxt/CTiMIQCz.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},1732182364040,false]</script>
12
+ <script>window.__NUXT__={};window.__NUXT__.config={public:{},app:{baseURL:"/__nuxt-i18n-micro",buildId:"8d5393e1-c8f1-4429-89a7-5f4d8a44ada2",buildAssetsDir:"/_nuxt/",cdnURL:""}}</script></body></html>
package/dist/module.d.mts CHANGED
@@ -12,8 +12,9 @@ interface Locale {
12
12
  baseUrl?: string;
13
13
  baseDefault?: boolean;
14
14
  }
15
+ type Params = Record<string, string | number | boolean>;
15
16
  type Getter = (key: string, params?: Record<string, string | number | boolean>, defaultValue?: string) => unknown;
16
- type PluralFunc = (key: string, count: number, locale: string, getter: Getter) => string | null;
17
+ type PluralFunc = (key: string, count: number, params: Params, locale: string, getter: Getter) => string | null;
17
18
  type GlobalLocaleRoutes = Record<string, Record<LocaleCode, string> | false | boolean> | null | undefined;
18
19
  interface ModuleOptions {
19
20
  locales?: Locale[];
package/dist/module.d.ts CHANGED
@@ -12,8 +12,9 @@ interface Locale {
12
12
  baseUrl?: string;
13
13
  baseDefault?: boolean;
14
14
  }
15
+ type Params = Record<string, string | number | boolean>;
15
16
  type Getter = (key: string, params?: Record<string, string | number | boolean>, defaultValue?: string) => unknown;
16
- type PluralFunc = (key: string, count: number, locale: string, getter: Getter) => string | null;
17
+ type PluralFunc = (key: string, count: number, params: Params, locale: string, getter: Getter) => string | null;
17
18
  type GlobalLocaleRoutes = Record<string, Record<LocaleCode, string> | false | boolean> | null | undefined;
18
19
  interface ModuleOptions {
19
20
  locales?: Locale[];
package/dist/module.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "nuxt-i18n-micro",
3
3
  "configKey": "i18n",
4
- "version": "1.32.3",
4
+ "version": "1.33.0",
5
5
  "builder": {
6
6
  "@nuxt/module-builder": "0.8.4",
7
7
  "unbuild": "2.0.0"
package/dist/module.mjs CHANGED
@@ -421,8 +421,8 @@ const module = defineNuxtModule({
421
421
  apiBaseUrl: "_locales",
422
422
  routesLocaleLinks: {},
423
423
  globalLocaleRoutes: {},
424
- plural: (key, count, _locale, getTranslation) => {
425
- const translation = getTranslation(key, {});
424
+ plural: (key, count, params, _locale, getTranslation) => {
425
+ const translation = getTranslation(key, params);
426
426
  if (!translation) {
427
427
  return null;
428
428
  }
@@ -39,17 +39,19 @@ export default defineComponent({
39
39
  setup(props, { slots, attrs }) {
40
40
  return () => {
41
41
  const options = {};
42
- const { $getLocale, $t, $tc } = useNuxtApp().$i18n;
42
+ const { $getLocale, $t, $tc } = useNuxtApp();
43
43
  if (props.plural !== void 0) {
44
+ const count = Number.parseInt(props.plural.toString());
44
45
  if (props.customPluralRule) {
45
46
  return h(props.tag, { ...attrs, innerHTML: props.customPluralRule(
46
47
  props.keypath,
47
- Number.parseInt(props.plural.toString()),
48
+ count,
49
+ props.params,
48
50
  $getLocale(),
49
51
  $t
50
52
  ) });
51
53
  } else {
52
- return h(props.tag, { ...attrs, innerHTML: $tc(props.keypath, Number.parseInt(props.plural.toString())) });
54
+ return h(props.tag, { ...attrs, innerHTML: $tc(props.keypath, { count, ...props.params }) });
53
55
  }
54
56
  }
55
57
  const translation = ($t(props.keypath, { ...props.params, ...options }) ?? "").toString();
@@ -1,5 +1,5 @@
1
1
  import type { RouteLocationNormalizedLoaded, RouteLocationRaw, RouteLocationResolved, RouteLocationResolvedGeneric } from 'vue-router';
2
- import type { Locale, I18nRouteParams } from '../../types.js';
2
+ import type { Locale, I18nRouteParams, Params } from '../../types.js';
3
3
  interface PluralTranslations {
4
4
  singular: string;
5
5
  plural: string;
@@ -8,7 +8,6 @@ type Translation = string | number | boolean | Translations | PluralTranslations
8
8
  export interface Translations {
9
9
  [key: string]: Translation;
10
10
  }
11
- type Params = Record<string, string | number | boolean>;
12
11
  declare const _default: import("#app").Plugin<{
13
12
  i18n: undefined;
14
13
  __micro: boolean;
@@ -19,7 +18,7 @@ declare const _default: import("#app").Plugin<{
19
18
  getRouteName: (route?: RouteLocationNormalizedLoaded | RouteLocationResolvedGeneric, locale?: string) => string;
20
19
  t: (key: string, params?: Params, defaultValue?: string) => Translation;
21
20
  ts: (key: string, params?: Params, defaultValue?: string) => string;
22
- tc: (key: string, count: number, defaultValue?: string) => string;
21
+ tc: (key: string, params: number | Params, defaultValue?: string) => string;
23
22
  tn: (value: number, options?: Intl.NumberFormatOptions) => string;
24
23
  td: (value: Date | number | string, options?: Intl.DateTimeFormatOptions) => string;
25
24
  has: (key: string) => boolean;
@@ -41,7 +40,7 @@ declare const _default: import("#app").Plugin<{
41
40
  getRouteName: (route?: RouteLocationNormalizedLoaded | RouteLocationResolvedGeneric, locale?: string) => string;
42
41
  t: (key: string, params?: Params, defaultValue?: string) => Translation;
43
42
  ts: (key: string, params?: Params, defaultValue?: string) => string;
44
- tc: (key: string, count: number, defaultValue?: string) => string;
43
+ tc: (key: string, params: number | Params, defaultValue?: string) => string;
45
44
  tn: (value: number, options?: Intl.NumberFormatOptions) => string;
46
45
  td: (value: Date | number | string, options?: Intl.DateTimeFormatOptions) => string;
47
46
  has: (key: string) => boolean;
@@ -63,7 +62,7 @@ export interface PluginsInjections {
63
62
  $getRouteName: (route?: RouteLocationNormalizedLoaded | RouteLocationResolvedGeneric, locale?: string) => string;
64
63
  $t: (key: string, params?: Params, defaultValue?: string) => Translation;
65
64
  $ts: (key: string, params?: Params, defaultValue?: string) => string;
66
- $tc: (key: string, count: number, defaultValue?: string) => string;
65
+ $tc: (key: string, params: number | Params, defaultValue?: string) => string;
67
66
  $tn: (value: number, options?: Intl.NumberFormatOptions) => string;
68
67
  $td: (value: Date | number | string, options?: Intl.DateTimeFormatOptions) => string;
69
68
  $has: (key: string) => boolean;
@@ -1,6 +1,6 @@
1
1
  import { useTranslationHelper } from "../translationHelper.js";
2
2
  import { defineNuxtPlugin, useRuntimeConfig } from "#app";
3
- import { useRoute, useRouter, useCookie, useState, navigateTo } from "#imports";
3
+ import { useRouter, useCookie, useState, navigateTo } from "#imports";
4
4
  import { plural } from "#build/i18n.plural.mjs";
5
5
  const i18nHelper = useTranslationHelper();
6
6
  const isDev = process.env.NODE_ENV !== "production";
@@ -204,8 +204,8 @@ export default defineNuxtPlugin(async (nuxtApp) => {
204
204
  console.warn(`[nuxt-i18n-next] The page name is missing in the path: ${path}. Please ensure that definePageMeta({ name: 'pageName' }) is set.`);
205
205
  return;
206
206
  }
207
- const route2 = `/${apiBaseUrl}/${fRouteName}/${locale}/data.json?v=${i18nConfig.dateBuild}`.replace(/\/{2,}/g, "/");
208
- const data = await $fetch(route2, { baseURL: runtimeConfig.app.baseURL });
207
+ const route = `/${apiBaseUrl}/${fRouteName}/${locale}/data.json?v=${i18nConfig.dateBuild}`.replace(/\/{2,}/g, "/");
208
+ const data = await $fetch(route, { baseURL: runtimeConfig.app.baseURL });
209
209
  await i18nHelper.loadPageTranslations(locale, routeName, data ?? {});
210
210
  }
211
211
  } catch (_error) {
@@ -227,7 +227,8 @@ export default defineNuxtPlugin(async (nuxtApp) => {
227
227
  i18nHelper.mergeTranslation(selectedLocale ?? locale, routeName, translations, true);
228
228
  }, locale);
229
229
  }
230
- useRouter().beforeEach(async (to, from, next) => {
230
+ const router = useRouter();
231
+ router.beforeEach(async (to, from, next) => {
231
232
  if (to.path !== from.path) {
232
233
  await loadTranslationsForRoute(to);
233
234
  }
@@ -235,14 +236,13 @@ export default defineNuxtPlugin(async (nuxtApp) => {
235
236
  next();
236
237
  }
237
238
  });
238
- const route = useRoute();
239
- await loadTranslationsForRoute(route);
239
+ await loadTranslationsForRoute(router.currentRoute.value);
240
240
  const getTranslation = (key, params, defaultValue) => {
241
241
  if (!key) return "";
242
- const route2 = useRoute();
242
+ const route = router.currentRoute.value;
243
243
  const hashLocale2 = i18nConfig.hashMode ? (useCookie("hash-locale").value ?? i18nConfig.defaultLocale).toString() : null;
244
- const locale = getCurrentLocale(route2, i18nConfig, hashLocale2);
245
- const routeName = getRouteName(route2, locale);
244
+ const locale = getCurrentLocale(route, i18nConfig, hashLocale2);
245
+ const routeName = getRouteName(route, locale);
246
246
  let value = i18nHelper.getTranslation(locale, routeName, key);
247
247
  if (!value) {
248
248
  if (isDev && import.meta.client) {
@@ -263,13 +263,13 @@ export default defineNuxtPlugin(async (nuxtApp) => {
263
263
  const provideData = {
264
264
  i18n: void 0,
265
265
  __micro: true,
266
- getLocale: () => getCurrentLocale(useRoute(), i18nConfig, hashLocale),
267
- getLocaleName: () => getCurrentName(useRoute(), i18nConfig, hashLocale),
266
+ getLocale: () => getCurrentLocale(router.currentRoute.value, i18nConfig, hashLocale),
267
+ getLocaleName: () => getCurrentName(router.currentRoute.value, i18nConfig, hashLocale),
268
268
  defaultLocale: () => i18nConfig.defaultLocale,
269
269
  getLocales: () => i18nConfig.locales || [],
270
- getRouteName: (route2, locale) => {
271
- const selectedLocale = locale ?? getCurrentLocale(useRoute(), i18nConfig, hashLocale);
272
- const selectedRoute = route2 ?? useRoute();
270
+ getRouteName: (route, locale) => {
271
+ const selectedLocale = locale ?? getCurrentLocale(router.currentRoute.value, i18nConfig, hashLocale);
272
+ const selectedRoute = route ?? router.currentRoute.value;
273
273
  return getRouteName(selectedRoute, selectedLocale);
274
274
  },
275
275
  t: getTranslation,
@@ -277,47 +277,46 @@ export default defineNuxtPlugin(async (nuxtApp) => {
277
277
  const value = getTranslation(key, params, defaultValue);
278
278
  return value?.toString() ?? defaultValue ?? key;
279
279
  },
280
- tc: (key, count, defaultValue) => {
281
- const route2 = useRoute();
282
- const currentLocale = getCurrentLocale(route2, i18nConfig, hashLocale);
283
- return plural(key, count, currentLocale, getTranslation) ?? defaultValue ?? key;
280
+ tc: (key, params, defaultValue) => {
281
+ const route = router.currentRoute.value;
282
+ const currentLocale = getCurrentLocale(route, i18nConfig, hashLocale);
283
+ const { count, ..._params } = typeof params === "number" ? { count: params } : params;
284
+ return plural(key, Number.parseInt(count.toString()), _params, currentLocale, getTranslation) ?? defaultValue ?? key;
284
285
  },
285
286
  tn: (value, options) => {
286
- const route2 = useRoute();
287
- const locale = getCurrentLocale(route2, i18nConfig, hashLocale);
287
+ const route = router.currentRoute.value;
288
+ const locale = getCurrentLocale(route, i18nConfig, hashLocale);
288
289
  return formatNumber(value, locale, options);
289
290
  },
290
291
  td: (value, options) => {
291
- const route2 = useRoute();
292
- const locale = getCurrentLocale(route2, i18nConfig, hashLocale);
292
+ const route = router.currentRoute.value;
293
+ const locale = getCurrentLocale(route, i18nConfig, hashLocale);
293
294
  return formatDate(value, locale, options);
294
295
  },
295
296
  has: (key) => {
296
297
  return !!getTranslation(key);
297
298
  },
298
299
  mergeTranslations: (newTranslations) => {
299
- const route2 = useRoute();
300
- const locale = getCurrentLocale(route2, i18nConfig, hashLocale);
301
- const routeName = getRouteName(route2, locale);
300
+ const route = router.currentRoute.value;
301
+ const locale = getCurrentLocale(route, i18nConfig, hashLocale);
302
+ const routeName = getRouteName(route, locale);
302
303
  i18nHelper.mergeTranslation(locale, routeName, newTranslations);
303
304
  },
304
305
  switchLocaleRoute: (toLocale) => {
305
- const router = useRouter();
306
- const route2 = useRoute();
307
- const fromLocale = getCurrentLocale(route2, i18nConfig, hashLocale);
306
+ const route = router.currentRoute.value;
307
+ const fromLocale = getCurrentLocale(route, i18nConfig, hashLocale);
308
308
  if (i18nConfig.hashMode) {
309
309
  hashLocale = toLocale;
310
310
  }
311
- return switchLocaleRoute(fromLocale, toLocale, route2, router, i18nConfig, i18nRouteParams.value);
311
+ return switchLocaleRoute(fromLocale, toLocale, route, router, i18nConfig, i18nRouteParams.value);
312
312
  },
313
313
  switchLocalePath: (toLocale) => {
314
- const router = useRouter();
315
- const route2 = useRoute();
316
- const fromLocale = getCurrentLocale(route2, i18nConfig, hashLocale);
314
+ const route = router.currentRoute.value;
315
+ const fromLocale = getCurrentLocale(route, i18nConfig, hashLocale);
317
316
  if (i18nConfig.hashMode) {
318
317
  hashLocale = toLocale;
319
318
  }
320
- const localeRoute = switchLocaleRoute(fromLocale, toLocale, route2, router, i18nConfig, i18nRouteParams.value);
319
+ const localeRoute = switchLocaleRoute(fromLocale, toLocale, route, router, i18nConfig, i18nRouteParams.value);
321
320
  if (typeof localeRoute === "string") {
322
321
  return localeRoute;
323
322
  }
@@ -327,34 +326,30 @@ export default defineNuxtPlugin(async (nuxtApp) => {
327
326
  return "";
328
327
  },
329
328
  switchLocale: (toLocale) => {
330
- const router = useRouter();
331
- const route2 = useRoute();
332
- const fromLocale = getCurrentLocale(route2, i18nConfig, hashLocale);
329
+ const route = router.currentRoute.value;
330
+ const fromLocale = getCurrentLocale(route, i18nConfig, hashLocale);
333
331
  if (i18nConfig.hashMode) {
334
332
  hashLocale = toLocale;
335
333
  }
336
- switchLocale(fromLocale, toLocale, route2, router, i18nConfig, i18nRouteParams.value);
334
+ switchLocale(fromLocale, toLocale, route, router, i18nConfig, i18nRouteParams.value);
337
335
  },
338
- switchRoute: (route2, toLocale) => {
339
- const router = useRouter();
340
- if (typeof route2 === "string") {
341
- route2 = router.resolve(route2);
336
+ switchRoute: (route, toLocale) => {
337
+ if (typeof route === "string") {
338
+ route = router.resolve(route);
342
339
  }
343
- const fromLocale = getCurrentLocale(route2, i18nConfig, hashLocale);
340
+ const fromLocale = getCurrentLocale(route, i18nConfig, hashLocale);
344
341
  if (i18nConfig.hashMode) {
345
342
  hashLocale = toLocale ?? fromLocale;
346
343
  }
347
- switchLocale(fromLocale, toLocale ?? fromLocale, route2, router, i18nConfig, i18nRouteParams.value);
344
+ switchLocale(fromLocale, toLocale ?? fromLocale, route, router, i18nConfig, i18nRouteParams.value);
348
345
  },
349
346
  localeRoute: (to, locale) => {
350
- const router = useRouter();
351
- const route2 = useRoute();
352
- return getLocalizedRoute(to, router, route2, i18nConfig, locale, hashLocale);
347
+ const route = router.currentRoute.value;
348
+ return getLocalizedRoute(to, router, route, i18nConfig, locale, hashLocale);
353
349
  },
354
350
  localePath: (to, locale) => {
355
- const router = useRouter();
356
- const route2 = useRoute();
357
- const localeRoute = getLocalizedRoute(to, router, route2, i18nConfig, locale, hashLocale);
351
+ const route = router.currentRoute.value;
352
+ const localeRoute = getLocalizedRoute(to, router, route, i18nConfig, locale, hashLocale);
358
353
  if (typeof localeRoute === "string") {
359
354
  return localeRoute;
360
355
  }
package/internals.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  declare module '#build/i18n.plural.mjs' {
2
- export function plural(key: string, count: number, locale: string, getter: Getter): string | null
2
+ export function plural(key: string, count: number, params: Params, locale: string, getter: Getter): string | null
3
3
  }
4
4
 
5
5
  declare module '#internal/i18n/options.mjs' {
6
- export function plural(key: string, count: number, locale: string, getter: Getter): string | null
6
+ export function plural(key: string, count: number, params: Params, locale: string, getter: Getter): string | null
7
7
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nuxt-i18n-micro",
3
- "version": "1.32.3",
3
+ "version": "1.33.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",
@@ -48,7 +48,7 @@
48
48
  "release": "npm run lint && npm run typecheck && npm run test && npm run prepack && changelogen --release && npm publish && git push --follow-tags",
49
49
  "lint": "eslint .",
50
50
  "lint:fix": "eslint . --fix",
51
- "test": "playwright test --grep-invert \"test/performance\\.test\\.ts\"",
51
+ "test": "playwright test",
52
52
  "test:watch": "vitest watch",
53
53
  "test:types": "vue-tsc --noEmit && cd playground && vue-tsc --noEmit",
54
54
  "client:build": "nuxi generate client",
@@ -1 +0,0 @@
1
- {"id":"97407185-9c30-415a-a770-7c7fbf00a393","timestamp":1731570644540,"matcher":{"static":{},"wildcard":{},"dynamic":{}},"prerendered":[]}