Prior to building a dictionary, you need to create your dictionary source file, prepare a style sheet, edit the property list file, and add any resources needed by your dictionary. This chapter explains how to perform these tasks, provides instructions for building your dictionary, and shows a few simple examples. You’ll also find out how to create a Japanese dictionary, set up preferences, and add front and back matter.

Preparing Source Data and Building a Dictionary

Before you start preparing your source data, copy the project_template folder from the development kit to the directory that you use for code development. Then, follow the instructions described in the following sections:

Preparing Dictionary Contents Take a look at the MyDictionary.xml file provided in the project template. Your dictionary should follow this form, using UTF-8 encoding. You can change the file name to something other than MyDictionary , but if you change the name, you must edit the DICT_SRC_PATH variable in the makefile. Dictionary User Interface and Markup ) describes the XML schema you should use to develop a dictionary. The schema uses the RELAX NG schema language, which is described on this website: http://www.relaxng.org/ You should validate your dictionary source prior to building a new dictionary You can use RELAX NG validators programs, which are available from this website: http://www.relaxng.org/#validators You can also validate XML using jing as follows: $ java -jar <path to jing.jar> <schema definition> <XML to validate> From the project_template folder, with jing located in ../jing/, the command line is as follows: $ java -jar ../jing/bin/jing.jar ../documents/DictionarySchema/AppleDictionarySchema.rng MyDictionary.xml For more information on jing, see: http://www.thaiopensource.com/relaxng/jing.html

Preparing a Style Sheet You can prepare a style sheet to use for the contents of the dictionary by editing the MyDictionary.css file provided with the project template. If you change the name of this css file, you need to edit the CSS_PATH variable in the makefile. You should minimally edit the style sheet. The Dictionary application and the Dictionary window control use their own style definitions to ensure that the contents fit the display. For best results, do not specify an absolute font or font size.

Editing the Property List File The property list file for a dictionary is an an XML text file. The project template contains an example file— MyInfo.plist —whose contents are shown in Listing 2-1. You can edit this file so that it contains entries appropriate for your dictionary. Table 2-1 explains the values that you need to provide for your dictionary. Note: The property list cannot use binary format. If you need to, you can convert a binary property list file to an XML text file using the plutil command. Listing 2-1 An example of a property list file for a dictionary <key>CFBundleDevelopmentRegion</key> <string>English</string> <key>CFBundleDisplayName</key> <string>My Dictionary</string> <key>CFBundleIdentifier</key> <string>com.apple.dictionary.MySample</string> <key>CFBundleName</key> <string>MyDictionary</string> <key>CFBundleShortVersionString</key> <string>1.0</string> <key>DCSDictionaryCopyright</key> <string>Copyright (c) Apple Computer, Inc.</string> <key>DCSDictionaryManufacturerName</key> <string>Apple Computer, Inc.</string> If you change the name of the property list file, you must edit the PLIST_PATH variable in the makefile. Table 2-1 Keys and values for the dictionary property list file Key Value CFBundleDevelopmentRegion A region CFBundleDisplayName The full display name of the dictionary. The default is to use the file system name. CFBundleIdentifier The identifier of the dictionary bundle; specify a unique ID. CFBundleName The short display name of the dictionary. CFBundleShortVersionString The version of the dictionary. DCSDictionaryCopyright The copyright notice of the dictionary. DCSDictionaryManufacturerName The manufacturer name of the dictionary.

Adding Resources Needed by Your Dictionary You must place any resources (for example, images) that your dictionary needs in the OtherResources folder in the project_template folder. When you build the dictionary, the resources are copied into the built dictionary. For example, if your dictionary uses an image file name test.png , you need to place it in the following location: project_template/OtherResources/Images/test.png The Images folder is copied into the dictionary. When the dictionary needs the image, it uses to the relative path— Images/test.png —which is written to the XML file during the build process.

Preparing the Makefile Name your dictionary and then edit the DICT_NAME variable in the makefile. This name is used as the folder name for the dictionary. For example, when DICT_NAME = “My Dictionary” , the built dictionary is My Dictionary.dictionary . If you change the location of the Dictionary Development Kit from / Developer/Extras/Dictionary Development Kit , you must modify the DICT_BUILD_TOOL_DIR variable in the makefile to reflect the change.