@fluenti/nuxt 0.6.1 → 0.6.3
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/detectors-BBAX-ZGA.cjs +1 -2
- package/dist/detectors-Ds481Wx6.js +0 -2
- package/dist/locale-head-Ezrd93Ax.js +0 -2
- package/dist/locale-head-jGmp0Xnb.cjs +1 -2
- package/dist/module.cjs +1 -2
- package/dist/module.js +0 -2
- package/dist/packages/nuxt/src/devtools.d.ts +0 -1
- package/dist/packages/nuxt/src/isr-validation.d.ts +0 -1
- package/dist/packages/nuxt/src/module.d.ts +0 -1
- package/dist/packages/nuxt/src/page-meta-transform.d.ts +0 -1
- package/dist/packages/nuxt/src/runtime/client.d.ts +0 -1
- package/dist/packages/nuxt/src/runtime/components/NuxtLinkLocale.d.ts +0 -1
- package/dist/packages/nuxt/src/runtime/composables.d.ts +0 -1
- package/dist/packages/nuxt/src/runtime/define-i18n-route.d.ts +0 -1
- package/dist/packages/nuxt/src/runtime/detectors/cookie.d.ts +0 -1
- package/dist/packages/nuxt/src/runtime/detectors/domain.d.ts +0 -1
- package/dist/packages/nuxt/src/runtime/detectors/header.d.ts +0 -1
- package/dist/packages/nuxt/src/runtime/detectors/index.d.ts +0 -1
- package/dist/packages/nuxt/src/runtime/detectors/path.d.ts +0 -1
- package/dist/packages/nuxt/src/runtime/detectors/query.d.ts +0 -1
- package/dist/packages/nuxt/src/runtime/index.d.ts +0 -1
- package/dist/packages/nuxt/src/runtime/locale-head.d.ts +0 -1
- package/dist/packages/nuxt/src/runtime/middleware/locale-redirect.d.ts +0 -1
- package/dist/packages/nuxt/src/runtime/page-extend.d.ts +0 -1
- package/dist/packages/nuxt/src/runtime/path-utils.d.ts +0 -1
- package/dist/packages/nuxt/src/runtime/plugin.d.ts +0 -1
- package/dist/packages/nuxt/src/runtime/server/locale-redirect.d.ts +0 -1
- package/dist/packages/nuxt/src/runtime/standalone-composables.d.ts +0 -1
- package/dist/packages/nuxt/src/runtime/utils/parse-accept-language.d.ts +0 -1
- package/dist/packages/nuxt/src/sitemap.d.ts +0 -1
- package/dist/packages/nuxt/src/types.d.ts +0 -1
- package/dist/page-extend-Bnxtcvnr.js +0 -2
- package/dist/page-extend-DqTELmU6.cjs +1 -2
- package/dist/parse-accept-language-BJacT1Mq.js +0 -2
- package/dist/parse-accept-language-ZKitIm3n.cjs +1 -2
- package/dist/path-utils-BQIsp_or.cjs +1 -2
- package/dist/path-utils-BcvXLCGi.js +0 -2
- package/dist/runtime/client.cjs +1 -2
- package/dist/runtime/client.js +0 -2
- package/dist/runtime/components/NuxtLinkLocale.cjs +1 -2
- package/dist/runtime/components/NuxtLinkLocale.js +0 -2
- package/dist/runtime/composables.cjs +1 -2
- package/dist/runtime/composables.js +0 -2
- package/dist/runtime/define-i18n-route.cjs +1 -2
- package/dist/runtime/define-i18n-route.js +0 -2
- package/dist/runtime/detectors/domain.cjs +1 -2
- package/dist/runtime/detectors/domain.js +0 -2
- package/dist/runtime/middleware/locale-redirect.cjs +1 -2
- package/dist/runtime/middleware/locale-redirect.js +0 -2
- package/dist/runtime/plugin.cjs +1 -2
- package/dist/runtime/plugin.js +0 -2
- package/dist/runtime/server/locale-redirect.cjs +1 -2
- package/dist/runtime/server/locale-redirect.js +0 -2
- package/dist/runtime/standalone-composables.cjs +1 -2
- package/dist/runtime/standalone-composables.js +0 -2
- package/package.json +3 -3
- package/dist/detectors-BBAX-ZGA.cjs.map +0 -1
- package/dist/detectors-Ds481Wx6.js.map +0 -1
- package/dist/locale-head-Ezrd93Ax.js.map +0 -1
- package/dist/locale-head-jGmp0Xnb.cjs.map +0 -1
- package/dist/module.cjs.map +0 -1
- package/dist/module.js.map +0 -1
- package/dist/packages/nuxt/src/devtools.d.ts.map +0 -1
- package/dist/packages/nuxt/src/isr-validation.d.ts.map +0 -1
- package/dist/packages/nuxt/src/module.d.ts.map +0 -1
- package/dist/packages/nuxt/src/page-meta-transform.d.ts.map +0 -1
- package/dist/packages/nuxt/src/runtime/client.d.ts.map +0 -1
- package/dist/packages/nuxt/src/runtime/components/NuxtLinkLocale.d.ts.map +0 -1
- package/dist/packages/nuxt/src/runtime/composables.d.ts.map +0 -1
- package/dist/packages/nuxt/src/runtime/define-i18n-route.d.ts.map +0 -1
- package/dist/packages/nuxt/src/runtime/detectors/cookie.d.ts.map +0 -1
- package/dist/packages/nuxt/src/runtime/detectors/domain.d.ts.map +0 -1
- package/dist/packages/nuxt/src/runtime/detectors/header.d.ts.map +0 -1
- package/dist/packages/nuxt/src/runtime/detectors/index.d.ts.map +0 -1
- package/dist/packages/nuxt/src/runtime/detectors/path.d.ts.map +0 -1
- package/dist/packages/nuxt/src/runtime/detectors/query.d.ts.map +0 -1
- package/dist/packages/nuxt/src/runtime/index.d.ts.map +0 -1
- package/dist/packages/nuxt/src/runtime/locale-head.d.ts.map +0 -1
- package/dist/packages/nuxt/src/runtime/middleware/locale-redirect.d.ts.map +0 -1
- package/dist/packages/nuxt/src/runtime/page-extend.d.ts.map +0 -1
- package/dist/packages/nuxt/src/runtime/path-utils.d.ts.map +0 -1
- package/dist/packages/nuxt/src/runtime/plugin.d.ts.map +0 -1
- package/dist/packages/nuxt/src/runtime/server/locale-redirect.d.ts.map +0 -1
- package/dist/packages/nuxt/src/runtime/standalone-composables.d.ts.map +0 -1
- package/dist/packages/nuxt/src/runtime/utils/parse-accept-language.d.ts.map +0 -1
- package/dist/packages/nuxt/src/sitemap.d.ts.map +0 -1
- package/dist/packages/nuxt/src/types.d.ts.map +0 -1
- package/dist/page-extend-Bnxtcvnr.js.map +0 -1
- package/dist/page-extend-DqTELmU6.cjs.map +0 -1
- package/dist/parse-accept-language-BJacT1Mq.js.map +0 -1
- package/dist/parse-accept-language-ZKitIm3n.cjs.map +0 -1
- package/dist/path-utils-BQIsp_or.cjs.map +0 -1
- package/dist/path-utils-BcvXLCGi.js.map +0 -1
- package/dist/runtime/client.cjs.map +0 -1
- package/dist/runtime/client.js.map +0 -1
- package/dist/runtime/components/NuxtLinkLocale.cjs.map +0 -1
- package/dist/runtime/components/NuxtLinkLocale.js.map +0 -1
- package/dist/runtime/composables.cjs.map +0 -1
- package/dist/runtime/composables.js.map +0 -1
- package/dist/runtime/define-i18n-route.cjs.map +0 -1
- package/dist/runtime/define-i18n-route.js.map +0 -1
- package/dist/runtime/detectors/domain.cjs.map +0 -1
- package/dist/runtime/detectors/domain.js.map +0 -1
- package/dist/runtime/middleware/locale-redirect.cjs.map +0 -1
- package/dist/runtime/middleware/locale-redirect.js.map +0 -1
- package/dist/runtime/plugin.cjs.map +0 -1
- package/dist/runtime/plugin.js.map +0 -1
- package/dist/runtime/server/locale-redirect.cjs.map +0 -1
- package/dist/runtime/server/locale-redirect.js.map +0 -1
- package/dist/runtime/standalone-composables.cjs.map +0 -1
- package/dist/runtime/standalone-composables.js.map +0 -1
|
@@ -1,2 +1 @@
|
|
|
1
|
-
const e=require(`./path-utils-BQIsp_or.cjs`);require(`./module.cjs`);const t=require(`./parse-accept-language-ZKitIm3n.cjs`),n=require(`./runtime/detectors/domain.cjs`);let r=require(`#imports`);function i(t){if(t.strategy===`no_prefix`)return;let{locale:n}=e.t(t.path,t.locales);n&&t.setLocale(n)}function a(e){if(!e.detectBrowserLanguage?.useCookie)return;if(e.cookieValue!==void 0){e.cookieValue&&e.locales.includes(e.cookieValue)&&e.setLocale(e.cookieValue);return}let t=e.detectBrowserLanguage.cookieKey??`fluenti_locale`;try{let n=(0,r.useCookie)(t);n.value&&e.locales.includes(n.value)&&e.setLocale(n.value)}catch{}}function o(e){if(!e.isServer)return;let n=e.acceptLanguage??s();if(n){let r=t.t(n,e.locales);r&&e.setLocale(r)}}function s(){try{return(0,r.useRequestHeaders)([`accept-language`])[`accept-language`]}catch{return}}function c(e){try{let t=(0,r.useRoute)(),n=(0,r.useRuntimeConfig)().public.fluenti.queryParamKey??`locale`,i=t.query[n];i&&e.locales.includes(i)&&e.setLocale(i)}catch{}}var l={path:i,cookie:a,header:o,query:c,domain:n};async function u(e,t,n,r,i,a,o){let s=null,c=!1,u={path:e,locales:t.locales,defaultLocale:t.defaultLocale,strategy:t.strategy,...t.detectBrowserLanguage?{detectBrowserLanguage:t.detectBrowserLanguage}:{},detectedLocale:null,setLocale(e){t.locales.includes(e)&&(s=e,u.detectedLocale=e,c=!0)},isServer:{}.server??!1,...i?{host:i}:{},...a==null?{}:{cookieValue:a},...o?{acceptLanguage:o}:{}};t.domains&&Object.assign(u,{domains:t.domains});for(let e of t.detectOrder){if(c)break;let t=l[e]??n?.get(e);t&&await t(u)}return r&&!c&&await r(u),s??t.detectBrowserLanguage?.fallbackLocale??t.defaultLocale}Object.defineProperty(exports,`t`,{enumerable:!0,get:function(){return u}});
|
|
2
|
-
//# sourceMappingURL=detectors-BBAX-ZGA.cjs.map
|
|
1
|
+
const e=require(`./path-utils-BQIsp_or.cjs`);require(`./module.cjs`);const t=require(`./parse-accept-language-ZKitIm3n.cjs`),n=require(`./runtime/detectors/domain.cjs`);let r=require(`#imports`);function i(t){if(t.strategy===`no_prefix`)return;let{locale:n}=e.t(t.path,t.locales);n&&t.setLocale(n)}function a(e){if(!e.detectBrowserLanguage?.useCookie)return;if(e.cookieValue!==void 0){e.cookieValue&&e.locales.includes(e.cookieValue)&&e.setLocale(e.cookieValue);return}let t=e.detectBrowserLanguage.cookieKey??`fluenti_locale`;try{let n=(0,r.useCookie)(t);n.value&&e.locales.includes(n.value)&&e.setLocale(n.value)}catch{}}function o(e){if(!e.isServer)return;let n=e.acceptLanguage??s();if(n){let r=t.t(n,e.locales);r&&e.setLocale(r)}}function s(){try{return(0,r.useRequestHeaders)([`accept-language`])[`accept-language`]}catch{return}}function c(e){try{let t=(0,r.useRoute)(),n=(0,r.useRuntimeConfig)().public.fluenti.queryParamKey??`locale`,i=t.query[n];i&&e.locales.includes(i)&&e.setLocale(i)}catch{}}var l={path:i,cookie:a,header:o,query:c,domain:n};async function u(e,t,n,r,i,a,o){let s=null,c=!1,u={path:e,locales:t.locales,defaultLocale:t.defaultLocale,strategy:t.strategy,...t.detectBrowserLanguage?{detectBrowserLanguage:t.detectBrowserLanguage}:{},detectedLocale:null,setLocale(e){t.locales.includes(e)&&(s=e,u.detectedLocale=e,c=!0)},isServer:{}.server??!1,...i?{host:i}:{},...a==null?{}:{cookieValue:a},...o?{acceptLanguage:o}:{}};t.domains&&Object.assign(u,{domains:t.domains});for(let e of t.detectOrder){if(c)break;let t=l[e]??n?.get(e);t&&await t(u)}return r&&!c&&await r(u),s??t.detectBrowserLanguage?.fallbackLocale??t.defaultLocale}Object.defineProperty(exports,`t`,{enumerable:!0,get:function(){return u}});
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
const e=require(`./path-utils-BQIsp_or.cjs`);function t(e,t){if(!e)return t;try{let n=new URL(t,e);return n.protocol!==`http:`&&n.protocol!==`https:`?t:n.href}catch{return t}}function n(n,r,i,a){let o=i.localeProperties?.[n],s=o?.iso??n,c={htmlAttrs:{lang:s,...o?.dir?{dir:o.dir}:{}},link:[],meta:[]};if(a?.addSeoAttributes){let o=a.baseUrl??``,l=i.domains?.length?new Map(i.domains.map(e=>[e.locale,e])):null;for(let n of i.locales){let a=i.localeProperties?.[n]?.iso??n;if(i.strategy===`domains`&&l){let e=l?.get(n);if(e){let n=o.startsWith(`https`)?`https`:`http`;c.link.push({rel:`alternate`,hreflang:a,href:t(`${n}://${e.domain}`,r)})}}else{let s=e.r(r,n,i.locales,i.defaultLocale,i.strategy);c.link.push({rel:`alternate`,hreflang:a,href:t(o,s)})}}if(i.strategy===`domains`&&l){let e=l?.get(i.defaultLocale);if(e){let n=o.startsWith(`https`)?`https`:`http`;c.link.push({rel:`alternate`,hreflang:`x-default`,href:t(`${n}://${e.domain}`,r)})}}else{let n=e.r(r,i.defaultLocale,i.locales,i.defaultLocale,i.strategy);c.link.push({rel:`alternate`,hreflang:`x-default`,href:t(o,n)})}if(a.addCanonical!==!1)if(i.strategy===`domains`&&l){let e=l?.get(n);if(e){let n=o.startsWith(`https`)?`https`:`http`;c.link.push({rel:`canonical`,hreflang:``,href:t(`${n}://${e.domain}`,r)})}}else{let a=e.r(r,n,i.locales,i.defaultLocale,i.strategy);c.link.push({rel:`canonical`,hreflang:``,href:t(o,a)})}c.meta.push({property:`og:locale`,content:s});for(let e of i.locales)if(e!==n){let t=i.localeProperties?.[e];c.meta.push({property:`og:locale:alternate`,content:t?.iso??e})}}return c}Object.defineProperty(exports,`t`,{enumerable:!0,get:function(){return n}});
|
|
2
|
-
//# sourceMappingURL=locale-head-jGmp0Xnb.cjs.map
|
|
1
|
+
const e=require(`./path-utils-BQIsp_or.cjs`);function t(e,t){if(!e)return t;try{let n=new URL(t,e);return n.protocol!==`http:`&&n.protocol!==`https:`?t:n.href}catch{return t}}function n(n,r,i,a){let o=i.localeProperties?.[n],s=o?.iso??n,c={htmlAttrs:{lang:s,...o?.dir?{dir:o.dir}:{}},link:[],meta:[]};if(a?.addSeoAttributes){let o=a.baseUrl??``,l=i.domains?.length?new Map(i.domains.map(e=>[e.locale,e])):null;for(let n of i.locales){let a=i.localeProperties?.[n]?.iso??n;if(i.strategy===`domains`&&l){let e=l?.get(n);if(e){let n=o.startsWith(`https`)?`https`:`http`;c.link.push({rel:`alternate`,hreflang:a,href:t(`${n}://${e.domain}`,r)})}}else{let s=e.r(r,n,i.locales,i.defaultLocale,i.strategy);c.link.push({rel:`alternate`,hreflang:a,href:t(o,s)})}}if(i.strategy===`domains`&&l){let e=l?.get(i.defaultLocale);if(e){let n=o.startsWith(`https`)?`https`:`http`;c.link.push({rel:`alternate`,hreflang:`x-default`,href:t(`${n}://${e.domain}`,r)})}}else{let n=e.r(r,i.defaultLocale,i.locales,i.defaultLocale,i.strategy);c.link.push({rel:`alternate`,hreflang:`x-default`,href:t(o,n)})}if(a.addCanonical!==!1)if(i.strategy===`domains`&&l){let e=l?.get(n);if(e){let n=o.startsWith(`https`)?`https`:`http`;c.link.push({rel:`canonical`,hreflang:``,href:t(`${n}://${e.domain}`,r)})}}else{let a=e.r(r,n,i.locales,i.defaultLocale,i.strategy);c.link.push({rel:`canonical`,hreflang:``,href:t(o,a)})}c.meta.push({property:`og:locale`,content:s});for(let e of i.locales)if(e!==n){let t=i.localeProperties?.[e];c.meta.push({property:`og:locale:alternate`,content:t?.iso??e})}}return c}Object.defineProperty(exports,`t`,{enumerable:!0,get:function(){return n}});
|
package/dist/module.cjs
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:`Module`}});var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;l<u;l++)d=c[l],!a.call(e,d)&&d!==o&&t(e,d,{get:(e=>i[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},s=(n,r,a)=>(a=n==null?{}:e(i(n)),o(r||!n||!n.__esModule?t(a,`default`,{value:n,enumerable:!0}):a,n));const c=require(`./page-extend-DqTELmU6.cjs`),l=require(`./path-utils-BQIsp_or.cjs`),u=require(`./locale-head-jGmp0Xnb.cjs`),d=require(`./runtime/standalone-composables.cjs`),f=require(`./runtime/define-i18n-route.cjs`);let p=require(`@nuxt/kit`),m=require(`@fluenti/core/compiler`),h=require(`@fluenti/core/config`),g=require(`@fluenti/vue/vite-plugin`);g=s(g);function _(e){let t={};for(let n of e)typeof n==`string`?t[n]={code:n}:t[n.code]=n;return t}function v(e,t){if(t?.length)return t;let n=[];for(let t of e)typeof t!=`string`&&t.domain&&n.push({domain:t.domain,locale:t.code});return n}function y(e,t,n){let r=[];if(!e?.enabled)return r;let i=n.filter(e=>e===`cookie`||e===`header`);return i.length>0&&r.push({level:`warn`,message:`[@fluenti/nuxt] ISR is enabled but detectOrder includes non-path detectors (${i.join(`, `)}). ISR caches by URL path, so cookie/header-based detection may serve the wrong locale from cache. Consider using detectOrder: ['path'] with ISR.`}),t===`no_prefix`&&r.push({level:`warn`,message:`[@fluenti/nuxt] ISR is enabled with strategy: 'no_prefix'. All locales share the same URL path, so ISR will cache only one locale per URL. Use 'prefix' or 'prefix_except_default' strategy with ISR.`}),r}function b(e,t,n,r){try{e.hook(`devtools:customTabs`,e=>{e.push({name:`fluenti`,title:`Fluenti i18n`,icon:`i-carbon-translate`,view:{type:`client-component`,componentName:`FluentiDevToolsPanel`}})})}catch{}e.hook(`nitro:config`,e=>{let i=e.runtimeConfig;if(i){let e=(i.public??={}).fluenti??{};e.devtools={enabled:!0,locales:t,defaultLocale:n,strategy:r}}})}function x(){return{name:`fluenti:page-meta-transform`,enforce:`pre`,transform(e,t){if(!t.includes(`/pages/`)&&!t.includes(`\\pages\\`)||!e.includes(`defineI18nRoute`)&&!e.includes(`i18n`))return null;let n=e;return n.includes(`defineI18nRoute`)&&(n=n.replace(/defineI18nRoute\s*\(([^)]*?)\)/g,(e,t)=>`definePageMeta({ i18nRoute: ${t.trim()} })`)),n.includes(`definePageMeta`)&&n.includes(`i18n:`)&&(n=n.replace(/(definePageMeta\s*\(\s*\{[^}]*?)\bi18n\s*:/g,`$1i18nRoute:`)),n===e?null:{code:n,map:null}}}}function S(e,t,n,r,i){let a=[],o=i??``;for(let i of e){let e=i.startsWith(`/`)?i:`/${i}`;for(let i of t){let s=C(e,i,n,r),c=t.map(t=>({hreflang:t,href:`${o}${C(e,t,n,r)}`}));c.push({hreflang:`x-default`,href:`${o}${C(e,n,n,r)}`}),a.push({loc:`${o}${s}`,alternatives:c})}}return a}function C(e,t,n,r){return r===`no_prefix`||r===`prefix_except_default`&&t===n?e:`/${t}${e===`/`?``:e}`}function w(e,t,n,r){return i=>{if(n===`no_prefix`)return i;let a=[];for(let o of i){let i=o.loc.replace(/^https?:\/\/[^/]+/,``);for(let o of e){let s=C(i,o,t,n),c=e.map(e=>({hreflang:e,href:`${r??``}${C(i,e,t,n)}`}));c.push({hreflang:`x-default`,href:`${r??``}${C(i,t,t,n)}`}),a.push({loc:`${r??``}${s}`,alternatives:c})}}return a}}var T=`@fluenti/nuxt`,E=`fluenti`;function D(e,t){return typeof e==`object`?{...h.DEFAULT_FLUENTI_CONFIG,...e}:(0,h.loadConfigSync)(typeof e==`string`?e:void 0,t)}var O=(0,p.defineNuxtModule)({meta:{name:T,configKey:E,compatibility:{nuxt:`>=3.0.0`}},defaults:{strategy:`prefix_except_default`},setup(e,t){let{resolve:n}=(0,p.createResolver)({}.url),r=t.options.rootDir??process.cwd(),i=D(e.config,r);e.locales&&(i.locales=e.locales),e.defaultLocale&&(i.defaultLocale=e.defaultLocale),e.sourceLocale&&(i.sourceLocale=e.sourceLocale),e.catalogDir&&(i.catalogDir=e.catalogDir);let a=(0,m.resolveLocaleCodes)(i.locales),o=_(i.locales),s=i.defaultLocale??i.sourceLocale,l=e.strategy===`domains`?v(i.locales,e.domains):void 0,u=e.detectOrder??(e.strategy===`domains`?[`domain`,`cookie`,`header`]:[`path`,`cookie`,`header`]);t.options.runtimeConfig.public.fluenti={locales:a,defaultLocale:s,strategy:e.strategy??`prefix_except_default`,detectBrowserLanguage:e.detectBrowserLanguage,detectOrder:u,queryParamKey:e.queryParamKey??`locale`,injectGlobalProperties:e.injectGlobalProperties!==!1,...l?{domains:l}:{},localeProperties:o},e.autoVitePlugin!==!1&&(t.options.vite=t.options.vite||{},t.options.vite.plugins=t.options.vite.plugins||[],t.options.vite.plugins.push(...(0,g.default)({config:i}))),e.pageMetaTransform!==!1&&(t.options.vite=t.options.vite||{},t.options.vite.plugins=t.options.vite.plugins||[],t.options.vite.plugins.push(x())),(0,p.addPlugin)({src:n(`./runtime/plugin`),mode:`all`});let d=e.strategy??`prefix_except_default`;d!==`no_prefix`&&d!==`domains`&&e.extendRoutes!==!1&&t.hook(`pages:extend`,t=>{c.t(t,{locales:a,defaultLocale:s,strategy:d,...e.routeNameTemplate?{routeNameTemplate:e.routeNameTemplate}:{},...e.routeOverrides?{routeOverrides:e.routeOverrides}:{},...e.routeMode?{routeMode:e.routeMode}:{}})}),d===`prefix`&&(0,p.addRouteMiddleware)({name:`fluenti-locale-redirect`,path:n(`./runtime/middleware/locale-redirect`),global:e.globalMiddleware!==!1}),e.autoImports!==!1&&(0,p.addImports)([{name:`useLocalePath`,from:n(`./runtime/composables`)},{name:`useSwitchLocalePath`,from:n(`./runtime/composables`)},{name:`useLocaleRoute`,from:n(`./runtime/composables`)},{name:`useLocaleHead`,from:n(`./runtime/composables`)},{name:`useI18nScoped`,from:n(`./runtime/composables`)},{name:`useI18n`,from:`@fluenti/vue`},{name:`defineI18nRoute`,from:n(`./runtime/define-i18n-route`)}]);let f=e.componentPrefix??``;if(e.registerNuxtLinkLocale!==!1&&(0,p.addComponent)({name:`${f}NuxtLinkLocale`,filePath:n(`./runtime/components/NuxtLinkLocale`)}),(0,p.addComponent)({name:`${f}Trans`,filePath:`@fluenti/vue/components`,export:`Trans`}),(0,p.addComponent)({name:`${f}Plural`,filePath:`@fluenti/vue/components`,export:`Plural`}),(0,p.addComponent)({name:`${f}Select`,filePath:`@fluenti/vue/components`,export:`Select`}),(0,p.addComponent)({name:`${f}DateTime`,filePath:`@fluenti/vue/components`,export:`DateTime`}),(0,p.addComponent)({name:`${f}NumberFormat`,filePath:`@fluenti/vue/components`,export:`NumberFormat`}),d!==`no_prefix`&&d!==`domains`){let n=t.options,r=n.nitro??={},i=r.prerender??={};i.crawlLinks=i.crawlLinks??!0,d===`prefix`&&(i.routes=(i.routes??[`/`]).map(e=>e===`/`?`/${s}`:e));for(let t of y(e.isr,d,u))console.warn(t.message);if(e.isr?.enabled){let t=n.routeRules??={},r=e.isr.ttl??3600;for(let e of a)e===s&&d===`prefix_except_default`?t[`/**`]={...t[`/**`],isr:r}:t[`/${e}/**`]={...t[`/${e}/**`],isr:r}}}t.options.dev&&b(t,a,s,d),(d===`prefix`||d===`prefix_and_default`)&&(0,p.addServerHandler)({handler:n(`./runtime/server/locale-redirect`),middleware:!0})}});exports.CONFIG_KEY=E,exports.MODULE_NAME=T,exports.buildLocaleHead=u.t,exports.createSitemapHook=w,exports.default=O,exports.defineI18nRoute=f.defineI18nRoute,exports.extendPages=c.t,exports.extractLocaleFromPath=l.t,exports.generateSitemapUrls=S,exports.localePath=l.n,exports.resolveDomainConfigs=v,Object.defineProperty(exports,`resolveLocaleCodes`,{enumerable:!0,get:function(){return m.resolveLocaleCodes}}),exports.resolveLocaleProperties=_,exports.switchLocalePath=l.r,exports.t=s,exports.useLocaleHead=d.useLocaleHead,exports.useLocalePath=d.useLocalePath,exports.useLocaleRoute=d.useLocaleRoute,exports.useSwitchLocalePath=d.useSwitchLocalePath;
|
|
2
|
-
//# sourceMappingURL=module.cjs.map
|
|
1
|
+
Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:`Module`}});var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;l<u;l++)d=c[l],!a.call(e,d)&&d!==o&&t(e,d,{get:(e=>i[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},s=(n,r,a)=>(a=n==null?{}:e(i(n)),o(r||!n||!n.__esModule?t(a,`default`,{value:n,enumerable:!0}):a,n));const c=require(`./page-extend-DqTELmU6.cjs`),l=require(`./path-utils-BQIsp_or.cjs`),u=require(`./locale-head-jGmp0Xnb.cjs`),d=require(`./runtime/standalone-composables.cjs`),f=require(`./runtime/define-i18n-route.cjs`);let p=require(`@nuxt/kit`),m=require(`@fluenti/core/compiler`),h=require(`@fluenti/core/config`),g=require(`@fluenti/vue/vite-plugin`);g=s(g);function _(e){let t={};for(let n of e)typeof n==`string`?t[n]={code:n}:t[n.code]=n;return t}function v(e,t){if(t?.length)return t;let n=[];for(let t of e)typeof t!=`string`&&t.domain&&n.push({domain:t.domain,locale:t.code});return n}function y(e,t,n){let r=[];if(!e?.enabled)return r;let i=n.filter(e=>e===`cookie`||e===`header`);return i.length>0&&r.push({level:`warn`,message:`[@fluenti/nuxt] ISR is enabled but detectOrder includes non-path detectors (${i.join(`, `)}). ISR caches by URL path, so cookie/header-based detection may serve the wrong locale from cache. Consider using detectOrder: ['path'] with ISR.`}),t===`no_prefix`&&r.push({level:`warn`,message:`[@fluenti/nuxt] ISR is enabled with strategy: 'no_prefix'. All locales share the same URL path, so ISR will cache only one locale per URL. Use 'prefix' or 'prefix_except_default' strategy with ISR.`}),r}function b(e,t,n,r){try{e.hook(`devtools:customTabs`,e=>{e.push({name:`fluenti`,title:`Fluenti i18n`,icon:`i-carbon-translate`,view:{type:`client-component`,componentName:`FluentiDevToolsPanel`}})})}catch{}e.hook(`nitro:config`,e=>{let i=e.runtimeConfig;if(i){let e=(i.public??={}).fluenti??{};e.devtools={enabled:!0,locales:t,defaultLocale:n,strategy:r}}})}function x(){return{name:`fluenti:page-meta-transform`,enforce:`pre`,transform(e,t){if(!t.includes(`/pages/`)&&!t.includes(`\\pages\\`)||!e.includes(`defineI18nRoute`)&&!e.includes(`i18n`))return null;let n=e;return n.includes(`defineI18nRoute`)&&(n=n.replace(/defineI18nRoute\s*\(([^)]*?)\)/g,(e,t)=>`definePageMeta({ i18nRoute: ${t.trim()} })`)),n.includes(`definePageMeta`)&&n.includes(`i18n:`)&&(n=n.replace(/(definePageMeta\s*\(\s*\{[^}]*?)\bi18n\s*:/g,`$1i18nRoute:`)),n===e?null:{code:n,map:null}}}}function S(e,t,n,r,i){let a=[],o=i??``;for(let i of e){let e=i.startsWith(`/`)?i:`/${i}`;for(let i of t){let s=C(e,i,n,r),c=t.map(t=>({hreflang:t,href:`${o}${C(e,t,n,r)}`}));c.push({hreflang:`x-default`,href:`${o}${C(e,n,n,r)}`}),a.push({loc:`${o}${s}`,alternatives:c})}}return a}function C(e,t,n,r){return r===`no_prefix`||r===`prefix_except_default`&&t===n?e:`/${t}${e===`/`?``:e}`}function w(e,t,n,r){return i=>{if(n===`no_prefix`)return i;let a=[];for(let o of i){let i=o.loc.replace(/^https?:\/\/[^/]+/,``);for(let o of e){let s=C(i,o,t,n),c=e.map(e=>({hreflang:e,href:`${r??``}${C(i,e,t,n)}`}));c.push({hreflang:`x-default`,href:`${r??``}${C(i,t,t,n)}`}),a.push({loc:`${r??``}${s}`,alternatives:c})}}return a}}var T=`@fluenti/nuxt`,E=`fluenti`;function D(e,t){return typeof e==`object`?{...h.DEFAULT_FLUENTI_CONFIG,...e}:(0,h.loadConfigSync)(typeof e==`string`?e:void 0,t)}var O=(0,p.defineNuxtModule)({meta:{name:T,configKey:E,compatibility:{nuxt:`>=3.0.0`}},defaults:{strategy:`prefix_except_default`},setup(e,t){let{resolve:n}=(0,p.createResolver)({}.url),r=t.options.rootDir??process.cwd(),i=D(e.config,r);e.locales&&(i.locales=e.locales),e.defaultLocale&&(i.defaultLocale=e.defaultLocale),e.sourceLocale&&(i.sourceLocale=e.sourceLocale),e.catalogDir&&(i.catalogDir=e.catalogDir);let a=(0,m.resolveLocaleCodes)(i.locales),o=_(i.locales),s=i.defaultLocale??i.sourceLocale,l=e.strategy===`domains`?v(i.locales,e.domains):void 0,u=e.detectOrder??(e.strategy===`domains`?[`domain`,`cookie`,`header`]:[`path`,`cookie`,`header`]);t.options.runtimeConfig.public.fluenti={locales:a,defaultLocale:s,strategy:e.strategy??`prefix_except_default`,detectBrowserLanguage:e.detectBrowserLanguage,detectOrder:u,queryParamKey:e.queryParamKey??`locale`,injectGlobalProperties:e.injectGlobalProperties!==!1,...l?{domains:l}:{},localeProperties:o},e.autoVitePlugin!==!1&&(t.options.vite=t.options.vite||{},t.options.vite.plugins=t.options.vite.plugins||[],t.options.vite.plugins.push(...(0,g.default)({config:i}))),e.pageMetaTransform!==!1&&(t.options.vite=t.options.vite||{},t.options.vite.plugins=t.options.vite.plugins||[],t.options.vite.plugins.push(x())),(0,p.addPlugin)({src:n(`./runtime/plugin`),mode:`all`});let d=e.strategy??`prefix_except_default`;d!==`no_prefix`&&d!==`domains`&&e.extendRoutes!==!1&&t.hook(`pages:extend`,t=>{c.t(t,{locales:a,defaultLocale:s,strategy:d,...e.routeNameTemplate?{routeNameTemplate:e.routeNameTemplate}:{},...e.routeOverrides?{routeOverrides:e.routeOverrides}:{},...e.routeMode?{routeMode:e.routeMode}:{}})}),d===`prefix`&&(0,p.addRouteMiddleware)({name:`fluenti-locale-redirect`,path:n(`./runtime/middleware/locale-redirect`),global:e.globalMiddleware!==!1}),e.autoImports!==!1&&(0,p.addImports)([{name:`useLocalePath`,from:n(`./runtime/composables`)},{name:`useSwitchLocalePath`,from:n(`./runtime/composables`)},{name:`useLocaleRoute`,from:n(`./runtime/composables`)},{name:`useLocaleHead`,from:n(`./runtime/composables`)},{name:`useI18nScoped`,from:n(`./runtime/composables`)},{name:`useI18n`,from:`@fluenti/vue`},{name:`defineI18nRoute`,from:n(`./runtime/define-i18n-route`)}]);let f=e.componentPrefix??``;if(e.registerNuxtLinkLocale!==!1&&(0,p.addComponent)({name:`${f}NuxtLinkLocale`,filePath:n(`./runtime/components/NuxtLinkLocale`)}),(0,p.addComponent)({name:`${f}Trans`,filePath:`@fluenti/vue/components`,export:`Trans`}),(0,p.addComponent)({name:`${f}Plural`,filePath:`@fluenti/vue/components`,export:`Plural`}),(0,p.addComponent)({name:`${f}Select`,filePath:`@fluenti/vue/components`,export:`Select`}),(0,p.addComponent)({name:`${f}DateTime`,filePath:`@fluenti/vue/components`,export:`DateTime`}),(0,p.addComponent)({name:`${f}NumberFormat`,filePath:`@fluenti/vue/components`,export:`NumberFormat`}),d!==`no_prefix`&&d!==`domains`){let n=t.options,r=n.nitro??={},i=r.prerender??={};i.crawlLinks=i.crawlLinks??!0,d===`prefix`&&(i.routes=(i.routes??[`/`]).map(e=>e===`/`?`/${s}`:e));for(let t of y(e.isr,d,u))console.warn(t.message);if(e.isr?.enabled){let t=n.routeRules??={},r=e.isr.ttl??3600;for(let e of a)e===s&&d===`prefix_except_default`?t[`/**`]={...t[`/**`],isr:r}:t[`/${e}/**`]={...t[`/${e}/**`],isr:r}}}t.options.dev&&b(t,a,s,d),(d===`prefix`||d===`prefix_and_default`)&&(0,p.addServerHandler)({handler:n(`./runtime/server/locale-redirect`),middleware:!0})}});exports.CONFIG_KEY=E,exports.MODULE_NAME=T,exports.buildLocaleHead=u.t,exports.createSitemapHook=w,exports.default=O,exports.defineI18nRoute=f.defineI18nRoute,exports.extendPages=c.t,exports.extractLocaleFromPath=l.t,exports.generateSitemapUrls=S,exports.localePath=l.n,exports.resolveDomainConfigs=v,Object.defineProperty(exports,`resolveLocaleCodes`,{enumerable:!0,get:function(){return m.resolveLocaleCodes}}),exports.resolveLocaleProperties=_,exports.switchLocalePath=l.r,exports.t=s,exports.useLocaleHead=d.useLocaleHead,exports.useLocalePath=d.useLocalePath,exports.useLocaleRoute=d.useLocaleRoute,exports.useSwitchLocalePath=d.useSwitchLocalePath;
|
package/dist/module.js
CHANGED
|
@@ -262,5 +262,3 @@ var N = g({
|
|
|
262
262
|
});
|
|
263
263
|
//#endregion
|
|
264
264
|
export { j as CONFIG_KEY, A as MODULE_NAME, i as buildLocaleHead, k as createSitemapHook, N as default, l as defineI18nRoute, e as extendPages, r as extractLocaleFromPath, D as generateSitemapUrls, t as localePath, C as resolveDomainConfigs, _ as resolveLocaleCodes, S as resolveLocaleProperties, n as switchLocalePath, a as useLocaleHead, o as useLocalePath, s as useLocaleRoute, c as useSwitchLocalePath };
|
|
265
|
-
|
|
266
|
-
//# sourceMappingURL=module.js.map
|
|
@@ -28,4 +28,3 @@ export declare function setupDevTools(nuxt: Nuxt, localeCodes: string[], default
|
|
|
28
28
|
* displays it in a simple, readable format.
|
|
29
29
|
*/
|
|
30
30
|
export declare const DEVTOOLS_PANEL_COMPONENT = "\n<template>\n <div style=\"padding: 16px; font-family: system-ui, sans-serif;\">\n <h2 style=\"margin: 0 0 16px; font-size: 18px;\">\uD83C\uDF10 Fluenti i18n</h2>\n\n <div style=\"display: grid; grid-template-columns: 140px 1fr; gap: 8px 16px; font-size: 14px;\">\n <span style=\"color: #888;\">Current locale:</span>\n <strong>{{ state.currentLocale }}</strong>\n\n <span style=\"color: #888;\">Default locale:</span>\n <span>{{ state.defaultLocale }}</span>\n\n <span style=\"color: #888;\">Strategy:</span>\n <span>{{ state.strategy }}</span>\n\n <span style=\"color: #888;\">Available:</span>\n <span>{{ state.availableLocales.join(', ') }}</span>\n\n <span style=\"color: #888;\">Loaded:</span>\n <span>{{ state.loadedLocales.join(', ') || 'none' }}</span>\n\n <span style=\"color: #888;\">Messages:</span>\n <span>{{ state.messageCount }}</span>\n\n <span style=\"color: #888;\">Missing keys:</span>\n <span :style=\"{ color: state.missingKeys.length > 0 ? '#e53e3e' : '#38a169' }\">\n {{ state.missingKeys.length > 0 ? state.missingKeys.length + ' missing' : 'All translated \u2713' }}\n </span>\n </div>\n\n <div v-if=\"state.missingKeys.length > 0\" style=\"margin-top: 16px;\">\n <h3 style=\"margin: 0 0 8px; font-size: 14px; color: #e53e3e;\">Missing translations:</h3>\n <ul style=\"margin: 0; padding: 0 0 0 20px; font-size: 13px; font-family: monospace;\">\n <li v-for=\"key in state.missingKeys\" :key=\"key\" style=\"margin: 2px 0;\">{{ key }}</li>\n </ul>\n </div>\n </div>\n</template>\n\n<script setup>\nimport { ref, onMounted } from 'vue'\n\nconst state = ref({\n currentLocale: '',\n defaultLocale: '',\n strategy: '',\n availableLocales: [],\n loadedLocales: [],\n messageCount: 0,\n missingKeys: [],\n})\n\nonMounted(() => {\n try {\n const nuxtApp = window.__NUXT_DEVTOOLS_VIEW__?.nuxtApp ?? useNuxtApp()\n const config = nuxtApp.$config?.public?.fluenti ?? {}\n const fluentiLocale = nuxtApp.$fluentiLocale ?? ref('')\n\n state.value = {\n currentLocale: fluentiLocale.value || config.defaultLocale || '',\n defaultLocale: config.defaultLocale || '',\n strategy: config.strategy || '',\n availableLocales: config.locales || [],\n loadedLocales: [],\n messageCount: 0,\n missingKeys: [],\n }\n } catch (e) {\n // DevTools context not available\n }\n})\n</script>\n";
|
|
31
|
-
//# sourceMappingURL=devtools.d.ts.map
|
|
@@ -22,4 +22,3 @@ export declare function useSwitchLocalePath(currentPath: Ref<string> | ComputedR
|
|
|
22
22
|
* Accepts explicit locale, currentPath, and config instead of using Nuxt auto-imports.
|
|
23
23
|
*/
|
|
24
24
|
export declare function useLocaleHead(locale: Ref<string>, currentPath: Ref<string> | ComputedRef<string>, config: FluentNuxtRuntimeConfig, options?: LocaleHeadOptions): ComputedRef<LocaleHeadMeta>;
|
|
25
|
-
//# sourceMappingURL=client.d.ts.map
|
|
@@ -41,4 +41,3 @@ declare const NuxtLinkLocale: import('vue').DefineComponent<import('vue').Extrac
|
|
|
41
41
|
}, {}, {}, {}, string, import('vue').ComponentProvideOptions, true, {}, any>;
|
|
42
42
|
export { NuxtLinkLocale };
|
|
43
43
|
export default NuxtLinkLocale;
|
|
44
|
-
//# sourceMappingURL=NuxtLinkLocale.d.ts.map
|
|
@@ -9,4 +9,3 @@ declare const builtinDetectors: Record<string, LocaleDetectorFn>;
|
|
|
9
9
|
export declare function runDetectors(path: string, config: FluentNuxtRuntimeConfig, customDetectors?: Map<string, LocaleDetectorFn>, hookFn?: (ctx: LocaleDetectContext) => void | Promise<void>, host?: string, cookieValue?: string | null, acceptLanguage?: string): Promise<string>;
|
|
10
10
|
export { builtinDetectors };
|
|
11
11
|
export type { LocaleDetectContext, LocaleDetectorFn };
|
|
12
|
-
//# sourceMappingURL=index.d.ts.map
|
|
@@ -5,4 +5,3 @@ export { buildLocaleHead } from './locale-head';
|
|
|
5
5
|
export type { LocaleHeadMeta, LocaleHeadOptions } from './locale-head';
|
|
6
6
|
export { useLocalePath, useSwitchLocalePath, useLocaleRoute, useLocaleHead, useI18nScoped } from './composables';
|
|
7
7
|
export { NuxtLinkLocale } from './components/NuxtLinkLocale';
|
|
8
|
-
//# sourceMappingURL=index.d.ts.map
|
|
@@ -30,4 +30,3 @@ export interface LocaleHeadOptions {
|
|
|
30
30
|
* use `useLocaleHead()` from `composables.ts` instead.
|
|
31
31
|
*/
|
|
32
32
|
export declare function buildLocaleHead(locale: string, currentPath: string, config: FluentNuxtRuntimeConfig, options?: LocaleHeadOptions): LocaleHeadMeta;
|
|
33
|
-
//# sourceMappingURL=locale-head.d.ts.map
|
|
@@ -16,4 +16,3 @@ export declare function extractLocaleFromPath(path: string, locales: string[]):
|
|
|
16
16
|
* preserving the current route path.
|
|
17
17
|
*/
|
|
18
18
|
export declare function switchLocalePath(currentPath: string, newLocale: string, locales: string[], defaultLocale: string, strategy: Strategy): string;
|
|
19
|
-
//# sourceMappingURL=path-utils.d.ts.map
|
|
@@ -22,4 +22,3 @@ export declare function useLocaleRoute(locale: Ref<string>, router: Router, conf
|
|
|
22
22
|
* Accepts explicit locale, path, and config refs.
|
|
23
23
|
*/
|
|
24
24
|
export declare function useLocaleHead(locale: Ref<string>, currentPath: Ref<string>, config: FluentNuxtRuntimeConfig, options?: LocaleHeadOptions): ComputedRef<LocaleHeadMeta>;
|
|
25
|
-
//# sourceMappingURL=standalone-composables.d.ts.map
|
|
@@ -21,4 +21,3 @@ export declare function generateSitemapUrls(paths: string[], locales: string[],
|
|
|
21
21
|
* Register this in your nuxt.config.ts or let the module auto-register it.
|
|
22
22
|
*/
|
|
23
23
|
export declare function createSitemapHook(locales: string[], defaultLocale: string, strategy: Strategy, baseUrl?: string): (urls: SitemapUrl[]) => SitemapUrl[];
|
|
24
|
-
//# sourceMappingURL=sitemap.d.ts.map
|
|
@@ -315,4 +315,3 @@ export interface FluentNuxtRuntimeConfig {
|
|
|
315
315
|
export declare function resolveLocaleProperties(locales: LocaleDefinition[]): Record<string, LocaleObject>;
|
|
316
316
|
/** Build domain configs from locale objects that have a `domain` field */
|
|
317
317
|
export declare function resolveDomainConfigs(locales: LocaleDefinition[], explicit?: DomainConfig[]): DomainConfig[];
|
|
318
|
-
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
var e=(e,t)=>`${e}___${t}`;function t(t,r){let{locales:i,defaultLocale:a,strategy:o,routeOverrides:s}=r,c=r.routeMode??`all`;if(o===`no_prefix`||o===`domains`)return;let l=r.routeNameTemplate??e,u=[...t],d=(e,t)=>{let n=e.meta?.i18nRoute;return c===`opt-in`&&n===void 0||n===!1?!1:n&&n.locales?n.locales.includes(t):!0};for(let e of i)if(!(o===`prefix_except_default`&&e===a))for(let r of u){if(!d(r,e))continue;let i=n(r,e,l,s);t.push(i)}if(o===`prefix`&&t.splice(0,u.length),o===`prefix_except_default`)for(let e=t.length-1;e>=0;e--){let n=t[e];u.includes(n)&&!d(n,a)&&t.splice(e,1)}}function n(e,t,n,r){let i=r?.[e.path]?.[t]??e.path,a={...e,path:`/${t}${i===`/`?``:i}`};return e.name&&(a.name=n(e.name,t)),e.children&&(a.children=e.children.map(e=>{let i=r?.[e.path]?.[t];if(!i&&!e.name)return e;let a={...e,...i?{path:i}:{}};return e.name&&(a.name=n(e.name,t)),a})),a}Object.defineProperty(exports,`t`,{enumerable:!0,get:function(){return t}});
|
|
2
|
-
//# sourceMappingURL=page-extend-DqTELmU6.cjs.map
|
|
1
|
+
var e=(e,t)=>`${e}___${t}`;function t(t,r){let{locales:i,defaultLocale:a,strategy:o,routeOverrides:s}=r,c=r.routeMode??`all`;if(o===`no_prefix`||o===`domains`)return;let l=r.routeNameTemplate??e,u=[...t],d=(e,t)=>{let n=e.meta?.i18nRoute;return c===`opt-in`&&n===void 0||n===!1?!1:n&&n.locales?n.locales.includes(t):!0};for(let e of i)if(!(o===`prefix_except_default`&&e===a))for(let r of u){if(!d(r,e))continue;let i=n(r,e,l,s);t.push(i)}if(o===`prefix`&&t.splice(0,u.length),o===`prefix_except_default`)for(let e=t.length-1;e>=0;e--){let n=t[e];u.includes(n)&&!d(n,a)&&t.splice(e,1)}}function n(e,t,n,r){let i=r?.[e.path]?.[t]??e.path,a={...e,path:`/${t}${i===`/`?``:i}`};return e.name&&(a.name=n(e.name,t)),e.children&&(a.children=e.children.map(e=>{let i=r?.[e.path]?.[t];if(!i&&!e.name)return e;let a={...e,...i?{path:i}:{}};return e.name&&(a.name=n(e.name,t)),a})),a}Object.defineProperty(exports,`t`,{enumerable:!0,get:function(){return t}});
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
function e(e,t){let n=e.split(`,`).map(e=>{let[t=``,n=``]=e.trim().split(`;q=`),r=n?parseFloat(n):1,i=Number.isFinite(r)?Math.min(1,Math.max(0,r)):0;return{lang:t.trim().toLowerCase(),quality:i}}).filter(e=>e.quality>0).sort((e,t)=>t.quality-e.quality);for(let{lang:e}of n){let n=t.find(t=>t.toLowerCase()===e);if(n)return n;let r=e.split(`-`)[0],i=t.find(e=>{let t=e.toLowerCase();return t===r||t.startsWith(r+`-`)});if(i)return i}return null}Object.defineProperty(exports,`t`,{enumerable:!0,get:function(){return e}});
|
|
2
|
-
//# sourceMappingURL=parse-accept-language-ZKitIm3n.cjs.map
|
|
1
|
+
function e(e,t){let n=e.split(`,`).map(e=>{let[t=``,n=``]=e.trim().split(`;q=`),r=n?parseFloat(n):1,i=Number.isFinite(r)?Math.min(1,Math.max(0,r)):0;return{lang:t.trim().toLowerCase(),quality:i}}).filter(e=>e.quality>0).sort((e,t)=>t.quality-e.quality);for(let{lang:e}of n){let n=t.find(t=>t.toLowerCase()===e);if(n)return n;let r=e.split(`-`)[0],i=t.find(e=>{let t=e.toLowerCase();return t===r||t.startsWith(r+`-`)});if(i)return i}return null}Object.defineProperty(exports,`t`,{enumerable:!0,get:function(){return e}});
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
function e(e,t,n,r){return r===`no_prefix`?e:r===`prefix_except_default`&&t===n?e.startsWith(`/`)?e:`/${e}`:`/${t}${e===`/`?``:e.startsWith(`/`)?e:`/${e}`}`}function t(e,t){let n=e.match(/^\/([^/]+)(.*)$/);if(!n)return{locale:null,pathWithoutLocale:e};let r=n[1],i=n[2]||`/`;return t.includes(r)?{locale:r,pathWithoutLocale:i||`/`}:{locale:null,pathWithoutLocale:e}}function n(n,r,i,a,o){if(o===`no_prefix`)return n;let{pathWithoutLocale:s}=t(n,i);return e(s,r,a,o)}Object.defineProperty(exports,`n`,{enumerable:!0,get:function(){return e}}),Object.defineProperty(exports,`r`,{enumerable:!0,get:function(){return n}}),Object.defineProperty(exports,`t`,{enumerable:!0,get:function(){return t}});
|
|
2
|
-
//# sourceMappingURL=path-utils-BQIsp_or.cjs.map
|
|
1
|
+
function e(e,t,n,r){return r===`no_prefix`?e:r===`prefix_except_default`&&t===n?e.startsWith(`/`)?e:`/${e}`:`/${t}${e===`/`?``:e.startsWith(`/`)?e:`/${e}`}`}function t(e,t){let n=e.match(/^\/([^/]+)(.*)$/);if(!n)return{locale:null,pathWithoutLocale:e};let r=n[1],i=n[2]||`/`;return t.includes(r)?{locale:r,pathWithoutLocale:i||`/`}:{locale:null,pathWithoutLocale:e}}function n(n,r,i,a,o){if(o===`no_prefix`)return n;let{pathWithoutLocale:s}=t(n,i);return e(s,r,a,o)}Object.defineProperty(exports,`n`,{enumerable:!0,get:function(){return e}}),Object.defineProperty(exports,`r`,{enumerable:!0,get:function(){return n}}),Object.defineProperty(exports,`t`,{enumerable:!0,get:function(){return t}});
|
package/dist/runtime/client.cjs
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`../page-extend-DqTELmU6.cjs`),t=require(`../path-utils-BQIsp_or.cjs`),n=require(`../locale-head-jGmp0Xnb.cjs`);require(`../module.cjs`);let r=require(`vue`);function i(e,n){return(r,i)=>t.n(r,i??e.value,n.defaultLocale,n.strategy)}function a(e,n){return r=>t.r(e.value,r,n.locales,n.defaultLocale,n.strategy)}function o(e,t,i,a){return(0,r.computed)(()=>n.t(e.value,t.value,i,a))}exports.buildLocaleHead=n.t,exports.extendPages=e.t,exports.extractLocaleFromPath=t.t,exports.localePath=t.n,exports.switchLocalePath=t.r,exports.useLocaleHead=o,exports.useLocalePath=i,exports.useSwitchLocalePath=a;
|
|
2
|
-
//# sourceMappingURL=client.cjs.map
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`../page-extend-DqTELmU6.cjs`),t=require(`../path-utils-BQIsp_or.cjs`),n=require(`../locale-head-jGmp0Xnb.cjs`);require(`../module.cjs`);let r=require(`vue`);function i(e,n){return(r,i)=>t.n(r,i??e.value,n.defaultLocale,n.strategy)}function a(e,n){return r=>t.r(e.value,r,n.locales,n.defaultLocale,n.strategy)}function o(e,t,i,a){return(0,r.computed)(()=>n.t(e.value,t.value,i,a))}exports.buildLocaleHead=n.t,exports.extendPages=e.t,exports.extractLocaleFromPath=t.t,exports.localePath=t.n,exports.switchLocalePath=t.r,exports.useLocaleHead=o,exports.useLocalePath=i,exports.useSwitchLocalePath=a;
|
package/dist/runtime/client.js
CHANGED
|
@@ -14,5 +14,3 @@ function c(e, t, n, r) {
|
|
|
14
14
|
}
|
|
15
15
|
//#endregion
|
|
16
16
|
export { i as buildLocaleHead, e as extendPages, r as extractLocaleFromPath, t as localePath, n as switchLocalePath, c as useLocaleHead, o as useLocalePath, s as useSwitchLocalePath };
|
|
17
|
-
|
|
18
|
-
//# sourceMappingURL=client.js.map
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:`Module`}}),require(`../../module.cjs`);const e=require(`../composables.cjs`);let t=require(`vue`),n=require(`#components`);var r=(0,t.defineComponent)({name:`NuxtLinkLocale`,props:{to:{type:[String,Object],required:!0},locale:{type:String,default:void 0}},setup(r,{slots:i,attrs:a}){let o=e.useLocalePath(),s=(0,t.computed)(()=>o(typeof r.to==`string`?r.to:r.to.path??`/`,r.locale));return()=>(0,t.h)(n.NuxtLink,{...a,to:s.value},i)}});exports.NuxtLinkLocale=r,exports.default=r;
|
|
2
|
-
//# sourceMappingURL=NuxtLinkLocale.cjs.map
|
|
1
|
+
Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:`Module`}}),require(`../../module.cjs`);const e=require(`../composables.cjs`);let t=require(`vue`),n=require(`#components`);var r=(0,t.defineComponent)({name:`NuxtLinkLocale`,props:{to:{type:[String,Object],required:!0},locale:{type:String,default:void 0}},setup(r,{slots:i,attrs:a}){let o=e.useLocalePath(),s=(0,t.computed)(()=>o(typeof r.to==`string`?r.to:r.to.path??`/`,r.locale));return()=>(0,t.h)(n.NuxtLink,{...a,to:s.value},i)}});exports.NuxtLinkLocale=r,exports.default=r;
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`../path-utils-BQIsp_or.cjs`),t=require(`../locale-head-jGmp0Xnb.cjs`);require(`../module.cjs`);let n=require(`vue`),r=require(`#imports`),i=require(`@fluenti/vue`);function a(){return(0,r.useRuntimeConfig)().public.fluenti}function o(){let{locale:t}=(0,i.useI18n)(),n=a();return(r,i)=>e.n(r,i??t.value,n.defaultLocale,n.strategy)}function s(){let t=(0,r.useRoute)(),n=a();return r=>e.r(t.path,r,n.locales,n.defaultLocale,n.strategy)}function c(){let{locale:t}=(0,i.useI18n)(),n=(0,r.useRouter)(),o=a();return(r,i)=>{let a=i??t.value;if(typeof r==`string`){let t=e.n(r,a,o.defaultLocale,o.strategy);return n.resolve(t)}if(`path`in r&&r.path){let t=e.n(r.path,a,o.defaultLocale,o.strategy);return n.resolve({...r,path:t})}return n.resolve(r)}}function l(e){let t=(0,i.useI18n)();return{...t,t(n,r){if(typeof n==`string`)return t.t(`${e}.${n}`,r);if(n&&typeof n==`object`&&`id`in n){let i=n;return t.t({...i,id:`${e}.${i.id}`},r)}return t.t(n,r)},te(n,r){return t.te(`${e}.${n}`,r)},tm(n,r){return t.tm(`${e}.${n}`,r)},namespace:e}}function u(e){let{locale:o}=(0,i.useI18n)(),s=(0,r.useRoute)(),c=a();return(0,n.computed)(()=>t.t(o.value,s.path,c,e))}exports.useI18nScoped=l,exports.useLocaleHead=u,exports.useLocalePath=o,exports.useLocaleRoute=c,exports.useSwitchLocalePath=s;
|
|
2
|
-
//# sourceMappingURL=composables.cjs.map
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`../path-utils-BQIsp_or.cjs`),t=require(`../locale-head-jGmp0Xnb.cjs`);require(`../module.cjs`);let n=require(`vue`),r=require(`#imports`),i=require(`@fluenti/vue`);function a(){return(0,r.useRuntimeConfig)().public.fluenti}function o(){let{locale:t}=(0,i.useI18n)(),n=a();return(r,i)=>e.n(r,i??t.value,n.defaultLocale,n.strategy)}function s(){let t=(0,r.useRoute)(),n=a();return r=>e.r(t.path,r,n.locales,n.defaultLocale,n.strategy)}function c(){let{locale:t}=(0,i.useI18n)(),n=(0,r.useRouter)(),o=a();return(r,i)=>{let a=i??t.value;if(typeof r==`string`){let t=e.n(r,a,o.defaultLocale,o.strategy);return n.resolve(t)}if(`path`in r&&r.path){let t=e.n(r.path,a,o.defaultLocale,o.strategy);return n.resolve({...r,path:t})}return n.resolve(r)}}function l(e){let t=(0,i.useI18n)();return{...t,t(n,r){if(typeof n==`string`)return t.t(`${e}.${n}`,r);if(n&&typeof n==`object`&&`id`in n){let i=n;return t.t({...i,id:`${e}.${i.id}`},r)}return t.t(n,r)},te(n,r){return t.te(`${e}.${n}`,r)},tm(n,r){return t.tm(`${e}.${n}`,r)},namespace:e}}function u(e){let{locale:o}=(0,i.useI18n)(),s=(0,r.useRoute)(),c=a();return(0,n.computed)(()=>t.t(o.value,s.path,c,e))}exports.useI18nScoped=l,exports.useLocaleHead=u,exports.useLocalePath=o,exports.useLocaleRoute=c,exports.useSwitchLocalePath=s;
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});function e(e){}exports.defineI18nRoute=e;
|
|
2
|
-
//# sourceMappingURL=define-i18n-route.cjs.map
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});function e(e){}exports.defineI18nRoute=e;
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
function e(e){if(e.strategy!==`domains`||!e.host)return;let t=e.domains;if(!t?.length)return;let n=e.host.toLowerCase().replace(/:\d+$/,``);for(let r of t)if(r.domain.toLowerCase()===n){e.setLocale(r.locale);return}}module.exports=e;
|
|
2
|
-
//# sourceMappingURL=domain.cjs.map
|
|
1
|
+
function e(e){if(e.strategy!==`domains`||!e.host)return;let t=e.domains;if(!t?.length)return;let n=e.host.toLowerCase().replace(/:\d+$/,``);for(let r of t)if(r.domain.toLowerCase()===n){e.setLocale(r.locale);return}}module.exports=e;
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
const e=require(`../../path-utils-BQIsp_or.cjs`);require(`../../module.cjs`);const t=require(`../../detectors-BBAX-ZGA.cjs`);let n=require(`#imports`);var r=(0,n.defineNuxtRouteMiddleware)(async r=>{let i=(0,n.useRuntimeConfig)().public.fluenti;if(i.strategy===`no_prefix`)return;let{locale:a}=e.t(r.path,i.locales);if(a||i.strategy===`prefix_except_default`)return;let o=(0,n.useNuxtApp)(),s={...i,detectOrder:i.detectOrder.filter(e=>e!==`path`)},c=await t.t(r.path,s),l=e.n(r.path,c,i.defaultLocale,i.strategy);if(l!==r.path)return o.runWithContext(()=>(0,n.navigateTo)(l,{redirectCode:302}))});module.exports=r;
|
|
2
|
-
//# sourceMappingURL=locale-redirect.cjs.map
|
|
1
|
+
const e=require(`../../path-utils-BQIsp_or.cjs`);require(`../../module.cjs`);const t=require(`../../detectors-BBAX-ZGA.cjs`);let n=require(`#imports`);var r=(0,n.defineNuxtRouteMiddleware)(async r=>{let i=(0,n.useRuntimeConfig)().public.fluenti;if(i.strategy===`no_prefix`)return;let{locale:a}=e.t(r.path,i.locales);if(a||i.strategy===`prefix_except_default`)return;let o=(0,n.useNuxtApp)(),s={...i,detectOrder:i.detectOrder.filter(e=>e!==`path`)},c=await t.t(r.path,s),l=e.n(r.path,c,i.defaultLocale,i.strategy);if(l!==r.path)return o.runWithContext(()=>(0,n.navigateTo)(l,{redirectCode:302}))});module.exports=r;
|
package/dist/runtime/plugin.cjs
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
const e=require(`../path-utils-BQIsp_or.cjs`);require(`../module.cjs`);const t=require(`../detectors-BBAX-ZGA.cjs`);let n=require(`vue`),r=require(`#imports`);var i=(0,r.defineNuxtPlugin)(async i=>{let a=(0,r.useRuntimeConfig)().public.fluenti,o=(0,r.useRoute)(),s=a.detectBrowserLanguage?.useCookie?a.detectBrowserLanguage:null,c=s?.cookieKey??`fluenti_locale`,l=s?(0,r.useCookie)(c):null,u,d;if({}.server)try{let e=(0,r.useRequestHeaders)([`host`,`accept-language`]);d=e[`accept-language`],a.strategy===`domains`&&(u=e.host)}catch(e){({}).dev&&console.debug(`[fluenti] Header read failed:`,e)}else if(a.strategy===`domains`)try{u=window.location.host}catch(e){({}).dev&&console.debug(`[fluenti] Domain detection failed:`,e)}let f;if({}.server){f=await t.t(o.path,a,void 0,async e=>{await i.callHook(`fluenti:detect-locale`,e)},u,l?.value??void 0,d),i.payload.fluentiLocale=f;try{let e=i.ssrContext?.event;e&&(e.context.locale=f)}catch(e){({}).dev&&console.debug(`[fluenti] Event context not available:`,e)}}else if(i.payload.fluentiLocale)f=i.payload.fluentiLocale;else if(a.strategy===`domains`&&u&&a.domains?.length){let e=u.toLowerCase().replace(/:\d+$/,``),t=a.domains.find(t=>t.domain.toLowerCase()===e);f=t?t.locale:a.defaultLocale}else{let{locale:t}=e.t(o.path,a.locales);f=t||(l&&l.value&&a.locales.includes(l.value)?l.value:a.defaultLocale)}let p=(0,n.ref)(f);if(a.strategy!==`no_prefix`&&a.strategy!==`domains`&&(0,n.watch)(()=>o.path,t=>{let{locale:n}=e.t(t,a.locales);n?p.value=n:a.strategy===`prefix_except_default`&&(p.value=a.defaultLocale)}),l&&(0,n.watch)(p,e=>{l.value=e}),a.injectGlobalProperties){let t=i.vueApp.config.globalProperties;t.$localePath=(t,n)=>e.n(t,n??p.value,a.defaultLocale,a.strategy),t.$switchLocalePath=t=>e.r(o.path,t,a.locales,a.defaultLocale,a.strategy)}return{provide:{fluentiLocale:p,fluentiConfig:a}}});module.exports=i;
|
|
2
|
-
//# sourceMappingURL=plugin.cjs.map
|
|
1
|
+
const e=require(`../path-utils-BQIsp_or.cjs`);require(`../module.cjs`);const t=require(`../detectors-BBAX-ZGA.cjs`);let n=require(`vue`),r=require(`#imports`);var i=(0,r.defineNuxtPlugin)(async i=>{let a=(0,r.useRuntimeConfig)().public.fluenti,o=(0,r.useRoute)(),s=a.detectBrowserLanguage?.useCookie?a.detectBrowserLanguage:null,c=s?.cookieKey??`fluenti_locale`,l=s?(0,r.useCookie)(c):null,u,d;if({}.server)try{let e=(0,r.useRequestHeaders)([`host`,`accept-language`]);d=e[`accept-language`],a.strategy===`domains`&&(u=e.host)}catch(e){({}).dev&&console.debug(`[fluenti] Header read failed:`,e)}else if(a.strategy===`domains`)try{u=window.location.host}catch(e){({}).dev&&console.debug(`[fluenti] Domain detection failed:`,e)}let f;if({}.server){f=await t.t(o.path,a,void 0,async e=>{await i.callHook(`fluenti:detect-locale`,e)},u,l?.value??void 0,d),i.payload.fluentiLocale=f;try{let e=i.ssrContext?.event;e&&(e.context.locale=f)}catch(e){({}).dev&&console.debug(`[fluenti] Event context not available:`,e)}}else if(i.payload.fluentiLocale)f=i.payload.fluentiLocale;else if(a.strategy===`domains`&&u&&a.domains?.length){let e=u.toLowerCase().replace(/:\d+$/,``),t=a.domains.find(t=>t.domain.toLowerCase()===e);f=t?t.locale:a.defaultLocale}else{let{locale:t}=e.t(o.path,a.locales);f=t||(l&&l.value&&a.locales.includes(l.value)?l.value:a.defaultLocale)}let p=(0,n.ref)(f);if(a.strategy!==`no_prefix`&&a.strategy!==`domains`&&(0,n.watch)(()=>o.path,t=>{let{locale:n}=e.t(t,a.locales);n?p.value=n:a.strategy===`prefix_except_default`&&(p.value=a.defaultLocale)}),l&&(0,n.watch)(p,e=>{l.value=e}),a.injectGlobalProperties){let t=i.vueApp.config.globalProperties;t.$localePath=(t,n)=>e.n(t,n??p.value,a.defaultLocale,a.strategy),t.$switchLocalePath=t=>e.r(o.path,t,a.locales,a.defaultLocale,a.strategy)}return{provide:{fluentiLocale:p,fluentiConfig:a}}});module.exports=i;
|
package/dist/runtime/plugin.js
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
require(`../../module.cjs`);const e=require(`../../parse-accept-language-ZKitIm3n.cjs`);let t=require(`h3`);var n=(0,t.defineEventHandler)(n=>{let i=n.path??`/`;if(i.startsWith(`/_nuxt/`)||i.startsWith(`/api/`)||i.startsWith(`/__nuxt`)||/\.\w{2,5}$/.test(i))return;let a=n.context.__fluenti_config??r(n);if(!a||a.strategy!==`prefix`&&a.strategy!==`prefix_and_default`)return;let o=i.split(`/`).filter(Boolean)[0];if(o&&a.locales.includes(o))return;let s=a.defaultLocale,c=a.queryParamKey??`locale`,l=(0,t.getQuery)(n)[c];if(typeof l==`string`&&a.locales.includes(l))s=l;else{let r=(0,t.getCookie)(n,a.detectBrowserLanguage?.cookieKey??`fluenti_locale`);if(r&&a.locales.includes(r))s=r;else{let r=(0,t.getHeader)(n,`accept-language`);if(r){let t=e.t(r,a.locales);t&&(s=t)}}}return(0,t.sendRedirect)(n,`/${s}${i===`/`?``:i}`,302)});function r(e){try{let t=(((e.context.nitro??e.context.__nitro)?.runtimeConfig??{}).public??{}).fluenti;return t&&(e.context.__fluenti_config=t),t}catch{return}}module.exports=n;
|
|
2
|
-
//# sourceMappingURL=locale-redirect.cjs.map
|
|
1
|
+
require(`../../module.cjs`);const e=require(`../../parse-accept-language-ZKitIm3n.cjs`);let t=require(`h3`);var n=(0,t.defineEventHandler)(n=>{let i=n.path??`/`;if(i.startsWith(`/_nuxt/`)||i.startsWith(`/api/`)||i.startsWith(`/__nuxt`)||/\.\w{2,5}$/.test(i))return;let a=n.context.__fluenti_config??r(n);if(!a||a.strategy!==`prefix`&&a.strategy!==`prefix_and_default`)return;let o=i.split(`/`).filter(Boolean)[0];if(o&&a.locales.includes(o))return;let s=a.defaultLocale,c=a.queryParamKey??`locale`,l=(0,t.getQuery)(n)[c];if(typeof l==`string`&&a.locales.includes(l))s=l;else{let r=(0,t.getCookie)(n,a.detectBrowserLanguage?.cookieKey??`fluenti_locale`);if(r&&a.locales.includes(r))s=r;else{let r=(0,t.getHeader)(n,`accept-language`);if(r){let t=e.t(r,a.locales);t&&(s=t)}}}return(0,t.sendRedirect)(n,`/${s}${i===`/`?``:i}`,302)});function r(e){try{let t=(((e.context.nitro??e.context.__nitro)?.runtimeConfig??{}).public??{}).fluenti;return t&&(e.context.__fluenti_config=t),t}catch{return}}module.exports=n;
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`../path-utils-BQIsp_or.cjs`),t=require(`../locale-head-jGmp0Xnb.cjs`);require(`../module.cjs`);let n=require(`vue`);function r(t,n){return(r,i)=>e.n(r,i??t.value,n.defaultLocale,n.strategy)}function i(t,n){return r=>e.r(t.value,r,n.locales,n.defaultLocale,n.strategy)}function a(t,n,r){return(i,a)=>{let o=a??t.value;if(typeof i==`string`){let t=e.n(i,o,r.defaultLocale,r.strategy);return n.resolve(t)}if(`path`in i&&i.path){let t=e.n(i.path,o,r.defaultLocale,r.strategy);return n.resolve({...i,path:t})}return n.resolve(i)}}function o(e,r,i,a){return(0,n.computed)(()=>t.t(e.value,r.value,i,a))}exports.useLocaleHead=o,exports.useLocalePath=r,exports.useLocaleRoute=a,exports.useSwitchLocalePath=i;
|
|
2
|
-
//# sourceMappingURL=standalone-composables.cjs.map
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`../path-utils-BQIsp_or.cjs`),t=require(`../locale-head-jGmp0Xnb.cjs`);require(`../module.cjs`);let n=require(`vue`);function r(t,n){return(r,i)=>e.n(r,i??t.value,n.defaultLocale,n.strategy)}function i(t,n){return r=>e.r(t.value,r,n.locales,n.defaultLocale,n.strategy)}function a(t,n,r){return(i,a)=>{let o=a??t.value;if(typeof i==`string`){let t=e.n(i,o,r.defaultLocale,r.strategy);return n.resolve(t)}if(`path`in i&&i.path){let t=e.n(i.path,o,r.defaultLocale,r.strategy);return n.resolve({...i,path:t})}return n.resolve(i)}}function o(e,r,i,a){return(0,n.computed)(()=>t.t(e.value,r.value,i,a))}exports.useLocaleHead=o,exports.useLocalePath=r,exports.useLocaleRoute=a,exports.useSwitchLocalePath=i;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fluenti/nuxt",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.3",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Nuxt module for Fluenti — locale-prefixed routes, SEO helpers, auto locale detection",
|
|
6
6
|
"homepage": "https://fluenti.dev",
|
|
@@ -70,8 +70,8 @@
|
|
|
70
70
|
"dependencies": {
|
|
71
71
|
"@nuxt/kit": "^4.4.2",
|
|
72
72
|
"@nuxt/schema": "^4.4.2",
|
|
73
|
-
"@fluenti/core": "0.6.
|
|
74
|
-
"@fluenti/vue": "0.6.
|
|
73
|
+
"@fluenti/core": "0.6.3",
|
|
74
|
+
"@fluenti/vue": "0.6.3"
|
|
75
75
|
},
|
|
76
76
|
"devDependencies": {
|
|
77
77
|
"typescript": "^5.9",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"detectors-BBAX-ZGA.cjs","names":[],"sources":["../src/runtime/detectors/path.ts","../src/runtime/detectors/cookie.ts","../src/runtime/detectors/header.ts","../src/runtime/detectors/query.ts","../src/runtime/detectors/index.ts"],"sourcesContent":["import type { LocaleDetectContext } from '../../types'\nimport { extractLocaleFromPath } from '../path-utils'\n\n/** Detect locale from URL path prefix (e.g. /ja/about → 'ja') */\nexport default function detectPath(ctx: LocaleDetectContext): void {\n if (ctx.strategy === 'no_prefix') return\n const { locale } = extractLocaleFromPath(ctx.path, ctx.locales)\n if (locale) {\n ctx.setLocale(locale)\n }\n}\n","import { useCookie } from '#imports'\nimport type { LocaleDetectContext } from '../../types'\n\n/** Detect locale from cookie value */\nexport default function detectCookie(ctx: LocaleDetectContext): void {\n if (!ctx.detectBrowserLanguage?.useCookie) return\n\n // Prefer pre-read cookie value from plugin (hoisted before await)\n if (ctx.cookieValue !== undefined) {\n if (ctx.cookieValue && ctx.locales.includes(ctx.cookieValue)) {\n ctx.setLocale(ctx.cookieValue)\n }\n return\n }\n\n // Fallback: read cookie directly (works when called synchronously in plugin context)\n const cookieKey = ctx.detectBrowserLanguage.cookieKey ?? 'fluenti_locale'\n try {\n const cookie = useCookie(cookieKey)\n if (cookie.value && ctx.locales.includes(cookie.value)) {\n ctx.setLocale(cookie.value)\n }\n } catch {\n // useCookie may fail outside Nuxt context\n }\n}\n","import { useRequestHeaders } from '#imports'\nimport type { LocaleDetectContext } from '../../types'\nimport { parseAcceptLanguage } from '../utils/parse-accept-language'\n\n/** Detect locale from Accept-Language header (SSR only) */\nexport default function detectHeader(ctx: LocaleDetectContext): void {\n if (!ctx.isServer) return\n\n // Prefer pre-read header from plugin (hoisted before await)\n const acceptLang = ctx.acceptLanguage ?? readAcceptLanguage()\n if (acceptLang) {\n const matched = parseAcceptLanguage(acceptLang, ctx.locales)\n if (matched) {\n ctx.setLocale(matched)\n }\n }\n}\n\nfunction readAcceptLanguage(): string | undefined {\n try {\n const headers = useRequestHeaders(['accept-language'])\n return headers['accept-language']\n } catch {\n return undefined\n }\n}\n","import { useRoute, useRuntimeConfig } from '#imports'\nimport type { LocaleDetectContext } from '../../types'\nimport type { FluentNuxtRuntimeConfig } from '../../types'\n\n/** Detect locale from query parameter (e.g. ?locale=ja) */\nexport default function detectQuery(ctx: LocaleDetectContext): void {\n try {\n const route = useRoute()\n const config = useRuntimeConfig().public['fluenti'] as FluentNuxtRuntimeConfig\n const paramKey = config.queryParamKey ?? 'locale'\n const queryLocale = route.query[paramKey] as string | undefined\n if (queryLocale && ctx.locales.includes(queryLocale)) {\n ctx.setLocale(queryLocale)\n }\n } catch {\n // May fail outside Nuxt context\n }\n}\n","import type { LocaleDetectContext, LocaleDetectorFn, FluentNuxtRuntimeConfig } from '../../types'\nimport detectPath from './path'\nimport detectCookie from './cookie'\nimport detectHeader from './header'\nimport detectQuery from './query'\nimport detectDomain from './domain'\n\n/** Map of built-in detector names to their implementations */\nconst builtinDetectors: Record<string, LocaleDetectorFn> = {\n path: detectPath,\n cookie: detectCookie,\n header: detectHeader,\n query: detectQuery,\n domain: detectDomain,\n}\n\n/**\n * Run the detection chain: iterate through detectOrder, then fire the hook.\n *\n * Returns the detected locale or the defaultLocale as fallback.\n */\nexport async function runDetectors(\n path: string,\n config: FluentNuxtRuntimeConfig,\n customDetectors?: Map<string, LocaleDetectorFn>,\n hookFn?: (ctx: LocaleDetectContext) => void | Promise<void>,\n host?: string,\n cookieValue?: string | null,\n acceptLanguage?: string,\n): Promise<string> {\n let resolved: string | null = null\n let stopped = false\n\n const ctx: LocaleDetectContext = {\n path,\n locales: config.locales,\n defaultLocale: config.defaultLocale,\n strategy: config.strategy,\n ...(config.detectBrowserLanguage ? { detectBrowserLanguage: config.detectBrowserLanguage } : {}),\n detectedLocale: null,\n setLocale(locale: string) {\n if (config.locales.includes(locale)) {\n resolved = locale\n ctx.detectedLocale = locale\n stopped = true\n }\n },\n isServer: import.meta.server ?? false,\n ...(host ? { host } : {}),\n ...(cookieValue != null ? { cookieValue } : {}),\n ...(acceptLanguage ? { acceptLanguage } : {}),\n }\n\n // Attach domains to context for domain detector\n if (config.domains) {\n Object.assign(ctx, { domains: config.domains })\n }\n\n // 1. Run detectors in order\n for (const name of config.detectOrder) {\n if (stopped) break\n\n const detector = builtinDetectors[name] ?? customDetectors?.get(name)\n if (detector) {\n await detector(ctx)\n }\n }\n\n // 2. Fire the hook — allows overriding or supplementing the detection chain\n if (hookFn && !stopped) {\n await hookFn(ctx)\n }\n\n // 3. Fallback\n return resolved ?? config.detectBrowserLanguage?.fallbackLocale ?? config.defaultLocale\n}\n\nexport { builtinDetectors }\nexport type { LocaleDetectContext, LocaleDetectorFn }\n"],"mappings":"mMAIA,SAAwB,EAAW,EAAgC,CACjE,GAAI,EAAI,WAAa,YAAa,OAClC,GAAM,CAAE,UAAW,EAAA,EAAsB,EAAI,KAAM,EAAI,QAAQ,CAC3D,GACF,EAAI,UAAU,EAAO,CCJzB,SAAwB,EAAa,EAAgC,CACnE,GAAI,CAAC,EAAI,uBAAuB,UAAW,OAG3C,GAAI,EAAI,cAAgB,IAAA,GAAW,CAC7B,EAAI,aAAe,EAAI,QAAQ,SAAS,EAAI,YAAY,EAC1D,EAAI,UAAU,EAAI,YAAY,CAEhC,OAIF,IAAM,EAAY,EAAI,sBAAsB,WAAa,iBACzD,GAAI,CACF,IAAM,GAAA,EAAA,EAAA,WAAmB,EAAU,CAC/B,EAAO,OAAS,EAAI,QAAQ,SAAS,EAAO,MAAM,EACpD,EAAI,UAAU,EAAO,MAAM,MAEvB,GCjBV,SAAwB,EAAa,EAAgC,CACnE,GAAI,CAAC,EAAI,SAAU,OAGnB,IAAM,EAAa,EAAI,gBAAkB,GAAoB,CAC7D,GAAI,EAAY,CACd,IAAM,EAAU,EAAA,EAAoB,EAAY,EAAI,QAAQ,CACxD,GACF,EAAI,UAAU,EAAQ,EAK5B,SAAS,GAAyC,CAChD,GAAI,CAEF,OAAA,EAAA,EAAA,mBADkC,CAAC,kBAAkB,CAAC,CACvC,wBACT,CACN,QClBJ,SAAwB,EAAY,EAAgC,CAClE,GAAI,CACF,IAAM,GAAA,EAAA,EAAA,WAAkB,CAElB,GAAA,EAAA,EAAA,mBAD2B,CAAC,OAAO,QACjB,eAAiB,SACnC,EAAc,EAAM,MAAM,GAC5B,GAAe,EAAI,QAAQ,SAAS,EAAY,EAClD,EAAI,UAAU,EAAY,MAEtB,GCNV,IAAM,EAAqD,CACzD,KAAM,EACN,OAAQ,EACR,OAAQ,EACR,MAAO,EACP,OAAQ,EACT,CAOD,eAAsB,EACpB,EACA,EACA,EACA,EACA,EACA,EACA,EACiB,CACjB,IAAI,EAA0B,KAC1B,EAAU,GAER,EAA2B,CAC/B,OACA,QAAS,EAAO,QAChB,cAAe,EAAO,cACtB,SAAU,EAAO,SACjB,GAAI,EAAO,sBAAwB,CAAE,sBAAuB,EAAO,sBAAuB,CAAG,EAAE,CAC/F,eAAgB,KAChB,UAAU,EAAgB,CACpB,EAAO,QAAQ,SAAS,EAAO,GACjC,EAAW,EACX,EAAI,eAAiB,EACrB,EAAU,KAGd,SAAA,EAAA,CAAsB,QAAU,GAChC,GAAI,EAAO,CAAE,OAAM,CAAG,EAAE,CACxB,GAAI,GAAe,KAAyB,EAAE,CAApB,CAAE,cAAa,CACzC,GAAI,EAAiB,CAAE,iBAAgB,CAAG,EAAE,CAC7C,CAGG,EAAO,SACT,OAAO,OAAO,EAAK,CAAE,QAAS,EAAO,QAAS,CAAC,CAIjD,IAAK,IAAM,KAAQ,EAAO,YAAa,CACrC,GAAI,EAAS,MAEb,IAAM,EAAW,EAAiB,IAAS,GAAiB,IAAI,EAAK,CACjE,GACF,MAAM,EAAS,EAAI,CAUvB,OALI,GAAU,CAAC,GACb,MAAM,EAAO,EAAI,CAIZ,GAAY,EAAO,uBAAuB,gBAAkB,EAAO"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"detectors-Ds481Wx6.js","names":[],"sources":["../src/runtime/detectors/path.ts","../src/runtime/detectors/cookie.ts","../src/runtime/detectors/header.ts","../src/runtime/detectors/query.ts","../src/runtime/detectors/index.ts"],"sourcesContent":["import type { LocaleDetectContext } from '../../types'\nimport { extractLocaleFromPath } from '../path-utils'\n\n/** Detect locale from URL path prefix (e.g. /ja/about → 'ja') */\nexport default function detectPath(ctx: LocaleDetectContext): void {\n if (ctx.strategy === 'no_prefix') return\n const { locale } = extractLocaleFromPath(ctx.path, ctx.locales)\n if (locale) {\n ctx.setLocale(locale)\n }\n}\n","import { useCookie } from '#imports'\nimport type { LocaleDetectContext } from '../../types'\n\n/** Detect locale from cookie value */\nexport default function detectCookie(ctx: LocaleDetectContext): void {\n if (!ctx.detectBrowserLanguage?.useCookie) return\n\n // Prefer pre-read cookie value from plugin (hoisted before await)\n if (ctx.cookieValue !== undefined) {\n if (ctx.cookieValue && ctx.locales.includes(ctx.cookieValue)) {\n ctx.setLocale(ctx.cookieValue)\n }\n return\n }\n\n // Fallback: read cookie directly (works when called synchronously in plugin context)\n const cookieKey = ctx.detectBrowserLanguage.cookieKey ?? 'fluenti_locale'\n try {\n const cookie = useCookie(cookieKey)\n if (cookie.value && ctx.locales.includes(cookie.value)) {\n ctx.setLocale(cookie.value)\n }\n } catch {\n // useCookie may fail outside Nuxt context\n }\n}\n","import { useRequestHeaders } from '#imports'\nimport type { LocaleDetectContext } from '../../types'\nimport { parseAcceptLanguage } from '../utils/parse-accept-language'\n\n/** Detect locale from Accept-Language header (SSR only) */\nexport default function detectHeader(ctx: LocaleDetectContext): void {\n if (!ctx.isServer) return\n\n // Prefer pre-read header from plugin (hoisted before await)\n const acceptLang = ctx.acceptLanguage ?? readAcceptLanguage()\n if (acceptLang) {\n const matched = parseAcceptLanguage(acceptLang, ctx.locales)\n if (matched) {\n ctx.setLocale(matched)\n }\n }\n}\n\nfunction readAcceptLanguage(): string | undefined {\n try {\n const headers = useRequestHeaders(['accept-language'])\n return headers['accept-language']\n } catch {\n return undefined\n }\n}\n","import { useRoute, useRuntimeConfig } from '#imports'\nimport type { LocaleDetectContext } from '../../types'\nimport type { FluentNuxtRuntimeConfig } from '../../types'\n\n/** Detect locale from query parameter (e.g. ?locale=ja) */\nexport default function detectQuery(ctx: LocaleDetectContext): void {\n try {\n const route = useRoute()\n const config = useRuntimeConfig().public['fluenti'] as FluentNuxtRuntimeConfig\n const paramKey = config.queryParamKey ?? 'locale'\n const queryLocale = route.query[paramKey] as string | undefined\n if (queryLocale && ctx.locales.includes(queryLocale)) {\n ctx.setLocale(queryLocale)\n }\n } catch {\n // May fail outside Nuxt context\n }\n}\n","import type { LocaleDetectContext, LocaleDetectorFn, FluentNuxtRuntimeConfig } from '../../types'\nimport detectPath from './path'\nimport detectCookie from './cookie'\nimport detectHeader from './header'\nimport detectQuery from './query'\nimport detectDomain from './domain'\n\n/** Map of built-in detector names to their implementations */\nconst builtinDetectors: Record<string, LocaleDetectorFn> = {\n path: detectPath,\n cookie: detectCookie,\n header: detectHeader,\n query: detectQuery,\n domain: detectDomain,\n}\n\n/**\n * Run the detection chain: iterate through detectOrder, then fire the hook.\n *\n * Returns the detected locale or the defaultLocale as fallback.\n */\nexport async function runDetectors(\n path: string,\n config: FluentNuxtRuntimeConfig,\n customDetectors?: Map<string, LocaleDetectorFn>,\n hookFn?: (ctx: LocaleDetectContext) => void | Promise<void>,\n host?: string,\n cookieValue?: string | null,\n acceptLanguage?: string,\n): Promise<string> {\n let resolved: string | null = null\n let stopped = false\n\n const ctx: LocaleDetectContext = {\n path,\n locales: config.locales,\n defaultLocale: config.defaultLocale,\n strategy: config.strategy,\n ...(config.detectBrowserLanguage ? { detectBrowserLanguage: config.detectBrowserLanguage } : {}),\n detectedLocale: null,\n setLocale(locale: string) {\n if (config.locales.includes(locale)) {\n resolved = locale\n ctx.detectedLocale = locale\n stopped = true\n }\n },\n isServer: import.meta.server ?? false,\n ...(host ? { host } : {}),\n ...(cookieValue != null ? { cookieValue } : {}),\n ...(acceptLanguage ? { acceptLanguage } : {}),\n }\n\n // Attach domains to context for domain detector\n if (config.domains) {\n Object.assign(ctx, { domains: config.domains })\n }\n\n // 1. Run detectors in order\n for (const name of config.detectOrder) {\n if (stopped) break\n\n const detector = builtinDetectors[name] ?? customDetectors?.get(name)\n if (detector) {\n await detector(ctx)\n }\n }\n\n // 2. Fire the hook — allows overriding or supplementing the detection chain\n if (hookFn && !stopped) {\n await hookFn(ctx)\n }\n\n // 3. Fallback\n return resolved ?? config.detectBrowserLanguage?.fallbackLocale ?? config.defaultLocale\n}\n\nexport { builtinDetectors }\nexport type { LocaleDetectContext, LocaleDetectorFn }\n"],"mappings":";;;;;AAIA,SAAwB,EAAW,GAAgC;AACjE,KAAI,EAAI,aAAa,YAAa;CAClC,IAAM,EAAE,cAAW,EAAsB,EAAI,MAAM,EAAI,QAAQ;AAC/D,CAAI,KACF,EAAI,UAAU,EAAO;;;;ACJzB,SAAwB,EAAa,GAAgC;AACnE,KAAI,CAAC,EAAI,uBAAuB,UAAW;AAG3C,KAAI,EAAI,gBAAgB,KAAA,GAAW;AACjC,EAAI,EAAI,eAAe,EAAI,QAAQ,SAAS,EAAI,YAAY,IAC1D,EAAI,UAAU,EAAI,YAAY;AAEhC;;CAIF,IAAM,IAAY,EAAI,sBAAsB,aAAa;AACzD,KAAI;EACF,IAAM,IAAS,EAAU,EAAU;AACnC,EAAI,EAAO,SAAS,EAAI,QAAQ,SAAS,EAAO,MAAM,IACpD,EAAI,UAAU,EAAO,MAAM;SAEvB;;;;ACjBV,SAAwB,EAAa,GAAgC;AACnE,KAAI,CAAC,EAAI,SAAU;CAGnB,IAAM,IAAa,EAAI,kBAAkB,GAAoB;AAC7D,KAAI,GAAY;EACd,IAAM,IAAU,EAAoB,GAAY,EAAI,QAAQ;AAC5D,EAAI,KACF,EAAI,UAAU,EAAQ;;;AAK5B,SAAS,IAAyC;AAChD,KAAI;AAEF,SADgB,EAAkB,CAAC,kBAAkB,CAAC,CACvC;SACT;AACN;;;;;AClBJ,SAAwB,EAAY,GAAgC;AAClE,KAAI;EACF,IAAM,IAAQ,GAAU,EAElB,IADS,GAAkB,CAAC,OAAO,QACjB,iBAAiB,UACnC,IAAc,EAAM,MAAM;AAChC,EAAI,KAAe,EAAI,QAAQ,SAAS,EAAY,IAClD,EAAI,UAAU,EAAY;SAEtB;;;;ACNV,IAAM,IAAqD;CACzD,MAAM;CACN,QAAQ;CACR,QAAQ;CACR,OAAO;CACP,QAAQ;CACT;AAOD,eAAsB,EACpB,GACA,GACA,GACA,GACA,GACA,GACA,GACiB;CACjB,IAAI,IAA0B,MAC1B,IAAU,IAER,IAA2B;EAC/B;EACA,SAAS,EAAO;EAChB,eAAe,EAAO;EACtB,UAAU,EAAO;EACjB,GAAI,EAAO,wBAAwB,EAAE,uBAAuB,EAAO,uBAAuB,GAAG,EAAE;EAC/F,gBAAgB;EAChB,UAAU,GAAgB;AACxB,GAAI,EAAO,QAAQ,SAAS,EAAO,KACjC,IAAW,GACX,EAAI,iBAAiB,GACrB,IAAU;;EAGd,UAAU,OAAO,KAAK,UAAU;EAChC,GAAI,IAAO,EAAE,SAAM,GAAG,EAAE;EACxB,GAAI,KAAe,OAAyB,EAAE,GAApB,EAAE,gBAAa;EACzC,GAAI,IAAiB,EAAE,mBAAgB,GAAG,EAAE;EAC7C;AAGD,CAAI,EAAO,WACT,OAAO,OAAO,GAAK,EAAE,SAAS,EAAO,SAAS,CAAC;AAIjD,MAAK,IAAM,KAAQ,EAAO,aAAa;AACrC,MAAI,EAAS;EAEb,IAAM,IAAW,EAAiB,MAAS,GAAiB,IAAI,EAAK;AACrE,EAAI,KACF,MAAM,EAAS,EAAI;;AAUvB,QALI,KAAU,CAAC,KACb,MAAM,EAAO,EAAI,EAIZ,KAAY,EAAO,uBAAuB,kBAAkB,EAAO"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"locale-head-Ezrd93Ax.js","names":[],"sources":["../src/runtime/locale-head.ts"],"sourcesContent":["import { switchLocalePath } from './path-utils'\nimport type { FluentNuxtRuntimeConfig } from '../types'\n\n/**\n * Safely construct an href from a base URL and path.\n * Guards against protocol injection and malformed URLs.\n */\nfunction buildSafeHref(baseUrl: string, path: string): string {\n if (!baseUrl) return path\n try {\n const url = new URL(path, baseUrl)\n if (url.protocol !== 'http:' && url.protocol !== 'https:') {\n return path\n }\n return url.href\n } catch {\n return path\n }\n}\n\n/** Head metadata for locale SEO */\nexport interface LocaleHeadMeta {\n htmlAttrs: { lang: string; dir?: string }\n link: Array<{ rel: string; hreflang: string; href: string }>\n meta: Array<{ property: string; content: string }>\n}\n\nexport interface LocaleHeadOptions {\n /** Add hreflang and og:locale SEO attributes */\n addSeoAttributes?: boolean\n /** Base URL for absolute hreflang links (e.g. 'https://example.com') */\n baseUrl?: string\n /** Add a canonical link tag for the current page (default: true when addSeoAttributes is true) */\n addCanonical?: boolean\n}\n\n/**\n * Pure function that builds locale-aware HTML head metadata.\n *\n * This is the framework-agnostic core logic. For the Nuxt composable,\n * use `useLocaleHead()` from `composables.ts` instead.\n */\nexport function buildLocaleHead(\n locale: string,\n currentPath: string,\n config: FluentNuxtRuntimeConfig,\n options?: LocaleHeadOptions,\n): LocaleHeadMeta {\n const props = config.localeProperties?.[locale]\n const isoTag = props?.iso ?? locale\n\n const head: LocaleHeadMeta = {\n htmlAttrs: {\n lang: isoTag,\n ...(props?.dir ? { dir: props.dir } : {}),\n },\n link: [],\n meta: [],\n }\n\n if (options?.addSeoAttributes) {\n const baseUrl = options.baseUrl ?? ''\n\n // Memoize domain lookups to avoid repeated .find() calls\n const domainMap = config.domains?.length\n ? new Map(config.domains.map(d => [d.locale, d]))\n : null\n\n // hreflang alternate links for each locale\n for (const loc of config.locales) {\n const locProps = config.localeProperties?.[loc]\n const locIso = locProps?.iso ?? loc\n\n if (config.strategy === 'domains' && domainMap) {\n // For domain strategy, build absolute URLs using domain configs\n const domainEntry = domainMap?.get(loc)\n if (domainEntry) {\n const protocol = baseUrl.startsWith('https') ? 'https' : 'http'\n head.link.push({\n rel: 'alternate',\n hreflang: locIso,\n href: buildSafeHref(`${protocol}://${domainEntry.domain}`, currentPath),\n })\n }\n } else {\n const path = switchLocalePath(\n currentPath,\n loc,\n config.locales,\n config.defaultLocale,\n config.strategy,\n )\n head.link.push({\n rel: 'alternate',\n hreflang: locIso,\n href: buildSafeHref(baseUrl, path),\n })\n }\n }\n\n // x-default hreflang\n if (config.strategy === 'domains' && domainMap) {\n const defaultDomain = domainMap?.get(config.defaultLocale)\n if (defaultDomain) {\n const protocol = baseUrl.startsWith('https') ? 'https' : 'http'\n head.link.push({\n rel: 'alternate',\n hreflang: 'x-default',\n href: buildSafeHref(`${protocol}://${defaultDomain.domain}`, currentPath),\n })\n }\n } else {\n const defaultPath = switchLocalePath(\n currentPath,\n config.defaultLocale,\n config.locales,\n config.defaultLocale,\n config.strategy,\n )\n head.link.push({\n rel: 'alternate',\n hreflang: 'x-default',\n href: buildSafeHref(baseUrl, defaultPath),\n })\n }\n\n // Canonical link tag (defaults to true when addSeoAttributes is enabled)\n if (options.addCanonical !== false) {\n if (config.strategy === 'domains' && domainMap) {\n const domainEntry = domainMap?.get(locale)\n if (domainEntry) {\n const protocol = baseUrl.startsWith('https') ? 'https' : 'http'\n head.link.push({\n rel: 'canonical',\n hreflang: '',\n href: buildSafeHref(`${protocol}://${domainEntry.domain}`, currentPath),\n })\n }\n } else {\n const canonicalPath = switchLocalePath(\n currentPath,\n locale,\n config.locales,\n config.defaultLocale,\n config.strategy,\n )\n head.link.push({\n rel: 'canonical',\n hreflang: '',\n href: buildSafeHref(baseUrl, canonicalPath),\n })\n }\n }\n\n // og:locale (use ISO tag if available)\n head.meta.push({ property: 'og:locale', content: isoTag })\n\n // og:locale:alternate for other locales\n for (const loc of config.locales) {\n if (loc !== locale) {\n const locProps = config.localeProperties?.[loc]\n head.meta.push({\n property: 'og:locale:alternate',\n content: locProps?.iso ?? loc,\n })\n }\n }\n }\n\n return head\n}\n"],"mappings":";;AAOA,SAAS,EAAc,GAAiB,GAAsB;AAC5D,KAAI,CAAC,EAAS,QAAO;AACrB,KAAI;EACF,IAAM,IAAM,IAAI,IAAI,GAAM,EAAQ;AAIlC,SAHI,EAAI,aAAa,WAAW,EAAI,aAAa,WACxC,IAEF,EAAI;SACL;AACN,SAAO;;;AA0BX,SAAgB,EACd,GACA,GACA,GACA,GACgB;CAChB,IAAM,IAAQ,EAAO,mBAAmB,IAClC,IAAS,GAAO,OAAO,GAEvB,IAAuB;EAC3B,WAAW;GACT,MAAM;GACN,GAAI,GAAO,MAAM,EAAE,KAAK,EAAM,KAAK,GAAG,EAAE;GACzC;EACD,MAAM,EAAE;EACR,MAAM,EAAE;EACT;AAED,KAAI,GAAS,kBAAkB;EAC7B,IAAM,IAAU,EAAQ,WAAW,IAG7B,IAAY,EAAO,SAAS,SAC9B,IAAI,IAAI,EAAO,QAAQ,KAAI,MAAK,CAAC,EAAE,QAAQ,EAAE,CAAC,CAAC,GAC/C;AAGJ,OAAK,IAAM,KAAO,EAAO,SAAS;GAEhC,IAAM,IADW,EAAO,mBAAmB,IAClB,OAAO;AAEhC,OAAI,EAAO,aAAa,aAAa,GAAW;IAE9C,IAAM,IAAc,GAAW,IAAI,EAAI;AACvC,QAAI,GAAa;KACf,IAAM,IAAW,EAAQ,WAAW,QAAQ,GAAG,UAAU;AACzD,OAAK,KAAK,KAAK;MACb,KAAK;MACL,UAAU;MACV,MAAM,EAAc,GAAG,EAAS,KAAK,EAAY,UAAU,EAAY;MACxE,CAAC;;UAEC;IACL,IAAM,IAAO,EACX,GACA,GACA,EAAO,SACP,EAAO,eACP,EAAO,SACR;AACD,MAAK,KAAK,KAAK;KACb,KAAK;KACL,UAAU;KACV,MAAM,EAAc,GAAS,EAAK;KACnC,CAAC;;;AAKN,MAAI,EAAO,aAAa,aAAa,GAAW;GAC9C,IAAM,IAAgB,GAAW,IAAI,EAAO,cAAc;AAC1D,OAAI,GAAe;IACjB,IAAM,IAAW,EAAQ,WAAW,QAAQ,GAAG,UAAU;AACzD,MAAK,KAAK,KAAK;KACb,KAAK;KACL,UAAU;KACV,MAAM,EAAc,GAAG,EAAS,KAAK,EAAc,UAAU,EAAY;KAC1E,CAAC;;SAEC;GACL,IAAM,IAAc,EAClB,GACA,EAAO,eACP,EAAO,SACP,EAAO,eACP,EAAO,SACR;AACD,KAAK,KAAK,KAAK;IACb,KAAK;IACL,UAAU;IACV,MAAM,EAAc,GAAS,EAAY;IAC1C,CAAC;;AAIJ,MAAI,EAAQ,iBAAiB,GAC3B,KAAI,EAAO,aAAa,aAAa,GAAW;GAC9C,IAAM,IAAc,GAAW,IAAI,EAAO;AAC1C,OAAI,GAAa;IACf,IAAM,IAAW,EAAQ,WAAW,QAAQ,GAAG,UAAU;AACzD,MAAK,KAAK,KAAK;KACb,KAAK;KACL,UAAU;KACV,MAAM,EAAc,GAAG,EAAS,KAAK,EAAY,UAAU,EAAY;KACxE,CAAC;;SAEC;GACL,IAAM,IAAgB,EACpB,GACA,GACA,EAAO,SACP,EAAO,eACP,EAAO,SACR;AACD,KAAK,KAAK,KAAK;IACb,KAAK;IACL,UAAU;IACV,MAAM,EAAc,GAAS,EAAc;IAC5C,CAAC;;AAKN,IAAK,KAAK,KAAK;GAAE,UAAU;GAAa,SAAS;GAAQ,CAAC;AAG1D,OAAK,IAAM,KAAO,EAAO,QACvB,KAAI,MAAQ,GAAQ;GAClB,IAAM,IAAW,EAAO,mBAAmB;AAC3C,KAAK,KAAK,KAAK;IACb,UAAU;IACV,SAAS,GAAU,OAAO;IAC3B,CAAC;;;AAKR,QAAO"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"locale-head-jGmp0Xnb.cjs","names":[],"sources":["../src/runtime/locale-head.ts"],"sourcesContent":["import { switchLocalePath } from './path-utils'\nimport type { FluentNuxtRuntimeConfig } from '../types'\n\n/**\n * Safely construct an href from a base URL and path.\n * Guards against protocol injection and malformed URLs.\n */\nfunction buildSafeHref(baseUrl: string, path: string): string {\n if (!baseUrl) return path\n try {\n const url = new URL(path, baseUrl)\n if (url.protocol !== 'http:' && url.protocol !== 'https:') {\n return path\n }\n return url.href\n } catch {\n return path\n }\n}\n\n/** Head metadata for locale SEO */\nexport interface LocaleHeadMeta {\n htmlAttrs: { lang: string; dir?: string }\n link: Array<{ rel: string; hreflang: string; href: string }>\n meta: Array<{ property: string; content: string }>\n}\n\nexport interface LocaleHeadOptions {\n /** Add hreflang and og:locale SEO attributes */\n addSeoAttributes?: boolean\n /** Base URL for absolute hreflang links (e.g. 'https://example.com') */\n baseUrl?: string\n /** Add a canonical link tag for the current page (default: true when addSeoAttributes is true) */\n addCanonical?: boolean\n}\n\n/**\n * Pure function that builds locale-aware HTML head metadata.\n *\n * This is the framework-agnostic core logic. For the Nuxt composable,\n * use `useLocaleHead()` from `composables.ts` instead.\n */\nexport function buildLocaleHead(\n locale: string,\n currentPath: string,\n config: FluentNuxtRuntimeConfig,\n options?: LocaleHeadOptions,\n): LocaleHeadMeta {\n const props = config.localeProperties?.[locale]\n const isoTag = props?.iso ?? locale\n\n const head: LocaleHeadMeta = {\n htmlAttrs: {\n lang: isoTag,\n ...(props?.dir ? { dir: props.dir } : {}),\n },\n link: [],\n meta: [],\n }\n\n if (options?.addSeoAttributes) {\n const baseUrl = options.baseUrl ?? ''\n\n // Memoize domain lookups to avoid repeated .find() calls\n const domainMap = config.domains?.length\n ? new Map(config.domains.map(d => [d.locale, d]))\n : null\n\n // hreflang alternate links for each locale\n for (const loc of config.locales) {\n const locProps = config.localeProperties?.[loc]\n const locIso = locProps?.iso ?? loc\n\n if (config.strategy === 'domains' && domainMap) {\n // For domain strategy, build absolute URLs using domain configs\n const domainEntry = domainMap?.get(loc)\n if (domainEntry) {\n const protocol = baseUrl.startsWith('https') ? 'https' : 'http'\n head.link.push({\n rel: 'alternate',\n hreflang: locIso,\n href: buildSafeHref(`${protocol}://${domainEntry.domain}`, currentPath),\n })\n }\n } else {\n const path = switchLocalePath(\n currentPath,\n loc,\n config.locales,\n config.defaultLocale,\n config.strategy,\n )\n head.link.push({\n rel: 'alternate',\n hreflang: locIso,\n href: buildSafeHref(baseUrl, path),\n })\n }\n }\n\n // x-default hreflang\n if (config.strategy === 'domains' && domainMap) {\n const defaultDomain = domainMap?.get(config.defaultLocale)\n if (defaultDomain) {\n const protocol = baseUrl.startsWith('https') ? 'https' : 'http'\n head.link.push({\n rel: 'alternate',\n hreflang: 'x-default',\n href: buildSafeHref(`${protocol}://${defaultDomain.domain}`, currentPath),\n })\n }\n } else {\n const defaultPath = switchLocalePath(\n currentPath,\n config.defaultLocale,\n config.locales,\n config.defaultLocale,\n config.strategy,\n )\n head.link.push({\n rel: 'alternate',\n hreflang: 'x-default',\n href: buildSafeHref(baseUrl, defaultPath),\n })\n }\n\n // Canonical link tag (defaults to true when addSeoAttributes is enabled)\n if (options.addCanonical !== false) {\n if (config.strategy === 'domains' && domainMap) {\n const domainEntry = domainMap?.get(locale)\n if (domainEntry) {\n const protocol = baseUrl.startsWith('https') ? 'https' : 'http'\n head.link.push({\n rel: 'canonical',\n hreflang: '',\n href: buildSafeHref(`${protocol}://${domainEntry.domain}`, currentPath),\n })\n }\n } else {\n const canonicalPath = switchLocalePath(\n currentPath,\n locale,\n config.locales,\n config.defaultLocale,\n config.strategy,\n )\n head.link.push({\n rel: 'canonical',\n hreflang: '',\n href: buildSafeHref(baseUrl, canonicalPath),\n })\n }\n }\n\n // og:locale (use ISO tag if available)\n head.meta.push({ property: 'og:locale', content: isoTag })\n\n // og:locale:alternate for other locales\n for (const loc of config.locales) {\n if (loc !== locale) {\n const locProps = config.localeProperties?.[loc]\n head.meta.push({\n property: 'og:locale:alternate',\n content: locProps?.iso ?? loc,\n })\n }\n }\n }\n\n return head\n}\n"],"mappings":"6CAOA,SAAS,EAAc,EAAiB,EAAsB,CAC5D,GAAI,CAAC,EAAS,OAAO,EACrB,GAAI,CACF,IAAM,EAAM,IAAI,IAAI,EAAM,EAAQ,CAIlC,OAHI,EAAI,WAAa,SAAW,EAAI,WAAa,SACxC,EAEF,EAAI,UACL,CACN,OAAO,GA0BX,SAAgB,EACd,EACA,EACA,EACA,EACgB,CAChB,IAAM,EAAQ,EAAO,mBAAmB,GAClC,EAAS,GAAO,KAAO,EAEvB,EAAuB,CAC3B,UAAW,CACT,KAAM,EACN,GAAI,GAAO,IAAM,CAAE,IAAK,EAAM,IAAK,CAAG,EAAE,CACzC,CACD,KAAM,EAAE,CACR,KAAM,EAAE,CACT,CAED,GAAI,GAAS,iBAAkB,CAC7B,IAAM,EAAU,EAAQ,SAAW,GAG7B,EAAY,EAAO,SAAS,OAC9B,IAAI,IAAI,EAAO,QAAQ,IAAI,GAAK,CAAC,EAAE,OAAQ,EAAE,CAAC,CAAC,CAC/C,KAGJ,IAAK,IAAM,KAAO,EAAO,QAAS,CAEhC,IAAM,EADW,EAAO,mBAAmB,IAClB,KAAO,EAEhC,GAAI,EAAO,WAAa,WAAa,EAAW,CAE9C,IAAM,EAAc,GAAW,IAAI,EAAI,CACvC,GAAI,EAAa,CACf,IAAM,EAAW,EAAQ,WAAW,QAAQ,CAAG,QAAU,OACzD,EAAK,KAAK,KAAK,CACb,IAAK,YACL,SAAU,EACV,KAAM,EAAc,GAAG,EAAS,KAAK,EAAY,SAAU,EAAY,CACxE,CAAC,MAEC,CACL,IAAM,EAAO,EAAA,EACX,EACA,EACA,EAAO,QACP,EAAO,cACP,EAAO,SACR,CACD,EAAK,KAAK,KAAK,CACb,IAAK,YACL,SAAU,EACV,KAAM,EAAc,EAAS,EAAK,CACnC,CAAC,EAKN,GAAI,EAAO,WAAa,WAAa,EAAW,CAC9C,IAAM,EAAgB,GAAW,IAAI,EAAO,cAAc,CAC1D,GAAI,EAAe,CACjB,IAAM,EAAW,EAAQ,WAAW,QAAQ,CAAG,QAAU,OACzD,EAAK,KAAK,KAAK,CACb,IAAK,YACL,SAAU,YACV,KAAM,EAAc,GAAG,EAAS,KAAK,EAAc,SAAU,EAAY,CAC1E,CAAC,MAEC,CACL,IAAM,EAAc,EAAA,EAClB,EACA,EAAO,cACP,EAAO,QACP,EAAO,cACP,EAAO,SACR,CACD,EAAK,KAAK,KAAK,CACb,IAAK,YACL,SAAU,YACV,KAAM,EAAc,EAAS,EAAY,CAC1C,CAAC,CAIJ,GAAI,EAAQ,eAAiB,GAC3B,GAAI,EAAO,WAAa,WAAa,EAAW,CAC9C,IAAM,EAAc,GAAW,IAAI,EAAO,CAC1C,GAAI,EAAa,CACf,IAAM,EAAW,EAAQ,WAAW,QAAQ,CAAG,QAAU,OACzD,EAAK,KAAK,KAAK,CACb,IAAK,YACL,SAAU,GACV,KAAM,EAAc,GAAG,EAAS,KAAK,EAAY,SAAU,EAAY,CACxE,CAAC,MAEC,CACL,IAAM,EAAgB,EAAA,EACpB,EACA,EACA,EAAO,QACP,EAAO,cACP,EAAO,SACR,CACD,EAAK,KAAK,KAAK,CACb,IAAK,YACL,SAAU,GACV,KAAM,EAAc,EAAS,EAAc,CAC5C,CAAC,CAKN,EAAK,KAAK,KAAK,CAAE,SAAU,YAAa,QAAS,EAAQ,CAAC,CAG1D,IAAK,IAAM,KAAO,EAAO,QACvB,GAAI,IAAQ,EAAQ,CAClB,IAAM,EAAW,EAAO,mBAAmB,GAC3C,EAAK,KAAK,KAAK,CACb,SAAU,sBACV,QAAS,GAAU,KAAO,EAC3B,CAAC,EAKR,OAAO"}
|