@lucidcms/core
Version:
The core of the Lucid CMS. It's responsible for spinning up the API and serving the CMS.
2 lines • 1.04 kB
JavaScript
import{createTranslationStore as e}from"./store.mjs";const t=e({defaultLocale:`en`,bundles:{}}),n=e=>{let t=e.config.i18n.locales.map(e=>e.code);if(e.locale&&t.includes(e.locale))return e.locale;for(let n of a(e.acceptLanguage)){if(t.includes(n))return n;let e=n.split(`-`)[0];if(e&&t.includes(e))return e}return e.config.i18n.defaultLocale};function r(e,n){return t.copy(e,{locale:n?.locale,options:{data:n?.data,defaultMessage:n?.defaultMessage}})}const i=e=>{let t=(t,n,r)=>e.store.copy(n,{locale:t,options:r});return Object.assign(((n,r)=>t(e.locale,n,r)),{locale:e.locale,forLocale:t=>i({store:e.store,locale:t}),adminBundle:()=>e.store.admin({locale:e.locale}),english:((e,n)=>t(`en`,e,n))})},a=e=>e?e.split(`,`).map(e=>{let[t,n]=e.trim().split(/\s*;\s*q=/);return{locale:t?.trim(),quality:n?Number.parseFloat(n):1}}).filter(e=>!!e.locale&&Number.isFinite(e.quality)).sort((e,t)=>t.quality-e.quality).map(e=>e.locale):[];export{i as createTranslator,n as resolveInterfaceLocale,r as translate};
//# sourceMappingURL=translate.mjs.map