BoboTiG / ebook-reader-dict

Finally decent dictionaries based on the Wiktionary for your beloved eBook reader. Daily updates & 14 locales supported so far.
http://www.tiger-222.fr/?d=2020/04/17/22/14/21-un-dictionnaire-alternatif-et-complet-pour-votre-liseuse
MIT License
426 stars 24 forks source link

Feature request: Create EPUB dictionaries valid for Kindles #1913

Closed Juliaria08 closed 1 year ago

Juliaria08 commented 1 year ago

I propose the program creates or at least makes it easier to create valid codepage 1252 dictionaries, similar to the files made by The Ficcionary.

I understand that this might not be the best issue or may not be acknowledged, but I hope someone finds this useful, and I certainly do.

The kindle that I've got is a old K4S, and I can test files generated if requested, but if so, for the first tests I'd prefer to have the English and Spanish dictionaries used, as those are the languages I can read and understand.

Juliaria08 commented 1 year ago

Oh, it seems like the codepage isn't important, as kindlegen seems to have that option in the manpage saying -western: force build of Windows-1252 book, so I think the following headers should be set from KindleUnpack

  Field:         dict_in_lang   Offset: 0x060   Width:  4   Value: 0x0409
  Field:        dict_out_lang   Offset: 0x064   Width:  4   Value: 0x0409

Or somthing similar.

lasconic commented 1 year ago

Do you have more information about the format? A page describing it ?

Does https://github.com/ilius/pyglossary support the format?

My understanding is that a Kindle can read *.mobi dictionary and pyglossary can export this format. No ?

Juliaria08 commented 1 year ago

I can try to make pyglossary export the file I have that seems to work, I can also upload the default installed files if you want. Am currently going to look into pyglossary.

BoboTiG commented 1 year ago

I think we already covered that topic in the wiki: https://github.com/BoboTiG/ebook-reader-dict/wiki/HOWTO-Convert-to-mobi-for-the-Kindle

Or it is something else you need?

Juliaria08 commented 1 year ago

Oh, sorry. Didn't notice.

I think we already covered that topic in the wiki: https://github.com/BoboTiG/ebook-reader-dict/wiki/HOWTO-Convert-to-mobi-for-the-Kindle

Sorry. Didn't notice, thought there was going to be the direct files in the downloadeable links to make a nicer UX (I am a unix nerd but most people aren't), but if there's a entry on how to do so, I can use that entry.

Or it is something else you need?

No it's not anything else I need.

Juliaria08 commented 1 year ago

Also, noticed that penelope is archived, but whilst it works we don't have any issues.

dbogdanov commented 7 months ago

I've followed the instructions in the https://github.com/BoboTiG/ebook-reader-dict/wiki/HOWTO-Convert-to-mobi-for-the-Kindle however, after importing the resulting .mobi files to Kindle, the dictionaries have empty definitions for all words. Any suggestion on what could be the problem?

kvn1351 commented 5 months ago

rchived, but whilst it works we don't have any issu

I've followed the instructions in the https://github.com/BoboTiG/ebook-reader-dict/wiki/HOWTO-Convert-to-mobi-for-the-Kindle however, after importing the resulting .mobi files to Kindle, the dictionaries have empty definitions for all words. Any suggestion on what could be the problem?

I've followed the instructions in the https://github.com/BoboTiG/ebook-reader-dict/wiki/HOWTO-Convert-to-mobi-for-the-Kindle however, after importing the resulting .mobi files to Kindle, the dictionaries have empty definitions for all words. Any suggestion on what could be the problem?

Same issue here.

Edit: Got it working by using PyGlossary instead of Penelope.

Things to keep in mind:

CsatiZoltan commented 1 month ago

@kvn1351 Thanks for the instructions. For me, kindlegen created a mobi directory, not a file. Where did you copy it so that the Kindle recognizes it?

@dbogdanov Did kindlegen generate a single file for you?

CsatiZoltan commented 1 month ago

Finally, I managed to make it work, relying on the solution of @kvn1351. Here is a detailed workflow for future reference. @BoboTiG, feel free to edit the Wiki page if you find these instructions useful.

TLDR

pyglossary dict-fr-fr.df Wiktionary_FR.mobi  --write-options='kindlegen_path=kindlegen' --name Wiktionary_FR

assuming that you use the French dictionary, and both the dictionary file dict-fr-fr.df and kindlegen are on the PATH. If they are not, adjust the paths.

Detailed instructions

My config:

  1. Create a Python virtual environment and install the pyglossary and prompt_toolkit packages, and any other packages required by pyglossary (you will get errors for missing packages, so you will know).
  2. Download the DictFile version (.df extension) of the dictionary and the kindlegen executable corresponding to your OS. In my case, I wanted to convert the French dictionary, so I have dict-fr-fr.df.
  3. Call pyglossary with the --name and --write-options flags, like this:

    pyglossary dict-fr-fr.df Wiktionary_FR.mobi  --write-options='kindlegen_path=kindlegen' --name Wiktionary_FR

    In this example, the output file name is Wiktionary_FR.mobi. We instruct pyglossary to use kindlegen. The --name flag embeds the name of the dictionary into the mobi file. Whatever the name of the file is, --name determines under which name you will see the dictionary on your Kindle. Here, I set the same name for the file and for the dictionary.

    While kvn1351 wrote that you need to use the --remove-html-all flag for the conversion to be successful, I didn't have to set this flag. In fact, it is recommended not to set this flag, otherwise you will get uglier dictionary entries on your Kindle. The reason is that --remove-html-all, as its name suggests, removes all HTML formatting. For instance, in case of the word global, the enumerations would be removed, making the text more difficult to read.

  4. When executing the command above, expect some warnings. Finally, it displays
    [INFO] Created .mobi file with kindlegen: Wiktionary_FR.mobi/OEBPS/content.mobi
    [INFO] Writing file 'Wiktionary_FR.mobi' done.

    In fact, it created a directory, and within that directory the file you are looking for: content.mobi. You can rename it if you want, but whatever name you give to the file, the dictionary will be identified as Wiktionary_FR, based on how we set it with the --name flag.

  5. Copy the content.mobi file (or whatever name you gave it) to your Kindle. I copied it to /documents/dictionaries to keep all the dictionaries in one place, but it also works if you copy it directly to /documents.

That's all, now the dictionary is available for use on your Kindle. Hope it helps.