aboutsummaryrefslogtreecommitdiff
path: root/ext/bg/js/backend.js
diff options
context:
space:
mode:
authortoasted-nutbread <toasted-nutbread@users.noreply.github.com>2020-11-29 13:09:02 -0500
committerGitHub <noreply@github.com>2020-11-29 13:09:02 -0500
commit34451ebf7122a2a5d140696215411abfb0dfe188 (patch)
treee9eddb52f133269853059372045dea510e8d02dc /ext/bg/js/backend.js
parenta8cd03cbecf4015483ce3479e589e65ce7eece45 (diff)
JapaneseUtil normalization (#1076)
* Use JapaneseUtil as a class which is manually instantiated * Use alias function for toKana
Diffstat (limited to 'ext/bg/js/backend.js')
-rw-r--r--ext/bg/js/backend.js13
1 files changed, 11 insertions, 2 deletions
diff --git a/ext/bg/js/backend.js b/ext/bg/js/backend.js
index 6ff4e3f7..f9c308e5 100644
--- a/ext/bg/js/backend.js
+++ b/ext/bg/js/backend.js
@@ -22,6 +22,7 @@
* ClipboardReader
* DictionaryDatabase
* Environment
+ * JapaneseUtil
* JsonSchemaValidator
* Mecab
* MediaUtility
@@ -30,14 +31,18 @@
* ProfileConditions
* RequestBuilder
* Translator
- * jp
+ * wanakana
*/
class Backend {
constructor() {
+ this._japaneseUtil = new JapaneseUtil(wanakana);
this._environment = new Environment();
this._dictionaryDatabase = new DictionaryDatabase();
- this._translator = new Translator(this._dictionaryDatabase);
+ this._translator = new Translator({
+ japaneseUtil: this._japaneseUtil,
+ database: this._dictionaryDatabase
+ });
this._anki = new AnkiConnect();
this._mecab = new Mecab();
this._mediaUtility = new MediaUtility();
@@ -48,6 +53,7 @@ class Backend {
mediaUtility: this._mediaUtility
});
this._clipboardMonitor = new ClipboardMonitor({
+ japaneseUtil: this._japaneseUtil,
clipboardReader: this._clipboardReader
});
this._options = null;
@@ -57,6 +63,7 @@ class Backend {
this._defaultAnkiFieldTemplates = null;
this._requestBuilder = new RequestBuilder();
this._audioDownloader = new AudioDownloader({
+ japaneseUtil: this._japaneseUtil,
requestBuilder: this._requestBuilder
});
this._optionsUtil = new OptionsUtil();
@@ -952,6 +959,7 @@ class Backend {
}
async _textParseScanning(text, options) {
+ const jp = this._japaneseUtil;
const {scanning: {length: scanningLength}, parsing: {readingMode}} = options;
const findTermsOptions = this._getTranslatorFindTermsOptions({wildcard: null}, options);
const results = [];
@@ -981,6 +989,7 @@ class Backend {
}
async _textParseMecab(text, options) {
+ const jp = this._japaneseUtil;
const {parsing: {readingMode}} = options;
const results = [];
const rawResults = await this._mecab.parseText(text);