diff options
author | siikamiika <siikamiika@users.noreply.github.com> | 2017-10-17 11:16:38 +0300 |
---|---|---|
committer | siikamiika <siikamiika@users.noreply.github.com> | 2017-10-17 11:16:38 +0300 |
commit | 81f0a616519d1cea66ee54ec47c5da868a208ef6 (patch) | |
tree | 698c00fbe40918737cb7f202319501742c1bb64b /ext/bg/js | |
parent | 1edeabdaa8861e149cd7f76f58d97aa127117f79 (diff) |
merged mode: Anki support
Diffstat (limited to 'ext/bg/js')
-rw-r--r-- | ext/bg/js/dictionary.js | 3 | ||||
-rw-r--r-- | ext/bg/js/options.js | 81 | ||||
-rw-r--r-- | ext/bg/js/translator.js | 5 |
3 files changed, 72 insertions, 17 deletions
diff --git a/ext/bg/js/dictionary.js b/ext/bg/js/dictionary.js index 6df77d73..97716e65 100644 --- a/ext/bg/js/dictionary.js +++ b/ext/bg/js/dictionary.js @@ -368,7 +368,8 @@ async function dictFieldFormat(field, definition, mode, options) { merge: options.general.resultOutputMode === 'merge', modeTermKanji: mode === 'term-kanji', modeTermKana: mode === 'term-kana', - modeKanji: mode === 'kanji' + modeKanji: mode === 'kanji', + compactGlossaries: options.general.compactGlossaries }; const html = await apiTemplateRender(options.anki.fieldTemplates, data, true); diff --git a/ext/bg/js/options.js b/ext/bg/js/options.js index 86c4e27c..34cb1240 100644 --- a/ext/bg/js/options.js +++ b/ext/bg/js/options.js @@ -21,10 +21,15 @@ function optionsFieldTemplates() { return ` {{#*inline "glossary-single"}} {{~#unless brief~}} - {{~#if tags~}}<i>({{#each tags}}{{name}}{{#unless @last}}, {{/unless}}{{/each}})</i> {{/if~}} + {{~#if definitionTags~}}<i>({{#each definitionTags}}{{name}}{{#unless @last}}, {{/unless}}{{/each}})</i> {{/if~}} + {{~#if only~}}({{#each only}}{{{.}}}{{#unless @last}}, {{/unless}}{{/each}} only) {{/if~}} {{~/unless~}} {{~#if glossary.[1]~}} - <ul>{{#each glossary}}<li>{{#multiLine}}{{.}}{{/multiLine}}</li>{{/each}}</ul> + {{~#if compactGlossaries~}} + {{#each glossary}}{{#multiLine}}{{.}}{{/multiLine}}{{#unless @last}} | {{/unless}}{{/each}} + {{~else~}} + <ul>{{#each glossary}}<li>{{#multiLine}}{{.}}{{/multiLine}}</li>{{/each}}</ul> + {{~/if~}} {{~else~}} {{~#multiLine}}{{glossary.[0]}}{{/multiLine~}} {{~/if~}} @@ -41,23 +46,56 @@ function optionsFieldTemplates() { {{/inline}} {{#*inline "expression"}} - {{~#if modeTermKana~}} - {{~#if definition.reading~}} - {{definition.reading}} + {{~#if merge~}} + {{~#if modeTermKana~}} + {{~#each definition.reading~}} + {{{.}}} + {{~#unless @last}}, {{/unless~}} + {{~else~}} + {{~#each definition.expression~}} + {{{.}}} + {{~#unless @last}}, {{/unless~}} + {{~/each~}} + {{~/each~}} {{~else~}} - {{definition.expression}} + {{~#each definition.expression~}} + {{{.}}} + {{~#unless @last}}, {{/unless~}} + {{~/each~}} {{~/if~}} {{~else~}} - {{definition.expression}} + {{~#if modeTermKana~}} + {{~#if definition.reading~}} + {{definition.reading}} + {{~else~}} + {{definition.expression}} + {{~/if~}} + {{~else~}} + {{definition.expression}} + {{~/if~}} {{~/if~}} {{/inline}} {{#*inline "furigana"}} - {{#furigana}}{{{definition}}}{{/furigana}} + {{~#if merge~}} + {{~#each definition.expressions~}} + {{~#furigana}}{{{.}}}{{/furigana~}} + {{~#unless @last}}, {{/unless~}} + {{~/each~}} + {{~else~}} + {{#furigana}}{{{definition}}}{{/furigana}} + {{~/if~}} {{/inline}} {{#*inline "furigana-plain"}} - {{#furiganaPlain}}{{{definition}}}{{/furiganaPlain}} + {{~#if merge~}} + {{~#each definition.expressions~}} + {{~#furiganaPlain}}{{{.}}}{{/furiganaPlain~}} + {{~#unless @last}}, {{/unless~}} + {{~/each~}} + {{~else~}} + {{#furiganaPlain}}{{{definition}}}{{/furiganaPlain}} + {{~/if~}} {{/inline}} {{#*inline "glossary"}} @@ -71,12 +109,18 @@ function optionsFieldTemplates() { {{~else~}} {{~#if group~}} {{~#if definition.definitions.[1]~}} - <ol>{{#each definition.definitions}}<li>{{> glossary-single brief=../brief}}</li>{{/each}}</ol> + <ol>{{#each definition.definitions}}<li>{{> glossary-single brief=../brief compactGlossaries=../compactGlossaries}}</li>{{/each}}</ol> {{~else~}} - {{~> glossary-single definition.definitions.[0] brief=brief~}} + {{~> glossary-single definition.definitions.[0] brief=brief compactGlossaries=compactGlossaries~}} + {{~/if~}} + {{~else if merge~}} + {{~#if definition.definitions.[1]~}} + <ol>{{#each definition.definitions}}<li>{{> glossary-single brief=../brief compactGlossaries=../compactGlossaries}}</li>{{/each}}</ol> + {{~else~}} + {{~> glossary-single definition.definitions.[0] brief=brief compactGlossaries=compactGlossaries~}} {{~/if~}} {{~else~}} - {{~> glossary-single definition brief=brief~}} + {{~> glossary-single definition brief=brief compactGlossaries=compactGlossaries~}} {{~/if~}} {{~/if~}} </div> @@ -95,7 +139,16 @@ function optionsFieldTemplates() { {{/inline}} {{#*inline "reading"}} - {{~#unless modeTermKana}}{{definition.reading}}{{/unless~}} + {{~#unless modeTermKana~}} + {{~#if merge~}} + {{~#each definition.reading~}} + {{{.}}} + {{~#unless @last}}, {{/unless~}} + {{~/each~}} + {{~else~}} + {{~definition.reading~}} + {{~/if~}} + {{~/unless~}} {{/inline}} {{#*inline "sentence"}} @@ -115,7 +168,7 @@ function optionsFieldTemplates() { {{/inline}} {{#*inline "tags"}} - {{~#each definition.tags}}{{name}}{{#unless @last}}, {{/unless}}{{/each~}} + {{~#each definition.definitionTags}}{{name}}{{#unless @last}}, {{/unless}}{{/each~}} {{/inline}} {{#*inline "url"}} diff --git a/ext/bg/js/translator.js b/ext/bg/js/translator.js index bf347343..70b01ce3 100644 --- a/ext/bg/js/translator.js +++ b/ext/bg/js/translator.js @@ -128,8 +128,9 @@ class Translator { result.expressions = expressions; - // result.expression = Array.from(result.expression).join(', '); - // result.reading = Array.from(result.reading).join(', '); + result.expression = Array.from(result.expression); + result.reading = Array.from(result.reading); + definitionsMerged.push(result); } |