[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-panel-devel
Subject: Review Request: Fix KRunner's 'spell in foreign language' feature
From: "Simeon Bird" <bladud () gmail ! com>
Date: 2012-08-27 21:33:47
Message-ID: 20120827213347.8444.77720 () vidsolbach ! de
[Download RAW message or body]
[Attachment #2 (multipart/alternative)]
-----------------------------------------------------------
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 bd291d21f096a714a1=
71e7af3a534ba345ca5659 (about two years ago) because it called Sonnet::Spel=
ler::setLanguage every time the spellchecker was invoked, which was (very m=
uch) not thread-safe. =
Review 106242 fixes the segfaults, this commit fixes the feature, which I u=
nderstand 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. Un=
fortunately, the response of the spell-checker to being fed an invalid lang=
uage was to crash on the next query (this is fixed in 106242). Furthermore,=
the spell-checker expected languages like 'fr_FR' or 'French (France)' whi=
ch 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 beca=
use 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 sp=
ecific 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
[Attachment #5 (text/html)]
<html>
<body>
<div style="font-family: Verdana, Arial, Helvetica, Sans-Serif;">
<table bgcolor="#f9f3c9" width="100%" cellpadding="8" style="border: 1px #c9c399 solid;">
<tr>
<td>
This is an automatically generated e-mail. To reply, visit:
<a href="http://git.reviewboard.kde.org/r/106244/">http://git.reviewboard.kde.org/r/106244/</a>
</td>
</tr>
</table>
<br />
<table bgcolor="#fefadf" width="100%" cellspacing="0" cellpadding="8" style="background-image: \
url('http://git.reviewboard.kde.org/media/rb/images/review_request_box_top_bg.png'); \
background-position: left top; background-repeat: repeat-x; border: 1px black solid;"> <tr>
<td>
<div>Review request for Plasma.</div>
<div>By Simeon Bird.</div>
<h1 style="color: #575012; font-size: 10pt; margin-top: 1.5em;">Description </h1>
<table width="100%" bgcolor="#ffffff" cellspacing="0" cellpadding="10" style="border: 1px \
solid #b8b5a0"> <tr>
<td>
<pre style="margin: 0; padding: 0; white-space: pre-wrap; white-space: -moz-pre-wrap; \
white-space: -pre-wrap; white-space: -o-pre-wrap; word-wrap: break-word;">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.
</pre>
</td>
</tr>
</table>
<h1 style="color: #575012; font-size: 10pt; margin-top: 1.5em;">Testing </h1>
<table width="100%" bgcolor="#ffffff" cellspacing="0" cellpadding="10" style="border: 1px solid \
#b8b5a0"> <tr>
<td>
<pre style="margin: 0; padding: 0; white-space: pre-wrap; white-space: -moz-pre-wrap; \
white-space: -pre-wrap; white-space: -o-pre-wrap; word-wrap: break-word;">Compiled, installed, \
ran for a week and spell-checked a bunch of things in European languages.</pre> </td>
</tr>
</table>
<h1 style="color: #575012; font-size: 10pt; margin-top: 1.5em;">Diffs</b> </h1>
<ul style="margin-left: 3em; padding-left: 0;">
<li>runners/spellchecker/spellcheck.cpp <span style="color: grey">(672732d)</span></li>
</ul>
<p><a href="http://git.reviewboard.kde.org/r/106244/diff/" style="margin-left: 3em;">View \
Diff</a></p>
</td>
</tr>
</table>
</div>
</body>
</html>
_______________________________________________
Plasma-devel mailing list
Plasma-devel@kde.org
https://mail.kde.org/mailman/listinfo/plasma-devel
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic