Review Request: Fix KRunner's 'spell in foreign language' feature
Simeon Bird
bladud at gmail.com
Mon Aug 27 21:33:47 UTC 2012
-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
http://git.reviewboard.kde.org/r/106244/
-----------------------------------------------------------
Review request for Plasma.
Description
-------
Krunner's spellcheck plugin has been pretty broken since bd291d21f096a714a171e7af3a534ba345ca5659 (about two years ago) because it called Sonnet::Speller::setLanguage every time the spellchecker was invoked, which was (very much) not thread-safe.
Review 106242 fixes the segfaults, this commit fixes the feature, which I understand to be, basically, the
ability to type 'spell french bonjour' and have it check the spelling.
The current code simply calls setLanguage on the second term in the search query, and then checks whether the resulting dictionary object is valid. Unfortunately, the response of the spell-checker to being fed an invalid language was to crash on the next query (this is fixed in 106242). Furthermore, the spell-checker expected languages like 'fr_FR' or 'French (France)' which the user was vanishingly unlikely to type in correctly.
So what this does is to only call setLanguage when necessary (just in case I missed something in 106242),
and then only after we have turned the query we are fed into a valid spell-checker language.
This is a little bit tricky, because in particular "spell english" is going to mean different things to different people.
My approach was to try and find the main language of the group: so 'french' gets you fr_FR. This works ok for most things, but not really for english. For that I default to US english, unless UK english is installed. Probably one should special case other english variants as well, but I haven't because I am unsure what spellings are in common use in practice.
I have not tested this spelling an asian language as I don't speak one.
I have not implemented 'spell canadian french' or similar. If you want a specific sublanguage you have to type in the language code directly.
Diffs
-----
runners/spellchecker/spellcheck.cpp 672732d
Diff: http://git.reviewboard.kde.org/r/106244/diff/
Testing
-------
Compiled, installed, ran for a week and spell-checked a bunch of things in European languages.
Thanks,
Simeon Bird
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.kde.org/pipermail/plasma-devel/attachments/20120827/c10a6522/attachment.html>
More information about the Plasma-devel
mailing list