aboutsummaryrefslogtreecommitdiff
path: root/ext/bg/js/translator.js
diff options
context:
space:
mode:
authorAlex Yatskov <alex@foosoft.net>2017-04-23 11:10:35 -0700
committerAlex Yatskov <alex@foosoft.net>2017-04-23 11:10:35 -0700
commita209228c311a13328ecdda4056a9302885639195 (patch)
treef412a23f65cbd3f325937d8cd94e8ccec5b7ef28 /ext/bg/js/translator.js
parent3523b85be0be618b00cd9b6992aaf255de12ebfb (diff)
parent3319d0d3cdaf98a8fd57b7c51e745f60960f607e (diff)
Merge branch 'master' into firefox-amo
Diffstat (limited to 'ext/bg/js/translator.js')
-rw-r--r--ext/bg/js/translator.js13
1 files changed, 10 insertions, 3 deletions
diff --git a/ext/bg/js/translator.js b/ext/bg/js/translator.js
index 67430aef..b3b90641 100644
--- a/ext/bg/js/translator.js
+++ b/ext/bg/js/translator.js
@@ -41,10 +41,17 @@ class Translator {
});
}
- findTerms(text, dictionaries, softKatakana) {
+ findTerms(text, dictionaries, softKatakana, alphanumeric) {
const titles = Object.keys(dictionaries);
const cache = {};
+ if (!alphanumeric && text.length > 0) {
+ const c = text[0];
+ if (!jpIsKana(c) && !jpIsKanji(c)) {
+ return Promise.resolve({length: 0, definitions: []});
+ }
+ }
+
return this.findTermsDeinflected(text, titles, cache).then(deinfLiteral => {
const textHiragana = wanakana._katakanaToHiragana(text);
if (text !== textHiragana && softKatakana) {
@@ -84,8 +91,8 @@ class Translator {
});
}
- findTermsGrouped(text, dictionaries, softKatakana) {
- return this.findTerms(text, dictionaries, softKatakana).then(({length, definitions}) => {
+ findTermsGrouped(text, dictionaries, softKatakana, alphanumeric) {
+ return this.findTerms(text, dictionaries, softKatakana, alphanumeric).then(({length, definitions}) => {
return {length, definitions: dictTermsGroup(definitions, dictionaries)};
});
}