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

Dict: OPTION MIME Support #947

Open
Michahel opened this Issue Jan 19, 2018 · 2 comments

Comments

Projects
None yet
2 participants
@Michahel

Michahel commented Jan 19, 2018

The DICT-server can give MIME content, i.e. give arbitrary content without restrictions with reference to their type. If the DICT-client is able to receive a MIME content, it shall send the OPTION MIME command to the DICT-server (see dict -M). In this case, the DICT-client goes to processing task of the content. dictd, in turn, can give Plain Text or MIME content depending on whether if the client gave the OPTION MIME command to him. See A Dictionary Server Protocol. So, DICT-dictionary can consist of two modules: one with PlainText content, and other with a MIME content. In the file /usr/share/doc/dictd/examples/dictd_mime.conf we can find for example how to set up the configuration file /etc/dictd/dictd.conf in order to DICT-server will able properly to process the OPTION MIME command.
The GoldenDict doesn't support the OPTION MIME for the dictionaries which are given in the "Edit > Dictionaries > Sources > DICT servers" menu, in this way all dictionaries installed in the "DICT servers" tab can be only with Plain Text content.
I express my desire about working out such a support. For testing MIME-heading I can suggest DICT-server: dict.bibleonline.ru; dictionaries:

  • heb-rus_strong
  • ell-rus_strong

These dictionaries have the following MIME-heading:

Content-type: text/html; charset=utf-8
Content-transfer-encoding: 8bit

In answer to the OPTION MIME command DICT-server may give arbitrary content without limit by indicating its type. DICT-client may not expect such content which will be given to him. In this case I will consider in the quality of the DICT-client the program GoldenDict. The task is included so that GoldenDict would give an error message in such a case if it receives such a MIME heading which it is not yet able to support. Sample message text: "The dictionary entry contains a MIME heading that is not supported in GoldenDict." Further, as a need appears a list of supported MIME headings can be expanded for the user.

@wzyboy

This comment has been minimized.

wzyboy commented Jun 1, 2018

This is an excellent idea. I am building my own dictd(1) server on localhost. I converted a Kindle dictionary to DICT format (MOBI -> HTML -> TSV -> DICT) and loaded it successfully with dictd(1). It works well, I can telnet localhost or dict -h localhost or use GoldenDict to get definitions. However, the returned definitions are in HTML as the source files use HTML.

My current workaround is to add a "Program" entry in GoldenDict, using dict %GDWORD% to send the query, and choose "HTML" type. This way, GoldenDict renders the HTML definitions perfectly.

@Michahel

This comment has been minimized.

Michahel commented Jun 4, 2018

I am very glad that I met someone likeminded. I also went that way. I want to now bring up those flaws which make themselves known when directly using dict as an external program.

How to reproduce the problem

Start up GoldenDict.
In the menu, under "Edit > Dictionaries > Sources" in the "Programs" tab click on the "Add" button and create a new entry. Choose the Type of program — Html. In the "Program name" field write "Dict dictionary". Enter in the "Command Line" field command as shown below:

dict -M -h dict.bible.ru -s word "%GDWORD%

Check the "Enabled" option and click OK.
In the Search Text box type the word "אדם" and wait a little until the definitions from the recently created dictionary are displayed.
See screen capture 1
See screen capture 2

The core of the problem:

  1. After the title we see MIME-heading which isn't on a separate line. The title (line begining with the word From) MIME-heading and the first line in the definition looks like one paragraph.
  2. The last line in the definition doesn't separate from the next definition lines following it but connects them into one paragraph. More precisely, in one paragraph the last paragraph of the first definition is joined with the first paragraph of the next definition.
  3. If the definitions are received from the dictionaries with Plain Text, then they all go without formating the paragraphs.

In order to solve all of these problems an intermediate script must be created which will run dict and will as a result format in the needed way. I created such a script in the JScript language. Look at the screen captures with these wort definitions:

See screen capture 3
See screen capture 4

How to install

Run the self-extracting archive dict1.12.1.exe.
After you click on the archive it will automatically extract the files, start the process of detecting GoldenDict on your computer, and after detection — it automatically adds three files (dict.js, dict.exe, cygwin1.dll), which are contained in the archive, to the sub-directory dict1.12.1 in the same directory as the GoldenDict is located.
Note:
You have to be in an administrator account under Vista or later to carry out this installation.
Start up GoldenDict.
In the menu click on "Edit > Dictionaries > Sources". In the "Programs" tab click on the "Add" button and create a new entry. Indicate the Type of program — Html. In the "Program name" field write "JScript dictionary". Type in the "Command Line" field:

cscript //Nologo //U dict1.12.1\dict.js /h:dict.bible.ru /p:2628 /s:word "%GDWORD%"

Check the "Enabled" option and click OK.

The flaw could be considered that which is calculated only for users with Windows, installer is intended only for russian language users, and the setup process itself, in my opinion, has turned out to be quite difficult.
I hope that the discussion of this topic will contribute so that in GoldenDict appears the support OPTION MIME.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment