[gnome-software] gs-plugin-loader: Fix parsing the language from the locale



commit f79c53f4469dfff255dea541c3a1ae8659d8ff21
Author: Philip Withnall <withnall endlessm com>
Date:   Fri Oct 11 11:30:39 2019 +0100

    gs-plugin-loader: Fix parsing the language from the locale
    
    The old code was only looking for the separator between the language and
    territory, but the user’s locale might not specify a territory. For
    example, extracting the language would have failed for locale `eo@euro`.
    
    (That locale doesn’t actually exist on my system, but could in theory.)
    
    Signed-off-by: Philip Withnall <withnall endlessm com>

 lib/gs-plugin-loader.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
---
diff --git a/lib/gs-plugin-loader.c b/lib/gs-plugin-loader.c
index 12b447df..ebc05ba9 100644
--- a/lib/gs-plugin-loader.c
+++ b/lib/gs-plugin-loader.c
@@ -2745,12 +2745,15 @@ gs_plugin_loader_init (GsPluginLoader *plugin_loader)
        priv->disallow_updates = g_hash_table_new (g_direct_hash, g_direct_equal);
        gs_plugin_loader_allow_updates_recheck (plugin_loader);
 
-       /* get the language from the locale */
+       /* get the language from the locale (i.e. strip the territory, codeset
+        * and modifier) */
        priv->language = g_strdup (priv->locale);
-       match = g_strrstr (priv->language, "_");
+       match = strpbrk (priv->language, "._@");
        if (match != NULL)
                *match = '\0';
 
+       g_debug ("Using locale = %s, language = %s", priv->locale, priv->language);
+
        g_mutex_init (&priv->pending_apps_mutex);
        g_mutex_init (&priv->events_by_id_mutex);
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]