Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

StarDict Textual: support resource files #558

Closed
homocomputeris opened this issue Apr 24, 2024 · 8 comments
Closed

StarDict Textual: support resource files #558

homocomputeris opened this issue Apr 24, 2024 · 8 comments

Comments

@homocomputeris
Copy link

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.

@ilius
Copy link
Owner

ilius commented Apr 29, 2024

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.

@homocomputeris
Copy link
Author

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.

@ilius
Copy link
Owner

ilius commented Apr 30, 2024

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.

@homocomputeris
Copy link
Author

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.

@ilius
Copy link
Owner

ilius commented May 1, 2024

Did you check the "res" folder?

@homocomputeris
Copy link
Author

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

@ilius
Copy link
Owner

ilius commented May 1, 2024

Our StarDict textual does not support resources.

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

@homocomputeris
Copy link
Author

homocomputeris commented May 1, 2024

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

@ilius ilius changed the title Preserve media when converting from Babylon BGL StarDict Textual: support resource files Jul 29, 2024
@ilius ilius closed this as completed Sep 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants