diff options
Diffstat (limited to 'libgnome-desktop')
-rw-r--r-- | libgnome-desktop/gnome-languages.c | 37 |
1 files changed, 16 insertions, 21 deletions
diff --git a/libgnome-desktop/gnome-languages.c b/libgnome-desktop/gnome-languages.c index 6a18ebae..5e9a2f30 100644 --- a/libgnome-desktop/gnome-languages.c +++ b/libgnome-desktop/gnome-languages.c @@ -88,27 +88,14 @@ gnome_locale_free (GnomeLocale *locale) static char * normalize_codeset (const char *codeset) { - char *normalized_codeset; - const char *p; - char *q; - - normalized_codeset = g_strdup (codeset); - - if (codeset != NULL) { - for (p = codeset, q = normalized_codeset; - *p != '\0'; p++) { - - if (*p == '-' || *p == '_') { - continue; - } + if (codeset == NULL) + return NULL; - *q = g_ascii_tolower (*p); - q++; - } - *q = '\0'; - } + if (g_str_equal (codeset, "UTF-8") || + g_str_equal (codeset, "utf8")) + return g_strdup ("UTF-8"); - return normalized_codeset; + return g_strdup (codeset); } /** @@ -340,7 +327,7 @@ language_name_get_codeset_details (const char *language_name, if (is_utf8 != NULL) { codeset = normalize_codeset (codeset); - *is_utf8 = strcmp (codeset, "utf8") == 0; + *is_utf8 = strcmp (codeset, "UTF-8") == 0; g_free (codeset); } @@ -411,7 +398,15 @@ add_locale (const char *language_name, if (is_utf8) { name = g_strdup (language_name); } else if (utf8_only) { - name = g_strdup_printf ("%s.utf8", language_name); + + if (strchr (language_name, '.')) + return FALSE; + + /* If the locale name has no dot, assume that its + * encoding part is missing and try again after adding + * ".UTF-8". This catches locale names like "de_DE". + */ + name = g_strdup_printf ("%s.UTF-8", language_name); language_name_get_codeset_details (name, NULL, &is_utf8); if (!is_utf8) { |