import { i18n } from '@kbn/i18n' ; import { Serializer } from '.' ; export const serializeToJson = ( messages , formats = i18n . formats ) => { const resultJsonObject = { formats , messages : { } as Record < string , string | { text : string ; comment : string ; } > , } ; for ( const [ mapKey , mapValue ] of messages ) { if ( mapValue . description ) { resultJsonObject . messages [ mapKey ] = { text : mapValue . message , comment : mapValue . description } ; } else { resultJsonObject . messages [ mapKey ] = mapValue . message ; } } return JSON . stringify ( resultJsonObject , undefined , 2 ) . concat ( '\n' ) ; } ;