nuxt-intlayer 8.4.3 → 8.4.5

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,2 +1,8 @@
1
- import{module as e}from"./module.mjs";var t=e;export{t as default};
1
+ import { module } from "./module.mjs";
2
+
3
+ //#region src/index.ts
4
+ var src_default = module;
5
+
6
+ //#endregion
7
+ export { src_default as default };
2
8
  //# sourceMappingURL=index.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","names":[],"sources":["../../src/index.ts"],"sourcesContent":["import { module } from './module';\n\nexport default module;\n"],"mappings":"sCAEA,IAAA,EAAe"}
1
+ {"version":3,"file":"index.mjs","names":[],"sources":["../../src/index.ts"],"sourcesContent":["import { module } from './module';\n\nexport default module;\n"],"mappings":";;;AAEA,kBAAe"}
@@ -1,2 +1,80 @@
1
- import{getConfiguration as e}from"@intlayer/config/node";import{getPrefix as t}from"@intlayer/core/localization";import{addPlugin as n,createResolver as r,defineNuxtModule as i}from"@nuxt/kit";import{intlayer as a,intlayerProxy as o}from"vite-intlayer";const s=i({meta:{name:`nuxt-intlayer`},setup(i,s){let c=e();s.options.typescript=s.options.typescript||{},s.options.typescript.tsConfig=s.options.typescript.tsConfig||{},s.options.typescript.tsConfig.include=s.options.typescript.tsConfig.include||[],s.options.typescript.tsConfig.include.includes(`../.intlayer/types/**/*.ts`)||s.options.typescript.tsConfig.include.push(`../.intlayer/types/**/*.ts`);let l=r(import.meta.url);n({src:l.resolve(`./runtime/intlayer-plugin`),mode:`all`}),n({src:l.resolve(`./runtime/html-lang`),mode:`all`}),s.hook(`vite:extendConfig`,(e,{isServer:t})=>{t&&(e.plugins??[]).push(o()),e.plugins?.push(a())}),s.hook(`pages:extend`,e=>{let{internationalization:{locales:n,defaultLocale:r},routing:{mode:i}}=c,a=n.filter(e=>{let{localePrefix:n}=t(e,{mode:i,defaultLocale:r});return n!==void 0}).map(String).join(`|`);if(!a)return;let o=[...e];for(let t of o){if(t.path.startsWith(`/:locale`))continue;let n=`/:locale(${a})`,r=t.path===`/`?`${n}`:`${n}${t.path}`;e.push({...t,path:r,name:t.name?`${t.name}___i18n`:void 0})}})}});export{s as module};
1
+ import { getConfiguration } from "@intlayer/config/node";
2
+ import { getPrefix } from "@intlayer/core/localization";
3
+ import { addPlugin, createResolver, defineNuxtModule } from "@nuxt/kit";
4
+ import { intlayer, intlayerProxy } from "vite-intlayer";
5
+
6
+ //#region src/module.ts
7
+ /**
8
+ * Nuxt module that integrates Intlayer into Nuxt applications.
9
+ *
10
+ * It handles:
11
+ * 1. Configuring TypeScript to include Intlayer's generated types.
12
+ * 2. Registering runtime plugins for Vue Intlayer and HTML lang management.
13
+ * 3. Extending Vite configuration with Intlayer and Intlayer Proxy plugins.
14
+ * 4. Extending Nuxt pages to support locale-aware routing based on the configuration.
15
+ *
16
+ * @example
17
+ * ```ts
18
+ * // nuxt.config.ts
19
+ * export default defineNuxtConfig({
20
+ * modules: ['nuxt-intlayer'],
21
+ * });
22
+ * ```
23
+ */
24
+ const module = defineNuxtModule({
25
+ meta: { name: "nuxt-intlayer" },
26
+ setup(_options, nuxt) {
27
+ const configuration = getConfiguration();
28
+ nuxt.options.typescript = nuxt.options.typescript || {};
29
+ nuxt.options.typescript.tsConfig = nuxt.options.typescript.tsConfig || {};
30
+ nuxt.options.typescript.tsConfig.include = nuxt.options.typescript.tsConfig.include || [];
31
+ if (!nuxt.options.typescript.tsConfig.include.includes("../.intlayer/types/**/*.ts")) nuxt.options.typescript.tsConfig.include.push("../.intlayer/types/**/*.ts");
32
+ /**
33
+ * -------------------------------------------------
34
+ * RUNTIME PLUGIN REGISTRATION
35
+ * -------------------------------------------------
36
+ * Automatically install `vue-intlayer` on the client
37
+ * so developers don't need to add the plugin manually
38
+ * in every Nuxt project.
39
+ */
40
+ const resolver = createResolver(import.meta.url);
41
+ addPlugin({
42
+ src: resolver.resolve("./runtime/intlayer-plugin"),
43
+ mode: "all"
44
+ });
45
+ addPlugin({
46
+ src: resolver.resolve("./runtime/html-lang"),
47
+ mode: "all"
48
+ });
49
+ nuxt.hook("vite:extendConfig", (viteConfig, { isServer }) => {
50
+ if (isServer) (viteConfig.plugins ?? []).push(intlayerProxy());
51
+ viteConfig.plugins?.push(intlayer());
52
+ });
53
+ nuxt.hook("pages:extend", (pages) => {
54
+ const { internationalization: { locales, defaultLocale }, routing: { mode } } = configuration;
55
+ const localeGroupRegex = locales.filter((locale) => {
56
+ const { localePrefix } = getPrefix(locale, {
57
+ mode,
58
+ defaultLocale
59
+ });
60
+ return localePrefix !== void 0;
61
+ }).map(String).join("|");
62
+ if (!localeGroupRegex) return;
63
+ const originalPages = [...pages];
64
+ for (const page of originalPages) {
65
+ if (page.path.startsWith("/:locale")) continue;
66
+ const dynPathPrefix = `/:locale(${localeGroupRegex})`;
67
+ const prefixedPath = page.path === "/" ? `${dynPathPrefix}` : `${dynPathPrefix}${page.path}`;
68
+ pages.push({
69
+ ...page,
70
+ path: prefixedPath,
71
+ name: page.name ? `${page.name}___i18n` : void 0
72
+ });
73
+ }
74
+ });
75
+ }
76
+ });
77
+
78
+ //#endregion
79
+ export { module };
2
80
  //# sourceMappingURL=module.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"module.mjs","names":[],"sources":["../../src/module.ts"],"sourcesContent":["import { getConfiguration } from '@intlayer/config/node';\nimport { getPrefix } from '@intlayer/core/localization';\nimport { addPlugin, createResolver, defineNuxtModule } from '@nuxt/kit';\nimport type { NuxtModule } from '@nuxt/schema';\nimport { intlayer, intlayerProxy } from 'vite-intlayer';\n\n/**\n * Nuxt module that integrates Intlayer into Nuxt applications.\n *\n * It handles:\n * 1. Configuring TypeScript to include Intlayer's generated types.\n * 2. Registering runtime plugins for Vue Intlayer and HTML lang management.\n * 3. Extending Vite configuration with Intlayer and Intlayer Proxy plugins.\n * 4. Extending Nuxt pages to support locale-aware routing based on the configuration.\n *\n * @example\n * ```ts\n * // nuxt.config.ts\n * export default defineNuxtConfig({\n * modules: ['nuxt-intlayer'],\n * });\n * ```\n */\nexport const module: NuxtModule = defineNuxtModule({\n meta: {\n name: 'nuxt-intlayer',\n },\n setup(_options, nuxt) {\n const configuration = getConfiguration();\n\n nuxt.options.typescript = nuxt.options.typescript || {};\n nuxt.options.typescript.tsConfig = nuxt.options.typescript.tsConfig || {};\n nuxt.options.typescript.tsConfig.include =\n nuxt.options.typescript.tsConfig.include || [];\n\n if (\n !nuxt.options.typescript.tsConfig.include.includes(\n '../.intlayer/types/**/*.ts'\n )\n ) {\n nuxt.options.typescript.tsConfig.include.push(\n '../.intlayer/types/**/*.ts'\n );\n }\n\n /**\n * -------------------------------------------------\n * RUNTIME PLUGIN REGISTRATION\n * -------------------------------------------------\n * Automatically install `vue-intlayer` on the client\n * so developers don't need to add the plugin manually\n * in every Nuxt project.\n */\n const resolver = createResolver(import.meta.url);\n\n addPlugin({\n src: resolver.resolve('./runtime/intlayer-plugin'),\n mode: 'all',\n });\n\n addPlugin({\n src: resolver.resolve('./runtime/html-lang'),\n mode: 'all',\n });\n\n // // Inject the intlayer middleware plugin into Nuxt's Vite config\n nuxt.hook('vite:extendConfig', (viteConfig, { isServer }) => {\n if (isServer) {\n // We only need the middleware on the server side during development\n // viteConfig.plugins can be undefined at this stage\n (viteConfig.plugins ?? []).push(intlayerProxy());\n }\n\n viteConfig.plugins?.push(intlayer());\n });\n\n // After setting up aliases, extend Nuxt pages with locale-aware routes\n nuxt.hook('pages:extend', (pages) => {\n const {\n internationalization: { locales, defaultLocale },\n routing: { mode },\n } = configuration;\n\n // Build a RegExp string with supported locales (e.g. \"en|fr|de\") to ensure the param only accepts known locales\n const filteredLocales = locales.filter((locale) => {\n const { localePrefix } = getPrefix(locale, {\n mode,\n defaultLocale,\n });\n return localePrefix !== undefined;\n });\n const localeGroupRegex = filteredLocales.map(String).join('|');\n\n // If no locales remain to prefix (e.g., only default locale and prefixDefault is false) skip extension\n if (!localeGroupRegex) return;\n\n // Clone the original page list to avoid infinite loops when pushing\n const originalPages = [...pages];\n\n for (const page of originalPages) {\n // Skip already localised routes (prevent double processing)\n if (page.path.startsWith('/:locale')) continue;\n\n // Determine the paths we need to add depending on prefixDefault flag\n // We always add the dynamic \":locale\" prefixed variant so that `/fr/about` works\n const dynPathPrefix = `/:locale(${localeGroupRegex})`;\n const isIndex = page.path === '/';\n const prefixedPath = isIndex\n ? `${dynPathPrefix}`\n : `${dynPathPrefix}${page.path}`;\n\n // If prefixDefault is false and this is the default locale, we keep the original\n // route (already in pages) and add the dynamic variant which will match non default\n // locales. When prefixDefault is true, we still keep the original route for SSR\n // convenience (middleware will redirect anyway) but also expose locale variants.\n\n // Create a shallow copy of the page with the new path\n pages.push({\n ...page,\n path: prefixedPath,\n name: page.name ? `${page.name}___i18n` : undefined,\n });\n }\n });\n },\n});\n"],"mappings":"6PAuBA,MAAa,EAAqB,EAAiB,CACjD,KAAM,CACJ,KAAM,gBACP,CACD,MAAM,EAAU,EAAM,CACpB,IAAM,EAAgB,GAAkB,CAExC,EAAK,QAAQ,WAAa,EAAK,QAAQ,YAAc,EAAE,CACvD,EAAK,QAAQ,WAAW,SAAW,EAAK,QAAQ,WAAW,UAAY,EAAE,CACzE,EAAK,QAAQ,WAAW,SAAS,QAC/B,EAAK,QAAQ,WAAW,SAAS,SAAW,EAAE,CAG7C,EAAK,QAAQ,WAAW,SAAS,QAAQ,SACxC,6BACD,EAED,EAAK,QAAQ,WAAW,SAAS,QAAQ,KACvC,6BACD,CAWH,IAAM,EAAW,EAAe,OAAO,KAAK,IAAI,CAEhD,EAAU,CACR,IAAK,EAAS,QAAQ,4BAA4B,CAClD,KAAM,MACP,CAAC,CAEF,EAAU,CACR,IAAK,EAAS,QAAQ,sBAAsB,CAC5C,KAAM,MACP,CAAC,CAGF,EAAK,KAAK,qBAAsB,EAAY,CAAE,cAAe,CACvD,IAGD,EAAW,SAAW,EAAE,EAAE,KAAK,GAAe,CAAC,CAGlD,EAAW,SAAS,KAAK,GAAU,CAAC,EACpC,CAGF,EAAK,KAAK,eAAiB,GAAU,CACnC,GAAM,CACJ,qBAAsB,CAAE,UAAS,iBACjC,QAAS,CAAE,SACT,EAUE,EAPkB,EAAQ,OAAQ,GAAW,CACjD,GAAM,CAAE,gBAAiB,EAAU,EAAQ,CACzC,OACA,gBACD,CAAC,CACF,OAAO,IAAiB,IAAA,IACxB,CACuC,IAAI,OAAO,CAAC,KAAK,IAAI,CAG9D,GAAI,CAAC,EAAkB,OAGvB,IAAM,EAAgB,CAAC,GAAG,EAAM,CAEhC,IAAK,IAAM,KAAQ,EAAe,CAEhC,GAAI,EAAK,KAAK,WAAW,WAAW,CAAE,SAItC,IAAM,EAAgB,YAAY,EAAiB,GAE7C,EADU,EAAK,OAAS,IAE1B,GAAG,IACH,GAAG,IAAgB,EAAK,OAQ5B,EAAM,KAAK,CACT,GAAG,EACH,KAAM,EACN,KAAM,EAAK,KAAO,GAAG,EAAK,KAAK,SAAW,IAAA,GAC3C,CAAC,GAEJ,EAEL,CAAC"}
