Mostafa Shahverdy Mostafa Shahverdy - 10 months ago 43
Javascript Question

How can I automatically set text direction based on input text language?

In Google plus (and a lot of other places), when I want to post something, when I type it in Persian, which is a right-to-left language, text direction is automatically set to rtl and

, and when I start to type in English it changes automatically to ltr and
. How can I have such functionality? Is this anything with HTML5 or Javascript? What clues should I follow?

Thanks in advance

Answer Source
  1. list the right to left languages typical characters
  2. detect them on the fly (usual js events)
  3. change css classes accordingly

Or follow this link: