Add tokenised version of appstream content type description to app search tokens
Following on from #1696 (comment 1417914), it would not be a bad idea to add the tokenised form of calling g_content_type_get_description()
on each <mimetype>
appstream element to the search tokens for each app.
I have checked, and GLib should return a localised string from g_content_type_get_description()
. The shared-mime-info database does contain localisations of content type descriptions.
Specifically I think the change would be to add something like the following in gs_plugin_appstream_tokenize_cb()
(but I haven’t tested this):
if (xb_builder_node_get_element (bn) != NULL &&
g_str_equal (xb_builder_node_get_element (bn), "mimetype")) {
g_autofree gchar **ascii_tokens = NULL;
g_autofree gchar **tokens = NULL;
const gchar *xml_lang = xb_builder_node_get_attr (bn, "xml:lang");
const gchar *content_type;
g_autofree gchar *description = NULL;
content_type = xb_builder_node_get_text (bn);
if (content_type != NULL)
description = g_content_type_get_description (content_type);
if (description != NULL)
tokens = g_str_tokenize_and_fold (description, xml_lang, &ascii_tokens);
for (gsize i = 0; tokens != NULL && tokens[i] != NULL; i++) {
if (!xb_string_token_valid (tokens[i]))
continue;
xb_builder_node_add_token (bn, tokens[i]);
}
… same for @ascii_tokens …
}
I think xb_string_token_valid()
would have to be made public in libxmlb, and/or we copy the definition into gnome-software (it’s a very simple function).