Psi spell-checking for multiple languages

Tagged:

Simple patch for Psi 0.11-0.13 which adds support for multiple languages in its spell-checking engine.

General info

Note: only aspell engine was modified, Mac engine is not supported - though, hopefully, shouldn’t be broken either

Basically, the patch allows you to select one or several different languages - and, correspondingly, enable appropriate dictionaries for spell-checking.

When checking the word, the aspell engine will enumerate all enabled dictionaries and will consider the word to be OK if it is matched by at least one dictionary.

Of course, theoretically this approach is completely wrong, as it may easily accept the words you did not want to be accepted by accidentally matching them in the dictionary of the language you aren’t actually typing this word in. The cleaner solution would be to try guessing your current input language - for example, by getting info about keyboard layout, or whatever.

However, as one may notice, even Microsoft with their Office suite wasn’t able to solve this task in the “right” way to make this detection 100% reliable, and I have no reasons to believe I can do it better.

Therefore, I stick to this “wrong, but simple” approach - and it seems that for most practical cases it works OK, especially if languages you use seriously differ - for example, have different alphabet.

The other issue could be that this approach is not really CPU-efficient, but in practice you’re unlikely to enable more than several languages simultaneously - therefore, I had no speed problems so far, and I doubt it becomes an issue for all but extreme usage scenarios.

Usage

The patch modifies context menu used by spell-checking engine in several ways:

  1. It groups suggestion words by language they’re suggested for with appropriate language name displayed.
  2. It adds new menu items to add the word to personal dictionary for specified language.
  3. It adds checkable menu items to select the languages to use for spell-checking.

Please note that spell-checking context menu is invoked only in the case the current word is misspelled according to current language settings - therefore, you cannot invoke it to change current languages if all your words are OK, but this seems to be rarely needed anyway, as typically you will like to change current languages exactly because they do not suit the language you’re typing in - so, you’ll have enough misspelled words to cause context menu to appear

Here’s what it looks like for 3 languages enabled (English, Russian, Ukrainian):

Context menu

Besides of context menu, the patch adds new options in “Advanced” options tab:

Options

I think that screenshot should be self-evident here.

Getting

Syndicate content