Enable katakana soft search (resolves #14)
This commit is contained in:
parent
5467ed11e1
commit
83f5bd24df
@ -105,11 +105,24 @@ class Translator {
|
|||||||
return Promise.all(deinflectPromises).then(() => deinflectGroups);
|
return Promise.all(deinflectPromises).then(() => deinflectGroups);
|
||||||
}
|
}
|
||||||
|
|
||||||
findTerm(text) {
|
findTerm(text, enableSoftKatakanaSearch) {
|
||||||
return this.findTermGroups(text).then(deinflectGroups => {
|
return this.findTermGroups(text).then(groups => {
|
||||||
|
const textHiragana = wanakana._katakanaToHiragana(text);
|
||||||
|
if (text !== textHiragana && enableSoftKatakanaSearch) {
|
||||||
|
return this.findTermGroups(textHiragana).then(groupsHiragana => {
|
||||||
|
for (const key in groupsHiragana) {
|
||||||
|
groups[key] = groups[key] || groupsHiragana[key];
|
||||||
|
}
|
||||||
|
|
||||||
|
return groups;
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
return groups;
|
||||||
|
}
|
||||||
|
}).then(groups => {
|
||||||
const definitions = [];
|
const definitions = [];
|
||||||
for (const key in deinflectGroups) {
|
for (const key in groups) {
|
||||||
definitions.push(deinflectGroups[key]);
|
definitions.push(groups[key]);
|
||||||
}
|
}
|
||||||
|
|
||||||
let length = 0;
|
let length = 0;
|
||||||
|
@ -243,7 +243,7 @@ class Yomichan {
|
|||||||
}
|
}
|
||||||
|
|
||||||
api_findTerm({text, callback}) {
|
api_findTerm({text, callback}) {
|
||||||
promiseCallback(this.translator.findTerm(text), callback);
|
promiseCallback(this.translator.findTerm(text, this.options.enableSoftKatakanaSearch), callback);
|
||||||
}
|
}
|
||||||
|
|
||||||
api_renderText({template, data, callback}) {
|
api_renderText({template, data, callback}) {
|
||||||
|
Loading…
Reference in New Issue
Block a user