aboutsummaryrefslogtreecommitdiff
path: root/ext/bg/js/translator.js
diff options
context:
space:
mode:
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;