aboutsummaryrefslogtreecommitdiff
path: root/ext/bg/js/translator.js
diff options
context:
space:
mode:
authortoasted-nutbread <toasted-nutbread@users.noreply.github.com>2021-01-28 21:33:30 -0500
committerGitHub <noreply@github.com>2021-01-28 21:33:30 -0500
commita81787c55b10b43344a9506b62d90c317b329667 (patch)
tree9a2ffe10e63efc85f3beacf31d0356ebe58ca606 /ext/bg/js/translator.js
parente610a62ceb07313c581a0bd2d5c8ebbc7c39ba4f (diff)
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
Diffstat (limited to 'ext/bg/js/translator.js')
-rw-r--r--ext/bg/js/translator.js15
1 files changed, 3 insertions, 12 deletions
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);