Skip to content

Commit

Permalink
Merge pull request #1015 from Onlineberatung/fix/OB-10082
Browse files Browse the repository at this point in the history
fix: merge base translations deep
  • Loading branch information
web-mi authored Feb 28, 2024
2 parents 5b4217a + 288df1c commit 97df5dd
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/i18n.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,11 +92,17 @@ export const init = async (
)
];

const mergeAndFlattenNamespace = (namespace) => {
if (Array.isArray(namespace)) {
return _.merge({}, ...namespace.map((ns) => flatten(ns)));
}
return flatten(namespace);
};
const flattenBaseResource = (resource) => {
if (!resource) return {};
return Object.keys(resource).reduce((acc, lng) => {
acc[lng] = Object.keys(resource[lng]).reduce((acc, ns) => {
acc[ns] = flatten(resource[lng][ns]);
acc[ns] = mergeAndFlattenNamespace(resource[lng][ns]);
return acc;
}, {});
return acc;
Expand Down

0 comments on commit 97df5dd

Please sign in to comment.