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

Add onyomi-hiragana handlebars #960

Merged
merged 3 commits into from
May 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
5 changes: 3 additions & 2 deletions docs/anki-integration.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,9 @@ Flashcard fields can be configured with the following steps:
| `{frequency-average-rank}` | The average of frequency data for the current kanji. Defaults to rank 9999999 when frequency data is not found, indicating extremely low rank-based kanji usage. |
| `{frequency-average-occurrence}` | The average of frequency data for the current kanji. Defaults to 0 occurrences when frequency data is not found, the lowest possible occurrence-based kanji usage. |
| `{glossary}` | List of definitions for the kanji. |
| `{kunyomi}` | Kunyomi (Japanese reading) for the kanji expressed as katakana. |
| `{onyomi}` | Onyomi (Chinese reading) for the kanji expressed as hiragana. |
| `{kunyomi}` | Kunyomi (Japanese reading) for the kanji expressed as hiragana. |
| `{onyomi}` | Onyomi (Chinese reading) for the kanji expressed as katakana. |
| `{onyomi-hiragana}` | Onyomi (Chinese reading) for the kanji expressed as hiragana. |
| `{screenshot}` | Screenshot of the web page taken at the time the kanji was added. |
| `{search-query}` | The full search query shown on the search page. |
| `{selection-text}` | The selected text on the search page or popup. |
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{{#*inline "onyomi-hiragana"}}
{{~#each definition.onyomi}}{{hiragana .}}{{#unless @last}}, {{/unless}}{{/each~}}
{{/inline}}
4 changes: 4 additions & 0 deletions ext/data/templates/default-anki-field-templates.handlebars
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,10 @@
{{~#each definition.onyomi}}{{.}}{{#unless @last}}, {{/unless}}{{/each~}}
{{/inline}}

{{#*inline "onyomi-hiragana"}}
{{~#each definition.onyomi}}{{hiragana .}}{{#unless @last}}, {{/unless}}{{/each~}}
{{/inline}}

{{#*inline "reading"}}
{{~#unless modeTermKana~}}
{{~#if merge~}}
Expand Down
1 change: 1 addition & 0 deletions ext/js/data/anki-template-util.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ export function getStandardFieldMarkers(type) {
'glossary',
'kunyomi',
'onyomi',
'onyomi-hiragana',
'screenshot',
'search-query',
'selection-text',
Expand Down
10 changes: 9 additions & 1 deletion ext/js/data/options-util.js
Original file line number Diff line number Diff line change
Expand Up @@ -542,7 +542,8 @@ export class OptionsUtil {
this._updateVersion32,
this._updateVersion33,
this._updateVersion34,
this._updateVersion35
this._updateVersion35,
this._updateVersion36
];
/* eslint-enable @typescript-eslint/unbound-method */
if (typeof targetVersion === 'number' && targetVersion < result.length) {
Expand Down Expand Up @@ -1286,6 +1287,13 @@ export class OptionsUtil {
await this._applyAnkiFieldTemplatesPatch(options, '/data/templates/anki-field-templates-upgrade-v35.handlebars');
}

/**
* - Added handlebars for onyomi reading in hiragana.
* @type {import('options-util').UpdateFunction}
*/
async _updateVersion36(options) {
await this._applyAnkiFieldTemplatesPatch(options, '/data/templates/anki-field-templates-upgrade-v36.handlebars');
}

/**
* @param {string} url
Expand Down
6 changes: 5 additions & 1 deletion ext/settings.html
Original file line number Diff line number Diff line change
Expand Up @@ -3088,10 +3088,14 @@ <h1>Yomitan Settings</h1>
</tr>
<tr>
<td><code class="anki-field-marker">{kunyomi}</code></td>
<td>Kunyomi (Japanese reading) for the kanji, expressed as katakana.</td>
<td>Kunyomi (Japanese reading) for the kanji, expressed as hiragana.</td>
StefanVukovic99 marked this conversation as resolved.
Show resolved Hide resolved
</tr>
<tr>
<td><code class="anki-field-marker">{onyomi}</code></td>
<td>Onyomi (Chinese reading) for the kanji, expressed as katakana.</td>
</tr>
<tr>
<td><code class="anki-field-marker">{onyomi-hiragana}</code></td>
<td>Onyomi (Chinese reading) for the kanji, expressed as hiragana.</td>
</tr>
<tr>
Expand Down
2 changes: 2 additions & 0 deletions test/data/anki-note-builder-test-results.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
"glossary": "<div style=\"text-align: left;\"><ol><li>utsu meaning 1</li><li>utsu meaning 2</li><li>utsu meaning 3</li><li>utsu meaning 4</li><li>utsu meaning 5</li></ol></div>",
"kunyomi": "う.つ, う.ち-, ぶ.つ",
"onyomi": "ダ, ダアス",
"onyomi-hiragana": "だ, だあす",
"screenshot": "",
"search-query": "fullQuery",
"selection-text": "",
Expand Down Expand Up @@ -50,6 +51,7 @@
"glossary": "<div style=\"text-align: left;\"><ol><li>komu meaning 1</li><li>komu meaning 2</li><li>komu meaning 3</li><li>komu meaning 4</li><li>komu meaning 5</li></ol></div>",
"kunyomi": "-こ.む, こ.む, こ.み, -こ.み, こ.める",
"onyomi": "",
"onyomi-hiragana": "",
"screenshot": "",
"search-query": "fullQuery",
"selection-text": "",
Expand Down
2 changes: 1 addition & 1 deletion test/options-util.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -605,7 +605,7 @@ function createOptionsUpdatedTestData1() {
}
],
profileCurrent: 0,
version: 35,
version: 36,
global: {
database: {
prefixWildcardsSupported: false
Expand Down