}
gchar *
-modest_text_utils_derived_subject (const gchar *subject, const gchar *prefix)
+modest_text_utils_derived_subject (const gchar *subject, gboolean is_reply)
{
- gchar *tmp, *subject_dup, *retval;
- gint prefix_len;
+ gchar *tmp, *subject_dup, *retval, *prefix;
+ const gchar *untranslated_prefix;
+ gint prefix_len, untranslated_prefix_len;
+ gboolean untranslated_found = FALSE;
g_return_val_if_fail (prefix, NULL);
subject_dup = g_strdup (subject);
tmp = g_strchug (subject_dup);
+ prefix = (is_reply) ? _("mail_va_re") : _("mail_va_fw");
+ prefix = g_strconcat (prefix, ":", NULL);
+ prefix_len = g_utf8_strlen (prefix, -1);
+
+ untranslated_prefix = (is_reply) ? "Re:" : "Fw:";
+ untranslated_prefix_len = 3;
+
/* We do not want things like "Re: Re: Re:" or "Fw: Fw:" so
delete the previous ones */
- prefix_len = strlen (prefix);
do {
if (g_str_has_prefix (tmp, prefix)) {
tmp += prefix_len;
tmp = g_strchug (tmp);
+ } else if (g_str_has_prefix (tmp, untranslated_prefix)) {
+ tmp += untranslated_prefix_len;
+ tmp = g_strchug (tmp);
+ untranslated_found = TRUE;
} else {
gchar *prefix_down, *tmp_down;
}
} while (tmp);
- retval = g_strdup_printf ("%s %s", prefix, tmp);
+ retval = g_strdup_printf ("%s %s", (untranslated_found) ? untranslated_prefix : prefix, tmp);
g_free (subject_dup);
+ g_free (prefix);
return retval;
}
/**
* modest_text_utils_derived_subject:
* @subject: a string which contains the original subject
- * @prefix: the prefix for the new subject (such as 'Re:' or 'Fwd:'),
- * must not be NULL
+ * @is_reply: whether the derived subject is for a reply or a forward message
+ *
+ * create a 'derived' subject line for eg. replies and forwards. Note
+ * that this function will use the localized versions of "Re" and
+ * "Fw", unless one of these two versions was already included. For
+ * example replying to an email in Finish would work as:
+ *
+ * "some subject" -> "VS: some subject"
+ * "VS: some subject" -> "VS: some subject"
+ * "Re: some subject" -> "Re: some subject"
+ * "Fw: some subject" -> "VS: Fw: some subject"
*
- * create a 'derived' subject line for eg. replies and forwards
- *
* Returns: a newly allocated string containing the resulting subject
- * subject == NULL, then @prefix " " will be returned
*/
-gchar* modest_text_utils_derived_subject (const gchar *subject,
- const gchar* prefix);
+gchar* modest_text_utils_derived_subject (const gchar *subject,
+ gboolean is_reply);
/**
TnyMimePart *body = NULL;
TnyMimePart *html_body = NULL;
ModestFormatter *formatter;
- gchar *subject_prefix;
gboolean no_text_part;
gchar *parent_uid;
gboolean forward_as_attach = FALSE;
tny_header_set_replyto (new_header, from);
/* Change the subject */
- if (is_reply)
- subject_prefix = g_strconcat (_("mail_va_re"), ":", NULL);
- else
- subject_prefix = g_strconcat (_("mail_va_fw"), ":", NULL);
old_subject = tny_header_dup_subject (header);
new_subject =
- (gchar *) modest_text_utils_derived_subject (old_subject,
- subject_prefix);
+ (gchar *) modest_text_utils_derived_subject (old_subject, is_reply);
g_free (old_subject);
- g_free (subject_prefix);
tny_header_set_subject (new_header, (const gchar *) new_subject);
g_free (new_subject);