Set direction of text depending on text itself

Facebook has it !

When Writing with an RTL language the ticker goes to the other way which gives a very intuitive experience.

I need this for my community because we are bilingual.
Thanks Discourse … Love

6 лайков

@codinghorror, Hi Jeff, do you think this is something we can have in the short term ?

Have a look at an old topic here about RTL support.

https://meta.discourse.org/t/rtl-support/1784

There is a library that automatically sets the direction of each paragraph based on the content.

1 лайк

Sure, submit a pull request with the work if you want it. This is how open source works.

Is there any update for this feature? I desperately need it.

Even if there is a button to change direction of text, when we write english/arabic/persian, would be great.

I just added pr-welcome on this, hopefully a bilingual developer looking for a contribution will look at this one day.

1 лайк

I just found that there is an html5 tag dir=auto that simply works in most situations.

For example I wrote this html

<html>
<body>

<p dir="auto">Write this جمله چپ به راست text left-to-right!</p>

<p dir="auto">این RTL sentence  جمله را از راست به چپ بنویس</p>

</body>
</html>

And pasted it in a simple html editor and it works perfectly fine

Could we use the same thing in discourse @sam?

btw I tried dir="auto" with firebug on <p> tags in discourse. However it didn’t do anything. I don’t know why.

1 лайк

Спустя годы это всё ещё проблема. Даже когда пост написан полностью на языке с написанием справа налево (RTL), он не выравнивается автоматически.


(это редактор, но предпросмотр справа точно отражает итоговый результат)
единственное рабочее решение — добавлять теги <div dir="auto">. Как отметил @hnaseri, <p> не работает, работает только <div>.

Честно говоря, это ужасно. Surely должно быть лучшее решение, чем требовать от пользователей добавлять <div dir="auto">. Более того, это даже не достаточно хорошее решение, потому что если вы откроете div, но не закроете его, остальной текст будет принудительно выровнен по направлению первой строки, а не абзац за абзацем. Необходимость добавлять ещё один <div dir="auto"> перед каждым абзацем — это не решение.


Просто уточняю: это проблема именно на англоязычных форумах, где вы иногда публикуете на иврите? (места со смешанным языком)

Поскольку в локализации на иврите всё, кажется, в порядке.

Одна вещь, которая может помочь здесь:

С этой кнопкой, включенной на панели инструментов, помощь становится намного проще. Чтобы её включить, вам нужно активировать настройку support mixed text direction.