[gnome-desktop] wall-clock: Replace ratio with colon on non-UTF-8 locales
- From: Rui Matos <rtcm src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-desktop] wall-clock: Replace ratio with colon on non-UTF-8 locales
- Date: Mon, 3 Feb 2014 17:28:00 +0000 (UTC)
commit 1b9b7a267ade221ad4000cd024547b42a3056bf4
Author: Rui Matos <tiagomatos gmail com>
Date: Tue Jan 21 22:04:42 2014 +0100
wall-clock: Replace ratio with colon on non-UTF-8 locales
Some of our translations use the ratio symbol which isn't convertible
to non-UTF-8 locale encodings which causes g_date_time_format() to
fail. Work around it by replacing the ratio symbol with a plain
colon.
https://bugzilla.gnome.org/show_bug.cgi?id=722664
libgnome-desktop/gnome-wall-clock.c | 27 +++++++++++++++++++++++++--
1 files changed, 25 insertions(+), 2 deletions(-)
---
diff --git a/libgnome-desktop/gnome-wall-clock.c b/libgnome-desktop/gnome-wall-clock.c
index a2f5e2c..8ccaac0 100644
--- a/libgnome-desktop/gnome-wall-clock.c
+++ b/libgnome-desktop/gnome-wall-clock.c
@@ -229,12 +229,32 @@ gnome_wall_clock_class_init (GnomeWallClockClass *klass)
g_type_class_add_private (gobject_class, sizeof (GnomeWallClockPrivate));
}
+/* Some of our translations use the ratio symbol which isn't
+ * convertible to non-UTF-8 locale encodings.
+ */
+static char *
+filter_ratio_for_locale (const char *input)
+{
+ char **pieces = NULL;
+ char *output = NULL;
+
+ if (g_get_charset (NULL)) /* UTF-8 is ok */
+ return g_strdup (input);
+
+ /* else, we'll replace ratio with a plain colon */
+ pieces = g_strsplit (input, "∶", -1);
+ output = g_strjoinv (":", pieces);
+ g_strfreev (pieces);
+ return output;
+}
+
static gboolean
update_clock (gpointer data)
{
GnomeWallClock *self = data;
GDesktopClockFormat clock_format;
const char *format_string;
+ char *safe_format_string;
gboolean show_full_date;
gboolean show_weekday;
gboolean show_seconds;
@@ -298,12 +318,15 @@ update_clock (gpointer data)
}
}
+ safe_format_string = filter_ratio_for_locale (format_string);
+
g_free (self->priv->clock_string);
- self->priv->clock_string = g_date_time_format (now, format_string);
+ self->priv->clock_string = g_date_time_format (now, safe_format_string);
g_date_time_unref (now);
g_date_time_unref (expiry);
-
+ g_free (safe_format_string);
+
g_object_notify ((GObject*)self, "clock");
return FALSE;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]