[evolution] Bug 783968 - Mark Fwd and Re Subject attribution for translation
- From: Milan Crha <mcrha src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution] Bug 783968 - Mark Fwd and Re Subject attribution for translation
- Date: Mon, 19 Jun 2017 17:35:48 +0000 (UTC)
commit 534e797d980d0bc980681255b707195a37306ad9
Author: Milan Crha <mcrha redhat com>
Date: Mon Jun 19 19:32:16 2017 +0200
Bug 783968 - Mark Fwd and Re Subject attribution for translation
src/libemail-engine/mail-tools.c | 60 +++++++++++++++++++++++--------------
src/mail/em-composer-utils.c | 3 +-
2 files changed, 39 insertions(+), 24 deletions(-)
---
diff --git a/src/libemail-engine/mail-tools.c b/src/libemail-engine/mail-tools.c
index e83d53e..fb8ac11 100644
--- a/src/libemail-engine/mail-tools.c
+++ b/src/libemail-engine/mail-tools.c
@@ -151,38 +151,52 @@ mail_tool_do_movemail (CamelStore *store,
gchar *
mail_tool_generate_forward_subject (CamelMimeMessage *msg)
{
- const gchar *subject;
+ const gchar *orig_subject;
+ gchar *subject = NULL;
gchar *fwd_subj;
const gint max_subject_length = 1024;
- subject = camel_mime_message_get_subject (msg);
-
- if (subject && *subject) {
- /* Truncate insanely long subjects */
- if (strlen (subject) < max_subject_length) {
- fwd_subj = g_strdup_printf ("[Fwd: %s]", subject);
- } else {
- /* We can't use %.*s because it depends on the
- * locale being C/POSIX or UTF-8 to work correctly
- * in glibc. */
- fwd_subj = g_malloc (max_subject_length + 11);
- memcpy (fwd_subj, "[Fwd: ", 6);
- memcpy (fwd_subj + 6, subject, max_subject_length);
- memcpy (fwd_subj + 6 + max_subject_length, "...]", 5);
+ orig_subject = camel_mime_message_get_subject (msg);
+
+ if (orig_subject && *orig_subject) {
+ gchar *utf8;
+
+ utf8 = e_util_utf8_make_valid (orig_subject);
+ if (utf8 && *utf8) {
+ /* Truncate insanely long subjects */
+ if (g_utf8_strlen (utf8, -1) < max_subject_length) {
+ subject = utf8;
+ utf8 = NULL;
+ } else {
+ gchar *end = g_utf8_offset_to_pointer (utf8, max_subject_length);
+
+ if (end) {
+ *end = '\0';
+
+ subject = g_strconcat (utf8, "...", NULL);
+ }
+ }
}
- } else {
+
+ g_free (utf8);
+ }
+
+ if (!subject) {
const CamelInternetAddress *from;
- gchar *fromstr;
from = camel_mime_message_get_from (msg);
- if (from) {
- fromstr = camel_address_format (CAMEL_ADDRESS (from));
- fwd_subj = g_strdup_printf ("[Fwd: %s]", fromstr);
- g_free (fromstr);
- } else
- fwd_subj = g_strdup ("[Fwd: No Subject]");
+ if (from)
+ subject = camel_address_format (CAMEL_ADDRESS (from));
}
+ /* Translators: This is a subject attribution for forwarded messages. The %s is replaced with subject
of the original message. */
+ fwd_subj = g_strdup_printf (_("[Fwd: %s]"),
+ /* Translators: This is a subject attribution for forwarded messages, used when there could
not be used any subject.
+ It results in "[Fwd: No Subject]" being used as a subject of the forwarded message. */
+ (subject && *subject) ? subject : _("No Subject"));
+
+ g_free (subject);
+
return fwd_subj;
}
diff --git a/src/mail/em-composer-utils.c b/src/mail/em-composer-utils.c
index 95e5d1b..4aff264 100644
--- a/src/mail/em-composer-utils.c
+++ b/src/mail/em-composer-utils.c
@@ -2525,7 +2525,8 @@ reply_setup_composer (EMsgComposer *composer,
if (em_utils_is_re_in_subject (subject, &skip_len, NULL, NULL) && skip_len > 0)
subject = subject + skip_len;
- subject = g_strdup_printf ("Re: %s", subject);
+ /* Translators: This is a reply attribution in the message reply subject. The %s is replaced
with the subject of the original message. */
+ subject = g_strdup_printf (_("Re: %s"), subject);
} else {
subject = g_strdup ("");
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]