# Emails for rtl languages have ltr direction

**URL:** https://meta.discourse.org/t/emails-for-rtl-languages-have-ltr-direction/41972
**Category:** Bug
**Created:** [April 3, 2016, 11:26am UTC](https://meta.discourse.org/t/emails-for-rtl-languages-have-ltr-direction/41972 "2016-04-03T11:26:34Z")
**Posts on this page:** 20
**Page:** 1

<div class="post-metadata">

### Author: ![Pad\_Pors](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pad_pors/32/52016_2.png) [@Pad\_Pors](https://meta.discourse.org/u/Pad_Pors)
#### Post date: [April 3, 2016, 11:26am UTC](https://meta.discourse.org/t/emails-for-rtl-languages-have-ltr-direction/41972/1 "2016-04-03T11:26:34Z")

</div>

all the invitation and digest and notification emails are ltr for Persian, and in a bad form as a result. Is there any way to fix this?

---

<div class="post-metadata">

### Author: ![simon](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/simon/32/339122_2.png) [@simon](https://meta.discourse.org/u/simon)
#### Post date: [April 3, 2016, 3:07pm UTC](https://meta.discourse.org/t/emails-for-rtl-languages-have-ltr-direction/41972/2 "2016-04-03T15:07:48Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![Pad\_Pors](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pad_pors/32/52016_2.png) [@Pad\_Pors](https://meta.discourse.org/u/Pad_Pors)
#### Post date: [April 3, 2016, 4:22pm UTC](https://meta.discourse.org/t/emails-for-rtl-languages-have-ltr-direction/41972/3 "2016-04-03T16:22:35Z")

</div>

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! 😉 but it seems they fit into the other complicated group, aren’t they?

---

<div class="post-metadata">

### Author: ![simon](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/simon/32/339122_2.png) [@simon](https://meta.discourse.org/u/simon)
#### Post date: [April 3, 2016, 4:27pm UTC](https://meta.discourse.org/t/emails-for-rtl-languages-have-ltr-direction/41972/4 "2016-04-03T16:27:44Z")

</div>

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

---

<div class="post-metadata">

### Author: ![simon](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/simon/32/339122_2.png) [@simon](https://meta.discourse.org/u/simon)
#### Post date: [April 12, 2016, 9:49pm UTC](https://meta.discourse.org/t/emails-for-rtl-languages-have-ltr-direction/41972/5 "2016-04-12T21:49:50Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![Pad\_Pors](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pad_pors/32/52016_2.png) [@Pad\_Pors](https://meta.discourse.org/u/Pad_Pors)
#### Post date: [April 18, 2016, 2:07pm UTC](https://meta.discourse.org/t/emails-for-rtl-languages-have-ltr-direction/41972/6 "2016-04-18T14:07:30Z")

</div>

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?

---

<div class="post-metadata">

### Author: ![simon](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/simon/32/339122_2.png) [@simon](https://meta.discourse.org/u/simon)
#### Post date: [April 19, 2016, 2:57am UTC](https://meta.discourse.org/t/emails-for-rtl-languages-have-ltr-direction/41972/7 "2016-04-19T02:57:46Z")

</div>

> [@Pad\_Pors](#):
>
> 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?

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

[quote=“Pad\_Pors, post:6,  
topic:41972”]  
the emails for rtl will be messed up when there exist English characters.  
[/quote]

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

---

<div class="post-metadata">

### Author: ![Pad\_Pors](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pad_pors/32/52016_2.png) [@Pad\_Pors](https://meta.discourse.org/u/Pad_Pors)
#### Post date: [April 19, 2016, 5:15am UTC](https://meta.discourse.org/t/emails-for-rtl-languages-have-ltr-direction/41972/8 "2016-04-19T05:15:30Z")

</div>

> [@simon](#):
>
> That could be done with a plugin. I’ll see what I can come up with.

thanks Simon.

> [@simon](#):
>
> What is the convention for writing English (ltr) words or phrases inside of a Persian (rtl) paragraph?

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

> <https://stackoverflow.com/questions/9613613/why-words-are-shuffled-when-i-insert-english-words-in-any-arabic-urdu-persian-te>

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?

---

<div class="post-metadata">

### Author: ![simon](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/simon/32/339122_2.png) [@simon](https://meta.discourse.org/u/simon)
#### Post date: [April 19, 2016, 5:29am UTC](https://meta.discourse.org/t/emails-for-rtl-languages-have-ltr-direction/41972/9 "2016-04-19T05:29:36Z")

</div>

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 🙂

---

<div class="post-metadata">

### Author: ![Mittineague](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/mittineague/32/114259_2.png) [@Mittineague](https://meta.discourse.org/u/Mittineague)
#### Post date: [April 19, 2016, 6:16am UTC](https://meta.discourse.org/t/emails-for-rtl-languages-have-ltr-direction/41972/10 "2016-04-19T06:16:41Z")

</div>

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

---

<div class="post-metadata">

### Author: ![Pad\_Pors](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pad_pors/32/52016_2.png) [@Pad\_Pors](https://meta.discourse.org/u/Pad_Pors)
#### Post date: [April 19, 2016, 7:10am UTC](https://meta.discourse.org/t/emails-for-rtl-languages-have-ltr-direction/41972/11 "2016-04-19T07:10:11Z")

</div>

> [@simon](#):
>
> What I am wondering is, what is the proper way to format English words that occur inside of a Persian sentence?

Text-align:right;  
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 😉

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

---

<div class="post-metadata">

### Author: ![hnaseri](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/hnaseri/32/120660_2.png) [@hnaseri](https://meta.discourse.org/u/hnaseri)
#### Post date: [June 12, 2017, 1:58pm UTC](https://meta.discourse.org/t/emails-for-rtl-languages-have-ltr-direction/41972/12 "2017-06-12T13:58:38Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![simon](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/simon/32/339122_2.png) [@simon](https://meta.discourse.org/u/simon)
#### Post date: [June 15, 2017, 3:32pm UTC](https://meta.discourse.org/t/emails-for-rtl-languages-have-ltr-direction/41972/13 "2017-06-15T15:32:54Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![Pad\_Pors](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pad_pors/32/52016_2.png) [@Pad\_Pors](https://meta.discourse.org/u/Pad_Pors)
#### Post date: [June 15, 2017, 3:49pm UTC](https://meta.discourse.org/t/emails-for-rtl-languages-have-ltr-direction/41972/14 "2017-06-15T15:49:34Z")

</div>

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 ☹ especially if there exist an English word in a sentences (which is very probable).

---

<div class="post-metadata">

### Author: ![hnaseri](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/hnaseri/32/120660_2.png) [@hnaseri](https://meta.discourse.org/u/hnaseri)
#### Post date: [June 15, 2017, 4:00pm UTC](https://meta.discourse.org/t/emails-for-rtl-languages-have-ltr-direction/41972/15 "2017-06-15T16:00:58Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![hnaseri](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/hnaseri/32/120660_2.png) [@hnaseri](https://meta.discourse.org/u/hnaseri)
#### Post date: [June 16, 2017, 11:03am UTC](https://meta.discourse.org/t/emails-for-rtl-languages-have-ltr-direction/41972/16 "2017-06-16T11:03:56Z")

</div>

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

> <https://github.com/discourse/discourse/pull/4934>
>
> Allows RTL digest emails that fixes \[this issue\](https://meta.discourse.org/t/em…ails-for-rtl-languages-have-ltr-direction/41972).
> For this to work, I have done the following major additions:
> 1- adding appropriate direction to body and tables
> 2- making text-direction compatible with rtl
> 3- making float, padding, and margin tags compatible with rtl

This is a screen shot of the preview

 ![](https://global.discourse-cdn.com/meta/original/3X/1/c/1ce758e1d4047f744c08ebe5a57a5148c9506547.png)

---

<div class="post-metadata">

### Author: ![neil](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/neil/32/102150_2.png) [@neil](https://meta.discourse.org/u/neil)
#### Post date: [June 16, 2017, 6:24pm UTC](https://meta.discourse.org/t/emails-for-rtl-languages-have-ltr-direction/41972/17 "2017-06-16T18:24:46Z")

</div>

Thanks @hnaseri. I merged your fixes.

---

<div class="post-metadata">

### Author: ![hnaseri](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/hnaseri/32/120660_2.png) [@hnaseri](https://meta.discourse.org/u/hnaseri)
#### Post date: [June 16, 2017, 11:03pm UTC](https://meta.discourse.org/t/emails-for-rtl-languages-have-ltr-direction/41972/18 "2017-06-16T23:03:18Z")

</div>

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

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

---

<div class="post-metadata">

### Author: ![Pad\_Pors](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pad_pors/32/52016_2.png) [@Pad\_Pors](https://meta.discourse.org/u/Pad_Pors)
#### Post date: [June 17, 2017, 2:33pm UTC](https://meta.discourse.org/t/emails-for-rtl-languages-have-ltr-direction/41972/19 "2017-06-17T14:33:55Z")

</div>

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!

> [@hnaseri](#):
>
> Are there any other email templates that might have RTL problem?

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.

---

<div class="post-metadata">

### Author: ![hnaseri](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/hnaseri/32/120660_2.png) [@hnaseri](https://meta.discourse.org/u/hnaseri)
#### Post date: [June 17, 2017, 2:56pm UTC](https://meta.discourse.org/t/emails-for-rtl-languages-have-ltr-direction/41972/20 "2017-06-17T14:56:55Z")

</div>

> [@Pad\_Pors](#):
>
> Can the site-font be added to the digest email as well?

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.

> [@Pad\_Pors](#):
>
> the invitation email, password changing email, … , are ltr

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

[Next page](https://meta.discourse.org/t/emails-for-rtl-languages-have-ltr-direction/41972.md?page=2)
