[goffice] try harder to find the locale; Ubuntu, for example, does not understand fi_FI but fi_FI.utf-8.



commit 5c16816961a4cebec114bc14a32328983e66041e
Author: Andreas J Guelzow <aguelzow pyrshep ca>
Date:   Wed Sep 7 01:42:08 2011 -0600

    try harder to find the locale; Ubuntu, for example, does not understand fi_FI but fi_FI.utf-8.
    
    2011-09-07  Andreas J. Guelzow <aguelzow pyrshep ca>
    
    	* goffice/utils/go-format.c (handle_common_token): try harder to find the
    	locale, Ubuntu, for example, does not understand fi_FI but fi_FI.utf-8.

 ChangeLog                 |    5 +++++
 goffice/utils/go-format.c |   14 +++++++++++++-
 2 files changed, 18 insertions(+), 1 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 17e628f..bb720e9 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2011-09-07  Andreas J. Guelzow <aguelzow pyrshep ca>
+
+	* goffice/utils/go-format.c (handle_common_token): try harder to find the
+	locale, Ubuntu, for example, does not understand fi_FI but fi_FI.utf-8.
+
 2011-09-06  Andreas J. Guelzow <aguelzow pyrshep ca>
 
 	* goffice/utils/go-format.c (go_format_parse_number_fraction): make
diff --git a/goffice/utils/go-format.c b/goffice/utils/go-format.c
index fb20d4e..009b48e 100644
--- a/goffice/utils/go-format.c
+++ b/goffice/utils/go-format.c
@@ -1233,6 +1233,7 @@ handle_common_token (const char *tstr, GOFormatToken t, GString *prg)
 		char *oldlocale;
 		GOFormatLocale locale;
 		const char *lang;
+		char *lname = NULL;
 		gsize nchars;
 		gboolean ok = go_format_parse_locale (tstr, &locale, &nchars);
 		/* Already parsed elsewhere */
@@ -1252,15 +1253,26 @@ handle_common_token (const char *tstr, GOFormatToken t, GString *prg)
 
 		oldlocale = g_strdup (setlocale (LC_ALL, NULL));
 		ok = setlocale (LC_ALL, lang) != NULL;
+
+		if (!ok) {
+			char *lname = g_strdup_printf ("%s.utf-8",lang);
+			lang = lname;
+			ok = setlocale (LC_ALL, lang) != NULL;
+			
+		}
+
 		setlocale (LC_ALL, oldlocale);
 		g_free (oldlocale);
 
-		if (!ok)
+		if (!ok) {
+			g_free (lname);
 			break;
+		}
 		ADD_OP (OP_LOCALE);
 		g_string_append_len (prg, (void *)&locale, sizeof (locale));
 		/* Include the terminating zero: */
 		g_string_append_len (prg, lang, strlen (lang) + 1);
+		g_free (lname);
 		break;
 	}
 



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