Creating a spell check dictionary add-on

This page describes how to package a Hunspell spell check dictionary as a Firefox add-on, or how to update your existing add-on, so that it can be installed, uninstalled and updated without a restart.

Parts needed

To create a dictionary add-on, you first need two things:

  • A spell check dictionary in Hunspell or Myspell format, with a license which allows you to use it. Such a dictionary consists of two files, one with a .dic and one with an .aff file extension.
  • A locale code to describe the language of the dictionary. For example en-US, de-DE or da. It is important to choose the right locale code, or the spell checker will not be able to match the language of your dictionary against the language of a web page in order to select the right dictionary to use.

If you are creating a new dictionary, as opposed to updating an existing one, please make sure that there is not already a dictionary available for your locale. If there already is one, try contacting the author to get it updated, or contact AMO editors if the author does not respond.

Packaging

A Firefox add-on is a ZIP file renamed to use an .xpi file extension instead of the normal .zip file extension. To create a dictionary add-on, simply create a ZIP file which contains the following files and folders:

my-dictionary.xpi

  • install.rdf
  • dictionaries/
    • locale-code.dic
    • locale-code.aff

The .dic and .aff files must be placed in a subfolder named dictionaries within the ZIP file. Both files must have the locale code as their file name. You also have to add a file named install.rdf to the root of the ZIP file. This file contains information about your add-on such as name and version number (see below). In addition to these required files, you may add optional files, for example to give your add-on an icon or to describe the license of the dictionary.

Here is an example of the install.rdf file. You can create and edit it with a plain text editor such as Notepad.

<?xml version="1.0"?>
<RDF xmlns="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:em="http://www.mozilla.org/2004/em-rdf#">
<Description about="urn:mozilla:install-manifest">
<em:id>locale-code@dictionaries.addons.mozilla.org</em:id>
<em:version>version number</em:version>
<em:type>64</em:type>
<em:unpack>true</em:unpack>
<em:name>Name</em:name>
<!--
Other install.rdf metadata such as em:localized, em:description, em:creator,
em:developer, em:translator, em:contributor or em:homepageURL
-->


<!-- Firefox -->
<em:targetApplication>
<Description>
<em:id>{ec8030f7-c20a-464f-9b0e-13a3a9e97384}</em:id>
<em:minVersion>18.0a1</em:minVersion>
<em:maxVersion>46.0</em:maxVersion>
</Description>
</em:targetApplication>

<!-- Thunderbird -->
<em:targetApplication>
<Description>
<em:id>{3550f703-e582-4d05-9a08-453d09bdfdc6}</em:id>
<em:minVersion>18.0a1</em:minVersion>
<em:maxVersion>22.0</em:maxVersion>
</Description>
</em:targetApplication>

<!-- SeaMonkey -->
<em:targetApplication>
<Description>
<em:id>{92650c4d-4b8e-4d2a-b7eb-24ecf4f6b63a}</em:id>
<em:minVersion>2.15a1</em:minVersion>
<em:maxVersion>2.49</em:maxVersion>
</Description>
</em:targetApplication>
</Description>
</RDF>

There are some rules about how you should adapt the install.rdf file:

  • If you are creating a new dictionary add-on, we recommend that the em:id consists of your locale code followed by @dictionaries.addons.mozilla.org, but if there is more than one dictionary for your language (for example the German "old spelling" versus "new spelling" dictionaries), you may need to choose another ID, that follows the rules of em:id. If you update an existing dictionary add-on, you must keep the existing em:id, or your users will not be updated to the latest version.
  • The em:version should follow the rules of Mozilla add-on version numbers, and if you update an existing dictionary add-on, the new version number must be greater than the old one.
  • Don't change em:type or em:unpack, and don't add a em:bootstrap element. Type = 64 indicates that the add-on is in the restartless format, and unpack is required for Hunspell to read the dictionary.
  • Although the restartless format for dictionary add-ons were introduced in Gecko 10, dictionary updates only works starting from Gecko 18. The em:minVersion should therefore be the same as in the example above (or greater). If you set em:minVersion to a lower value, Gecko 10-17 will not be able to update your dictionary add-on once the restartless dictionary is installed (bug 782118), and Gecko 10-16 may warn the user that your dictionary is not compatible, when users try to update to a newer version of Firefox/Thunderbird (bug 782115).
  • Update the em:maxVersion to the greatest versions available.

Once you have added these files to your ZIP file and renamed the file to have the .xpi extension, you can install your add-on in Firefox and test it. After a successful test, you can upload your add-on to addons.mozilla.org and ask for it to be included in the Dictionaries & Language Packs page.

Reference