From 69f94f8cb8225cc20f2c860524b142642d385412 Mon Sep 17 00:00:00 2001 From: toasted-nutbread Date: Tue, 6 Oct 2020 19:31:53 -0400 Subject: Update merged definitions to have consistent structure (#890) * Update comment about definitions type * Add conversion to ensure consistent data structure --- ext/bg/js/translator.js | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'ext') diff --git a/ext/bg/js/translator.js b/ext/bg/js/translator.js index e11d0269..3767b47e 100644 --- a/ext/bg/js/translator.js +++ b/ext/bg/js/translator.js @@ -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) { -- cgit v1.2.3