Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dictionary alias #1270

Merged
merged 50 commits into from
Aug 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
142098a
Able to edit dictionary alias on settings
khaitruong922 Jul 25, 2024
71ef14e
Merge branch 'master' into dictionary-alias
khaitruong922 Jul 25, 2024
5c05a9d
Fix lint
khaitruong922 Jul 25, 2024
efee5a5
Merge branch 'dictionary-alias' of https://github.com/khaitruong922/y…
khaitruong922 Jul 25, 2024
d5153c6
Persist alias
khaitruong922 Jul 25, 2024
fe2257b
Alias for tag
khaitruong922 Jul 25, 2024
008d5d4
Fix lint
khaitruong922 Jul 25, 2024
19a9dc9
update test
khaitruong922 Jul 25, 2024
f13dfac
draft
khaitruong922 Jul 25, 2024
4fb1c10
handle dom data binder for contenteditable
khaitruong922 Jul 26, 2024
8f9b8cb
Merge branch 'master' into dictionary-alias
khaitruong922 Jul 26, 2024
4391ed7
kanji dict alias
khaitruong922 Jul 26, 2024
0be1c5a
Merge branch 'dictionary-alias' of https://github.com/khaitruong922/y…
khaitruong922 Jul 26, 2024
452be89
alias frequency dict
khaitruong922 Jul 26, 2024
5e0663c
update test
khaitruong922 Jul 26, 2024
7fd82f1
add alias to anki
khaitruong922 Jul 26, 2024
49c266b
Revert "add alias to anki"
khaitruong922 Jul 26, 2024
914472d
Fix alias not working correctly for grouped entries
khaitruong922 Jul 26, 2024
618b53c
Remove contenteditable event listener
khaitruong922 Jul 26, 2024
3a15e06
renaming
khaitruong922 Jul 26, 2024
6603fe3
reset original name when alias empty && make alias pastable
khaitruong922 Jul 26, 2024
6a5f1f5
refactor
khaitruong922 Jul 26, 2024
7dc2913
Handle contenteditable empty makes observer child triggered
khaitruong922 Jul 27, 2024
6d040c4
lint
khaitruong922 Jul 27, 2024
824fda8
add alias to anki glossary && add dictionary-alias marker
khaitruong922 Jul 29, 2024
ea7ef6f
merge master
khaitruong922 Jul 29, 2024
51a67c0
fallback to dictionary name if alias is empty
khaitruong922 Jul 29, 2024
4f94cf2
update handlebars
khaitruong922 Jul 29, 2024
aea9e9b
add alias to test
khaitruong922 Jul 29, 2024
c31146a
update test glossary
khaitruong922 Jul 29, 2024
55bda55
fixing test
khaitruong922 Jul 30, 2024
2863a8e
add alias term frequncy & pitch accent anki
khaitruong922 Jul 30, 2024
dbaba41
Pass dictionary alias to all anki type
khaitruong922 Jul 30, 2024
b794e89
update all unit tests
khaitruong922 Jul 30, 2024
551f80d
test populate alias after update
khaitruong922 Jul 30, 2024
e4771bb
clean up
khaitruong922 Jul 30, 2024
5352565
Merge branch 'master' into dictionary-alias
khaitruong922 Jul 30, 2024
550ab45
alias for frequency handlebars
khaitruong922 Jul 30, 2024
9cb30eb
Alias for pronunciation dict
khaitruong922 Jul 30, 2024
ff43607
lint
khaitruong922 Jul 30, 2024
4910fb0
refactor
khaitruong922 Jul 30, 2024
13861d0
Merge branch 'master' into dictionary-alias
khaitruong922 Jul 30, 2024
5325bce
trim alias && save on enter
khaitruong922 Jul 30, 2024
ec1c1c3
Merge branch 'dictionary-alias' of https://github.com/khaitruong922/y…
khaitruong922 Jul 30, 2024
f457ff3
move edit alias to kebab menu
khaitruong922 Jul 30, 2024
a8d1601
fix lint issues
khaitruong922 Jul 30, 2024
00b088e
Merge branch 'master' into dictionary-alias
khaitruong922 Jul 31, 2024
9066cab
Merge branch 'master' into dictionary-alias
khaitruong922 Aug 7, 2024
c83caec
Update text
khaitruong922 Aug 7, 2024
ee153cd
update doc for {dictionary} marker
khaitruong922 Aug 7, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions docs/anki-integration.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ Flashcard fields can be configured with the following steps:
| `{cloze-prefix}` | Fragment of the containing `{sentence}` starting at the beginning of `{sentence}` until the beginning of `{cloze-body}`. |
| `{cloze-suffix}` | Fragment of the containing `{sentence}` starting at the end of `{cloze-body}` until the end of `{sentence}`. |
| `{conjugation}` | Conjugation path from the raw inflected term to the source term. |
| `{dictionary}` | Name of the dictionary from which the card is being created (unavailable in _grouped_ mode). |
| `{dictionary}` | Original name of the dictionary from which the card is being created (unavailable in _grouped_ mode). |
| `{dictionary-alias}` | Display name of the dictionary from which the card is being created (unavailable in _grouped_ mode). |
| `{document-title}` | Title of the web page that the term appeared in. |
| `{expression}` | Term expressed as kanji (will be displayed in kana if kanji is not available). |
| `{frequencies}` | Frequency information for the term. |
Expand Down Expand Up @@ -79,7 +80,8 @@ Flashcard fields can be configured with the following steps:
| `{cloze-body}` | Raw, inflected parent term as it appeared before being reduced to dictionary form by Yomitan. |
| `{cloze-prefix}` | Fragment of the containing `{sentence}` starting at the beginning of `{sentence}` until the beginning of `{cloze-body}`. |
| `{cloze-suffix}` | Fragment of the containing `{sentence}` starting at the end of `{cloze-body}` until the end of `{sentence}`. |
| `{dictionary}` | Name of the dictionary from which the card is being created. |
| `{dictionary}` | Original name of the dictionary from which the card is being created. |
| `{dictionary-alias}` | Display name of the dictionary from which the card is being created. |
| `{document-title}` | Title of the web page that the kanji appeared in. |
| `{frequencies}` | Frequency information for the kanji. |
| `{frequency-harmonic-rank}` | The harmonic mean of frequency data for the current kanji. Defaults to rank 9999999 when frequency data is not found, indicating extremely low rank-based kanji usage. |
Expand Down
4 changes: 4 additions & 0 deletions ext/css/settings.css
Original file line number Diff line number Diff line change
Expand Up @@ -2404,6 +2404,10 @@ input[type=number].dictionary-priority {
overflow: auto;
}

