Bug 428194

Summary: Search is not language agnostic
Product: [Plasma] krunner Reporter: Mikhail Shchemelev <mikhail.schemelev>
Component: generalAssignee: Alexander Lohnau <alexander.lohnau>
Status: RESOLVED FIXED    
Severity: wishlist CC: nate, plasma-bugs
Priority: NOR    
Version: 5.20.1   
Target Milestone: ---   
Platform: Other   
OS: Other   
Latest Commit: Version Fixed In: 5.21
Sentry Crash Report:

Description Mikhail Shchemelev 2020-10-24 19:28:25 UTC
SUMMARY

Search terms for krunner are bound to language defined by system locale.
For example on english locale power actions (shutdown/restart/suspend) can be found by their respective terms. However in russian locale you have to enter localized terms (выключить/перезагрузить/спящий режим)

The same holds for application search in cases where additional terms are present. For example, konsole can be found by typing in "konsole", or "terminal" in english locale, while in russian you have to enter "konsole" or "терминал" - the latter being translated term for "terminal"

This behaviour is inconvenient, since it prompts for an additional layout switch when english keyboard layout is default (and it might be default for variety of reasons, among them the fact that, for example, terminal commands can not be entered in russian layouts, due to incompatible character sets)


This issue is not exclusive to russian, all languages that have translated terms are somewhat affected. Even for languages that have an ascii-based charset, while layout switch is not required, there is an issue that user is expected to enter translated term, while they might not be aware of such requirement. For example it was independently confirmed that in order to execute shutdown in german locale, user have to enter "herunterfahren" while "shutdown" won't work.

STEPS TO REPRODUCE
1. Prepare a system with locale that has translated search terms for actions, for example russian
2. Try to execute search with original (english) terms, for example: "suspend"

OBSERVED RESULT
Nothing is found

EXPECTED RESULT
Search engine should allow search for original (english) versions of terms regardless of system language

SOFTWARE/OS VERSIONS
Any linux distribution
Any KDE version
Comment 1 Alexander Lohnau 2020-10-24 19:33:08 UTC
Currently only the translated strings are used to compare the trigger words. So allowing both English+Native locale should be the way to go. Just like the activity runner (there activity and the translated version are trigger words).

In that case the parsing logic for this runner would need to be rewritten, because the way it is currently done would not scale well.
Comment 2 Mikhail Shchemelev 2020-10-24 19:46:51 UTC
(In reply to Alexander Lohnau from comment #1)
> Currently only the translated strings are used to compare the trigger words.
> So allowing both English+Native locale should be the way to go. Just like
> the activity runner (there activity and the translated version are trigger
> words).
> 
> In that case the parsing logic for this runner would need to be rewritten,
> because the way it is currently done would not scale well.

Sadly i'm not familiar with implementation details of krunner engine.
Can it be implemented by simply adding bilingual keyword sets into translation file? Or is there some additional work that is needed to make that work?

As a matter of fact, this is how it is done in gnome (they are affected too). Their greek translators have added both greek and english keywords into gnome-shell po file. I did a patch for their russian translation, but their russian translation team is somewhat inactive now.
Comment 3 Alexander Lohnau 2020-10-31 08:46:20 UTC
>Can it be implemented by simply adding bilingual keyword sets into translation file? Or is there some additional work that is needed to make that work?
It will need to be adjusted in the individual plugin where the match logic happens. But there are some things that need to be adjusted first to make sure the runner is future-proof.
Comment 4 Bug Janitor Service 2020-12-16 20:28:19 UTC
A possibly relevant merge request was started @ https://invent.kde.org/plasma/plasma-workspace/-/merge_requests/521
Comment 5 Alexander Lohnau 2020-12-27 21:56:13 UTC
Git commit 6f54d49ade5f11f1a5d8f4944e61e0ede7380267 by Alexander Lohnau.
Committed on 27/12/2020 at 21:56.
Pushed by alex into branch 'master'.

Rewrite match logic of PowerDevil runner

- Support partial matches
- Allow both translated and non-translated trigger words
- Avoid duplicating the translated strings. This can become useful in
 case we also want to add the non-translated trigger words to the
 syntaxes (once they get displayed somewhere ;))
- Get rid of QRegExp usage
Related: bug 428193
FIXED-IN: 5.21

M  +101  -83   runners/powerdevil/PowerDevilRunner.cpp
M  +16   -2    runners/powerdevil/PowerDevilRunner.h

https://invent.kde.org/plasma/plasma-workspace/commit/6f54d49ade5f11f1a5d8f4944e61e0ede7380267