Project

General

Profile

Wiki

This is a Smart Client plugin that adds many features that are not available in the spellcheck plugin that ships with Servoy. This plugin is based on the open source JOrtho project at SourceForge. The plugin includes 6 dictionaries/languages: German, English, Spanish, French, Italian, and Russian. Additional languages can be added following the instructions later in this wiki.


  • Spell check multiple elements at a time
  • Easily spell check all the elements on a form
  • Spell check in case sensitive, or insensitive (slightly buggy in JOrtho)
  • Auto-Spell feature with red squiggly lines, and right-click pop-up suggestions list
  • Standard visual spell check dialog to walk the user though fixing grammatical errors
  • Users can add words to their own personal dictionary
  • Several languages supported.
  • German, English, Spanish, French, Italian, and Russian (more can be added)
  • For additional languages, contact i-net software (the author of JOrtho) to get a .ortho dictionary from Wiktionary for your language. I can then add that as a dictionary to this plugin
  • Since this is based on Wiktionary, it is a community contributed dictionary. So, if something is missing, you can go to Wiktionary.org and add it online. Then on the next dictionary build, it will be available.
  • JNLP file will download correct dictionary to client's machine based on their locale. Updated to support 4.0. If you modify the JNLP file to load multiple dictionaries, you can also load multiple languages into the plugin so the user can switch their language. This is done with registerSpellCheckPro(allCommaSeparatedLanguages, defaultLanguage, isCaseSensitive)

Functions

  • registerSpellCheckPro(language, isCaseSensitive)
    This must be called before using any other functions
  • addToSpellChecker(element, inPopup, inAutoSpell)
    Enable an element to be spellchecked. Specify if it should be included in popup spellchecker, autospell, or both.
    Supports: TEXT_FIELD, TEXT_AREA, and HTML_AREA
    If inAutoSpell==true, it will be applied immediately and you will see a red squiggly underline on misspelled word with right-click suggestions
  • clearElementsFromPopupSpellChecker()
    Removes all elements that were added to the spellchecker
  • startSpellCheck()
    Starts the popup spellchecker and shows popup dialog walking the user through the misspellings.
    This isn't needed if you are only using auto-spell

Examples of usage:

//EXAMPLE #1  Show the visual pop-up spellchecker for only 1 element.  Make the spellchecker case sensitive
var success = plugins.servoyguy_spellcheck_pro.registerSpellCheckPro(i18n.getCurrentLanguage(), true)
if(success)
{
    plugins.servoyguy_spellcheck_pro.clearElementsFromPopupSpellChecker() //clear any other elements that may have been previously added
    plugins.servoyguy_spellcheck_pro.addToSpellChecker(elements.someElementName, true, false)
    plugins.servoyguy_spellcheck_pro.startSpellCheck()
}
else
{
    plugins.dialogs.showErrorDialog('Spell Check Error',  'Unable to load dictionary for language: ' + i18n.getCurrentLanguage(),  'OK')
}

//EXAMPLE #2  Enable Auto-Spell for only 1 element.  Make the spellchecker case insensitive
//Will show a red squiggly underline on mispelled word with right-click suggestions.
var success = plugins.servoyguy_spellcheck_pro.registerSpellCheckPro(i18n.getCurrentLanguage(), false)
if(success)
{
    plugins.servoyguy_spellcheck_pro.addToSpellChecker(elements.someElementName, true, true)
}
else
{
    plugins.dialogs.showErrorDialog('Spell Check Error',  'Unable to load dictionary for language: ' + i18n.getCurrentLanguage(),  'OK')
}

//EXAMPLE #3  Enable visual pop-up spellchecker and Auto-Spell for all elements on this form.
//The addToSpellChecker will automatically only allow TEXT_FIELD, TEXT_AREA, and HTML_AREA.  It will filter out any other types of elements.
var success = plugins.servoyguy_spellcheck_pro.registerSpellCheckPro(i18n.getCurrentLanguage(), false)
if(success)
{
    plugins.servoyguy_spellcheck_pro.clearElementsFromPopupSpellChecker() //clear any other elements that may have been previously added

    for(var i=0; i<elements.length; i++)
    {
        plugins.servoyguy_spellcheck_pro.addToSpellChecker(elements[i], true, true)
    }

    plugins.servoyguy_spellcheck_pro.startSpellCheck()
}
else
{
    plugins.dialogs.showErrorDialog('Spell Check Error',  'Unable to load dictionary for language: ' + i18n.getCurrentLanguage(),  'OK')
}

You can also add your own dictionaries following the instructions from the jOrtho project: http://jortho.sourceforge.net/
The dictionaries are based on the Wiktionary dictionaries. This is a step by step description how you can generate a new dictionary version.

  1. Download the data from Wiktionary. The file for the English language is http://download.wikimedia.org/enwiktionary/latest/enwiktionary-latest-pages-articles.xml.bz2 Replace the red part with your language. Some languages also require the data of the English Wiktionary (currently Polish and Arabic)
  2. Extract the XML file from the archive
  3. Download or check out the sources of JOrtho and compile it.
  4. Execute the command
    java -Xmx256M com.inet.jorthodictionaries.BookGenerator en <wiktionary folder>
    Replace the red part with your language.

Installation Instructions: Unzip the download file and then add the servoyguy_spellcheck_pro.jar, servoyguy_spellcheck_pro.jar.jnlp, and servoyguy_spellcheck_pro folder to your {servoy_install}/plugins folder.
Language Support: In this latest version, the download below is bundled with all 6 of the languages mentioned above. Install all of them on your application server. The .jnlp file uses the client's locale to determine what dictionary to download to the client. So, for example, a Spanish user will only download the dictionary_es.jar dictionary file. If you want to change this to allows users to download more dictionaries than their default locale, you must modify the .jnlp file accordingly.

Language / Dictionary Troubleshooting: The .jnlp file attempts to use the client's locale to determine the correct dictionary to download. Some users have reported problems with this. If you experience problems, you can follow these steps to explicitly determine what dictionaries to download.
You can open the .jnlp file with a text editor. Inside the file, you will see several lines starting with "<resources". Inside that element list the files that should be downloaded. Everything inside the item "<resources>" will be downloaded to all users. You'll also see an item that looks like this "<resource locale="de">". Everything in side that item will only be downloaded if the clients machine matches that locale. So, as an example, if you want to change the .jnlp file to download the Spanish dictionary to all clients, you <resources> would look like this:

<resources>
<jar href="/plugins/servoyguy_spellcheck_pro.jar" download="eager" version="2.0"/>
<jar href="/plugins/servoyguy_spellcheck_pro/dictionary_es.jar" download="%%loadmethod%%" version="1.0"/>
</resources>