[gnome-desktop: 2/6] wall-clock: Separate date and time by em-space



commit 86892ad03a632c4eea2553bce42661666924fdb5
Author: Florian Müllner <fmuellner gnome org>
Date:   Mon Apr 23 20:32:41 2018 +0200

    wall-clock: Separate date and time by em-space
    
    The designers consider it more elegant and balanced than a comma, so
    use that to separate date and time. Handle it the same way as colon
    vs. ratio is handled, and only use the UTF8 character when using
    a UTF8 locale. Otherwise fall back to a double space.
    
    https://gitlab.gnome.org/GNOME/gnome-desktop/issues/8

 libgnome-desktop/gnome-wall-clock.c | 70 +++++++++++++++++++++++--------------
 tests/C.ref.ui                      |  2 +-
 tests/en_US.utf-8.ref.ui            |  2 +-
 tests/he_IL.utf8.ref.ui             |  2 +-
 4 files changed, 47 insertions(+), 29 deletions(-)
---
diff --git a/libgnome-desktop/gnome-wall-clock.c b/libgnome-desktop/gnome-wall-clock.c
index fb5140f5..3c095264 100644
--- a/libgnome-desktop/gnome-wall-clock.c
+++ b/libgnome-desktop/gnome-wall-clock.c
@@ -221,33 +221,47 @@ string_replace (const char *input,
 }
 
 /* This function wraps g_date_time_format, replacing colon with the ratio
- * character as it looks visually better in time strings.
+ * character and underscores with em-space as it looks visually better
+ * in time strings.
  */
 static char *
 date_time_format (GDateTime *datetime,
                   const char *format)
 {
-       char *format_with_colon;
+       char *replaced_format;
        char *ret;
-       char *tmp;
+       char *no_ratio, *no_emspace;
        gboolean is_utf8;
 
        is_utf8 = g_get_charset (NULL);
 
-       /* First, replace ratio with plain colon before passing it to
+       /* First, replace ratio with plain colon */
+       no_ratio = string_replace (format, "∶", ":");
+       /* Then do the same with em-space and underscore before passing it to
         * g_date_time_format.  */
-       tmp = string_replace (format, "∶", ":");
-       format_with_colon = g_date_time_format (datetime, tmp);
-       g_free (tmp);
-
-       /* Then, after formatting, replace the plain colon with ratio, and
-        * prepend it with an LTR marker to force direction. */
-       if (is_utf8)
-               ret = string_replace (format_with_colon, ":", "\xE2\x80\x8E∶");
-       else
-               ret = g_strdup (format_with_colon);
+       no_emspace = string_replace (no_ratio, " ", "_");
+       replaced_format = g_date_time_format (datetime, no_emspace);
+
+       g_free (no_ratio);
+       g_free (no_emspace);
+
+       if (is_utf8) {
+               char *tmp;
+               /* Then, after formatting, replace the plain colon with ratio,
+                * and prepend it with an LTR marker to force direction. */
+               tmp = string_replace (replaced_format, ":", "\xE2\x80\x8E∶");
+
+               /* Finally, replace double spaces with a single em-space.*/
+               ret = string_replace (tmp, "_", " ");
+
+               g_free (tmp);
+       } else {
+               /* Colon instead of ratio is already fine, but replace the
+                * underscore with double spaces instead of em-space */
+               ret = string_replace (replaced_format, "_", "  ");
+       }
 
-       g_free (format_with_colon);
+       g_free (replaced_format);
        return ret;
 }
 
@@ -271,14 +285,16 @@ gnome_wall_clock_string_for_datetime (GnomeWallClock      *self,
                if (show_full_date) {
                        if (show_weekday)
                                /* Translators: This is the time format with full date
-                                  plus day used in 24-hour mode. */
-                               format_string = show_seconds ? _("%a %b %e, %R:%S")
-                                       : _("%a %b %e, %R");
+                                  plus day used in 24-hour mode. Please keep the under-
+                                  score to separate the date from the time. */
+                               format_string = show_seconds ? _("%a %b %e_%R:%S")
+                                       : _("%a %b %e_%R");
                        else
                                /* Translators: This is the time format with full date
-                                  used in 24-hour mode. */
+                                  used in 24-hour mode. Please keep the underscore to
+                                  separate the date from the time. */
                                format_string = show_seconds ? _("%b %e, %R:%S")
-                                       : _("%b %e, %R");
+                                       : _("%b %e_%R");
                } else if (show_weekday) {
                        /* Translators: This is the time format with day used
                           in 24-hour mode. */
@@ -293,14 +309,16 @@ gnome_wall_clock_string_for_datetime (GnomeWallClock      *self,
                if (show_full_date) {
                        if (show_weekday)
                                /* Translators: This is a time format with full date
-                                  plus day used for AM/PM. */
-                               format_string = show_seconds ? _("%a %b %e, %l:%M:%S %p")
-                                       : _("%a %b %e, %l:%M %p");
+                                  plus day used for AM/PM. Please keep the under-
+                                  score to separate the date from the time. */
+                               format_string = show_seconds ? _("%a %b %e_%l:%M:%S %p")
+                                       : _("%a %b %e_%l:%M %p");
                        else
                                /* Translators: This is a time format with full date
-                                  used for AM/PM. */
-                               format_string = show_seconds ? _("%b %e, %l:%M:%S %p")
-                                       : _("%b %e, %l:%M %p");
+                                  used for AM/PM. Please keep the underscore to
+                                  separate the date from the time. */
+                               format_string = show_seconds ? _("%b %e_%l:%M:%S %p")
+                                       : _("%b %e_%l:%M %p");
                } else if (show_weekday) {
                        /* Translators: This is a time format with day used
                           for AM/PM. */
diff --git a/tests/C.ref.ui b/tests/C.ref.ui
index 1c4f662f..bc2f8936 100644
--- a/tests/C.ref.ui
+++ b/tests/C.ref.ui
@@ -9,7 +9,7 @@
       <object class="GtkLabel" id="label1">
         <property name="visible">True</property>
         <property name="can_focus">False</property>
-        <property name="label" translatable="yes">Wed May 28, 23:59:59</property>
+        <property name="label" translatable="yes">Wed May 28  23:59:59</property>
       </object>
     </child>
   </object>
diff --git a/tests/en_US.utf-8.ref.ui b/tests/en_US.utf-8.ref.ui
index bb1da1ff..c676e422 100644
--- a/tests/en_US.utf-8.ref.ui
+++ b/tests/en_US.utf-8.ref.ui
@@ -9,7 +9,7 @@
       <object class="GtkLabel" id="label1">
         <property name="visible">True</property>
         <property name="can_focus">False</property>
-        <property name="label" translatable="yes">Wed May 28, 23‎∶59‎∶59</property>
+        <property name="label" translatable="yes">Wed May 28 23‎∶59‎∶59</property>
       </object>
     </child>
   </object>
diff --git a/tests/he_IL.utf8.ref.ui b/tests/he_IL.utf8.ref.ui
index 291c3bb9..e1b44729 100644
--- a/tests/he_IL.utf8.ref.ui
+++ b/tests/he_IL.utf8.ref.ui
@@ -9,7 +9,7 @@
       <object class="GtkLabel" id="label1">
         <property name="visible">True</property>
         <property name="can_focus">False</property>
-        <property name="label" translatable="yes">ד' מאי 28, 23‎∶59‎∶59</property>
+        <property name="label" translatable="yes">ד' מאי 28 23‎∶59‎∶59</property>
       </object>
     </child>
   </object>


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