This is the legacy 4D documentation web site. Documentations are progressively being moved to developer.4d.com

Home

 
4D v20 R7
Spell checking

Spell checking  


 

4D includes built-in and customizable spell checking features. Spell checking can be performed for Alpha and Text fields and variables - as well as for 4D Write Pro documents.

The correction can be triggered automatically or by programming. Correction actions are performed via the default interface or standard actions.

You can configure both the spellchecker and the language dictionaries to use. 4D also offers a specific feature to use specialized dictionaries.

To enable the spell checker in your forms, you have the following options:

  • Check the Auto spellcheck property ("Entry" theme) for each object (see Spell-check). In this case, the spell checking is performed automatically when typing.
    You can also manage the correction process using specific Standard actions.
  • Call the SPELL CHECKING command for each object to be checked.

In 4D, spell-checking is applied continuously in text areas, with errors highlighted directly in the text with a dotted underline:

Dotted lines in different colors are used in order to determine the type of correction to be made:

  • In red for spelling errors,
  • In green for grammatical errors (only with native Mac spell checker),
  • In blue for words to substitute (when the Show text substitutions option is enabled, see below).

The user can then correct the text using the context menu (right-clicking on underlined word) or using the spell checker dialog box.

To display the spell check options, you can right-click on an unknown word and a context menu containing spell checker commands appears:

Note: The Auto Spellcheck and Context Menu options must be checked for the object.

You can select the Display spell checker dialog option to display a dialog where you can enter a corrected value:

This dialog box is a floating window that remains available for all the windows of the application during the session, until the user closes it.

In addition to suggestions for corrections, the following options and functions are provided by the spell checker in 4D (in the context menu and/or the spell checker dialog box):

  • Learn: The unknown word is added to the dictionary; it will no longer be indicated by the spell checker.
    • In Mac systems, learned words are kept permanently in /Users/[UserName]/Library/Spelling (so a word learned by the system spell checker is also learned for all the applications using the system spell checker).
    • With Hunspell, learned words are saved in a custom Hunspell dictionary in the user system directory of the current application data that is always loaded along with the main dictionary (as in previous versions).
  • Unlearn (context menu): This option appears when a previously-learned word is selected. It lets the user remove this word from the list of learned words so that it is once again indicated as a possible spelling error.
  • Ignore: The unknown word is left untouched and is no longer underlined, however it will be indicated again if it is detected later on.
    The spell checker keeps a table of words to ignore for each document. You can erase this table using the Clear list of ignored words option (see below).
  • Previous / Next (dialog box): The unknown word is ignored but remains underlined and the spell checker examines the previous or next unknown word in the text.
  • Spell checking (context menu): Generally enables or disables spell checking in the area for the current process.
  • Replace (dialog box): When the word selected in the text matches the one in the first editable field, it is replaced by the word in the second editable field, and moves on to the next error.
  • Replace Always (dialog box): Same as Replace but the substitution is memorized (see Text substitution below).

The Spell settings> submenu contains the following functions:

  • Automatic correction: Enables or disables automatic correction mode in the area for the current process. In this mode, unknown words are automatically replaced by the closest known word (except when the ambiguity is too great). Corrections are performed during input.
    By default, automatic correction is disabled.
  • Text substitution: Enables or disables text substitution. This consists in replacing one word by another. For example, you can choose to replace the word "Mr" with "Mister".
    To create "to be replaced"/"replaced by" word pairs, you must use the spell checker dialog box: enter the word to be replaced in the "Not in dictionary" area and the replacement word in the "Replace with" area, then click the Replace Always button:

    Replacements are performed throughout the application. With Hunspell, the spell checker keeps a global table of substitutions for the application that is saved in the user system directory of the application; for the Mac spellchecker, this table is merged with the system substitutions ("Use symbol and text substitution" option in the System Preferences).
    The substitution process differs depending on whether or not the Show text substitutions option in the Spell settings submenu is checked (see below).
  • Show text substitutions (This option is only shown when the Text substitution option is checked): When this option is checked, the spell checker underlines possible substitutions in the text with a blue line and the user must right-click on the word to select the value to be substituted.

    When this option is not checked, substitutions are performed automatically, without any user intervention.
  • Clear list of ignored words: Erases the list of words chosen to be ignored in the document.

