Thursday, November 29, 2012

Adding Hyphenation And Spelling Dictionaries To InDesign CS 6 (and CS 5.5)


As I recently learned while helping a South African Maths text book publisher, if you want to spell-check and hyphenate text in Adobe InDesign CS6, in say, Afrikaans, you will need to add a few new dictionaries to your InDesign installation. Many of these dictionaries are free. The process is quickly documented in Adobe help, but there are a few stumbling points - especially on the Mac -- so I thought I would go through it here in a bit more detail. We'll go through the all the steps of installing a new dictionary and then testing it on the Macintosh and Windows.

The process described here is for adding new dictionaries. Adobe recommends you leave your existing dictionaries alone. We will be adding a new dictionary for the South African language - Afrikaans.

CopyFlow Gold for InDesign CS6 has a great new tool for setting the InDesign language settings quickly and easily even in layered multilingual documents -- there's a link to more information about CopyFlow Gold at the end of this article.

Dictionaries for many languages can be found for free online. Search for 'Hunspell dictionaries'. Two of the popular sites are Open Office and the Mozilla Firefox site. Our Afrikaans dictionary came from the Open Office site. I also downloaded a Macedonian spelling dictionary from Firefox. It came down with a .xpi extension which I renamed to be .zip to access the dictionary. Try the same approach of you download a .oxt file - rename it to be a .zip.

Our Afrikaans dictionary downloaded as 'dict-af.zip'. Here are its contents:

Afrikaans Dictionary files - click to enlarge
Out of all of this, we will need only 3 files: 'af_ZA.dic' and 'af_ZA.aff' which together make up the spelling dictionary and the 'hyph_af_ZA.dic' which is the hyphenation dictionary. We'll also show how to add a Afrikaans User Dictionary at the end of this article - for all the special terms or proper names you don't want showing up as spelling mistakes.

The notation for the language and the country codes, 'af-ZA',  is familiar to translators-- in this case 'af'  for Afrikaans and 'ZA' for South Africa. Links to more information about language and country codes can be found at the end of this article among 'Other Resources'.

New Dictionary Installation

The installation process consists of 3 steps:
  1. Make a new folder for the new language. In our case, a folder named: 'af_ZA'
  2. Copy the dictionary files into the new folder -> 'af_ZA'
  3. Edit another text file - info.plist - to make 3 new entries for 'af-ZA' 

The details vary by platform - so we'll do each separately below.

New Dictionary Installation (WINDOWS)

  1. Make a new folder. We must create a new folder in the 'languageCode_countryCode' form in the 'Dictionaries' folder which is located at:

    C:/ProgramFiles/Common Files/Adobe/Linguistics/6.0/Providers/Plugins2/AdobeHunspellPlugin/Dictionaries/

    For our example this new folder in Dictionaries will be called : 'af_ZA'
  2. Copy dictionary files into the newly created new folder, 'af_ZA'

  3. Edit the info.plist file. On Windows this file is found at:

    C:/ProgramFiles/Common Files/Adobe/Linguistics/6.0/Providers/Plugins2/AdobeHunspellPlugin/info.plist

    First make a backup copy of 'info.plist' somewhere safe -- in case something goes wrong.

    This is a text file, so open info.plist with a trusted text editor and scroll down to about line 60 or search for 'SpellingService'. You should see a long list of language and country codes. This is one of three places in this file we are going to add the line:

    <string>af_ZA</string>

    Here is the file after we have made the first edit.

Info.plist - click to enlarge
Then repeat this same edit in two other locations further down the file - to add the new language entry to the other lists of language and country codes for hyphenation (if we have a hyphenation dictionary) and user dictionaries. Once you are done close and save the file.

After you have made these edits - restart InDesign and select some document text with the text tool. You should now see the language you have added as a valid choice in the language pop-up.

New Language in InDesign - click to enlarge

New Dictionary Installation ( MACINTOSH )

  1. Make a new folder. Unfortunately the dictionary folder is inside a bundle on the Mac so first find the file:

    /Library/Application Support/Adobe/Linguistics/6.0/Providers/Plugins2/AdobeHunspellPlugin.bundle

    Then back it up - somewhere safe. We will be editing its contents. Once that is done, Control-click (aka right click) on the file name: 'AdobeHunspellPlugin.bundle' and select the menu item: Show Package Contents. Then we can step down in this window to the Dictionaries folder.

    /Contents/SharedSupport/Dictionaries/

    For our example this new folder will be called : 'af_ZA'. Using the Finder I created a new folder by selecting an existing folder - e.g., 'ar_AE' and right clicked to Duplicate it. Then I opened up this new copy of the 'ar_AE' folder, selected its contents and moved them to the trash. Finally I  renamed this copy of 'ar_AE' to the folder I wanted:  'af_ZA'

    Opening The Bundle - click to enlarge
  2.  Copy dictionary files into the newly created new folder, 'af_ZA' with a Finder copy & paste.

  3. Edit the info.plist file.  This file is also with the bundle we have already opened - at the top level  location:

    Contents/info.plist

    You'll need a good text editor to edit this file. I used the free TextWrangler from  BareBones.

    Open info.plist with your text editor and scroll down to about line 20 or search for 'HyphenationService'  You should see a long list of language and country codes. This is one of three places in this file we are going to add the line:

    <string>af_ZA</string>

    Then repeat this same edit in two other locations further down the file - to add the new language entry to the other lists of language and country codes for spelling and a user dictionaries. Once you are done close and save the file. Then close the bundle.

    After you have made these edits - restart InDesign and select some document text with the text tool. You should now see the language you have added as a valid choice in the language pop-up.
Edited info.plist - click to enlarge

Initial Testing:

I do not speak Afrikaans - so I clipped part of a news article and used Google translate to make some Afrikaans text which I pasted into an InDesign text box. Leaving the InDesign language setting on English - it found plenty of spelling 'errors' in my Afrikaans text


Then I selected the paragraph and set all the text to use my new dictionaries with the 'Afrikaans (South Africa) language menu setting. Spell check re-evaluated my text like this:


Now only the proper names and untranslated English phrases like 'First Lady' remain. To fix these, we need to add a User Dictionary.

Adding a New User Dictionary for the new language

Now that we have our spelling and hyphenation dictionaries in place we are ready to create an Afrikaans InDesign User Dictionary. This is a several stage process:

  • Open InDesign's preferences and select Dictionaries
  • Select your dictionary language - e.g., Afrikaans
  • Use the little icon below the list of dictionaries to make a new user dictionary file and specify where you would like to store it. Give it a unique name, not User Dictionary!
  • Once that is done, you can gather words into a simple list - one word per line in a plain text file (.txt)
  • Add your word list to your new user dictionary by going to InDesign's menu Edit-> Spelling -> User Dictionary... , then selecting your language and the new dictionary we created above. Click Import to read the file in. You can also add words interactively. For this example, we needed the Case Sensitive box checked.

Editing User Dictionary - click to enlarge

 Now we have a clean spell check in Afrikaans.







Other Resources:

Language Tags In HTML and XML:  http://www.w3.org/International/articles/language-tags/ 

Adobe Help about adding dictionaries : http://helpx.adobe.com/indesign/kb/add_cs_dictionaries.html 

CopyFlow Gold's new tool for setting InDesign language: http://www.napsys.com/CFGInDesignCS6.html#setlang

OpenOffice dictionaries: http://wiki.openoffice.org/wiki/Dictionaries

Language code lists : http://www.w3schools.com/tags/ref_language_codes.asp

Country code list: http://www.iso.org/iso/country_names_and_code_elements