mirror of
https://github.com/ecency/ecency-mobile.git
synced 2024-12-22 04:41:43 +03:00
13 lines
394 B
JavaScript
13 lines
394 B
JavaScript
export const flattenMessages = (nestedMessages, prefix = '') => Object.keys(nestedMessages).reduce((messages, key) => {
|
|
const value = nestedMessages[key];
|
|
const prefixedKey = prefix ? `${prefix}.${key}` : key;
|
|
|
|
if (typeof value === 'string') {
|
|
messages[prefixedKey] = value;
|
|
} else {
|
|
Object.assign(messages, flattenMessages(value, prefixedKey));
|
|
}
|
|
|
|
return messages;
|
|
}, {});
|