1
+ {"version":3,"file":"module.mjs","names":[],"sources":["../../src/module.ts"],"sourcesContent":["import { getConfiguration } from '@intlayer/config/node';\nimport { getPrefix } from '@intlayer/core/localization';\nimport { addPlugin, createResolver, defineNuxtModule } from '@nuxt/kit';\nimport type { NuxtModule } from '@nuxt/schema';\nimport { intlayer, intlayerProxy } from 'vite-intlayer';\n\n/**\n * Nuxt module that integrates Intlayer into Nuxt applications.\n *\n * It handles:\n * 1. Configuring TypeScript to include Intlayer's generated types.\n * 2. Registering runtime plugins for Vue Intlayer and HTML lang management.\n * 3. Extending Vite configuration with Intlayer and Intlayer Proxy plugins.\n * 4. Extending Nuxt pages to support locale-aware routing based on the configuration.\n *\n * @example\n * ```ts\n * // nuxt.config.ts\n * export default defineNuxtConfig({\n * modules: ['nuxt-intlayer'],\n * });\n * ```\n */\nexport const module: NuxtModule = defineNuxtModule({\n meta: {\n name: 'nuxt-intlayer',\n },\n setup(_options, nuxt) {\n const configuration = getConfiguration();\n\n nuxt.options.typescript = nuxt.options.typescript || {};\n nuxt.options.typescript.tsConfig = nuxt.options.typescript.tsConfig || {};\n nuxt.options.typescript.tsConfig.include =\n nuxt.options.typescript.tsConfig.include || [];\n\n if (\n !nuxt.options.typescript.tsConfig.include.includes(\n '../.intlayer/types/**/*.ts'\n )\n ) {\n nuxt.options.typescript.tsConfig.include.push(\n '../.intlayer/types/**/*.ts'\n );\n }\n\n /**\n * -------------------------------------------------\n * RUNTIME PLUGIN REGISTRATION\n * -------------------------------------------------\n * Automatically install `vue-intlayer` on the client\n * so developers don't need to add the plugin manually\n * in every Nuxt project.\n */\n const resolver = createResolver(import.meta.url);\n\n addPlugin({\n src: resolver.resolve('./runtime/intlayer-plugin'),\n mode: 'all',\n });\n\n addPlugin({\n src: resolver.resolve('./runtime/html-lang'),\n mode: 'all',\n });\n\n // // Inject the intlayer middleware plugin into Nuxt's Vite config\n nuxt.hook('vite:extendConfig', (viteConfig, { isServer }) => {\n if (isServer) {\n // We only need the middleware on the server side during development\n // viteConfig.plugins can be undefined at this stage\n (viteConfig.plugins ?? []).push(intlayerProxy());\n }\n\n viteConfig.plugins?.push(intlayer());\n });\n\n // After setting up aliases, extend Nuxt pages with locale-aware routes\n nuxt.hook('pages:extend', (pages) => {\n const {\n internationalization: { locales, defaultLocale },\n routing: { mode },\n } = configuration;\n\n // Build a RegExp string with supported locales (e.g. \"en|fr|de\") to ensure the param only accepts known locales\n const filteredLocales = locales.filter((locale) => {\n const { localePrefix } = getPrefix(locale, {\n mode,\n defaultLocale,\n });\n return localePrefix !== undefined;\n });\n const localeGroupRegex = filteredLocales.map(String).join('|');\n\n // If no locales remain to prefix (e.g., only default locale and prefixDefault is false) skip extension\n if (!localeGroupRegex) return;\n\n // Clone the original page list to avoid infinite loops when pushing\n const originalPages = [...pages];\n\n for (const page of originalPages) {\n // Skip already localised routes (prevent double processing)\n if (page.path.startsWith('/:locale')) continue;\n\n // Determine the paths we need to add depending on prefixDefault flag\n // We always add the dynamic \":locale\" prefixed variant so that `/fr/about` works\n const dynPathPrefix = `/:locale(${localeGroupRegex})`;\n const isIndex = page.path === '/';\n const prefixedPath = isIndex\n ? `${dynPathPrefix}`\n : `${dynPathPrefix}${page.path}`;\n\n // If prefixDefault is false and this is the default locale, we keep the original\n // route (already in pages) and add the dynamic variant which will match non default\n // locales. When prefixDefault is true, we still keep the original route for SSR\n // convenience (middleware will redirect anyway) but also expose locale variants.\n\n // Create a shallow copy of the page with the new path\n pages.push({\n ...page,\n path: prefixedPath,\n name: page.name ? `${page.name}___i18n` : undefined,\n });\n }\n });\n },\n});\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAuBA,MAAa,SAAqB,iBAAiB;CACjD,MAAM,EACJ,MAAM,iBACP;CACD,MAAM,UAAU,MAAM;EACpB,MAAM,gBAAgB,kBAAkB;AAExC,OAAK,QAAQ,aAAa,KAAK,QAAQ,cAAc,EAAE;AACvD,OAAK,QAAQ,WAAW,WAAW,KAAK,QAAQ,WAAW,YAAY,EAAE;AACzE,OAAK,QAAQ,WAAW,SAAS,UAC/B,KAAK,QAAQ,WAAW,SAAS,WAAW,EAAE;AAEhD,MACE,CAAC,KAAK,QAAQ,WAAW,SAAS,QAAQ,SACxC,6BACD,CAED,MAAK,QAAQ,WAAW,SAAS,QAAQ,KACvC,6BACD;;;;;;;;;EAWH,MAAM,WAAW,eAAe,OAAO,KAAK,IAAI;AAEhD,YAAU;GACR,KAAK,SAAS,QAAQ,4BAA4B;GAClD,MAAM;GACP,CAAC;AAEF,YAAU;GACR,KAAK,SAAS,QAAQ,sBAAsB;GAC5C,MAAM;GACP,CAAC;AAGF,OAAK,KAAK,sBAAsB,YAAY,EAAE,eAAe;AAC3D,OAAI,SAGF,EAAC,WAAW,WAAW,EAAE,EAAE,KAAK,eAAe,CAAC;AAGlD,cAAW,SAAS,KAAK,UAAU,CAAC;IACpC;AAGF,OAAK,KAAK,iBAAiB,UAAU;GACnC,MAAM,EACJ,sBAAsB,EAAE,SAAS,iBACjC,SAAS,EAAE,WACT;GAUJ,MAAM,mBAPkB,QAAQ,QAAQ,WAAW;IACjD,MAAM,EAAE,iBAAiB,UAAU,QAAQ;KACzC;KACA;KACD,CAAC;AACF,WAAO,iBAAiB;KACxB,CACuC,IAAI,OAAO,CAAC,KAAK,IAAI;AAG9D,OAAI,CAAC,iBAAkB;GAGvB,MAAM,gBAAgB,CAAC,GAAG,MAAM;AAEhC,QAAK,MAAM,QAAQ,eAAe;AAEhC,QAAI,KAAK,KAAK,WAAW,WAAW,CAAE;IAItC,MAAM,gBAAgB,YAAY,iBAAiB;IAEnD,MAAM,eADU,KAAK,SAAS,MAE1B,GAAG,kBACH,GAAG,gBAAgB,KAAK;AAQ5B,UAAM,KAAK;KACT,GAAG;KACH,MAAM;KACN,MAAM,KAAK,OAAO,GAAG,KAAK,KAAK,WAAW;KAC3C,CAAC;;IAEJ;;CAEL,CAAC"}
@@ -1,2 +1,16 @@
1
- import{getHTMLTextDir as e}from"@intlayer/core/localization";import{defineNuxtPlugin as t}from"#app";import{useRoute as n}from"#imports";var r=t(t=>{t.hook(`page:finish`,()=>{let t=n().params.locale;document.documentElement.lang=t,document.documentElement.dir=e(t)})});export{r as default};
1
+ import { getHTMLTextDir } from "@intlayer/core/localization";
2
+ import { defineNuxtPlugin } from "#app";
3
+ import { useRoute } from "#imports";
4
+
5
+ //#region src/runtime/html-lang.ts
6
+ var html_lang_default = defineNuxtPlugin((nuxtApp) => {
7
+ nuxtApp.hook("page:finish", () => {
8
+ const locale = useRoute().params.locale;
9
+ document.documentElement.lang = locale;
10
+ document.documentElement.dir = getHTMLTextDir(locale);
11
+ });
12
+ });
13
+
14
+ //#endregion
15
+ export { html_lang_default as default };
2
16
  //# sourceMappingURL=html-lang.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"html-lang.mjs","names":[],"sources":["../../../src/runtime/html-lang.ts"],"sourcesContent":["// @ts-nocheck -- Nuxt runtime types are provided at application level\n\nimport { getHTMLTextDir } from '@intlayer/core/localization';\nimport type { Locale } from '@intlayer/types/allLocales';\nimport { defineNuxtPlugin } from '#app';\nimport { useRoute } from '#imports';\n\nexport default defineNuxtPlugin((nuxtApp) => {\n nuxtApp.hook('page:finish', () => {\n const locale = useRoute().params.locale as Locale;\n document.documentElement.lang = locale;\n document.documentElement.dir = getHTMLTextDir(locale);\n });\n});\n"],"mappings":"yIAOA,IAAA,EAAe,EAAkB,GAAY,CAC3C,EAAQ,KAAK,kBAAqB,CAChC,IAAM,EAAS,GAAU,CAAC,OAAO,OACjC,SAAS,gBAAgB,KAAO,EAChC,SAAS,gBAAgB,IAAM,EAAe,EAAO,EACrD,EACF"}
1
+ {"version":3,"file":"html-lang.mjs","names":[],"sources":["../../../src/runtime/html-lang.ts"],"sourcesContent":["// @ts-nocheck -- Nuxt runtime types are provided at application level\n\nimport { getHTMLTextDir } from '@intlayer/core/localization';\nimport type { Locale } from '@intlayer/types/allLocales';\nimport { defineNuxtPlugin } from '#app';\nimport { useRoute } from '#imports';\n\nexport default defineNuxtPlugin((nuxtApp) => {\n nuxtApp.hook('page:finish', () => {\n const locale = useRoute().params.locale as Locale;\n document.documentElement.lang = locale;\n document.documentElement.dir = getHTMLTextDir(locale);\n });\n});\n"],"mappings":";;;;;AAOA,wBAAe,kBAAkB,YAAY;AAC3C,SAAQ,KAAK,qBAAqB;EAChC,MAAM,SAAS,UAAU,CAAC,OAAO;AACjC,WAAS,gBAAgB,OAAO;AAChC,WAAS,gBAAgB,MAAM,eAAe,OAAO;GACrD;EACF"}
@@ -1,2 +1,33 @@
1
- import{defineNuxtPlugin as e}from"#app";import{useRoute as t}from"#imports";import{createIntlayerClient as n,installIntlayer as r}from"vue-intlayer";var i=e(e=>{r(e.vueApp);let{setLocale:i}=n(),a=t(),o=()=>{let e=a.params.locale;e&&i(e)};o(),e.hook(`page:start`,()=>{o()})});export{i as default};
1
+ import { defineNuxtPlugin } from "#app";
2
+ import { useRoute } from "#imports";
3
+ import { createIntlayerClient, installIntlayer } from "vue-intlayer";
4
+
5
+ //#region src/runtime/intlayer-plugin.ts
6
+ /**
7
+ * Nuxt client plugin injected by `nuxt-intlayer` module.
8
+ * It installs the Intlayer Vue composables in the current Nuxt application and keeps
9
+ * the active locale in sync with the current route (e.g. `/fr/about` → `fr`).
10
+ */
11
+ var intlayer_plugin_default = defineNuxtPlugin((nuxtApp) => {
12
+ /**
13
+ * Register the Intlayer provider. We don't pass an explicit locale here so it
14
+ * will fallback to the `defaultLocale` defined in the user configuration.
15
+ * We will synchronise the active locale afterwards, once the current route
16
+ * information is reliably available.
17
+ */
18
+ installIntlayer(nuxtApp.vueApp);
19
+ const { setLocale } = createIntlayerClient();
20
+ const route = useRoute();
21
+ const syncLocale = () => {
22
+ const localeParam = route.params.locale;
23
+ if (localeParam) setLocale(localeParam);
24
+ };
25
+ syncLocale();
26
+ nuxtApp.hook("page:start", () => {
27
+ syncLocale();
28
+ });
29
+ });
30
+
31
+ //#endregion
32
+ export { intlayer_plugin_default as default };
2
33
  //# sourceMappingURL=intlayer-plugin.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"intlayer-plugin.mjs","names":[],"sources":["../../../src/runtime/intlayer-plugin.ts"],"sourcesContent":["// @ts-nocheck -- Nuxt runtime types are provided at application level\n\nimport type { Locale } from '@intlayer/types/allLocales';\nimport { createIntlayerClient, installIntlayer } from 'vue-intlayer';\nimport { defineNuxtPlugin } from '#app';\nimport { useRoute } from '#imports';\n\n/**\n * Nuxt client plugin injected by `nuxt-intlayer` module.\n * It installs the Intlayer Vue composables in the current Nuxt application and keeps\n * the active locale in sync with the current route (e.g. `/fr/about` → `fr`).\n */\nexport default defineNuxtPlugin((nuxtApp) => {\n /**\n * Register the Intlayer provider. We don't pass an explicit locale here so it\n * will fallback to the `defaultLocale` defined in the user configuration.\n * We will synchronise the active locale afterwards, once the current route\n * information is reliably available.\n */\n installIntlayer(nuxtApp.vueApp);\n\n // Obtain a reference to the singleton Intlayer client so we can update the\n // locale reactively whenever the route changes.\n const { setLocale } = createIntlayerClient();\n\n const route = useRoute();\n\n // Helper that applies the `:locale` route param (if any) to Intlayer.\n const syncLocale = () => {\n const localeParam = route.params.locale as Locale | undefined;\n if (localeParam) setLocale(localeParam);\n };\n\n // Initial sync (client & server) once the plugin is executed.\n syncLocale();\n\n // Keep Intlayer locale in sync on every navigation.\n nuxtApp.hook('page:start', () => {\n syncLocale();\n });\n});\n"],"mappings":"qJAYA,IAAA,EAAe,EAAkB,GAAY,CAO3C,EAAgB,EAAQ,OAAO,CAI/B,GAAM,CAAE,aAAc,GAAsB,CAEtC,EAAQ,GAAU,CAGlB,MAAmB,CACvB,IAAM,EAAc,EAAM,OAAO,OAC7B,GAAa,EAAU,EAAY,EAIzC,GAAY,CAGZ,EAAQ,KAAK,iBAAoB,CAC/B,GAAY,EACZ,EACF"}
1
+ {"version":3,"file":"intlayer-plugin.mjs","names":[],"sources":["../../../src/runtime/intlayer-plugin.ts"],"sourcesContent":["// @ts-nocheck -- Nuxt runtime types are provided at application level\n\nimport type { Locale } from '@intlayer/types/allLocales';\nimport { createIntlayerClient, installIntlayer } from 'vue-intlayer';\nimport { defineNuxtPlugin } from '#app';\nimport { useRoute } from '#imports';\n\n/**\n * Nuxt client plugin injected by `nuxt-intlayer` module.\n * It installs the Intlayer Vue composables in the current Nuxt application and keeps\n * the active locale in sync with the current route (e.g. `/fr/about` → `fr`).\n */\nexport default defineNuxtPlugin((nuxtApp) => {\n /**\n * Register the Intlayer provider. We don't pass an explicit locale here so it\n * will fallback to the `defaultLocale` defined in the user configuration.\n * We will synchronise the active locale afterwards, once the current route\n * information is reliably available.\n */\n installIntlayer(nuxtApp.vueApp);\n\n // Obtain a reference to the singleton Intlayer client so we can update the\n // locale reactively whenever the route changes.\n const { setLocale } = createIntlayerClient();\n\n const route = useRoute();\n\n // Helper that applies the `:locale` route param (if any) to Intlayer.\n const syncLocale = () => {\n const localeParam = route.params.locale as Locale | undefined;\n if (localeParam) setLocale(localeParam);\n };\n\n // Initial sync (client & server) once the plugin is executed.\n syncLocale();\n\n // Keep Intlayer locale in sync on every navigation.\n nuxtApp.hook('page:start', () => {\n syncLocale();\n });\n});\n"],"mappings":";;;;;;;;;;AAYA,8BAAe,kBAAkB,YAAY;;;;;;;AAO3C,iBAAgB,QAAQ,OAAO;CAI/B,MAAM,EAAE,cAAc,sBAAsB;CAE5C,MAAM,QAAQ,UAAU;CAGxB,MAAM,mBAAmB;EACvB,MAAM,cAAc,MAAM,OAAO;AACjC,MAAI,YAAa,WAAU,YAAY;;AAIzC,aAAY;AAGZ,SAAQ,KAAK,oBAAoB;AAC/B,cAAY;GACZ;EACF"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nuxt-intlayer",
3
- "version": "8.4.3",
3
+ "version": "8.4.5",
4
4
  "private": false,
5
5
  "description": "Easily internationalize i18n your Nuxt applications with type-safe multilingual content management.",
6
6
  "keywords": [
@@ -77,11 +77,11 @@
77
77
  "typecheck": "tsc --noEmit --project tsconfig.types.json"
78
78
  },
79
79
  "dependencies": {
80
- "@intlayer/config": "8.4.3",
81
- "@intlayer/core": "8.4.3",
82
- "@intlayer/types": "8.4.3",
83
- "vite-intlayer": "8.4.3",
84
- "vue-intlayer": "8.4.3"
80
+ "@intlayer/config": "8.4.5",
81
+ "@intlayer/core": "8.4.5",
82
+ "@intlayer/types": "8.4.5",
83
+ "vite-intlayer": "8.4.5",
84
+ "vue-intlayer": "8.4.5"
85
85
  },
86
86
  "devDependencies": {
87
87
  "@types/node": "25.5.0",