aboutsummaryrefslogtreecommitdiff
path: root/ext/bg/js/translator.js
diff options
context:
space:
mode:
authorAlex Yatskov <alex@foosoft.net>2016-08-07 19:56:50 -0700
committerAlex Yatskov <alex@foosoft.net>2016-08-07 19:56:50 -0700
commit29135ff84ff51dfdbf271490bc53138e306e75d8 (patch)
tree9a92a7ce668af1e4cccb1c226665b382244ddf53 /ext/bg/js/translator.js
parenta9e86544c176ad8295c1df83924778fa45421461 (diff)
Updating kanji display
Diffstat (limited to 'ext/bg/js/translator.js')
-rw-r--r--ext/bg/js/translator.js35
1 files changed, 34 insertions, 1 deletions
diff --git a/ext/bg/js/translator.js b/ext/bg/js/translator.js
index b7fce392..cdcdda28 100644
--- a/ext/bg/js/translator.js
+++ b/ext/bg/js/translator.js
@@ -148,7 +148,7 @@ class Translator {
}
}
- return definitions;
+ return this.processKanji(definitions);
}
processTerm(groups, source, tags, rules=[], root='') {
@@ -227,6 +227,39 @@ class Translator {
}
}
+ processKanji(entries) {
+ const results = [];
+ for (let entry of entries) {
+ const tagItems = [];
+ for (let tag of entry.tags) {
+ const tagItem = {
+ class: 'default',
+ order: Number.MAX_SAFE_INTEGER,
+ name: tag
+ };
+
+ const tagMeta = this.tagMeta[tag];
+ if (tagMeta) {
+ for (const tagProp in tagMeta) {
+ tagItem[tagProp] = tagMeta[tagProp] || tagItem[tagProp];
+ }
+ }
+
+ tagItems.push(tagItem);
+ }
+
+ results.push({
+ character: entry.character,
+ kunyomi: entry.kunyomi,
+ onyomi: entry.onyomi,
+ tags: tagItems,
+ glossary: entry.glossary
+ });
+ }
+
+ return results;
+ }
+
static isKanji(c) {
const code = c.charCodeAt(0);
return code >= 0x4e00 && code < 0x9fb0 || code >= 0x3400 && code < 0x4dc0;