diff options
author | Rui Matos <tiagomatos@gmail.com> | 2014-01-21 22:04:42 +0100 |
---|---|---|
committer | Rui Matos <tiagomatos@gmail.com> | 2014-02-03 18:25:59 +0100 |
commit | 1b9b7a267ade221ad4000cd024547b42a3056bf4 (patch) | |
tree | cea4059ffe102aaba1d3b357151637e02d5658dd /libgnome-desktop/gnome-wall-clock.c | |
parent | b7826cca943bd3d64189931fd6ad1b250985ee8e (diff) | |
download | gnome-desktop-1b9b7a267ade221ad4000cd024547b42a3056bf4.tar.gz |
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
Diffstat (limited to 'libgnome-desktop/gnome-wall-clock.c')
-rw-r--r-- | 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 a2f5e2c2..8ccaac03 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; |