[gcompris] core, proper locale detection from the env variable
- From: Bruno Coudoin <bcoudoin src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gcompris] core, proper locale detection from the env variable
- Date: Mon, 9 Mar 2015 20:33:18 +0000 (UTC)
commit e93dccbd43217e3c47547033354d1a11db759974
Author: Bruno Coudoin <bruno coudoin gcompris net>
Date: Mon Mar 9 21:25:36 2015 +0100
core, proper locale detection from the env variable
We were not respecting the env variable precedence.
fixes bug https://bugs.launchpad.net/ubuntu/+source/gcompris/+bug/1404947
src/gcompris/gcompris.c | 15 ++++++++++-----
1 files changed, 10 insertions(+), 5 deletions(-)
---
diff --git a/src/gcompris/gcompris.c b/src/gcompris/gcompris.c
index 12e4eb7..efb6065 100644
--- a/src/gcompris/gcompris.c
+++ b/src/gcompris/gcompris.c
@@ -1371,13 +1371,18 @@ const gchar *gc_locale_get()
if(gc_locale != NULL)
return(gc_locale);
+ /* Env variable precedences.
+ * LC_ALL Takes precedence over LC_MESSAGES and LANG
+ * LC_MESSAGES Takes precedence over LANG.
+ * LANG
+ */
locale = g_getenv("LC_ALL");
- if(locale == NULL)
- locale = g_getenv("LC_CTYPE");
- if(locale == NULL)
+ if(locale == NULL || locale[0] == 0 )
+ locale = g_getenv("LC_MESSAGES");
+ if(locale == NULL || locale[0] == 0 )
locale = g_getenv("LANG");
- if(locale!=NULL)
+ if(locale!=NULL && strncmp(locale, "C", 2))
return(locale);
return("en_US.UTF-8");
@@ -1695,7 +1700,7 @@ main (int argc, char *argv[])
gc_locale_set(properties->locale);
}
#else
- gc_user_default_locale = g_strdup(setlocale(LC_CTYPE, NULL));
+ gc_user_default_locale = g_strdup(gc_locale_get());
// Set the user's choice locale
gc_locale_set(properties->locale);
#endif
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]