@astrolicious/i18n
Version:
Yet another i18n integration for Astro with server and client utilities, type safety and translations built-in.
2 lines • 622 B
JavaScript
import{existsSync as l,readFileSync as y,readdirSync as d}from"node:fs";import{basename as u,extname as j,join as a}from"node:path";import{normalizePath as c}from"vite";var I=(o,{locales:p},f)=>{let r={},m=p.map(t=>({locale:t,dir:c(a(f,t))})).filter(t=>l(t.dir));for(let{locale:t,dir:s}of m){let g=d(s).filter(e=>e.endsWith(".json"));for(let e of g){let n=c(a(s,e));try{let i=JSON.parse(y(n,"utf-8"));r[t]??={},r[t][u(e,j(e))]=i}catch{o.warn(`Can't parse "${n}", skipping.`)}}}return o.info(`${Object.keys(Object.values(r)).length} resources registered`),r};export{I as getResources};
//# sourceMappingURL=resources.js.map