import { forEach , reduce } from 'lodash' ; import { TransformedTranslationsType , TranslationsType } from './types' ; param { object } translations returns { object } export default ( translations ) : TransformedTranslationsType => reduce < TranslationsType , TransformedTranslationsType > ( translations , ( transformedTranslations , namespace , namespaceName ) => { const newTransformedTranslations = transformedTranslations ; forEach ( namespace , ( language , languageTag ) => { newTransformedTranslations [ languageTag ] = { ... newTransformedTranslations [ languageTag ] , [ namespaceName ] : language as Record < string , string > } ; } ) ; return newTransformedTranslations ; } , { } ) ;