From a81787c55b10b43344a9506b62d90c317b329667 Mon Sep 17 00:00:00 2001 From: toasted-nutbread Date: Thu, 28 Jan 2021 21:33:30 -0500 Subject: Remove the dictionary tag from the definitionTags (#1324) * Remove dictionary tag from term definitionTags and kanji tags * Update test data * Update templates * Update tests * Update information --- ext/bg/js/settings/anki-controller.js | 1 + ext/bg/js/translator.js | 15 +++------------ 2 files changed, 4 insertions(+), 12 deletions(-) (limited to 'ext/bg/js') diff --git a/ext/bg/js/settings/anki-controller.js b/ext/bg/js/settings/anki-controller.js index c2292bc9..e7c8db15 100644 --- a/ext/bg/js/settings/anki-controller.js +++ b/ext/bg/js/settings/anki-controller.js @@ -94,6 +94,7 @@ class AnkiController { 'furigana-plain', 'glossary', 'glossary-brief', + 'glossary-no-dictionary', 'pitch-accents', 'pitch-accent-graphs', 'pitch-accent-positions', diff --git a/ext/bg/js/translator.js b/ext/bg/js/translator.js index 7242ec56..729c8294 100644 --- a/ext/bg/js/translator.js +++ b/ext/bg/js/translator.js @@ -133,7 +133,6 @@ class Translator { for (const {character, onyomi, kunyomi, tags, glossary, stats, dictionary} of databaseDefinitions) { const expandedStats = await this._expandStats(stats, dictionary); const expandedTags = await this._expandTags(tags, dictionary); - expandedTags.push(this._createDictionaryTag(dictionary)); this._sortTags(expandedTags); const definition = this._createKanjiDefinition(character, dictionary, onyomi, kunyomi, glossary, expandedTags, expandedStats); @@ -541,17 +540,14 @@ class Translator { } _flagRedundantDefinitionTags(definitions) { - let lastDictionary = ''; + let lastDictionary = null; let lastPartOfSpeech = ''; const removeCategoriesSet = new Set(); - for (const {definitionTags} of definitions) { - const dictionary = this._createMapKey(this._getTagNamesWithCategory(definitionTags, 'dictionary')); + for (const {dictionary, definitionTags} of definitions) { const partOfSpeech = this._createMapKey(this._getTagNamesWithCategory(definitionTags, 'partOfSpeech')); - if (lastDictionary === dictionary) { - removeCategoriesSet.add('dictionary'); - } else { + if (lastDictionary !== dictionary) { lastDictionary = dictionary; lastPartOfSpeech = ''; } @@ -1054,10 +1050,6 @@ class Translator { return JSON.stringify(array); } - _createDictionaryTag(name) { - return this._createTag(name, 'dictionary', '', 100, 0, name, false); - } - _createTag(name, category, notes, order, score, dictionary, redundant) { return { name, @@ -1101,7 +1093,6 @@ class Translator { const dictionaryPriority = this._getDictionaryPriority(dictionary, enabledDictionaryMap); const termTagsExpanded = await this._expandTags(termTags, dictionary); const definitionTagsExpanded = await this._expandTags(definitionTags, dictionary); - definitionTagsExpanded.push(this._createDictionaryTag(dictionary)); this._sortTags(definitionTagsExpanded); this._sortTags(termTagsExpanded); -- cgit v1.2.3