pyglossary
pyglossary copied to clipboard
StarDict Textual: support resource files
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.
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.
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.
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.
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.
Did you check the "res" folder?
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
Our StarDict textual does not support resources.
The "res" folder is for StarDict format (binary). Convert directly from bgl to stardict.
What is the problem to create a resource folder for stardict xml if it is created for apple xml?