[gcompris/gcomprixogoo] A few fixes to better manage locale especially in click_on_letter to properly display the locale to



commit 8b5c69501130e46e5bae973431d9949b5a473781
Author: Bruno Coudoin <bruno coudoin free fr>
Date:   Tue Jun 15 01:23:10 2010 +0200

    A few fixes to better manage locale especially in click_on_letter to
    properly display the locale to search if its not a 2 letter prefix like
    for asturian (locale=ast).

 src/click_on_letter-activity/click_on_letter.c |   23 +++++++++++++++++------
 src/gcompris/board_config_combo.c              |    2 +-
 src/gcompris/gameutil.c                        |    5 ++++-
 src/gcompris/gcompris.h                        |    2 ++
 4 files changed, 24 insertions(+), 8 deletions(-)
---
diff --git a/src/click_on_letter-activity/click_on_letter.c b/src/click_on_letter-activity/click_on_letter.c
index 616320c..4206e17 100644
--- a/src/click_on_letter-activity/click_on_letter.c
+++ b/src/click_on_letter-activity/click_on_letter.c
@@ -70,7 +70,7 @@ static void click_on_letter_destroy_all_items(void);
 static void click_on_letter_next_level(void);
 static gint item_event(GooCanvasItem *item, GooCanvasItem *target,
 		       GdkEvent *event, gpointer data);
-static gboolean sounds_are_fine();
+static guint sounds_are_fine();
 
 static int right_position;
 static int number_of_letters=MAX_NUMBER_OF_LETTERS;
@@ -260,7 +260,7 @@ static void repeat ()
     }
 }
 
-static gboolean sounds_are_fine()
+static guint sounds_are_fine()
 {
   char *letter_str;
   char *str2;
@@ -285,13 +285,19 @@ static gboolean sounds_are_fine()
 
   if (!str2)
     {
-      gchar *locale = NULL;
+      gchar *locale;
+      gchar **localsearch;
+
+      localsearch = g_strsplit_set(gc_locale_get(), "_", 2);
+      if(g_strv_length(localsearch) <= 1)
+	return NOT_OK; /* Should not happens */
+      locale = g_strdup(localsearch[0]);
+      g_strfreev(localsearch);
 
-      locale = g_strndup(gc_locale_get(), 2);
       gc_locale_reset();
-      gc_locale_set("en_US");
+      gc_locale_set(GC_DEFAULT_LOCALE);
 
-      str2 = gc_file_find_absolute("voices/en/alphabet/%s", letter_str);
+      str2 = gc_file_find_absolute("voices/$LOCALE/alphabet/%s", letter_str);
 
       if (!str2)
 	{
@@ -299,6 +305,8 @@ static gboolean sounds_are_fine()
 					locale, "en");
 	  gc_dialog(msg, gc_board_stop);
 	  g_free(msg);
+	  g_free(locale);
+	  g_free(letter_str);
 	  return (NOT_OK);
 	}
       else
@@ -307,12 +315,15 @@ static gboolean sounds_are_fine()
 	  gc_dialog(msg, click_on_letter_next_level);
 	  g_free(msg);
 	  g_free(str2);
+	  g_free(locale);
+	  g_free(letter_str);
 	  return(OK_NO_INIT);
 	}
     }
   else
     {
       g_free(str2);
+      g_free(letter_str);
     }
 
   return(OK);
diff --git a/src/gcompris/board_config_combo.c b/src/gcompris/board_config_combo.c
index 391675a..d73c3f9 100644
--- a/src/gcompris/board_config_combo.c
+++ b/src/gcompris/board_config_combo.c
@@ -347,7 +347,7 @@ gc_locale_gets_asset_list(const gchar *filename)
       /* Check there is a $LOCALE to replace */
       if((tmp = g_strsplit(filename, "$LOCALE", -1)))
 	{
-	  gchar locale[6];
+	  gchar locale[16];
 	  gchar *filename2;
 
 	  /* try with the locale */
diff --git a/src/gcompris/gameutil.c b/src/gcompris/gameutil.c
index 7a81352..bdbd40b 100644
--- a/src/gcompris/gameutil.c
+++ b/src/gcompris/gameutil.c
@@ -609,7 +609,10 @@ gc_file_find_absolute(const gchar *format, ...)
 
 	  locale = g_strsplit_set(gc_locale_get(), ".", 2);
 	  if(g_strv_length(locale) <= 1)
-	    goto NOT_FOUND;
+	    {
+	      absolute_filename = g_strdup("");
+	      goto NOT_FOUND;
+	    }
 
 	  /* First try with the long locale */
 	  filename2 = g_strjoinv(locale[0], tmp);
diff --git a/src/gcompris/gcompris.h b/src/gcompris/gcompris.h
index eb3a3e7..8f4b914 100644
--- a/src/gcompris/gcompris.h
+++ b/src/gcompris/gcompris.h
@@ -77,6 +77,8 @@
 #define N_(String) gettext_noop (String)
 #endif
 
+#define GC_DEFAULT_LOCALE "en_US.UTF-8"
+
 /*****************************************************************************/
 /* Method usefull for boards provided by gcompris */
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]