#dictionary-alias-input {
width: 100%;
}

#dictionary-move-up>span.icon-button-inner,
#dictionary-move-down>span.icon-button-inner {
width: 26px;
Expand Down
5 changes: 5 additions & 0 deletions ext/data/schemas/options-schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -831,6 +831,7 @@
"type": "object",
"required": [
"name",
"alias",
"priority",
"enabled",
"allowSecondarySearches",
Expand All @@ -843,6 +844,10 @@
"type": "string",
"default": ""
},
"alias": {
"type": "string",
"default": ""
},
"priority": {
"type": "number",
"default": 0
Expand Down
115 changes: 115 additions & 0 deletions ext/data/templates/anki-field-templates-upgrade-v49.handlebars
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
{{<<<<<<<}}
{{#*inline "glossary-single"}}
{{~#unless brief~}}
{{~#scope~}}
{{~set "any" false~}}
{{~#each definitionTags~}}
{{~#if (op "||" (op "!" @root.compactTags) (op "!" redundant))~}}
{{~#if (get "any")}}, {{else}}<i>({{/if~}}
{{name}}
{{~set "any" true~}}
{{~/if~}}
{{~/each~}}
{{~#unless noDictionaryTag~}}
{{~#if (op "||" (op "!" @root.compactTags) (op "!==" dictionary (get "previousDictionary")))~}}
{{~#if (get "any")}}, {{else}}<i>({{/if~}}
{{dictionary}}
{{~set "any" true~}}
{{~/if~}}
{{~/unless~}}
{{~#if (get "any")}})</i> {{/if~}}
{{~/scope~}}
{{~#if only~}}({{#each only}}{{.}}{{#unless @last}}, {{/unless}}{{/each}} only) {{/if~}}
{{~/unless~}}
{{~#if (op "<=" glossary.length 1)~}}
{{#each glossary}}{{formatGlossary ../dictionary .}}{{/each}}
{{~else if @root.compactGlossaries~}}
{{#each glossary}}{{formatGlossary ../dictionary .}}{{#unless @last}} | {{/unless}}{{/each}}
{{~else~}}
<ul>{{#each glossary}}<li>{{formatGlossary ../dictionary .}}</li>{{/each}}</ul>
{{~/if~}}
{{~set "previousDictionary" dictionary~}}
{{/inline}}
{{=======}}
{{#*inline "glossary-single"}}
{{~#unless brief~}}
{{~#scope~}}
{{~set "any" false~}}
{{~#each definitionTags~}}
{{~#if (op "||" (op "!" @root.compactTags) (op "!" redundant))~}}
{{~#if (get "any")}}, {{else}}<i>({{/if~}}
{{name}}
{{~set "any" true~}}
{{~/if~}}
{{~/each~}}
{{~#unless noDictionaryTag~}}
{{~#if (op "||" (op "!" @root.compactTags) (op "!==" dictionary (get "previousDictionary")))~}}
{{~#if (get "any")}}, {{else}}<i>({{/if~}}
{{dictionaryAlias}}
{{~set "any" true~}}
{{~/if~}}
{{~/unless~}}
{{~#if (get "any")}})</i> {{/if~}}
{{~/scope~}}
{{~#if only~}}({{#each only}}{{.}}{{#unless @last}}, {{/unless}}{{/each}} only) {{/if~}}
{{~/unless~}}
{{~#if (op "<=" glossary.length 1)~}}
{{#each glossary}}{{formatGlossary ../dictionary .}}{{/each}}
{{~else if @root.compactGlossaries~}}
{{#each glossary}}{{formatGlossary ../dictionary .}}{{#unless @last}} | {{/unless}}{{/each}}
{{~else~}}
<ul>{{#each glossary}}<li>{{formatGlossary ../dictionary .}}</li>{{/each}}</ul>
{{~/if~}}
{{~set "previousDictionary" dictionary~}}
{{/inline}}
{{>>>>>>>}}

{{<<<<<<<}}
{{#*inline "dictionary"}}
{{~definition.dictionary~}}
{{/inline}}
{{=======}}
{{#*inline "dictionary"}}
{{~definition.dictionary~}}
{{/inline}}

{{#*inline "dictionary-alias"}}
{{~definition.dictionaryAlias~}}
{{/inline}}
{{>>>>>>>}}

{{<<<<<<<}}
{{#*inline "frequencies"}}
{{~#if (op ">" definition.frequencies.length 0)~}}
<ul style="text-align: left;">
{{~#each definition.frequencies~}}
<li>
{{~#if (op "!==" ../definition.type "kanji")~}}
{{~#if (op "||" (op ">" ../uniqueExpressions.length 1) (op ">" ../uniqueReadings.length 1))~}}(
{{~furigana expression reading~}}
) {{/if~}}
{{~/if~}}
{{~dictionary}}: {{frequency~}}
</li>
{{~/each~}}
</ul>
{{~/if~}}
{{/inline}}
{{=======}}
{{#*inline "frequencies"}}
{{~#if (op ">" definition.frequencies.length 0)~}}
<ul style="text-align: left;">
{{~#each definition.frequencies~}}
<li>
{{~#if (op "!==" ../definition.type "kanji")~}}
{{~#if (op "||" (op ">" ../uniqueExpressions.length 1) (op ">" ../uniqueReadings.length 1))~}}(
{{~furigana expression reading~}}
) {{/if~}}
{{~/if~}}
{{~dictionaryAlias}}: {{frequency~}}
</li>
{{~/each~}}
</ul>
{{~/if~}}
{{/inline}}
{{>>>>>>>}}
8 changes: 6 additions & 2 deletions ext/data/templates/default-anki-field-templates.handlebars
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
{{~#unless noDictionaryTag~}}
{{~#if (op "||" (op "!" @root.compactTags) (op "!==" dictionary (get "previousDictionary")))~}}
{{~#if (get "any")}}, {{else}}<i>({{/if~}}
{{dictionary}}
{{dictionaryAlias}}
{{~set "any" true~}}
{{~/if~}}
{{~/unless~}}
Expand Down Expand Up @@ -44,6 +44,10 @@
{{~definition.dictionary~}}
{{/inline}}

{{#*inline "dictionary-alias"}}
{{~definition.dictionaryAlias~}}
{{/inline}}

{{#*inline "expression"}}
{{~#if merge~}}
{{~#if modeTermKana~}}
Expand Down Expand Up @@ -365,7 +369,7 @@
{{~furigana expression reading~}}
) {{/if~}}
{{~/if~}}
{{~dictionary}}: {{frequency~}}
{{~dictionaryAlias}}: {{frequency~}}
</li>
{{~/each~}}
</ul>
Expand Down
4 changes: 3 additions & 1 deletion ext/js/background/backend.js
Original file line number Diff line number Diff line change
Expand Up @@ -2472,6 +2472,7 @@ export class Backend {
if (mode === 'merge' && !enabledDictionaryMap.has(mainDictionary)) {
enabledDictionaryMap.set(mainDictionary, {
index: enabledDictionaryMap.size,
alias: mainDictionary,
StefanVukovic99 marked this conversation as resolved.
Show resolved Hide resolved
priority: 0,
allowSecondarySearches: false,
partsOfSpeechFilter: true,
Expand Down Expand Up @@ -2516,9 +2517,10 @@ export class Backend {
const enabledDictionaryMap = new Map();
for (const dictionary of options.dictionaries) {
if (!dictionary.enabled) { continue; }
const {name, priority, allowSecondarySearches, partsOfSpeechFilter, useDeinflections} = dictionary;
const {name, alias, priority, allowSecondarySearches, partsOfSpeechFilter, useDeinflections} = dictionary;
enabledDictionaryMap.set(name, {
index: enabledDictionaryMap.size,
alias,
priority,
allowSecondarySearches,
partsOfSpeechFilter,
Expand Down
Loading
Loading