Update merged definitions to have consistent structure (#890)

* Update comment about definitions type

* Add conversion to ensure consistent data structure
This commit is contained in:
toasted-nutbread 2020-10-06 19:31:53 -04:00 committed by GitHub
parent 7ce87c51b4
commit 69f94f8cb8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -199,7 +199,7 @@ class Translator {
const compatibilityDefinition = this._createMergedTermDefinition(
source,
rawSource,
definitions2,
this._convertTermDefinitionsToMergedGlossaryTermDefinitions(definitions2),
[expression],
[reading],
termDetailsList,
@ -647,6 +647,18 @@ class Translator {
}
}
_convertTermDefinitionsToMergedGlossaryTermDefinitions(definitions) {
const convertedDefinitions = [];
for (const definition of definitions) {
const {source, rawSource, expression, reading} = definition;
const expressions = new Set([expression]);
const readings = new Set([reading]);
const convertedDefinition = this._createMergedGlossaryTermDefinition(source, rawSource, [definition], expressions, readings, expressions, readings);
convertedDefinitions.push(convertedDefinition);
}
return convertedDefinitions;
}
// Metadata building
async _buildTermMeta(definitions, enabledDictionaryMap) {