You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Replace the unit Unavailable error with variants apps can match, fail
closed on unknown locales, and expose locale() / available_locales().
Add examples and a README that states Spellkit wraps system backends
instead of bundling dictionaries.
Applications should not reimplement macOS, Windows, and Hunspell separately. Spellkit is one small API over those backends.
25
+
26
+
This project is **based on**[euclio/spellbound](https://github.com/euclio/spellbound) (last upstream commit 2020).
27
+
28
+
## What Spellkit is not
29
+
30
+
Spellkit does **not** bundle dictionaries or implement its own spelling algorithm. It wraps the platform backend and uses system / installed dictionaries. Behavior can differ across operating systems where the APIs differ.
22
31
23
-
## Example
32
+
That is the distinction from crates that ship an engine and word lists (for example Spellbook).
33
+
34
+
## Quick start
35
+
36
+
cargo add spellkit
24
37
25
38
```rust
26
39
usespellkit::Checker;
27
40
28
41
fnmain() ->Result<(), spellkit::Error> {
29
42
letchecker=Checker::new()?;
30
-
// Or: Checker::with_locale("en-US")?;
31
43
32
-
forerrinchecker.check("I beleeve I can fly") {
44
+
forerrinchecker.check("I havv a spelling error.") {
`Checker::new()`uses a platform default: system language on macOS, the user locale on Windows (falling back to `en-US`), and `LC_ALL` / `LC_MESSAGES` / `LANG` on Linux when a dictionary exists (otherwise `en_US` / `en_GB`). Use `with_locale` for another language.
54
+
`Checker::locale()`is the language this instance is using. `Checker::available_locales()` lists what the OS can check.
43
55
44
-
Unknown or unsupported locales behave differently by platform:
|`available_locales`|`*.dic` stems on disk (`DICPATH` then system dirs) |`availableLanguages`|`SupportedLanguages`|
88
+
|`Send` / `Sync`| no | no | no |
89
+
90
+
Linux also honors `DICPATH` (colon-separated directories) before `/usr/share/hunspell` and the other built-in paths.
53
91
54
-
## Linux
92
+
Word breaks are **not** identical: Linux tokenizes alphanumeric / `'` runs; macOS and Windows use the OS checker.
55
93
56
-
Needs a hunspell dictionary on disk (default search includes `/usr/share/hunspell`). Example:
94
+
## How it works
95
+
96
+
`Checker` is a thin wrapper. On each OS it calls the native API, then converts misspelling ranges to UTF-8 byte offsets into the original `&str`.
97
+
98
+
## Spellkit vs other approaches
99
+
100
+
**Why not Spellbook?** Use Spellbook when you want a portable engine and bundled (or app-shipped) dictionaries. Use Spellkit when you want the OS dictionaries, native suggestions, and minimal integration.
101
+
102
+
**Why not Hunspell directly?** You would own dictionary discovery, FFI, and a second implementation for macOS and Windows. Spellkit is that integration.
103
+
104
+
**Why not ispell?** You would own an external process, its lifetime, and the command protocol. Spellkit stays in-process.
105
+
106
+
## Errors
107
+
108
+
- empty locale → `Error::InvalidLocale`
109
+
- Linux missing `.aff`/`.dic` → `Error::DictionaryNotFound` (includes search paths)
110
+
- macOS / Windows language not installed → `Error::UnsupportedLocale`
111
+
- backend failed to start (null Hunspell handle, COM factory, empty macOS language) → `Error::InitializationFailed`
0 commit comments