From c5cb5e9263d22d7c1e666fe155b72cc15c4bc5d0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Markus=20G=C3=B6llnitz?= Date: Thu, 7 Dec 2023 04:03:48 +0100 Subject: [PATCH] add support for [lang]:[search term] format to in-app and shell search MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The format [lang]:[page name] is the common and widely known format for interwiki links, and thus makes sense to support as a format for the search for a deviation from the default language. Signed-off-by: Markus Göllnitz --- src/search.py | 4 ++++ src/wike-sp.in | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/src/search.py b/src/search.py index 1dd13c6..3ed09af 100644 --- a/src/search.py +++ b/src/search.py @@ -102,6 +102,10 @@ def _get_search_terms(self, text): text = terms[1] else: text = '' + elif ':' in text: + for available_lang in languages.wikilangs.keys(): + if text.startswith(available_lang + ':'): + lang, text = text.split(':', 1) return text, lang # When search stoped with ESC hide suggestions diff --git a/src/wike-sp.in b/src/wike-sp.in index 004e199..e9f479f 100755 --- a/src/wike-sp.in +++ b/src/wike-sp.in @@ -83,6 +83,10 @@ class WikeSearchService: text = text.split(' ', 1)[1] else: text = '' + elif ':' in text: + for available_lang in languages.wikilangs.keys(): + if text.startswith(available_lang + ':'): + lang, text = text.split(':', 1) if len(text) > 2: if settings.get_boolean('search-desktop'):