[gnome-software] Fixes #683. No package show available as localized in language
- From: Richard Hughes <rhughes src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-software] Fixes #683. No package show available as localized in language
- Date: Mon, 15 Jul 2019 11:07:37 +0000 (UTC)
commit 512a2e6efffcd59c242f034b9e99bb6c962dd918
Author: Jordi Mas <jmas softcatala org>
Date: Mon Jul 15 11:07:25 2019 +0000
Fixes #683. No package show available as localized in language
plugins/core/gs-appstream.c | 29 ++++++++++++++++++++++++++---
1 file changed, 26 insertions(+), 3 deletions(-)
---
diff --git a/plugins/core/gs-appstream.c b/plugins/core/gs-appstream.c
index 1be51998..ec6ade61 100644
--- a/plugins/core/gs-appstream.c
+++ b/plugins/core/gs-appstream.c
@@ -556,6 +556,20 @@ _gs_utils_locale_has_translations (const gchar *locale)
return TRUE;
}
+static gchar *
+_gs_utils_get_language_from_locale (const gchar *locale)
+{
+ gchar *separator;
+
+ separator = strpbrk (locale, "._");
+
+ if (separator == NULL)
+ return NULL;
+
+ return g_strndup (locale, separator - locale);
+}
+
+
static gboolean
gs_appstream_origin_valid (const gchar *origin)
{
@@ -908,9 +922,18 @@ gs_appstream_refine_app (GsPlugin *plugin,
if (!_gs_utils_locale_has_translations (tmp)) {
gs_app_add_kudo (app, GS_APP_KUDO_MY_LANGUAGE);
} else {
- g_autofree gchar *xpath = NULL;
- xpath = g_strdup_printf ("languages/lang[text()='%s'][@percentage>50]", tmp);
- if (xb_node_query_text (component, xpath, NULL) != NULL)
+
+ g_autoptr(GString) xpath = g_string_new (NULL);
+ g_autofree gchar *language;
+
+ xb_string_append_union (xpath, "languages/lang[text()='%s'][@percentage>50]", tmp);
+
+ language = _gs_utils_get_language_from_locale (tmp);
+ if (language != NULL) {
+ xb_string_append_union (xpath, "languages/lang[text()='%s'][@percentage>50]",
language);
+ }
+
+ if (xb_node_query_text (component, xpath->str, NULL) != NULL)
gs_app_add_kudo (app, GS_APP_KUDO_MY_LANGUAGE);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]