Emails for rtl languages have ltr direction

The emails that are passed to UserNotifications#notification_email should be being displayed as rtl for rtl users. These are the emails that are sent for things like user_posted, and user_quoted etc. The other notification emails, the ones for things like signup and forgot_password and also the digest, are not being displayed rtl for rtl languages.

The fix for the digest is simple. I can make a pull request for that. The fix for the other emails (signup, forgot_password…) is a little more complicated because they are derived from templates, but the template isn’t wrapped in anything that you can give a direction to.


Thanks Simon, and yes the notification emails are rtl as said.

the fix for digest would be great as the digest content are something you give to users directly! and you’d rather it be as clean as possible.

the invitation emails are more or less important as they are an invitation! :wink: but it seems they fit into the other complicated group, aren’t they?

1 Like

They can be fixed with a simple plugin. I can make something later this week.


I haven’t had the time to do this yet, but I’m starting to work on a forum that will need it to work. I’ll get it done soon.


just another question raised:

the emails for rtl will be messed up when there exist English characters.
and the user names can be only English characters.
and the invitation emails start with %{invitee_name}, some part of which is the English user name.

Is there a way to remove the user name in the emails and only contain the full name which can be other characters rather than English?

1 Like

That could be done with a plugin. I’ll see what I can come up with.

[quote=“Pad_Pors, post:6,
the emails for rtl will be messed up when there exist English characters.

What is the convention for writing English (ltr) words or phrases inside of a Persian (rtl) paragraph?

1 Like

thanks Simon.

i’m not sure if i got your question correctly, do you mean something like this?

if yes, an answer from the stackoverflow which seems to work is:

  1. Finish typing the Arabic/Persian word and add a space after it (this space separates the embedded text from the Arabic text to its right).
  • Insert special character U+200F (to render the preceding space an Arabic character).
  • Insert special character U+202A (to begin the left-to-right embedding).
  • Insert another space (to separate the embedded text from the Arabic text that will continue to its left).
  • Change the keyboard to e.g. English and type the left-to-right word.
  • Insert special character U+202C (to restore the bidrectional state to what it was before the left-to-right embedding).
  • Change the keyboard back and continue writing in Arabic.

if you’re asking something else, may you explain more?

1 Like

Sort of. What I am wondering is, what is the proper way to format English words that occur inside of a Persian sentence? Maybe it doesn’t happen very often :slight_smile:


I’m guessing something like this but using English glyphs for the English name only.

.thgis railucep tsom a deciton ew nehw Aristophanes dneirf tseb ym htiw krap eht ni gniklaw saw I

1 Like

Direction :RTL

if these two html tags exist in the style, everything goes well with the Persian sentence, even when there exist an English word.

so far, i couldn’t find any other answer for the above question :wink:

p.s.: in customizing the emails i could use bold-tags with ** word ** , is it possible to use the alignment tags somehow as well?

1 Like

Is there any update for this bug @simon

My digest emails are still improperly formatted and I don’t know what to do about it.

1 Like

It’s possible to add a @dir property to UserNotifications::digest. The @dir property can then be used as a switch for changing all the text-align values in the template. This isn’t very complicated, but it’s slow to test and would have to involve the Discourse team.

Another approach that might be safer would be to include a separate digest_rtl.html.erb view. That way this could be developed without having to alter the current digest.html.erb view.

If that can’t be done, maybe a way could be found to override the digest template with a plugin.

1 Like

it’d be great if the digest email can be set for both directions, as currently the design of the digest email is very nice, but in the rtl languages it’s damaged :frowning: especially if there exist an English word in a sentences (which is very probable).

So the problem here is if we create a digest_rtl.html.erb file which is pretty easy and straightforward, How can we make use of it in the core? If someone from the discourse team would help answering this question, we can move forward.

I’ve done the following PR. Worked fine in my development environment. Hope it would help.

This is a screen shot of the preview


Thanks @hnaseri. I merged your fixes.


Thanks @neil for the merge. Now we got a nice looking digest email :blush:

Are there any other email templates that might have RTL problem?

Can the site-font be added to the digest email as well?

p.s.: I’m not sure if fonts are related to the email provider (e.g. yahoo or gmail) or email sender (e.g. the forum). forgive me if the question doesn’t make sense!

if I’m not wrong all the emails, e.g. the invitation email, password changing email, … , are ltr. among them the invitation emails are the most important, especially if one is invited to a topic with an English-Persian title.

I think not as far as I know. Never heard of custom fonts in emails. So even if it would be possible, It seems its not a good idea.

If someone point me to all email templates, I’m willing to take a look at all of them.

This topic was automatically closed after 3 days. New replies are no longer allowed.