UNPKG

piral-translate

Version:

Plugin for providing translated messages in Piral.

23 lines 692 B
function flat(source) { const target = {}; flatten(source, target); return target; } function flatten(source, target, prop = '') { if (typeof source === 'string') { target[prop] = source; return; } if (typeof source === 'object' && source !== null) { Object.keys(source).forEach((key) => { flatten(source[key], target, prop ? `${prop}.${key}` : key); }); return; } } export function flattenTranslations(messages) { return Object.fromEntries(Object.entries(messages).map(([language, translations]) => { return [language, flat(translations)]; })); } //# sourceMappingURL=flatten-translations.js.map