Improvements to error output in translation generation

This commit is contained in:
pietervdvn 2021-06-21 00:11:23 +02:00
parent 65486b6953
commit d297676620

View file

@ -231,8 +231,7 @@ function MergeTranslation(source: any, target: any, language: string, context: s
}
if (typeof targetV === "string") {
console.error("Could not add a translation to string ", targetV, ". The translation is", sourceV, " in " + context)
continue;
throw `At context ${context}: Could not add a translation. The target object has a string at the given path, whereas the translation contains an object.\n String at target: ${targetV}\n Object at translation source: ${JSON.stringify(sourceV)}`
}
targetV[language] = sourceV;
@ -261,7 +260,7 @@ function mergeLayerTranslation(layerConfig: { id: string }, path: string, transl
const id = layerConfig.id;
translationFiles.forEach((translations, lang) => {
const translationsForLayer = translations[id]
MergeTranslation(translationsForLayer, layerConfig, lang, id)
MergeTranslation(translationsForLayer, layerConfig, lang, path+":"+id)
})
}