[evolution] Bug 765112 - Match Reply credits line time parts to LC_MESSAGES



commit 833410a0dc3b6931c57c70a53a5f5ad117edef41
Author: Guido Trentalancia <guido trentalancia net>
Date:   Thu Apr 21 10:08:14 2016 +0200

    Bug 765112 - Match Reply credits line time parts to LC_MESSAGES

 .../evolution-util/evolution-util-sections.txt     |    1 +
 e-util/e-misc-utils.c                              |   52 ++++++++++++++++++++
 e-util/e-misc-utils.h                              |    5 ++
 mail/em-composer-utils.c                           |    2 +-
 4 files changed, 59 insertions(+), 1 deletions(-)
---
diff --git a/doc/reference/evolution-util/evolution-util-sections.txt 
b/doc/reference/evolution-util/evolution-util-sections.txt
index 0ab4883..3d92a4e 100644
--- a/doc/reference/evolution-util/evolution-util-sections.txt
+++ b/doc/reference/evolution-util/evolution-util-sections.txt
@@ -3210,6 +3210,7 @@ ESortCompareFunc
 e_bsearch
 e_strftime_fix_am_pm
 e_utf8_strftime_fix_am_pm
+e_utf8_strftime_match_lc_messages
 e_get_month_name
 e_get_weekday_name
 e_weekday_get_next
diff --git a/e-util/e-misc-utils.c b/e-util/e-misc-utils.c
index 919eaf8..baa0849 100644
--- a/e-util/e-misc-utils.c
+++ b/e-util/e-misc-utils.c
@@ -1810,6 +1810,58 @@ e_utf8_strftime_fix_am_pm (gchar *str,
 }
 
 /**
+ * e_utf8_strftime_match_lc_messages:
+ * @string: The string to store the result in.
+ * @max: The size of the @string.
+ * @fmt: The formatting to use on @tm.
+ * @tm: The time value to format.
+ *
+ * The UTF-8 equivalent of e_strftime (), which also
+ * makes sure that the locale used for time and date
+ * formatting matches the locale used by the
+ * application so that, for example, the quoted
+ * message header produced by the mail composer in a
+ * reply uses only one locale (i.e. LC_MESSAGES, where
+ * available, overrides LC_TIME for consistency).
+ *
+ * Returns: The number of characters placed in @string.
+ *
+ * Since: 3.22
+ **/
+gsize
+e_utf8_strftime_match_lc_messages (gchar *string,
+                                   gsize max,
+                                   const gchar *fmt,
+                                   const struct tm *tm)
+{
+       gsize ret;
+#if defined(LC_MESSAGES) && defined(LC_TIME)
+       gchar *ctime, *cmessages, *saved_locale;
+
+       /* Use LC_MESSAGES instead of LC_TIME for time
+        * formatting (for consistency).
+        */
+       ctime = setlocale (LC_TIME, NULL);
+       saved_locale = g_strdup (ctime);
+       g_return_val_if_fail (saved_locale != NULL, 0);
+       cmessages = setlocale (LC_MESSAGES, NULL);
+       setlocale (LC_TIME, cmessages);
+#endif
+
+       ret = e_utf8_strftime(string, max, fmt, tm);
+
+#if defined(LC_MESSAGES) && defined(LC_TIME)
+       /* Restore LC_TIME, if it has been changed to match
+        * LC_MESSAGES.
+        */
+       setlocale (LC_TIME, saved_locale);
+       g_free (saved_locale);
+#endif
+
+       return ret;
+}
+
+/**
  * e_get_month_name:
  * @month: month index
  * @abbreviated: if %TRUE, abbreviate the month name
diff --git a/e-util/e-misc-utils.h b/e-util/e-misc-utils.h
index 02abf06..7b41112 100644
--- a/e-util/e-misc-utils.h
+++ b/e-util/e-misc-utils.h
@@ -167,6 +167,11 @@ gsize              e_utf8_strftime_fix_am_pm       (gchar *str,
                                                 gsize max,
                                                 const gchar *fmt,
                                                 const struct tm *tm);
+gsize          e_utf8_strftime_match_lc_messages
+                                               (gchar *string,
+                                                gsize max,
+                                                const gchar *fmt,
+                                                const struct tm *tm);
 const gchar *  e_get_month_name                (GDateMonth month,
                                                 gboolean abbreviated);
 const gchar *  e_get_weekday_name              (GDateWeekday weekday,
diff --git a/mail/em-composer-utils.c b/mail/em-composer-utils.c
index d316b57..936df14 100644
--- a/mail/em-composer-utils.c
+++ b/mail/em-composer-utils.c
@@ -3111,7 +3111,7 @@ attribution_format (CamelMimeMessage *message)
                                str, attribvars[i].v.format, tzone);
                        break;
                case ATTRIB_STRFTIME:
-                       e_utf8_strftime (
+                       e_utf8_strftime_match_lc_messages (
                                buf, sizeof (buf), attribvars[i].v.format, &tm);
                        g_string_append (str, buf);
                        break;


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