Spellchecker for NetBeans IDE
By lahvac on May 26, 2006
As some of you may already know, there is a spellchecker module for NetBeans. It can be installed from the nbextras.
In the spellchecker, the dictionary that should be used for spellchecking of a particular file is found through locale. Each dictionary registered in the spellchecker specifies a locale and each file specifies a locale too. When a file is to be spellchecked, the file locale is used to look-up the correct dicionary.
For Java, only "default locale" is currently used. The initial default locale
is the system locale with which the IDE runs. If you need to change it (eg. you
run on cs_CZ locale but write comments in english), go to
Tools/Options/Spellchecker and set the
Default Locale to
whatever locale you need.
The english dictionaries (en_US and en_GB) are available on the nbextras update center.
But, what if you need different dictionary? Solution is simple - create a word list
for a given language and install it through
The word list file format is simple: one word per line.
Although currently only Java and LaTeX are supported by the spellchecker, it is simple to add support for another language. Basically, the following needs to be done to support a new language:
- write a new TokenList, which tokenizes the source code and returns words that should be spellchecked
- write a new TokenListProvider, which will provide a TokenList for a given document
- add some magic lines into the layer:
<folder name="Editors"> <folder name="<your mime-type before slash (usually text)>"> <folder name="<your mime-type after slash>"> <folder name="TokenListProvider"> <file name="<FQN of your TokenListProvider, using '-' instead of '.'>.instance" /> </folder> <!--keep the following lines as they are--> <folder name="Hints"> <file name="org-netbeans-modules-spellchecker-hints-DictionaryBasedHintsProvider.instance"> <attr name="instanceCreate" methodvalue="org.netbeans.modules.spellchecker.hints.DictionaryBasedHintsProvider.create" /> </file> </folder> <folder name="CompletionProviders"> <file name="org-netbeans-modules-spellchecker-completion-WordCompletion.instance"/> </folder> </folder> </folder> </folder>