# NativeSpellCheckingProvider
Class Inherits TextServiceProvider
## About
`NativeSpellCheckingProvider` integrates the platform spelling service with editor-drawn text. It uses NSSpellChecker on macOS, the Microsoft Spell Checking API on Windows, and the system-installed Enchant 2 library on Linux. It supplies misspelling detection, suggestions, corrections, learned and ignored words, and native menu commands where the platform service supports them.
The effective `TextServices.Language` BCP 47 tag is passed to the native service. With no override, `TextServices` resolves and normalizes `Locale.Current.Identifier`; assigning `TextServices.Language` selects another installed dictionary. Windows and Linux calls defensively remove ICU keyword and encoding suffixes. Linux converts hyphens to Enchant's underscore form and falls back from a regional tag such as `en_US` to its base language, `en`. Its command captions are exposed through `Text`-prefixed localization properties.
Missing Linux dependencies or dictionaries do not prevent the application from starting. The provider logs a diagnostic message and reports itself unavailable.
## Methods
| Name | Parameters | Return Type | Description |
| --- | :---: | :---: | --- |
| CheckWord | word As String <br> language As String = "" | Boolean | Returns whether the supplied word is accepted by the operating system's spelling service. |
| Constructor | (None) | (None) | Creates the native spelling provider and its document-scoped spelling context. |
| ContextMenuItems | session As TextServiceSession <br> placement As GraffitiProEditor.TextServices.MenuPlacements | DesktopMenuItem | Returns native spelling suggestions and spelling controls appropriate to the supplied session and menu placement. |
| Correction | word As String <br> language As String = "" | String | Returns the first native spelling suggestion when automatic correction is enabled, or an empty string otherwise. |
| CorrectionEnabled | (None) | Boolean | Returns whether automatic correction is currently enabled for this provider. |
| HandleContextMenuItem | session As TextServiceSession <br> selectedItem As DesktopMenuItem | Boolean | Handles a native spelling suggestion, dictionary command, or spelling preference menu item. |
| IgnoreWord | word As String <br> language As String = "" | (None) | Adds the supplied word to the native document-scoped ignored-word list. |
| IsAvailable | language As String = "" | Boolean | Returns whether the operating system supplies the native spelling service used by this provider. |
| LearnWord | word As String <br> language As String = "" | (None) | Adds the supplied word to the operating system's learned spelling dictionary. |
| Suggestions | word As String <br> language As String = "" | String | Returns spelling alternatives supplied by the operating system for the requested word. |
## Properties
| Name | Type | Default Value | Description |
| --- | :---: | :---: | --- |
| AllowAutoCorrection | Boolean | (None) | Gets or sets whether this provider may automatically replace misspelled words at word boundaries. |
| AllowSpellChecking | Boolean | (None) | Gets or sets whether native spelling checks and suggestion menus are enabled. |
## Linux Installation
Install the Enchant 2 runtime and at least one dictionary before using native spell checking on Linux. Common English (United States) package commands are:
```shell
# Debian or Ubuntu
sudo apt install libenchant-2-2 hunspell-en-us
# Fedora
sudo dnf install enchant2 hunspell-en-US
# Arch Linux
sudo pacman -S enchant hunspell-en_us
```
Install the matching Hunspell, Nuspell, Aspell, Voikko, or other Enchant-compatible dictionary package for each language the application should check. Package names vary by distribution and language.
The provider dynamically checks for `libenchant-2.so.2`. When the library or requested dictionary is unavailable, it writes a diagnostic message and otherwise behaves as an unavailable spelling provider. No application crash or startup failure is expected.