Fix sorting of non-top-level definitions (#1516)
This commit is contained in:
parent
5fe40d7ec4
commit
638e5783ac
@ -519,7 +519,7 @@ class Translator {
|
||||
);
|
||||
glossaryDefinitions.push(glossaryDefinition);
|
||||
}
|
||||
this._sortDefinitions(glossaryDefinitions);
|
||||
this._sortDefinitions(glossaryDefinitions, false);
|
||||
|
||||
const termDetailsList = this._createTermDetailsList(allDefinitions);
|
||||
|
||||
@ -594,7 +594,7 @@ class Translator {
|
||||
|
||||
const results = [];
|
||||
for (const groupDefinitions of groups.values()) {
|
||||
this._sortDefinitions(groupDefinitions);
|
||||
this._sortDefinitions(groupDefinitions, false);
|
||||
const definition = this._createGroupedTermDefinition(groupDefinitions);
|
||||
results.push(definition);
|
||||
}
|
||||
@ -1259,12 +1259,14 @@ class Translator {
|
||||
});
|
||||
}
|
||||
|
||||
_sortDefinitions(definitions) {
|
||||
_sortDefinitions(definitions, topLevel=true) {
|
||||
if (definitions.length <= 1) { return; }
|
||||
const stringComparer = this._stringComparer;
|
||||
const compareFunction = (v1, v2) => {
|
||||
let i;
|
||||
if (topLevel) {
|
||||
// Sort by length of source term
|
||||
let i = v2.source.length - v1.source.length;
|
||||
i = v2.source.length - v1.source.length;
|
||||
if (i !== 0) { return i; }
|
||||
|
||||
// Sort by the number of inflection reasons
|
||||
@ -1274,6 +1276,7 @@ class Translator {
|
||||
// Sort by how many terms exactly match the source (e.g. for exact kana prioritization)
|
||||
i = v2.sourceTermExactMatchCount - v1.sourceTermExactMatchCount;
|
||||
if (i !== 0) { return i; }
|
||||
}
|
||||
|
||||
// Sort by dictionary priority
|
||||
i = v2.dictionaryOrder.priority - v1.dictionaryOrder.priority;
|
||||
|
Loading…
Reference in New Issue
Block a user