Bug 439544

Summary: Spell checker doesn't work with non-default languages
Product: [Plasma] krunner Reporter: Oleg Solovyov <mcpain>
Component: spellcheckerAssignee: Alexander Lohnau <alexander.lohnau>
Status: RESOLVED FIXED    
Severity: normal CC: drake14524, nate, plasma-bugs, qydwhotmail
Priority: NOR    
Version: 5.22.2   
Target Milestone: ---   
Platform: Manjaro   
OS: Linux   
Latest Commit: Version Fixed In: 5.25
Attachments: krunner, spell

Description Oleg Solovyov 2021-07-06 08:30:01 UTC
SUMMARY
Spellchecker module doesn't show anything when checking a word on not default but enabled in preferenes language

STEPS TO REPRODUCE
1. install hunspell-ru package
2. enable Russian in list of languages
3. make russian default
4. reboot
5. type in krunner "spell магма"
the "магма" spell would be checked
6. type in krunner "spell dog"

OBSERVED RESULT
spell is not checked

EXPECTED RESULT
Spellchecker shows that "dog" is correct

SOFTWARE/OS VERSIONS
Linux/KDE Plasma: 5.8.0-59
KDE Plasma Version: 5.22.2
KDE Frameworks Version: 5.83.0
Qt Version: 5.15.3
Comment 1 mr.drake 2022-03-02 03:29:35 UTC
Still same problem.
Comment 2 Bug Janitor Service 2022-03-02 07:31:13 UTC
A possibly relevant merge request was started @ https://invent.kde.org/plasma/kdeplasma-addons/-/merge_requests/121
Comment 3 mr.drake 2022-03-02 07:42:25 UTC
Created attachment 147234 [details]
krunner, spell
Comment 4 mr.drake 2022-03-02 07:43:16 UTC
(In reply to Bug Janitor Service from comment #2)
> A possibly relevant merge request was started @
> https://invent.kde.org/plasma/kdeplasma-addons/-/merge_requests/121

unfortunately not working for me
Comment 5 mr.drake 2022-03-02 07:45:35 UTC
Comment on attachment 147234 [details]
krunner, spell

spell <language-code> <search-term> still not working on krunner.
Comment 6 mr.drake 2022-03-02 07:57:27 UTC
(In reply to mr.drake from comment #4)
> (In reply to Bug Janitor Service from comment #2)
> > A possibly relevant merge request was started @
> > https://invent.kde.org/plasma/kdeplasma-addons/-/merge_requests/121
> 
> unfortunately not working for me

I was using wrong language code. It works!
Thank you very much!
Comment 7 Fushan Wen 2022-03-02 08:32:03 UTC
Git commit e567213e30a0d8c541b48a2164c16c4e365a5879 by Fushan Wen.
Committed on 02/03/2022 at 08:30.
Pushed by fusionfuture into branch 'master'.

runners/spellchecker: Match the language code using `startWith`

And make the match case-insensitive, so "en" or "en_us" can work.

M  +17   -10   runners/spellchecker/spellcheck.cpp
M  +1    -0    runners/spellchecker/spellcheck.h

https://invent.kde.org/plasma/kdeplasma-addons/commit/e567213e30a0d8c541b48a2164c16c4e365a5879
Comment 8 Bug Janitor Service 2022-03-02 10:56:48 UTC
A possibly relevant merge request was started @ https://invent.kde.org/plasma/kdeplasma-addons/-/merge_requests/122
Comment 9 Fushan Wen 2022-03-03 23:12:14 UTC
Git commit 10b7007cae463384bb1e27138a692a820f670f3f by Fushan Wen.
Committed on 02/03/2022 at 11:14.
Pushed by fusionfuture into branch 'master'.

runners/spellchecker: Add automatic language detection of search term

If the default dictionary returns an empty result, try to iterate over
all available dictionaries (except the default one) to get the suggestion.

M  +45   -17   runners/spellchecker/spellcheck.cpp

https://invent.kde.org/plasma/kdeplasma-addons/commit/10b7007cae463384bb1e27138a692a820f670f3f
Comment 10 Fushan Wen 2022-03-03 23:12:18 UTC
Git commit 84f964d65f3bc66277142074b9637c7f350c4c27 by Fushan Wen.
Committed on 02/03/2022 at 16:21.
Pushed by fusionfuture into branch 'master'.

runners/spellchecker: Add autotests

1. `testDefaultDictionary`: Test the runner can return a suggestion.
   (spell hello)
2. `testSpecifiedDictionary`: Test the runner can return a suggestion
   when the language is specified. (spell en_US hello)
3. `testAutomaticDictionary`: Test the runner can return a suggestion
   when the term is not in the default language. (spell мама)
4. `testSuggestions`: Test the runner can return a suggestion when the
   term is misspelled.

M  +11   -2    runners/spellchecker/CMakeLists.txt
A  +12   -0    runners/spellchecker/autotests/CMakeLists.txt
A  +156  -0    runners/spellchecker/autotests/spellcheckrunnertest.cpp     [License: LGPL(3+eV) LGPL(v3.0) LGPL(v2.1)]
M  +2    -0    runners/spellchecker/spellcheck.h

https://invent.kde.org/plasma/kdeplasma-addons/commit/84f964d65f3bc66277142074b9637c7f350c4c27