summaryrefslogtreecommitdiff
path: root/ext/bg/js/translator.js
diff options
context:
space:
mode:
authorsiikamiika <siikamiika@users.noreply.github.com>2017-10-24 18:31:18 +0300
committersiikamiika <siikamiika@users.noreply.github.com>2017-10-24 18:31:18 +0300
commit27a56dc236d8f05508160c28d9115baad26453d2 (patch)
treef04a4b9ea7dbdaea366222015f335d6bf0538957 /ext/bg/js/translator.js
parent78442fff1a995632f2b315994f2540459ee20eca (diff)
expand tags before dictTermsMergeByGloss
Diffstat (limited to 'ext/bg/js/translator.js')
-rw-r--r--ext/bg/js/translator.js19
1 files changed, 11 insertions, 8 deletions
diff --git a/ext/bg/js/translator.js b/ext/bg/js/translator.js
index e6790fbf..238af94d 100644
--- a/ext/bg/js/translator.js
+++ b/ext/bg/js/translator.js
@@ -73,6 +73,13 @@ class Translator {
const result = definitionsBySequence[sequence];
const rawDefinitionsBySequence = await this.database.findTermsBySequence(Number(sequence), options.general.mainDictionary);
+
+ for (const definition of rawDefinitionsBySequence) {
+ const tags = await this.expandTags(definition.definitionTags, definition.dictionary);
+ tags.push(dictTagBuildSource(definition.dictionary));
+ definition.definitionTags = tags;
+ }
+
const definitionsByGloss = dictTermsMergeByGloss(result, rawDefinitionsBySequence);
const secondarySearchResults = [];
@@ -84,6 +91,9 @@ class Translator {
for (const reading of result.expressions.get(expression).keys()) {
for (const definition of await this.database.findTermsExact(expression, reading, secondarySearchTitles)) {
+ const tags = await this.expandTags(definition.definitionTags, definition.dictionary);
+ tags.push(dictTagBuildSource(definition.dictionary));
+ definition.definitionTags = tags;
secondarySearchResults.push(definition);
}
}
@@ -94,11 +104,7 @@ class Translator {
for (const gloss in definitionsByGloss) {
const definition = definitionsByGloss[gloss];
-
- const tags = await this.expandTags(definition.definitionTags, definition.dictionary);
- tags.push(dictTagBuildSource(definition.dictionary));
- definition.definitionTags = dictTagsSort(tags);
-
+ dictTagsSort(definition.definitionTags);
result.definitions.push(definition);
}
@@ -289,9 +295,6 @@ class Translator {
async expandTags(names, title) {
const tags = [];
for (const name of names) {
- if (typeof name !== 'string') {
- continue;
- }
const base = name.split(':')[0];
const meta = await this.database.findTagForTitle(base, title);