Ajatt-Tools / anki.koplugin

KOReader plugin enabling Anki card generations for words looked up in the internal dictionary.
49 stars 6 forks source link

Plugin can't determine language of a word in PDF files. #27

Closed ginger-aleeeee closed 2 months ago

ginger-aleeeee commented 2 months ago

KOReader version: Most recent version as of posting

Issue description: When highlighting an unknown word in a PDF with selectable text, an error is given: "1 note(s) failed to sync: - Could not determine language of word! (1)" which occurs despite having manually changed the document's language to the target language "fr"

Steps to reproduce the behavior:

  1. Open a selectable text PDF in KOReader.
  2. Hamburger menu > Book information > Page 2 > Tap and hold "Language" and enter "fr" > go back to document
  3. Highlight a word and tap "Add to Anki"
  4. See error

No crash encountered but crash log file is still attached. crash.log

Screenshot of the error in app: IMG_9572 This error does not occur with epub files (tested immediately after encountering this issue).

nairyosangha commented 2 months ago

I wasn't aware it was that easy to overwrite the language of the document on KOReader's side itself, so the plugin doesn't even look at that

Another thing to note is that I see you're trying to sync offline notes, the way this works is that it saves all the info it needs to do this in a JSON file on the e-reader itself. The language is part of what it needs, so that would be saved in that file itself (and in this case it would be empty).

If you update it afterwards, these notes stored locally will not reflect that change, you would have to update them manually, or just delete them and try again.

That said, this isn't that great, since you can't fix it and you only get to see the error when you try to sync the note, at which point it's too late to fix it.

I reworked this a bit on this branch: https://github.com/Ajatt-Tools/anki.koplugin/tree/feat/user_lang Now it fails immediately before trying to store the note locally. I still need to update the README with a note about this, I'll get to that tonight probably. It also actually looks at the language you set in the book information itself now so that PDF should work now

nairyosangha commented 2 months ago

I've merged this to master and updated the README with a note about it, so this should be fixed now. Feel free to reopen if I missed something