Use 'UTF-8' instead of 'utf8' as locale codeset suffix

This makes us work on OpenBSD's libc. GNU libc accepts both suffixes.

https://bugzilla.gnome.org/show_bug.cgi?id=710412
This commit is contained in:
Rui Matos 2014-01-20 22:42:56 +01:00
parent 3423286b5e
commit 880f9f1475
2 changed files with 32 additions and 16 deletions

View file

@ -578,6 +578,10 @@ add_other_users_language (GHashTable *ht)
g_object_unref (proxy);
}
/*
* Note that @lang needs to be formatted like the locale strings
* returned by gnome_get_all_locales().
*/
static void
insert_language (GHashTable *ht,
const char *lang)
@ -600,10 +604,7 @@ insert_language (GHashTable *ht,
g_debug ("We have translations for %s", lang);
if (g_str_has_suffix (lang, ".utf8"))
key = g_strdup (lang);
else
key = g_strdup_printf ("%s.utf8", lang);
label_own_lang = gnome_get_language_from_locale (key, key);
label_current_lang = gnome_get_language_from_locale (key, NULL);
@ -632,15 +633,15 @@ cc_common_language_get_initial_languages (void)
ht = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free);
insert_language (ht, "en_US");
insert_language (ht, "en_GB");
insert_language (ht, "de_DE");
insert_language (ht, "fr_FR");
insert_language (ht, "es_ES");
insert_language (ht, "zh_CN");
insert_language (ht, "ja_JP");
insert_language (ht, "ru_RU");
insert_language (ht, "ar_EG");
insert_language (ht, "en_US.UTF-8");
insert_language (ht, "en_GB.UTF-8");
insert_language (ht, "de_DE.UTF-8");
insert_language (ht, "fr_FR.UTF-8");
insert_language (ht, "es_ES.UTF-8");
insert_language (ht, "zh_CN.UTF-8");
insert_language (ht, "ja_JP.UTF-8");
insert_language (ht, "ru_RU.UTF-8");
insert_language (ht, "ar_EG.UTF-8");
return ht;
}
@ -741,6 +742,21 @@ cc_common_language_add_user_languages (GtkTreeModel *model)
name = cc_common_language_get_current_language ();
display = g_hash_table_lookup (user_langs, name);
if (!display) {
char *language = NULL;
char *country = NULL;
char *codeset = NULL;
gnome_parse_locale (name, &language, &country, &codeset, NULL);
g_free (name);
if (!codeset || !g_str_equal (codeset, "UTF-8"))
g_warning ("Current user locale codeset isn't UTF-8");
name = g_strdup_printf ("%s_%s.UTF-8", language, country);
g_free (language);
g_free (country);
g_free (codeset);
insert_language (user_langs, name);
display = g_hash_table_lookup (user_langs, name);
}

View file

@ -897,7 +897,7 @@ get_ibus_locale_infos (GtkWidget *chooser)
lang_code != NULL &&
country_code != NULL)
{
gchar *locale = g_strdup_printf ("%s_%s.utf8", lang_code, country_code);
gchar *locale = g_strdup_printf ("%s_%s.UTF-8", lang_code, country_code);
info = g_hash_table_lookup (priv->locales, locale);
if (info)
@ -1023,9 +1023,9 @@ get_locale_infos (GtkWidget *chooser)
continue;
if (country_code != NULL)
simple_locale = g_strdup_printf ("%s_%s.utf8", lang_code, country_code);
simple_locale = g_strdup_printf ("%s_%s.UTF-8", lang_code, country_code);
else
simple_locale = g_strdup_printf ("%s.utf8", lang_code);
simple_locale = g_strdup_printf ("%s.UTF-8", lang_code);
if (g_hash_table_contains (priv->locales, simple_locale))
{