The native Mac spell checker provides several other correction options:


  • Automatic Language: Automatically identifies dictionary language to be used based on text contents.
    By default, this spell checker uses the language of the 4D application, just like the Hunspell spell checker.
  • Check grammar: Enables grammar checking of text.
  • Smart dashes: replaces double hyphens (--) with em dashes (—) during input.
  • Smart quotes: replaces straight quotes with smart quotes adapted to the current language.

4D applications use the following spell checkers:

  • Windows - the open source "Hunspell" dictionary.
  • Mac - two types of dictionaries are usable:
    • the native system spell checker. This dictionary is used by default.
    • the open source "Hunspell" dictionairies . To use them, you must call the SET DATABASE PARAMETER command with the Spellchecker selector.

In Mac, the native system spell checker has the advantage of being integrated into the working environment and can propose advanced correction options  (cf. Additional options for native Mac spell checker).

The open source Hunspell dictionary is used by many applications such as OpenOffice, Mozilla FireFox, Google Chrome, etc. A large number of additional language dictionaries are available and can be installed in to your 4D databases (cf. Support of Hunspell dictionaries below).

By default, 4D uses the dictionary corresponding to the current language of the application. You can force the opening of a different dictionary using the SPELL SET CURRENT DICTIONARY command.

When the 4D application uses the Hunspell dictionary (see above), you can add additional language dictionaries. You can download Hunspell dictionaries at the following address: https://openoffice.org

Each Hunspell dictionary consists of a .aff file and a .dic file that have the same name. For example, the dictionary "fr-modern" is composed of the files fr-modern.aff and fr-modern.dic. To use a Hunspell dictionary in a 4D application, you must install its .aff and .dic .

Note: Downloadable dictionary files are usually compacted (for example in .oxt format on OpenOffce.org) and must be uncompressed before use.

To use a Hunspell dictionary in a 4D application, you must install its .aff and .dic files in one of the following locations (first level):

  • in the 4D application: <4D>/Resources/Spellcheck/Hunspell/
  • in the 4D database: <Database_Files>/Resources/Hunspell

Both locations are compatible: the database folder is parsed first, then it is completed by the one in the 4D application, which means that you can encapsulate specialized dictionaries within your 4D databases. If two dictionaries with the same name are present in both locations, the one in the database is given priority. 

4D includes a mechanism to define custom lists of words that will be accepted by the spellchecker. This mechanism makes it possible to use specialized dictionaries containing terms specific to a profession, field of application, a company, etc., within an application.

It's possible to use several specialized dictionaries for each main language. This principle works with 4D and 4D Write Pro.

To add a specialized dictionary in a given language, simply place a text format file in the subfolder of the main language, inside the Spellcheck folder. The file can be named freely but it must end with the “.txt” suffix (for example, “astronomy.txt”).

The language subfolders are created in 4D at the following location:

  • Windows: (4D Application folder)\Resources\Spellcheck\
  • Mac: (4D Package):Contents:Resources:Spellcheck:

The names of the subfolders correspond to the main languages; they must not be modified:

  • English
  • French
  • German
  • Spanish
  • Norsk

Each folder contains a word file by default. You can add words to this file or add other files. User files must be stored in UTF-8 format.

The spell-check files are stored in the remote 4D application. If you want to install specialized dictionaries within a client/server solution, you must make sure that the dictionaries are installed on each remote machine (at the location described above).

The files of the specialized dictionaries are lists of words separated by carriage returns. For example:
    4D
    Server
    Desktop

You can add single words (e.g.: boogie) and compound hyphenated words (e.g.: boogie-woogie), but you cannot add sequences of words separated by spaces (e.g.: Mark Smith). 

The internal format of text files differs between Windows and Mac, for reasons linked more particularly to line breaks. You must thus create and provide a specialized dictionary file for each platform. To be able to transpose a dictionary file from one platform to another, you must first convert line breaks to the Mac or Windows format according to the destination platform, using a software such as Notepad++.

Specialized dictionaries are loaded on application startup, just like standard dictionaries. The current language of the dictionaries is based on that of the application. 

During a session, you can change the current dictionary using the SPELL SET CURRENT DICTIONARY command. In this case, if a specialized dictionary exists in the corresponding language folder, it will be loaded. 

During use, there is no difference between the processing of words from standard dictionaries and those from specialized dictionaries.

 
PROPERTIES 

Product: 4D
Theme: Properties for active objects

 
PAGE CONTENTS 
 
HISTORY 

 
ARTICLE USAGE

4D Design Reference ( 4D v20 R7)