--- a/liblightdm-gobject/language.c +++ b/liblightdm-gobject/language.c @@ -37,6 +37,12 @@ static gboolean have_languages = FALSE; static GList *languages = NULL; +static gboolean +is_utf8 (const gchar *code) +{ + return g_strrstr (code, ".utf8") || g_strrstr (code, ".UTF-8"); +} + static void update_languages (void) { @@ -73,11 +79,26 @@ continue; /* Ignore the non-interesting languages */ - if (strcmp (command, "locale -a") == 0 && !g_strrstr (code, ".utf8")) + if (strcmp (command, "locale -a") == 0 && !is_utf8 (code)) continue; + + /* Replace simplified codeset name (utf8) with full name (UTF-8) for better compatibility */ + if (strstr (code, ".utf8")) + { + gchar **parts; + parts = g_strsplit(code, ".utf8", 2); + code = g_strjoinv(".UTF-8", parts); + g_strfreev (parts); + } + else + { + code = g_strdup (code); + } language = g_object_new (LIGHTDM_TYPE_LANGUAGE, "code", code, NULL); languages = g_list_append (languages, language); + + g_free (code); } g_strfreev (tokens); @@ -87,12 +108,6 @@ g_free (stderr_text); have_languages = TRUE; -} - -static gboolean -is_utf8 (const gchar *code) -{ - return g_strrstr (code, ".utf8") || g_strrstr (code, ".UTF-8"); } /* Get a valid locale name that can be passed to setlocale(), so we always can use nl_langinfo() to get language and country names. */ @@ -134,7 +149,7 @@ for (i = 0; avail_locales[i]; i++) { gchar *loc = avail_locales[i]; - if (!g_strrstr (loc, ".utf8")) + if (!is_utf8 (loc)) continue; if (g_str_has_prefix (loc, language)) {