mirror of
https://github.com/spalencsar/bearhub.git
synced 2026-07-07 03:34:15 +02:00
[wgem] handling i18n suggestion description | fix indexed search
This commit is contained in:
@@ -34,7 +34,7 @@ def main():
|
|||||||
|
|
||||||
i18n_key, current_i18n = translation.get_locale_keys(args.locale)
|
i18n_key, current_i18n = translation.get_locale_keys(args.locale)
|
||||||
default_i18n = translation.get_locale_keys(DEFAULT_I18N_KEY)[1] if i18n_key != DEFAULT_I18N_KEY else {}
|
default_i18n = translation.get_locale_keys(DEFAULT_I18N_KEY)[1] if i18n_key != DEFAULT_I18N_KEY else {}
|
||||||
i18n = I18n(current_i18n, default_i18n)
|
i18n = I18n(i18n_key, current_i18n, DEFAULT_I18N_KEY, default_i18n)
|
||||||
|
|
||||||
cache_cleaner = CacheCleaner()
|
cache_cleaner = CacheCleaner()
|
||||||
cache_factory = DefaultMemoryCacheFactory(expiration_time=args.cache_exp, cleaner=cache_cleaner)
|
cache_factory = DefaultMemoryCacheFactory(expiration_time=args.cache_exp, cleaner=cache_cleaner)
|
||||||
|
|||||||
@@ -190,13 +190,18 @@ class WebApplicationManager(SoftwareManager):
|
|||||||
split_words = lower_words.split(' ')
|
split_words = lower_words.split(' ')
|
||||||
singleword = ''.join(lower_words)
|
singleword = ''.join(lower_words)
|
||||||
|
|
||||||
index_match_keys = set()
|
query_list = [*split_words, singleword]
|
||||||
for word in (*split_words, singleword):
|
|
||||||
indexed = index.get(word)
|
|
||||||
if indexed:
|
|
||||||
index_match_keys.update(indexed)
|
|
||||||
|
|
||||||
if index_match_keys:
|
index_match_keys = set()
|
||||||
|
for key in index:
|
||||||
|
for query in query_list:
|
||||||
|
if query in key:
|
||||||
|
index_match_keys.update(index[key])
|
||||||
|
|
||||||
|
if not index_match_keys:
|
||||||
|
self.logger.info("Query '{}' was not found in the suggestion's index".format(words))
|
||||||
|
res.installed.extend(installed_matches)
|
||||||
|
else:
|
||||||
if not os.path.exists(SUGGESTIONS_CACHE_FILE):
|
if not os.path.exists(SUGGESTIONS_CACHE_FILE):
|
||||||
# if the suggestions cache was not found, it will not be possible to retrieve the matched apps
|
# if the suggestions cache was not found, it will not be possible to retrieve the matched apps
|
||||||
# so only the installed matches will be returned
|
# so only the installed matches will be returned
|
||||||
@@ -224,7 +229,7 @@ class WebApplicationManager(SoftwareManager):
|
|||||||
# checking if any of the installed matches is one of the matched suggestions
|
# checking if any of the installed matches is one of the matched suggestions
|
||||||
|
|
||||||
for sug in matched_suggestions:
|
for sug in matched_suggestions:
|
||||||
found = (installed for installed in installed_matches if i.url == sug.get('url'))
|
found = [i for i in installed_matches if i.url == sug.get('url')]
|
||||||
|
|
||||||
if found:
|
if found:
|
||||||
res.installed.extend(found)
|
res.installed.extend(found)
|
||||||
@@ -376,7 +381,7 @@ class WebApplicationManager(SoftwareManager):
|
|||||||
op_igcert = InputOption(id_='ignore_certs', label=self.i18n['web.install.option.ignore_certificate.label'], value="--ignore-certificate", tooltip=self.i18n['web.install.option.ignore_certificate.tip'])
|
op_igcert = InputOption(id_='ignore_certs', label=self.i18n['web.install.option.ignore_certificate.label'], value="--ignore-certificate", tooltip=self.i18n['web.install.option.ignore_certificate.tip'])
|
||||||
|
|
||||||
adv_opts = [op_single, op_allow_urls, op_max, op_fs, op_nframe, op_ncache, op_insecure, op_igcert]
|
adv_opts = [op_single, op_allow_urls, op_max, op_fs, op_nframe, op_ncache, op_insecure, op_igcert]
|
||||||
def_adv_opts = {op_single}
|
def_adv_opts = {op_single, op_allow_urls}
|
||||||
|
|
||||||
if app.preset_options:
|
if app.preset_options:
|
||||||
for opt in adv_opts:
|
for opt in adv_opts:
|
||||||
@@ -623,6 +628,18 @@ class WebApplicationManager(SoftwareManager):
|
|||||||
icon_url=suggestion.get('icon_url'),
|
icon_url=suggestion.get('icon_url'),
|
||||||
categories=[suggestion['category']] if suggestion.get('category') else None,
|
categories=[suggestion['category']] if suggestion.get('category') else None,
|
||||||
preset_options=suggestion.get('options'))
|
preset_options=suggestion.get('options'))
|
||||||
|
|
||||||
|
description = suggestion.get('description')
|
||||||
|
|
||||||
|
if isinstance(description, dict):
|
||||||
|
app.description = description.get(self.i18n.current_key, description.get(self.i18n.default_key))
|
||||||
|
elif isinstance(description, str):
|
||||||
|
app.description = description
|
||||||
|
|
||||||
|
if self.env_settings and self.env_settings.get('electron'):
|
||||||
|
app.version = self.env_settings['electron']['version']
|
||||||
|
app.latest_version = app.version
|
||||||
|
|
||||||
app.status = PackageStatus.LOADING_DATA
|
app.status = PackageStatus.LOADING_DATA
|
||||||
|
|
||||||
Thread(target=self._fill_suggestion, args=(app,)).start()
|
Thread(target=self._fill_suggestion, args=(app,)).start()
|
||||||
|
|||||||
@@ -7,9 +7,11 @@ from bauh.view.util import resource
|
|||||||
|
|
||||||
class I18n(dict):
|
class I18n(dict):
|
||||||
|
|
||||||
def __init__(self, current_locale: dict, default_locale: dict):
|
def __init__(self, current_key: str, current_locale: dict, default_key: str, default_locale: dict):
|
||||||
super(I18n, self).__init__()
|
super(I18n, self).__init__()
|
||||||
|
self.current_key = current_key
|
||||||
self.current = current_locale
|
self.current = current_locale
|
||||||
|
self.default_key = default_key
|
||||||
self.default = default_locale
|
self.default = default_locale
|
||||||
|
|
||||||
def __getitem__(self, item):
|
def __getitem__(self, item):
|
||||||
|
|||||||
Reference in New Issue
Block a user