summaryrefslogtreecommitdiff
path: root/ext/bg/js
diff options
context:
space:
mode:
Diffstat (limited to 'ext/bg/js')
-rw-r--r--ext/bg/js/translator.js21
-rw-r--r--ext/bg/js/yomichan.js2
2 files changed, 18 insertions, 5 deletions
diff --git a/ext/bg/js/translator.js b/ext/bg/js/translator.js
index 8f895800..44f37e31 100644
--- a/ext/bg/js/translator.js
+++ b/ext/bg/js/translator.js
@@ -105,11 +105,24 @@ class Translator {
return Promise.all(deinflectPromises).then(() => deinflectGroups);
}
- findTerm(text) {
- return this.findTermGroups(text).then(deinflectGroups => {
+ findTerm(text, enableSoftKatakanaSearch) {
+ 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 = [];
- for (const key in deinflectGroups) {
- definitions.push(deinflectGroups[key]);
+ for (const key in groups) {
+ definitions.push(groups[key]);
}
let length = 0;
diff --git a/ext/bg/js/yomichan.js b/ext/bg/js/yomichan.js
index 3091e503..7bca579d 100644
--- a/ext/bg/js/yomichan.js
+++ b/ext/bg/js/yomichan.js
@@ -243,7 +243,7 @@ class Yomichan {
}
api_findTerm({text, callback}) {
- promiseCallback(this.translator.findTerm(text), callback);
+ promiseCallback(this.translator.findTerm(text, this.options.enableSoftKatakanaSearch), callback);
}
api_renderText({template, data, callback}) {