UNPKG

@lucidcms/core

Version:

The core of the Lucid CMS. It's responsible for spinning up the API and serving the CMS.

2 lines 1.34 kB
import{parseCopyKey as e}from"./copy.mjs";import{coreTranslations as t,formatTranslation as n,mergeTranslationBundles as r,normalizeTranslationBundles as i}from"./translations.mjs";const a=e=>{let t=e.locale??e.defaultLocale;return n(e.bundles[t]?.[e.scope][e.key]??e.bundles[e.defaultLocale]?.[e.scope][e.key]??e.bundles.en?.[e.scope][e.key]??e.options?.defaultMessage??e.key,e.options?.data)},o=(t,r)=>{if(!t)return t;if(typeof t==`string`){let{scope:n,key:i}=e(t);return a({bundles:r.bundles,defaultLocale:r.defaultLocale,scope:n,key:i,locale:r.locale,options:r.options})}return t.type===`lucid.literal`?n(t.value,{...t.values??{},...r.options?.data??{}}):a({bundles:r.bundles,defaultLocale:r.defaultLocale,scope:t.scope,key:t.key,locale:r.locale,options:{...r.options,data:{...t.values??{},...r.options?.data??{}},defaultMessage:r.options?.defaultMessage??t.defaultMessage}})},s=e=>{let n=i(r(t,e.bundles));return{defaultLocale:e.defaultLocale,bundles:n,resolve:({scope:t,key:r,locale:i,options:o})=>a({bundles:n,defaultLocale:e.defaultLocale,scope:t,key:r,locale:i,options:o}),copy:(t,r)=>o(t,{bundles:n,defaultLocale:e.defaultLocale,locale:r?.locale,options:r?.options}),admin:({locale:t})=>({...n.en?.admin??{},...n[e.defaultLocale]?.admin??{},...n[t]?.admin??{}})}};export{s as createTranslationStore}; //# sourceMappingURL=store.mjs.map