UNPKG

next-intl-split

Version:

A loader for next-intl to split translation files properly.

3 lines (2 loc) 592 B
import{writeFileSync as o}from"fs";import e from"path";const t=(t,n,r)=>{const l=(o=>Object.entries(o))(n),s="production"===process.env.NODE_ENV;s&&!r?.muteLogs&&(console.log("\n"),console.log(" ▲ Next Intl Split"));for(let n=0;n<l.length;n++){const c=l[n][0],i=l[n][1];try{const n=e.resolve(t,`${c}.json`),l=JSON.stringify(i,null,2);o(n,l),s&&!r?.muteLogs&&console.log(`\tSuccessfully merged JSON content for ${c}`)}catch(o){console.error("The following error occured in writer in next-intl-split.",o)}}s&&console.log("\n")};export{t as writeMessages}; //# sourceMappingURL=index.mjs.map