Editorial note (April 25, 2008): With Enchant 1.4.1 the strategy for finding dictionaries has changed. I have updated this information to reflect this version.
So far, I have covered how to get started using Enchant and how to set up dictionaries. This post will cover more advanced concepts that let an application developer or a user take more control over Enchant.
Where Enchant looks for providers
Enchant looks for which providers are available when the enchant_broker_init function is called.
Providers can be installed on the machine for all users to share or can be installed for only one user. If Enchant finds a particular provider as a shared provider and as a user provider, the user provider in more than one place, the first one found is used.
Enchant looks for shared providers in the following locations:
The directory value found in the registry at HKEY_LOCAL_MACHINE\Software\Enchant\Config\Module_Dir, if there is one.
Otherwise, in <enchant>\lib\enchant, where <enchant> is the location of libenchant.dll.
The provider location for the user is determined by:
Enchant loads providers from the following locations:
- The directory value found in the registry at
HKEY_CURRENT_USER\Software\Enchant\Config\Module_Dir, if there is one.
Otherwise, in %APPDATA%\enchant, where %APPDATA% is shorthand for the C:\Users\<username>\AppData\Roaming\ folder (Windows Vista) or the C:\Documents and Settings\<username>\Application Data\ folder (Windows XP/2000).
- The
enchant subdirectory of the directory value found in the registry at HKEY_CURRENT_USER\Software\Enchant\Config\Home_Dir, if there is one.
%USERPROFILE%\enchant, where %USERPROFILE% is shorthand for the C:\Users\<username> folder (Windows Vista) or the C:\Documents and Settings\<username> folder (Windows XP/2000).
- The directory value found in the registry at
HKEY_LOCAL_MACHINE\Software\Enchant\Config\Module_Dir, if there is one.
<enchant>\lib\enchant, where <enchant> is the location of libenchant.dll.
How Enchant decides which provider to load for a given language
The provider that is used for a given language is determined by the provider ordering. This can be set programatically by using the enchant_broker_set_ordering function. Enchant initializes the ordering by looking in the enchant.ordering file. Later entries override earlier entries. There is a shared ordering file as well as a user ordering file. A user entry overrides a shared entry.
Enchant looks for the shared enchant.ordering file in the following locations:
The value found in the registry at HKEY_LOCAL_MACHINE\Software\Enchant\Config\Data_Dir, if any
Otherwise, in <enchant>\share\enchant, where <enchant> is the location of libenchant.dll.
Enchant looks for the user enchant.ordering file in the following locations:
Using the value found in the registry at HKEY_CURRENT_USER\Software\Enchant\Config\Data_Dir, if there is one.
Otherwise, in %APPDATA%\enchant, where %APPDATA% is shorthand for the C:\Users\<username>\AppData\Roaming\ folder (Windows Vista) or the C:\Documents and Settings\<username>\Application Data\ folder (Windows XP/2000).
<enchant>\share\enchant, where <enchant> is the location of libenchant.dll.
- The value found in the registry at
HKEY_LOCAL_MACHINE\Software\Enchant\Config\Data_Dir, if any
If enchant doesn’t find any ordering files and the ordering is not overridden programmatically then the ordering is system dependent (but I think that means they will be ordered alphabetically by filename).
Where Enchant looks for Ispell dictionaries
Enchant looks for user Ispell dictionaries in the following locations:
Using The ispell subdirectory of the value found in the registry at HKEY_CURRENT_USER\Software\Enchant\Config\Data_Dir, if there is one.
Otherwise, in %APPDATA%\enchant\ispell, where %APPDATA% is shorthand for the C:\Users\<username>\AppData\Roaming\ folder (Windows Vista) or the C:\Documents and Settings\<username>\Application Data\ folder (Windows XP/2000).
- The
enchant\ispell subdirectory of the directory value found in the registry at HKEY_CURRENT_USER\Software\Enchant\Config\Home_Dir, if there is one.
%USERPROFILE%\enchant\ispell, where %USERPROFILE% is shorthand for the C:\Users\<username> folder (Windows Vista) or the C:\Documents and Settings\<username> folder (Windows XP/2000).
Enchant looks for shared Ispell dictionaries in the following locations:
- Using the value found in the registry at
HKEY_CURRENT_USER\Software\Enchant\Ispell\Data_Dir, if there is one. Otherwise, using the value found in the registry at HKEY_LOCAL_MACHINE\Software\Enchant\Ispell\Data_Dir, if there is one.
Otherwise, using the value found in the registry at HKEY_LOCAL_MACHINE\Software\Enchant\Ispell\Data_Dir, if there is one.
Otherwise, in <enchant>\share\enchant\ispell, where <enchant> is the location of libenchant.dll.
Where Enchant looks for MySpell dictionaries
Enchant looks for user MySpell dictionaries in the following locations:
UsingThe myspell subdirectory of the value found in the registry at HKEY_CURRENT_USER\Software\Enchant\Config\Data_Dir, if there is one.
Otherwise, in %APPDATA%\enchant\myspell, where %APPDATA% is shorthand for the C:\Users\<username>\AppData\Roaming\ folder (Windows Vista) or the C:\Documents and Settings\<username>\Application Data\ folder (Windows XP/2000).
- The
enchant\myspell subdirectory of the directory value found in the registry at HKEY_CURRENT_USER\Software\Enchant\Config\Home_Dir, if there is one.
%USERPROFILE%\enchant\myspell, where %USERPROFILE% is shorthand for the C:\Users\<username> folder (Windows Vista) or the C:\Documents and Settings\<username> folder (Windows XP/2000).
Enchant looks for shared Myspell dictionaries in the following locations:
- Using the value found in the registry at
HKEY_CURRENT_USER\Software\Enchant\Myspell\Data_Dir, if there is one.Otherwise, using the value found in the registry at HKEY_LOCAL_MACHINE\Software\Enchant\Myspell\Data_Dir, if there is one.
Otherwise, using the value found in the registry at HKEY_LOCAL_MACHINE\Software\Enchant\Myspell\Data_Dir, if there is one.
Otherwise, in <enchant>\share\enchant\myspell, where <enchant> is the location of libenchant.dll.
In addition, if OpenOffice (or StarOffice) is installed, Enchant will find the dictionaries that are located in <openoffice>\share\dict\ooo, where <openoffice> is the location where OpenOffice is installed. A user dictionary will be used before a shared dictionary, which in turn will be used before an OpenOffice dictionary.
Where Enchant looks for the Aspell library
Enchant looks for the aspell-15.dll using the following locations:
- Using the value found in the registry at
HKEY_CURRENT_USER\Software\Enchant\Aspell\Module, if there is one (this value should include the filename and not just the path).
- Otherwise, using the value found in the registry at
HKEY_LOCAL_MACHINE\Software\Enchant\Aspell\Module, if there is one (this value should include the filename and not just the path).
- Otherwise, using the value found in the registry at
HKEY_LOCAL_MACHINE\Software\Aspell\Path, if there is one, as the path to find aspell-15.dll (this is set by the Aspell installer for Windows).
- Otherwise, in the same directory as
libenchant_aspell.dll.
- Otherwise, it uses the normal Windows search strategy, which includes looking in the path.