Following from a question asked at the l10n IRC meeting (2004-Jun-11), this page describes how to add (non–en-US) dictionary files to:
- A Mozilla language pack (ie langabcd.xpi)
- A full Mozilla Suite installer
The processes are fairly straightforward, as long as you start from the right place.
NB: this guide doesn't address legal aspects (ie "Am I allowed to bundle dictionary X with my language pack?"), only technical ones.
Section 1: Adding files to the Language Pack
You will need:
- Either:
- A completed language pack – langabcd.xpi; or
- The unarchived language pack contents – ab-CD.jar, ab-mac.jar, ab-unix.jar & ab-win.jar.
- The relevant dictionary files for the Myspell dictionary – ab-CD.dic & ab-CD.aff
- Your favourite ZIP-compatible (de-)compression tool (I like Winzip's Command Line add-on).
The Steps
If you are beginning with a completed language pack, extract its contents (keeping the internal structure):
C:\spellcheck>wzunzip -d langengb.xpi xpi\ WinZip(R) Command Line Support Add-On Version 1.0 (Build 3181) Copyright (c) WinZip Computing, Inc. 1991-2000 - All Rights Reserved Zip file: langengb.xpi creating: xpi/bin/ creating: xpi/bin/chrome/ unzipping xpi/bin/chrome/en-GB.jar unzipping xpi/bin/chrome/en-GB-mac.jar unzipping xpi/bin/chrome/en-GB-win.jar unzipping xpi/bin/chrome/en-GB-unix.jar unzipping xpi/install.js
Notes: (i) Extracting into a sub-directory (the "xpi\" at the end of the command) keeps all the files nicely separate. (ii) The -mac.jar, -unix.jar and -win.jar files are so-named because of Bug 102509.
Anyway, the folder structure now looks like this:
xpi\ ├─ install.js └── bin\ └── chrome\ ├─ ab-CD.jar ├─ ab-mac.jar ├─ ab-unix.jar └─ ab-win.jar
This is where you join in if you have all the component parts.
Under xpi\bin\, create a new folder, "components"; in that, create "myspell". Move or copy the ab-CD.dic and ab-CD.aff files into the myspell folder. Your folder structure should look like this:
xpi\ ├─ install.js └── bin\ ├── chrome\ | ├─ ab-CD.jar | ├─ ab-mac.jar | ├─ ab-unix.jar | └─ ab-win.jar └── components\ └── myspell\ ├─ ab-CD.dic └─ ab-CD.aff
Because the install.js already copies the contents of the bin\ folder to the relevant place, the new files will get added automatically with no changes required.
All you now need to do is to re-archive the language pack, to the same or a different (as shown below) archive.
C:\spellcheck>wzzip -ex -rp langengb+dic.xpi xpi\*.* WinZip(R) Command Line Support Add-On Version 1.0 (Build 3181) Copyright (c) WinZip Computing, Inc. 1991-2000 - All Rights Reserved Adding bin/ Adding bin/chrome/ Adding bin/chrome/en-GB.jar Adding bin/chrome/en-GB-mac.jar Adding bin/chrome/en-GB-win.jar Adding bin/chrome/en-GB-unix.jar Adding bin/components/ Adding bin/components/myspell/ Adding bin/components/myspell/README_en_GB.txt Adding bin/components/myspell/en-GB.dic Adding bin/components/myspell/en-GB.aff Adding install.js creating Zip file langengb+dic.xpi
Et voilà!
Section 2: Adding files to a full Mozilla installer
You will need:
- A full en-US mozilla installer. (Note: you can also obtain the spellcheck.xpi from the windows-xpi/ sub-folder of any mozilla release folder on the mozilla ftp server)
- The relevant dictionary files for the Myspell dictionary – ab-CD.dic & ab-CD.aff
- Your favourite ZIP-compatible (de-)compression tool (I like Winzip's Command Line add-on).
- piaip’s mozip tool.
The Steps
With mozip, extract the spellcheck.xpi file:
C:\spellcheck>mozip -x installer-filename spellcheck.xpi
Extract all the files from spellcheck.xpi using your zip tool:
C:\spellcheck>wzunzip -d spellcheck.xpi spell\ WinZip(R) Command Line Support Add-On Version 1.0 (Build 3181) Copyright (c) WinZip Computing, Inc. 1991-2000 - All Rights Reserved Zip file: SPELLCHECK.XPI creating: spell/bin/ creating: spell/bin/components/ unzipping spell/bin/components/myspell.dll unzipping spell/bin/components/spellchk.dll unzipping spell/bin/components/spellchecker.xpt creating: spell/bin/components/myspell/ unzipping spell/install.js unzipping spell/bin/components/myspell/en-US.dic unzipping spell/bin/components/myspell/en-US.aff
Replace the en-US files with your ab-CD files. For completeness, you can change the message on (or around) line 100 of install.js to report the correct language:
var err = initInstall("Mozilla Myspell Spellchecker (en-GB)", "Spellchecker", "1.5.0.2003100716");
Then, re-archive:
C:\spellcheck>wzzip -ex -rp spellcheck_en-GB.xpi spell\*.* WinZip(R) Command Line Support Add-On Version 1.0 (Build 3181) Copyright (c) WinZip Computing, Inc. 1991-2000 - All Rights Reserved Adding bin/ Adding bin/components/ Adding bin/components/myspell.dll Adding bin/components/spellchk.dll Adding bin/components/spellchecker.xpt Adding bin/components/myspell/ Adding bin/components/myspell/README_en_GB.txt Adding bin/components/myspell/en-GB.dic Adding bin/components/myspell/en-GB.aff Adding install.js creating Zip file spellcheck_en-GB.xpi
This file can now replace the spellcheck.xpi file in your localised installer. I've written a guide on how to make a localised installer, and one on how to fill it full of other bits and pieces as well.