summaryrefslogtreecommitdiff
path: root/ext/bg/js/translator.js
diff options
context:
space:
mode:
authorAlex Yatskov <alex@foosoft.net>2016-08-21 13:32:36 -0700
committerAlex Yatskov <alex@foosoft.net>2016-08-21 13:32:36 -0700
commit67f906ab24acb80a8ffbad29ff8ddda5fc570cf0 (patch)
tree119358264dd2de12d0af016f4fe97bb683e2be43 /ext/bg/js/translator.js
parent96c6c4ad1ae8dd784ba4d90546ae3bf7ce1861f6 (diff)
Import stubs
Diffstat (limited to 'ext/bg/js/translator.js')
-rw-r--r--ext/bg/js/translator.js47
1 files changed, 22 insertions, 25 deletions
diff --git a/ext/bg/js/translator.js b/ext/bg/js/translator.js
index fd414847..f373fe83 100644
--- a/ext/bg/js/translator.js
+++ b/ext/bg/js/translator.js
@@ -31,31 +31,28 @@ class Translator {
return;
}
- Translator.loadData('bg/data/rules.json')
- .then((response) => {
- this.deinflector.setRules(JSON.parse(response));
- return Translator.loadData('bg/data/tags.json');
- })
- .then((response) => {
- this.tagMeta = JSON.parse(response);
- return Translator.loadData('bg/data/edict.json');
- })
- .then((response) => {
- this.dictionary.addTermDict('edict', JSON.parse(response));
- return Translator.loadData('bg/data/kanjidic.json');
- })
- .then((response) => {
- this.dictionary.addKanjiDict('kanjidic', JSON.parse(response));
- return loadEnamDict ? Translator.loadData('bg/data/enamdict.json') : Promise.resolve(null);
- })
- .then((response) => {
- if (response !== null) {
- this.dictionary.addTermDict('enamdict', JSON.parse(response));
- }
-
- this.loaded = true;
- callback();
- });
+ Translator.loadData('bg/data/rules.json').then((response) => {
+ this.deinflector.setRules(JSON.parse(response));
+ return Translator.loadData('bg/data/tags.json');
+ }).then((response) => {
+ this.tagMeta = JSON.parse(response);
+ return this.dictionary.loadDb();
+ }).then(() => {
+ this.loaded = true;
+ callback();
+ }).catch(() => {
+ return Translator.loadData('bg/data/edict.json');
+ }).then((response) => {
+ this.dictionary.importTermDict('edict', JSON.parse(response));
+ return Translator.loadData('bg/data/enamdict.json');
+ }).then((response) => {
+ this.dictionary.importTermDict('enamdict', JSON.parse(response));
+ return Translator.loadData('bg/data/kanjidic.json');
+ }).then((response) => {
+ this.dictionary.importKanjiDict('kanjidic', JSON.parse(response));
+ this.loaded = true;
+ callback();
+ });
}
findTerm(text) {