Index: ChangeLog
===================================================================
--- ChangeLog	(revision 34776)
+++ ChangeLog	(working copy)
@@ -1,3 +1,9 @@
+2008-01-07  Djihed Afifi <djihed@gmail.com>
+
+	** Fix for bug #309432
+
+	* em-format-html.c: Fix the message headers for RTL languages.
+
 2008-01-07  Milan Crha  <mcrha@redhat.com>
 
 	** Fix for bug #300336
Index: em-format-html.c
===================================================================
--- em-format-html.c	(revision 34776)
+++ em-format-html.c	(working copy)
@@ -1484,22 +1484,34 @@
 	else
 		html = mhtml = camel_text_to_html (value, emfh->text_html_flags, 0);
 
+	gboolean is_rtl = gtk_widget_get_default_direction() == GTK_TEXT_DIR_RTL;
 	if (emfh->simple_headers) {
 		fmt = "<b>%s</b>: %s<br>";
 	} else {
 		if (flags & EM_FORMAT_HTML_HEADER_NOCOLUMNS) {
-			if (flags & EM_FORMAT_HEADER_BOLD)
+			if (flags & EM_FORMAT_HEADER_BOLD){
 				fmt = "<tr><td><b>%s:</b> %s</td></tr>";
-			else
+			}else{
 				fmt = "<tr><td>%s: %s</td></tr>";
+			}
 		} else if (flags & EM_FORMAT_HTML_HEADER_NODEC) {
-			fmt = "<tr><th align=\"right\" valign=\"top\" nowrap>%s<b>&nbsp;</b></th><td valign=top>%s</td></tr>";
+			if(is_rtl)
+				fmt = "<tr><td align=\"right\" valign=\"top\" width=\"100%%\">%2$s</td><td valign=top align=\"left\" nowrap>%1$s<b>&nbsp;</b></td></tr>";
+			else
+				fmt = "<tr><th align=\"right\" valign=\"top\" nowrap>%s<b>&nbsp;</b></th><td valign=top>%s</td></tr>";
 		} else {
-
-			if (flags & EM_FORMAT_HEADER_BOLD)
-				fmt = "<tr><th align=\"right\" valign=\"top\" nowrap>%s:<b>&nbsp;</b></th><td>%s</td></tr>";
-			else
-				fmt = "<tr><td align=\"right\" valign=\"top\" nowrap>%s:<b>&nbsp;</b></td><td>%s</td></tr>";
+			
+			if (flags & EM_FORMAT_HEADER_BOLD) {
+				if(is_rtl)
+					fmt = "<tr><td align=\"right\" valign=\"top\" width=\"100%%\">%2$s</td><td align=\"left\" nowrap>%1$s:<b>&nbsp;</b></td></tr>";
+				else
+					fmt = "<tr><th align=\"right\" valign=\"top\" nowrap>%s:<b>&nbsp;</b></th><td>%s</td></tr>";
+			} else {
+				if(is_rtl)
+					fmt = "<tr><td align=\"right\" valign=\"top\" width=\"100%\">%2$s</td><td align=\"left\" nowrap>%1$s:<b>&nbsp;</b></td></tr>";
+				else
+					fmt = "<tr><td align=\"right\" valign=\"top\" nowrap>%s:<b>&nbsp;</b></td><td>%s</td></tr>";
+			}
 		}
 	}
 
@@ -1838,7 +1850,10 @@
 
 		if (header_sender && header_from && mail_from_delegate) {
 			camel_stream_printf(stream, "<tr><td><table border=1 width=\"100%%\" cellspacing=2 cellpadding=2><tr>");
-			camel_stream_printf(stream, "<td align=\"left\" width=\"100%%\">");
+			if(gtk_widget_get_default_direction() == GTK_TEXT_DIR_RTL)
+				camel_stream_printf(stream, "<td align=\"right\" width=\"100%%\">");
+			else
+				camel_stream_printf(stream, "<td align=\"left\" width=\"100%%\">");
 			/* To translators: This message suggests to the receipients that the sender of the mail is
 			   different from the one listed in From field.
 			*/
@@ -1852,9 +1867,12 @@
 
 	g_free (header_sender);
 	g_free (header_from);
+	
+	if(gtk_widget_get_default_direction() == GTK_TEXT_DIR_RTL)
+		camel_stream_printf(stream, "<tr><td><table width=\"100%%\" border=0 cellpadding=\"0\">\n");
+	else
+		camel_stream_printf(stream, "<tr><td><table border=0 cellpadding=\"0\">\n");
 
-	camel_stream_printf(stream, "<tr><td><table border=0 cellpadding=\"0\">\n");
-
 	/* dump selected headers */
 	h = (EMFormatHeader *)emf->header_list.head;
 	if (h->next == NULL || emf->mode == EM_FORMAT_ALLHEADERS) {
