aboutsummaryrefslogtreecommitdiff
path: root/ext/bg
diff options
context:
space:
mode:
Diffstat (limited to 'ext/bg')
-rw-r--r--ext/bg/data/anki-field-templates-upgrade-v8.handlebars18
-rw-r--r--ext/bg/data/default-anki-field-templates.handlebars18
-rw-r--r--ext/bg/js/settings/anki-controller.js1
-rw-r--r--ext/bg/js/translator.js15
-rw-r--r--ext/bg/settings2.html4
5 files changed, 38 insertions, 18 deletions
diff --git a/ext/bg/data/anki-field-templates-upgrade-v8.handlebars b/ext/bg/data/anki-field-templates-upgrade-v8.handlebars
index 32c61343..b3aed45f 100644
--- a/ext/bg/data/anki-field-templates-upgrade-v8.handlebars
+++ b/ext/bg/data/anki-field-templates-upgrade-v8.handlebars
@@ -52,6 +52,13 @@
{{~#set "any" true}}{{/set~}}
{{~/if~}}
{{~/each~}}
+ {{~#unless noDictionaryTag~}}
+ {{~#if (op "||" (op "!" @root.compactTags) (op "!==" dictionary (get "previousDictionary")))~}}
+ {{~#if (get "any")}}, {{else}}<i>({{/if~}}
+ {{dictionary}}
+ {{~#set "any" true}}{{/set~}}
+ {{~/if~}}
+ {{~/unless~}}
{{~#if (get "any")}})</i> {{/if~}}
{{~/scope~}}
{{~#if only~}}({{#each only}}{{.}}{{#unless @last}}, {{/unless}}{{/each}} only) {{/if~}}
@@ -63,6 +70,7 @@
{{~else~}}
<ul>{{#each glossary}}<li>{{#multiLine}}{{.}}{{/multiLine}}</li>{{/each}}</ul>
{{~/if~}}
+ {{~#set "previousDictionary" dictionary~}}{{~/set~}}
{{/inline}}
{{>>>>>>>}}
@@ -99,12 +107,12 @@
<div style="text-align: left;">
{{~#scope~}}
{{~#if (op "===" definition.type "term")~}}
- {{~> glossary-single definition brief=brief ~}}
+ {{~> glossary-single definition brief=brief noDictionaryTag=noDictionaryTag ~}}
{{~else if (op "||" (op "===" definition.type "termGrouped") (op "===" definition.type "termMerged"))~}}
{{~#if (op ">" definition.definitions.length 1)~}}
- <ol>{{~#each definition.definitions~}}<li>{{~> glossary-single . brief=../brief ~}}</li>{{~/each~}}</ol>
+ <ol>{{~#each definition.definitions~}}<li>{{~> glossary-single . brief=../brief noDictionaryTag=../noDictionaryTag ~}}</li>{{~/each~}}</ol>
{{~else~}}
- {{~#each definition.definitions~}}{{~> glossary-single . brief=../brief ~}}{{~/each~}}
+ {{~#each definition.definitions~}}{{~> glossary-single . brief=../brief noDictionaryTag=../noDictionaryTag ~}}{{~/each~}}
{{~/if~}}
{{~else if (op "===" definition.type "kanji")~}}
{{~#if (op ">" definition.glossary.length 1)~}}
@@ -116,4 +124,8 @@
{{~/scope~}}
</div>
{{~/inline~}}
+
+{{#*inline "glossary-no-dictionary"}}
+ {{~> glossary noDictionaryTag=true ~}}
+{{/inline}}
{{>>>>>>>}}
diff --git a/ext/bg/data/default-anki-field-templates.handlebars b/ext/bg/data/default-anki-field-templates.handlebars
index 94553183..8ee2e00d 100644
--- a/ext/bg/data/default-anki-field-templates.handlebars
+++ b/ext/bg/data/default-anki-field-templates.handlebars
@@ -9,6 +9,13 @@
{{~#set "any" true}}{{/set~}}
{{~/if~}}
{{~/each~}}
+ {{~#unless noDictionaryTag~}}
+ {{~#if (op "||" (op "!" @root.compactTags) (op "!==" dictionary (get "previousDictionary")))~}}
+ {{~#if (get "any")}}, {{else}}<i>({{/if~}}
+ {{dictionary}}
+ {{~#set "any" true}}{{/set~}}
+ {{~/if~}}
+ {{~/unless~}}
{{~#if (get "any")}})</i> {{/if~}}
{{~/scope~}}
{{~#if only~}}({{#each only}}{{.}}{{#unless @last}}, {{/unless}}{{/each}} only) {{/if~}}
@@ -20,6 +27,7 @@
{{~else~}}
<ul>{{#each glossary}}<li>{{#multiLine}}{{.}}{{/multiLine}}</li>{{/each}}</ul>
{{~/if~}}
+ {{~#set "previousDictionary" dictionary~}}{{~/set~}}
{{/inline}}
{{#*inline "audio"}}
@@ -93,12 +101,12 @@
<div style="text-align: left;">
{{~#scope~}}
{{~#if (op "===" definition.type "term")~}}
- {{~> glossary-single definition brief=brief ~}}
+ {{~> glossary-single definition brief=brief noDictionaryTag=noDictionaryTag ~}}
{{~else if (op "||" (op "===" definition.type "termGrouped") (op "===" definition.type "termMerged"))~}}
{{~#if (op ">" definition.definitions.length 1)~}}
- <ol>{{~#each definition.definitions~}}<li>{{~> glossary-single . brief=../brief ~}}</li>{{~/each~}}</ol>
+ <ol>{{~#each definition.definitions~}}<li>{{~> glossary-single . brief=../brief noDictionaryTag=../noDictionaryTag ~}}</li>{{~/each~}}</ol>
{{~else~}}
- {{~#each definition.definitions~}}{{~> glossary-single . brief=../brief ~}}{{~/each~}}
+ {{~#each definition.definitions~}}{{~> glossary-single . brief=../brief noDictionaryTag=../noDictionaryTag ~}}{{~/each~}}
{{~/if~}}
{{~else if (op "===" definition.type "kanji")~}}
{{~#if (op ">" definition.glossary.length 1)~}}
@@ -111,6 +119,10 @@
</div>
{{~/inline~}}
+{{#*inline "glossary-no-dictionary"}}
+ {{~> glossary2 noDictionaryTag=true ~}}
+{{/inline}}
+
{{#*inline "glossary-brief"}}
{{~> glossary brief=true ~}}
{{/inline}}
diff --git a/ext/bg/js/settings/anki-controller.js b/ext/bg/js/settings/anki-controller.js
index c2292bc9..e7c8db15 100644
--- a/ext/bg/js/settings/anki-controller.js
+++ b/ext/bg/js/settings/anki-controller.js
@@ -94,6 +94,7 @@ class AnkiController {
'furigana-plain',
'glossary',
'glossary-brief',
+ 'glossary-no-dictionary',
'pitch-accents',
'pitch-accent-graphs',
'pitch-accent-positions',
diff --git a/ext/bg/js/translator.js b/ext/bg/js/translator.js
index 7242ec56..729c8294 100644
--- a/ext/bg/js/translator.js
+++ b/ext/bg/js/translator.js
@@ -133,7 +133,6 @@ class Translator {
for (const {character, onyomi, kunyomi, tags, glossary, stats, dictionary} of databaseDefinitions) {
const expandedStats = await this._expandStats(stats, dictionary);
const expandedTags = await this._expandTags(tags, dictionary);
- expandedTags.push(this._createDictionaryTag(dictionary));
this._sortTags(expandedTags);
const definition = this._createKanjiDefinition(character, dictionary, onyomi, kunyomi, glossary, expandedTags, expandedStats);
@@ -541,17 +540,14 @@ class Translator {
}
_flagRedundantDefinitionTags(definitions) {
- let lastDictionary = '';
+ let lastDictionary = null;
let lastPartOfSpeech = '';
const removeCategoriesSet = new Set();
- for (const {definitionTags} of definitions) {
- const dictionary = this._createMapKey(this._getTagNamesWithCategory(definitionTags, 'dictionary'));
+ for (const {dictionary, definitionTags} of definitions) {
const partOfSpeech = this._createMapKey(this._getTagNamesWithCategory(definitionTags, 'partOfSpeech'));
- if (lastDictionary === dictionary) {
- removeCategoriesSet.add('dictionary');
- } else {
+ if (lastDictionary !== dictionary) {
lastDictionary = dictionary;
lastPartOfSpeech = '';
}
@@ -1054,10 +1050,6 @@ class Translator {
return JSON.stringify(array);
}
- _createDictionaryTag(name) {
- return this._createTag(name, 'dictionary', '', 100, 0, name, false);
- }
-
_createTag(name, category, notes, order, score, dictionary, redundant) {
return {
name,
@@ -1101,7 +1093,6 @@ class Translator {
const dictionaryPriority = this._getDictionaryPriority(dictionary, enabledDictionaryMap);
const termTagsExpanded = await this._expandTags(termTags, dictionary);
const definitionTagsExpanded = await this._expandTags(definitionTags, dictionary);
- definitionTagsExpanded.push(this._createDictionaryTag(dictionary));
this._sortTags(definitionTagsExpanded);
this._sortTags(termTagsExpanded);
diff --git a/ext/bg/settings2.html b/ext/bg/settings2.html
index d557d366..d29bd4a1 100644
--- a/ext/bg/settings2.html
+++ b/ext/bg/settings2.html
@@ -2627,6 +2627,10 @@
<td>List of definitions for the term in a more compact format.</td>
</tr>
<tr>
+ <td><code class="anki-field-marker">{glossary-no-dictionary}</code></td>
+ <td>List of definitions for the term, except the dictionary tag is omitted.</td>
+ </tr>
+ <tr>
<td><code class="anki-field-marker">{pitch-accents}</code></td>
<td>List of pitch accent downstep notations for the term.</td>
</tr>