0

I'm using froala editor to send messages from my webpage to client side, when sending the message all in English or all in Arabic there is no problem, but when I write a message consists of a combined Arabic & English text it changes the order of the sentence written, for example:

The sentence I wrote:

ونتمنى لكم دراسة سعيدة Developer School أهلا بكم في مدرسة

The sentence generated:

أهلا بكم في مدرسة Developer School ونتمنى لكم دراسة سعيدة

keeping in mind that when writing the message in froala editor it doesn't give the feeling that anything is wrong and it shows what I'm actually writing in a correct format, but after submitting and getting the message out, that's what I'm getting.

Muhammed Refaat
  • 8,914
  • 14
  • 83
  • 118

1 Answers1

0

It looks like the output is not aware that there are Arabic characters. It would be good to check with a regular expression if the output has Arabic chars and if so, then wrap it with a DIV tag having the direction set to rtl.

Here is how you can do it in JS, based on another answer from Stackoverflow.

 var arabic = /[\u0600-\u06FF]/;
 var output = '<p>أهلا بكم في مدرسة Developer School ونتمنى لكم دراسة سعيدة</p>'; 

 // Check if there are Arabic chars.
 if (arabic.test(output)) {
    output = '<div dir="rtl">' + output + '</div>';
 }
st3fan
  • 1,630
  • 14
  • 32