The OSX Dictionary comes pre-installed with several dictionaries but the process of creating your own dictionaries or converting existing ones is surprisingly complex.
This post is an attempt to make this process easier for everyone.
Most third-party dictionaries that I use are in DSL (ABBY Lingov) and BGL (Babylon) formats. I have collected them over the years, and have been using them both on the desktop via the open-source app GoldenDict, and on my smartphone thanks to GoldenDict for android. The OSX version of GoldenDict is still buggy, and apparently not properly maintained, so I wanted to find a way to migrate my existing dictionaries to the native OSX dictionary app.
After a bit of research I finally figured out the toolchain for converting my existing dictionaries in Babylon and Lingvo DSL formats to the AppleDict format which the OSX Dictionary.app expects.
Auxiliary Tools for Xcode
Download Auxiliary Tools for Xcode from http://developer.apple.com/downloads. To be able to download you might be able to use your iCloud credentials to log in, or otherwise you'll have to register for a free Apple Developer account.
Copy the contents of the DMG file to a folder, e.g. ~/Downloads/Auxiliary Tools.
Next, As the root user create a folder at /Developer/Extras and copy the Dictionary Development Kit folder from the Auxiliary Tools into that folder.
sudo mkdir -p /Developer/Extras sudo cp -r "~/Downloads/Auxiliary Tools/Dictionary Development Kit" /Developer/Extras
Clone the pyGlossary project to a folder on your drive:
mkdir -p ~/projects cd ~/projects git clone --depth 1 firstname.lastname@example.org:ilius/pyglossary.gitNext, locate the path to pyglossary.pyw — that's the script you'll need for converting the DSL file in UTF-8 encoding to AppleDict XML.
DSL to AppleDict conversionThe DSL sequence:
- DSL files come in Unicode Little Endian encoding, so the first step would be converting your DSL file from UTF-16 to UTF-8:
- Now do the actual conversion to AppleDict source format. Make sure you include the correct path to pyglossary.pyw. When the command completes (which might take several minutes if the source file is big), a new file dict.html will be created along with some make files.
- Now run from the same folder as in the previous step the following commands:
iconv -f UTF-16 -t UTF-8 dict_utf16.dsl > dict_utf8.dsl
~/projects/pyglossary/pyglossary.pyw --read-format=ABBYYLingvoDSL --write-format=AppleDict dict_utf8.dsl dict.xml
make make install
I have created a bash script that automates the process of DSL to AppleDict conversion: https://gist.github.com/elFua/8540294. Run the bash script without arguments to see usage notes.
IMPORTANT: You will need to edit the script and set the correct value of PYGLOSSARY_HOME, by default it is ~/projects/pyglossary.
Babylon BGL to AppleDict conversionThe conversion steps for BGL dictionaries:
~/projects/pyglossary/pyglossary.pyw --read-options=resPath=OtherResources --write-format=AppleDict dict.bgl dict.xml make make install
A bash script for BGL to AppleDict is available at https://gist.github.com/elFua/8541228. To get this toolchain to work I recommend reading the readme files which are included both with pyglossary and the Apple Dictionary Development Kit. I have included the most important points in the help section of the bash script for DSL.
Where to get the dictionaries?There are literally hundreds, maybe thousands of dictionaries in DSL, Stardict, and Babylon BGL formats. A search engine query with the format and language pairs will most likely return some links where you'll be able to download the files. For example try stardict+english+spanish. The Goldendict dictionaries download page also has some useful links.
There are also a couple of command line utilities for converting between free dictionary formats: dictconv, makedict.