Create Custom Dictionaries For Mac OSX

Over the last couple of months I’ve been chipping away at creating an add-on dictionary for the Dictionary application on Mac. I wanted to create a dictionary for CFWheels.

Information on how to create such dictionaries was not all that easy to find. So I thought I’d share what I found in case it helps some else.

Apple’s Dictionary Services Programming Tutorial

First up, have a look at this tutorial on Dictionary Services Programming over at developer.apple.com. It provides all the information one needs to get started. You can also download a PDF of this tutorial.

Template Files for Dictionary

One thing that the tutorial assumes is that you have the template files for dictionary development are. First challenge was to figure out where they were. I found that they are installed with XCode at: /Developer/Examples/Dictionary Development Kit. If you don’t have XCode installed, then you can download the this zip file that contains the Dictionary Development Kit.

The Make Command

Before you customize anything in these files, simply run ‘make’ command in directory where you unzip these files. It should create a dictionary called “My Dictionary”. If you move this dictionary to /Library/Dictionaries or ~/Library/Dictionaries, it will start showing up i the Dictionary app.

There are a couple of other things that the make command can do:

  • make clean : cleans older builds
  • make install : installs the created dictionary to ~/Library/Dictionaries folder
  • make : creates the dictionary

Change the XML and Info.plist

Now add the stuff you want in the XML that will be used to create the dictionary. You will have to generate the XML with the appropriate structure and content. Also modify the plist file as required. Run “make” to create your dictionary.

A Big Gotcha – Cached Dictionaries

On thing that really had me flummoxed was that despite making a new dictionary, the Dictionary app was not reliably showing all the changes I expected.

This took a while to figure. There is a bunch of caching that comes into play if you are creating new builds of the dictionary. Cached versions show up and throw you off the track.

So I had to write this shell script to clean Dictionary app cache. Make sure that you

  • make the script executable before running it, and
  • quit the Dictionary app before you run

I found that I had run this each time I made a change to the XML file.

A downside to doing this is that it resets all Dictionary preferences. So when you start the Dictionary app after running this script, you have go to Preferences and turn on the dictionary you are working on. A bit painful, but not such a biggie.

My Development Workflow

So as I was making changes to the XML file with data, I was running the following commands:

  • ./clean.sh (cleans out all dictionary caches)
  • make clean (cleans out older builds of the dictionary)
  • make (makes the dictionary)
  • make install (installs the dictionary)

Example Dictionary: CFWheels

If you want to see an example of the dictionary that I created, check out: https://github.com/indynagpal/CFWheels-Mac-Dictionary

Look at the XML and Info.plist files.

That’s it… go and have fun creating dictionaries now!

11 thoughts on “Create Custom Dictionaries For Mac OSX”

  1. Is there some way to learn about this if you have no programming experience. I’m a language guy, not a programming guy, and I don’t have any idea what this stuff means. All I want to do is make a dictionary from the ground up with my translations for non-english languages. Can anyone help me with this?

    1. I’m not sure what you are actually wanting to do?

      Do you want to create a dictionary module that can be used in the OSX dictionary app?

      If so, then from what I know, you’d need to know the basics of programming.

      You can always hire someone to do it for you if it is important enough.

      1. I was just wondering if there was an easier way to add my own dictionary of terms. I don’t know the first thing about programing.

  2. Thanks for providing informations on building dictionary
    i have a G4 Macintosh, running Mac OS X 10.4.11 (Tiger)
    i downloaded
    http://nagpals.com/wp-content/uploads/2011/02/Dictionary-Development-Kit.zip
    http://nagpals.com/wp-content/uploads/2011/02/CFWheels.dictionary.zip
    http://nagpals.com/wp-content/uploads/2011/02/clean.sh.zip

    i could not find build_dict.sh on http://nagpals.com
    however this build_dict.sh
    http://mac-dictionary-kit.googlecode.com/svn-history/r20/trunk/sdconv/bin/build_dict.sh
    requires make_dict_package
    which i found there:
    http://mac-dictionary-kit.googlecode.com/svn-history/r20/trunk/sdconv/bin/make_dict_package

    unfortunately, make_dict_package is a universal binary for
    Mach-O 64-bit executable x86_64 and
    Mach-O executable i386
    which is uncompatible with my G4 PPC Macintosh running Tiger

    pmg4:~/Desktop/dico pb$ file make_dict_package
    make_dict_package: Mach-O universal binary with 2 architectures
    make_dict_package (for architecture cputype (16777223) cpusubtype (-2147483645)): Mach-O 64-bit executable x86_64
    make_dict_package (for architecture i386): Mach-O executable i386
    pmg4:~/Desktop/dico pb$

    Do you think that it is possible to build a thesaurus/dictionary with this G4 PPC Macintosh running Tiger?
    And if yes, how?
    thanks
    philippe

  3. Thank you for the tutorial, but it doesn’t work for me. I run ‘make’ from the command line on the directory I just downloaded from the link you provided and it says “build_dict.sh: No such file or directory”.

Leave a Reply to pbrosson Cancel reply

Your email address will not be published. Required fields are marked *