Using NHunspell Dictionary

The editor embeds NHunspell Spell Checker Engine and therefore you can use any Open Office dictionary. In order to use NHunspell Spell Checker Engine, you need to follow the following steps.

1. Set the SpellCheckerOption.SpellChecker = NHunspell

NHunspell setting

2. Import the 2 NHunspell DLL files that you found in the Download Package, in a folder named "NHunspell DLL".

3. Import these 2 DLL files to your Project and set "Copy to Output Directory" property value for these files = Copy Always.

NHunspell Dlls

Thats all you need to do in order to use NHunspell Spell Checker Engine when you want to use US English Dictionary. Because, US English Dictionary is already embedded to the editor and if you do not specify any dictionary file path, the US English Dictionary is used from its embedded resource.

If you want to use a dictionary file other than US English Language, then, you need to set Dictionary File Path and Affix File Path as shown in the following Screenshot.

NHunspell dictionaries

But it is not practical to set the Dictionary files from Design Time unless you want to test quickly. Because, the design time setting will always Absolute Path and you wont use absolute path for your distributable application. Rather you should import the dictionary files (along with affix files) to your project and set the Dictionary and Affix file path Run time to resolve the path dynamically. Say, you have added the fr-FR.aff and fr-FR.dic file to your project and set "Copy to Output Directory" property value for these files = Copy Always so that these files are copied to the bin folder. After that, the typical snippet to set the dictionary files can be as follows:

C#

private void Window1_OnLoaded(object sender, RoutedEventArgs e)
{
    WpfHtmlEditor.SpellCheckOptions.DictionaryFile.DictionaryFilePath =
        Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "fr_FR.dic");

    WpfHtmlEditor.SpellCheckOptions.DictionaryFile.AffixFilePath =
        Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "fr_FR.aff");
}

VB

Private Sub Window1_OnLoaded(sender As Object, e As RoutedEventArgs)
 WpfHtmlEditor.SpellCheckOptions.DictionaryFile.DictionaryFilePath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "fr_FR.dic")

 WpfHtmlEditor.SpellCheckOptions.DictionaryFile.AffixFilePath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "fr_FR.aff")
End Sub

Where to find the Dictionary Files ?

Ok, once you started liking the NHunspell Spell checker, you would be asking, where can I get the *.dic and *.aff files for other languages.

You can use any Open Office Dictionary files as NHunspell supports Open Office Dictionaries. You can visit http://extensions.openoffice.org, browse the Dictionaries menu and you will find various language dictionaries. Click the link for your preferred dictionary and Download the Dictionary package which is usually a file with extension *.oxt.

downloading_open_office_dic 1

downloading_open_office_dic 2

Once you downloaded the *.oxt file, rename the file to a *.zip file and unzip.

oxt_to_zip_renaming

Once you unzip the file, you will find a folder with the name of Language code. For the above example, the folder name would be de_DE_frami. Open that folder and you will find the *.aff and *.dic file.

opening_language_folder

Once you found the *.aff and *.dic file, you can import these files to your project and set the Affix File and Dictionary File path accordingly.

HNunspell DLL folder path

The editor has setting SpellCheckOptions.NHunspellDllFolderPath. It allows you to override the path where the editor loads NHunspell DLLs from. By default, this setting is not set and the editor loads the DLLs from the application directory.

NHunspell DLL folder path

Last updated on 31 March 2016, Thursday, 7:44:28 AM
If you have any questions or concerns about this tutorial, Please feel free to share your comment.