export const serializer = ( text: string, translations: Record, ) => { const array = text.split(/{{([a-zA-Z]*)}}/g); const formated: (string | number | React.ReactElement)[] = array.map( (word) => { if (word in translations) { return translations[word]; } return word; }, ); return formated.join(''); };