diff options
author | toasted-nutbread <toasted-nutbread@users.noreply.github.com> | 2021-03-25 19:55:31 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-03-25 19:55:31 -0400 |
commit | 4be5c8fd9f7860e701d0b7d3c8c0ee934bc60a4f (patch) | |
tree | dcd78316afdf00bbb67d3d1aa6555a9c8ea3efec /dev | |
parent | e7035dcff41d94f20c0bc8865d413412afc7c229 (diff) |
Refactor Translator and dictionary entry format (#1553)
* Update test data
* Move translator.js
* Create new version of Translator
* Update Backend
* Update DictionaryDataUtil
* Update DisplayGenerator
* Create AnkiNoteDataCreator
* Replace AnkiNoteData with AnkiNoteDataCreator
* Update tests
* Remove AnkiNoteData
* Update test data
* Remove translator-old.js
* Add TypeScript interface definitions for the new translator data format
Diffstat (limited to 'dev')
-rw-r--r-- | dev/translator-vm.js | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/dev/translator-vm.js b/dev/translator-vm.js index d6443d37..b7760f4a 100644 --- a/dev/translator-vm.js +++ b/dev/translator-vm.js @@ -30,7 +30,7 @@ class TranslatorVM extends DatabaseVM { super(); this._japaneseUtil = null; this._translator = null; - this._AnkiNoteData = null; + this._ankiNoteDataCreator = null; this._dictionaryName = null; } @@ -38,10 +38,14 @@ class TranslatorVM extends DatabaseVM { return this._translator; } + get ankiNoteDataCreator() { + return this._ankiNoteDataCreator; + } + async prepare(dictionaryDirectory, dictionaryName) { this.execute([ 'js/core.js', - 'js/data/anki-note-data.js', + 'js/data/anki-note-data-creator.js', 'js/data/database.js', 'js/data/json-schema.js', 'js/general/cache-map.js', @@ -60,13 +64,13 @@ class TranslatorVM extends DatabaseVM { DictionaryDatabase, JapaneseUtil, Translator, - AnkiNoteData + AnkiNoteDataCreator ] = this.get([ 'DictionaryImporter', 'DictionaryDatabase', 'JapaneseUtil', 'Translator', - 'AnkiNoteData' + 'AnkiNoteDataCreator' ]); // Dictionary @@ -98,7 +102,7 @@ class TranslatorVM extends DatabaseVM { this._translator.prepare(deinflectionReasions); // Assign properties - this._AnkiNoteData = AnkiNoteData; + this._ankiNoteDataCreator = new AnkiNoteDataCreator(this._japaneseUtil); } createTestAnkiNoteData(definition, mode) { @@ -116,8 +120,7 @@ class TranslatorVM extends DatabaseVM { }, injectedMedia: null }; - const AnkiNoteData = this._AnkiNoteData; - return new AnkiNoteData(this._japaneseUtil, marker, data).createPublic(); + return this._ankiNoteDataCreator.create(marker, data); } buildOptions(optionsPresets, optionsArray) { |