pyglossary icon indicating copy to clipboard operation
pyglossary copied to clipboard

StarDict Textual: support resource files

Open homocomputeris opened this issue 9 months ago • 8 comments

Babilon dictionaries have some media inside, at least the icon. It can be seen when converted to AppleDict:

test
├── Makefile
├── OtherResources
│   ├── 8EAF66FD.bmp
│   ├── C2EEF3F6.html
│   ├── icon1.ico
│   └── icon2.ico
├── test.css
├── test.plist
└── test.xml

However, when converted to, for example, StarDict (both text and binary) the icons are lost.

Enhancement suggestion: preserve icons according to the GoldenDict conventions:

For Babylon, StarDict, DictD, ABBYY Lingvo, AardDictionary, SDictionary, Zim, MDict, Lsa, Zips, Slob, Gls dictionaries such graphics file must be named by main dictionary file name and places beside one.

homocomputeris avatar Apr 24 '24 19:04 homocomputeris

To be clear, you are only talking about the icon showed by GoldenDict as dictionry icon.

Media files aka resources, are placed in "res" folder for StarDict output. And are supposed to be used inside the dictionary text.

And what if there are multiple .ico files like this example? GoldenDict supports one.

ilius avatar Apr 29 '24 03:04 ilius

And what if there are multiple .ico files like this example?

It is the bmp one. If not, it may be dict_name_1.ico, dict_name_2.bmp, etc. Seems better that silent >/dev/null.

homocomputeris avatar Apr 29 '24 22:04 homocomputeris

Well how do we know if it's the dictionary icon or just an image used in some word's definition? There could be multiple bmp and ico files.

ilius avatar Apr 30 '24 05:04 ilius

This is why the title is "Preserve media when converting from Babylon BGL". They shouldn't be lost, so the user can decide what to do with them afterwards.

homocomputeris avatar Apr 30 '24 20:04 homocomputeris

Did you check the "res" folder?

ilius avatar May 01 '24 05:05 ilius

Did you check the "res" folder?

There is no such folder when converting Babylon to Stardict. Whatever goes to OtherResources in the AppleDict case is lost for Stardict.

~/test % ls -l
total 40
-rw-r--r--  1 user  staff  18717 Mar 19  2011 example.bgl

~/test % pyglossary *.bgl stardicttextual.xml --read-format=BabylonBgl --write-format=StardictTextual
[INFO] Writing to StardictTextual file '/Users/user/test/stardicttextual.xml'
Converting | |██████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████|%100.0 Time: 0:00:00
[INFO] Writing file '/Users/user/test/stardicttextual.xml' done.
[INFO] Running time of convert: 0.2 seconds

~/test % ls -l
total 168
-rw-r--r--  1 user  staff  18717 Mar 19  2011 example.bgl
-rw-r--r--@ 1 user  staff  65015 May  1 12:21 stardicttextual.xml

~/test % pyglossary *.bgl appledict --read-format=BabylonBgl --write-format=AppleDict
[INFO] Writing to AppleDict file '/Users/user/test/appledict'
/Users/user/.local/pipx/venvs/pyglossary/lib/python3.12/site-packages/pyglossary/plugins/appledict/_content.py:173: MarkupResemblesLocatorWarning: The input looks more like a filename than markup. You may want to open this file and pass the filehandle into Beautiful Soup.
  soup = BeautifulSoup.BeautifulSoup(body, features="lxml")
/Users/user/.local/pipx/venvs/pyglossary/lib/python3.12/site-packages/pyglossary/plugins/appledict/_normalize.py:119: MarkupResemblesLocatorWarning: The input looks more like a filename than markup. You may want to open this file and pass the filehandle into Beautiful Soup.
  title = BeautifulSoup.BeautifulSoup(
Converting | |██████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████|%100.0 Time: 0:00:00
[INFO] Writing file '/Users/user/test/appledict' done.
[INFO] Running time of convert: 0.5 seconds

~/test % tree appledict      
appledict
├── Makefile
├── OtherResources
│   ├── 8EAF66FD.bmp
│   ├── C2EEF3F6.html
│   └── icon1.ico
├── appledict.css
├── appledict.plist
└── appledict.xml

homocomputeris avatar May 01 '24 10:05 homocomputeris

Our StarDict textual does not support resources.

The "res" folder is for StarDict format (binary). Convert directly from bgl to stardict.

ilius avatar May 01 '24 10:05 ilius

What is the problem to create a resource folder for stardict xml if it is created for apple xml?

homocomputeris avatar May 01 '24 11:05 homocomputeris