summaryrefslogtreecommitdiff
path: root/ext
diff options
context:
space:
mode:
authortoasted-nutbread <toasted-nutbread@users.noreply.github.com>2021-04-18 18:15:58 -0400
committerGitHub <noreply@github.com>2021-04-18 18:15:58 -0400
commitb40cfe0458f277b1153c3ebc6713305491dbec22 (patch)
treebeb35750846c2143a68b88ce7238afdfdba5c454 /ext
parent03dd1dc6ff808390fed7e770822a961c4db3fb2a (diff)
Translator refactoring for consistency (#1619)
* Remove unused argument * Improve naming in _groupDictionaryEntriesByHeadword More consistent with _getRelatedDictionaryEntries.
Diffstat (limited to 'ext')
-rw-r--r--ext/js/language/translator.js23
1 files changed, 11 insertions, 12 deletions
diff --git a/ext/js/language/translator.js b/ext/js/language/translator.js
index 04c78258..3ee9c3b7 100644
--- a/ext/js/language/translator.js
+++ b/ext/js/language/translator.js
@@ -371,7 +371,7 @@ class Translator {
if (sequenceList.length > 0) {
const secondarySearchDictionaryMap = this._getSecondarySearchDictionaryMap(enabledDictionaryMap);
- await this._addRelatedDictionaryEntries(groupedDictionaryEntries, ungroupedDictionaryEntriesMap, sequenceList, mainDictionary, enabledDictionaryMap);
+ await this._addRelatedDictionaryEntries(groupedDictionaryEntries, ungroupedDictionaryEntriesMap, sequenceList, enabledDictionaryMap);
for (const group of groupedDictionaryEntries) {
this._sortTermDictionaryEntriesById(group.dictionaryEntries);
}
@@ -388,7 +388,7 @@ class Translator {
return newDictionaryEntries;
}
- async _addRelatedDictionaryEntries(groupedDictionaryEntries, ungroupedDictionaryEntriesMap, sequenceList, mainDictionary, enabledDictionaryMap) {
+ async _addRelatedDictionaryEntries(groupedDictionaryEntries, ungroupedDictionaryEntriesMap, sequenceList, enabledDictionaryMap) {
const databaseEntries = await this._database.findTermsBySequenceBulk(sequenceList);
for (const databaseEntry of databaseEntries) {
const {dictionaryEntries, ids} = groupedDictionaryEntries[databaseEntry.index];
@@ -474,20 +474,19 @@ class Translator {
for (const dictionaryEntry of dictionaryEntries) {
const {inflections, headwords: [{term, reading}]} = dictionaryEntry;
const key = this._createMapKey([term, reading, ...inflections]);
- let dictionaryEntries2 = groups.get(key);
- if (typeof dictionaryEntries2 === 'undefined') {
- dictionaryEntries2 = [];
- groups.set(key, dictionaryEntries2);
+ let groupDictionaryEntries = groups.get(key);
+ if (typeof groupDictionaryEntries === 'undefined') {
+ groupDictionaryEntries = [];
+ groups.set(key, groupDictionaryEntries);
}
- dictionaryEntries2.push(dictionaryEntry);
+ groupDictionaryEntries.push(dictionaryEntry);
}
- const results = [];
- for (const dictionaryEntries2 of groups.values()) {
- const dictionaryEntry = this._createGroupedDictionaryEntry(dictionaryEntries2, false);
- results.push(dictionaryEntry);
+ const newDictionaryEntries = [];
+ for (const groupDictionaryEntries of groups.values()) {
+ newDictionaryEntries.push(this._createGroupedDictionaryEntry(groupDictionaryEntries, false));
}
- return results;
+ return newDictionaryEntries;
}
// Tags