Account for multiple headers in single translation file

This commit is contained in:
Iván Ovejero 2021-11-23 12:14:13 +01:00
parent d3b9e21bf0
commit d3519e44d0
2 changed files with 18 additions and 9 deletions

View file

@ -85,7 +85,9 @@ function getTranslationPaths() {
function getHeadersAndTranslations(paths) { function getHeadersAndTranslations(paths) {
return paths.reduce((acc, cur) => { return paths.reduce((acc, cur) => {
const translation = require(cur.source); const translation = require(cur.source);
const nodeType = Object.keys(translation).pop(); const nodeTypes = Object.keys(translation);
for (const nodeType of nodeTypes) {
const { header } = translation[nodeType]; const { header } = translation[nodeType];
if (isValidHeader(header, ALLOWED_HEADER_KEYS)) { if (isValidHeader(header, ALLOWED_HEADER_KEYS)) {
@ -96,6 +98,7 @@ function getHeadersAndTranslations(paths) {
destinationPath: cur.destination, destinationPath: cur.destination,
content: translation, content: translation,
}); });
}
return acc; return acc;
}, { headers: {}, translations: [] }); }, { headers: {}, translations: [] });

View file

@ -1,4 +1,10 @@
module.exports = { module.exports = {
githubTrigger: {
header: {
displayName: '🇩🇪 GitHub Trigger',
description: '🇩🇪 Listen to GitHub events',
},
},
github: { github: {
header: { header: {
displayName: '🇩🇪 GitHub', displayName: '🇩🇪 GitHub',