aboutsummaryrefslogtreecommitdiff
path: root/ext/bg/js/translator.js
diff options
context:
space:
mode:
authorAlex Yatskov <alex@foosoft.net>2016-05-07 18:24:31 -0700
committerAlex Yatskov <alex@foosoft.net>2016-05-07 18:24:31 -0700
commit4a6055d781cd9bafb1887ef4e8ee26d3735ad405 (patch)
tree4a2e181de42c9e29df905eabba38beabe996c904 /ext/bg/js/translator.js
parente6ea1ddb150bd97a427a9a3119de57bde88613fa (diff)
WIP
Diffstat (limited to 'ext/bg/js/translator.js')
-rw-r--r--ext/bg/js/translator.js21
1 files changed, 14 insertions, 7 deletions
diff --git a/ext/bg/js/translator.js b/ext/bg/js/translator.js
index 1a7b9bb4..30bc92c1 100644
--- a/ext/bg/js/translator.js
+++ b/ext/bg/js/translator.js
@@ -33,14 +33,19 @@ class Translator {
this.deinflector = new Deinflector();
}
- loadData(callback) {
+ loadData({loadEnamDict=true}, callback) {
if (this.loaded) {
callback();
return;
}
+ let files = ['rules', 'tags', 'edict', 'kanjidic'];
+ if (loadEnamDict) {
+ files = files.concat('enamdict');
+ }
+
const pendingLoads = [];
- for (const key of ['rules', 'tags', 'edict', 'enamdict', 'kanjidic']) {
+ for (const key of files) {
pendingLoads.push(key);
Translator.loadData(this.paths[key], (response) => {
switch (key) {
@@ -82,10 +87,12 @@ class Translator {
return tags;
});
- if (dfs !== null) {
- for (const df of dfs) {
- this.processTerm(groups, df.source, df.tags, df.rules, df.root);
- }
+ if (dfs === null) {
+ continue;
+ }
+
+ for (const df of dfs) {
+ this.processTerm(groups, df.source, df.tags, df.rules, df.root);
}
}
@@ -131,7 +138,7 @@ class Translator {
}
findKanji(text) {
- let definitions = [];
+ let definitions = [];
const processed = {};
for (const c of text) {