summaryrefslogtreecommitdiff
path: root/liblightdm-gobject/language.c
diff options
context:
space:
mode:
authorRobert Ancell <robert.ancell@canonical.com>2011-09-20 11:49:16 +1000
committerRobert Ancell <robert.ancell@canonical.com>2011-09-20 11:49:16 +1000
commitc69c36f6d93abb16076c9bd50ecba22eb0acb2d4 (patch)
treeb4053174da3893c10c28992233315051cc4f7e10 /liblightdm-gobject/language.c
parent8005ca24b6ca1419171d3a7d7a2c4a74c2d010f1 (diff)
downloadlightdm-c69c36f6d93abb16076c9bd50ecba22eb0acb2d4.tar.gz
Add language selector into GTK greeter (disabled by default)
Diffstat (limited to 'liblightdm-gobject/language.c')
-rw-r--r--liblightdm-gobject/language.c20
1 files changed, 16 insertions, 4 deletions
diff --git a/liblightdm-gobject/language.c b/liblightdm-gobject/language.c
index 5c4f7d57..edcf9974 100644
--- a/liblightdm-gobject/language.c
+++ b/liblightdm-gobject/language.c
@@ -71,7 +71,7 @@ update_languages (void)
continue;
/* Ignore the non-interesting languages */
- if (strcmp (code, "C") == 0 || strcmp (code, "POSIX") == 0)
+ if (strcmp (code, "C") == 0 || g_str_has_prefix (code, "C.") || strcmp (code, "POSIX") == 0)
continue;
language = g_object_new (LIGHTDM_TYPE_LANGUAGE, "code", code, NULL);
@@ -94,13 +94,16 @@ update_languages (void)
*
* Return value: (transfer none): The current language or #NULL if no language.
**/
-const LightDMLanguage *
+LightDMLanguage *
lightdm_get_language (void)
{
const gchar *lang;
GList *link;
lang = g_getenv ("LANG");
+ if (!lang)
+ return NULL;
+
for (link = lightdm_get_languages (); link; link = link->next)
{
LightDMLanguage *language = link->data;
@@ -164,7 +167,9 @@ lightdm_language_get_name (LightDMLanguage *language)
#ifdef _NL_IDENTIFICATION_LANGUAGE
priv->name = g_strdup (nl_langinfo (_NL_IDENTIFICATION_LANGUAGE));
#else
- priv->name = g_strdup ("Unknown");
+ priv->name = g_strdup (priv->code);
+ if (strchr (priv->name, '_'))
+ *strchr (priv->name, '_') = '\0';
#endif
setlocale(LC_ALL, current);
}
@@ -196,7 +201,14 @@ lightdm_language_get_territory (LightDMLanguage *language)
#ifdef _NL_IDENTIFICATION_TERRITORY
priv->territory = g_strdup (nl_langinfo (_NL_IDENTIFICATION_TERRITORY));
#else
- priv->territory = g_strdup ("Unknown");
+ if (strchr (priv->code, '_'))
+ {
+ priv->territory = g_strdup (strchr (priv->code, '_') + 1);
+ if (strchr (priv->territory, '.'))
+ *strchr (priv->territory, '.') = '\0';
+ }
+ else
+ priv->territory = g_strdup ("");
#endif
setlocale(LC_ALL, current);
}