gdcv is a command-line interface for searching GoldenDict dictionaries(*.dsl.dz). The program is a very rudimentary workaround to allow searching until an official command-line interface is available.
As an example of a similar interface, GoldenDict has gdcl (Command-line interface for Goldendict), but for my dictionary collection(10 GB) it works really slow due to no pre-made index for faster searching.
StarDict has sdcv (StarDict Console Version), but it can only handle dictionaries in the StarDict format. For users of GoldenDict who have large collections of dictionaries in DSL format, converting and maintaining two parallel sets of dictionaries is not a practical solution.
gdcv does not require an installation of GoldenDict and does not use GoldenDict’s pre-made index files, it creates new one.
The main catch is that gdcv is written in C by a person who has never programmed anything before. It seems the program does not leak memory, but the software architecture is horrible.
Please vote for official command-line interface for GoldenDict.
- Search a word in a dictionary
- Find words that contain a substring
- Syntax highlighting
- Extracting media files
- Emacs dynamic module, if necessary
- gcc or clang
- zlib
- unzip (in order to unpack resources in zip files)
For Ubuntu:
sudo apt install zlib1g-dev unzip
git clone https://github.com/konstare/gdcv
cd gdcv
make gdcv
Put gdcv into a directory from the $PATH.
Sometimes GoldenDict dictionaries (DSL) comes in UTF-16. It is above my pay-grade to deal with it, all dictionaries should be converted to UTF-8. It is not the problem for GoldenDict as it supports both UTF-16 and UTF-8. Moreover dictionaries in UTF-8 take 20% less space
To convert dictionaries dos2unix is needed.
In the GoldenDict directory:
find . -name '*.dsl.dz' -exec gunzip -S .dz {} \;
find . -name '*.dsl' -exec dos2unix --add-bom -f {} \;
find . -name '*.dsl' -exec gdcv -z {} \;
find . -name '*.ann' -exec dos2unix --add-bom -f {} \;
gdcv -i /path/to/directory/in/DSL/format /path/to/second/directory/in/DSL/format
Two index files will be saved in the directory:
$XDG_CONFIG_HOME/gdcv/
or $HOME/.config/gdcv/
if XDG_CONFIG_HOME
is not defined.
To look up a word “cat”
gdcv cat
To search words containing “cat”
gdcv *cat
Put all additional media files to directory /tmp
gdcv cat --unzip=/tmp/
It is easy to create a dictionary in GoldenDict format. Essentially the format is specified here, except that @ tag is not supported. One can use typical dictionary in DSL format. The dsl file has to be compressed in dictzip format and moved to GoldenDict directory.
gdcv -z dictionary.dsl
Note, that the result dsl.dz file can be uncompressed back with gzip:
gunzip -S .dz dictionary.dsl.dz
For many years I have successfully used sdcv-mode and sdcv in my work flow. Turn out all modern dictionaries are formatted in GoldenDict format (DSL). I tried to convert DSL to StarDict format with pyglossary but the result was mediocre. There is goldendict-el for Emacs but I wanted something similar to sdcv-mode.
make gdcv emacs-module
gdcv -i /path/to/directory/in/DSL/format
cp gdcv-elisp.so ~/.emacs.d/site-lisp/
cp gdcv.el ~/.emacs.d/site-lisp/
Add to the init file
(use-package gdcv
:load-path "~/.emacs.d/site-lisp"
:bind (("C-c d" . gdcv-search-word)))
If the index file is not saved in default directory, add:
(setq gdcv-index-path "path/to/index/file")
To show the selected dictionary first, modify gdcv-default-dictionary-list
(setq gdcv-default-dictionary-list '("OxfordDictionary (En-En)" "Merriam-Webster's Advanced Learner's Dictionary (En-En)"))
All media files for the translated word are unpacked to gdcv-media-temp-directory
and are played by gdcv-play-media
function (by default it is just wrapper around xdg-open).
(setq gdcv-media-temp-directory "/tmp/gdcv/"
gdcv-play-media (lambda (file)
(let ((process-connection-type nil))
(start-process "" nil "xdg-open" file))))
C-c d
to translate word (or text selection) under the cursor.
The gdcv-mode goes with simple ivy interface ivy-gdcv, which can be used to search a word. By default, the prefix search is used, for example for “cat”, one can get: “cat”,”catamaran”, “cater”… For the substring search one can type “*cat” and get: “cat”,”muscatel”,…
- DaDaKo Dictionaries for all languages (the website interface is in Russian)
- Webster and WordNet English-English
- Bilingual dictionaries from Wiktionary
http://lingvo.helpmax.net/en/troubleshooting/dsl-compiler/your-first-dsl-dictionary/
https://github.com/Tvangeste/SampleDSL
https://github.com/dohliam/dsl-tools
https://github.com/dohliam/gdcl
- https://github.com/nongeneric/lsd2dsl C++ implementation
- https://github.com/sv99/lsdreader python implementation