UNPKG

next-intl

Version:

Internationalization (i18n) for Next.js

2 lines (1 loc) 506 B
import{getSortedMessages as o,setNestedProperty as t}from"../../utils.js";import{defineCodec as e}from"../ExtractorCodec.js";var r=e((()=>({decode(o){const t=JSON.parse(o),e=[];return s(t,((o,t)=>{e.push({id:t,message:o})})),e},encode(e){const r={};for(const s of o(e))t(r,s.id,s.message);return JSON.stringify(r,null,2)+"\n"},toJSONString:o=>o})));function s(o,t,e=""){for(const r of Object.keys(o)){const n=e?e+"."+r:r,c=o[r];"string"==typeof c?t(c,n):"object"==typeof c&&s(c,t,n)}}export{r as default};