FooSoft / yomichan

Japanese pop-up dictionary extension for Chrome and Firefox.
https://foosoft.net/projects/yomichan
Other
1.06k stars 213 forks source link

Kanji Stroke Count #348

Closed psychodelicwasabi closed 3 years ago

psychodelicwasabi commented 4 years ago

The stroke count information is available on the Kanjidic, still, you can't import them with Yomichan. Frequency could also be a nice thing to have.

toasted-nutbread commented 4 years ago

Is this not on the kanji info page? A KANJIDIC dictionary file is able to be installed by Yomichan.

image

psychodelicwasabi commented 4 years ago

Sorry, I guess I wasn't obvious. What I mean is, I want to be able to import that data into the cards when I add the kanji to Anki.

siikamiika commented 4 years ago

You can edit your Anki templates if you enable advanced settings. It can also be useful to enable debugging while you do it, so you can see the structure of the object passed to the templates. You can always reset the templates if you mess it up.

However, it's not currently possible to reliably add stroke count to templates by yourself because not all kanji have the same amount of statistics available and Handlebars can't natively perform equality checks with the names of the statistics.

If a helper such as one described here was added to https://github.com/FooSoft/yomichan/blob/e8701cb950edd4c90f6c911e340db3af32194113/ext/bg/js/handlebars.js#L123-L135 you could do something like this within an existing template such as {glossary}:

        {{#each definition.stats.misc}}
            {{#ifEquals name "strokes"}}
            <p>Stroke count: {{value}}</p>
            {{/ifEquals}}
        {{/each}}

Right now the best you can do is just list everything in definition.stats.misc like so:

        <ul>
        {{#each definition.stats.misc}}
            <li>{{notes}}: {{value}}</li>
        {{/each}}
        </ul>