-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #19 from derian-all-win-software/main
Added the flexible language path in `TranslationConfiguration`
- Loading branch information
Showing
6 changed files
with
159 additions
and
95 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
/** | ||
* Function: mergeDeep() | ||
* Description: Method used to deeply merge objects that are nested. | ||
* | ||
* @param target - Main Object to merge into | ||
* @param source - Object 2 containing data to merge into main object | ||
* @returns target | ||
*/ | ||
// @ts-ignore - Unknown object definitions | ||
export const mergeDeep = (target, source) => { | ||
// @ts-ignore - Unknown object definitions | ||
const isObject = (obj) => obj && typeof obj === 'object'; | ||
|
||
if (!isObject(target) || !isObject(source)) { | ||
return source; | ||
} | ||
|
||
Object.keys(source).forEach((key) => { | ||
const targetValue = target[key]; | ||
const sourceValue = source[key]; | ||
|
||
if (Array.isArray(targetValue) && Array.isArray(sourceValue)) { | ||
target[key] = targetValue.concat(sourceValue); | ||
} else if (isObject(targetValue) && isObject(sourceValue)) { | ||
target[key] = mergeDeep(Object.assign({}, targetValue), sourceValue); | ||
} else { | ||
target[key] = sourceValue; | ||
} | ||
}); | ||
|
||
return target; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters