Set direction of text depending on text itself

AI-generated summary

The discussion revolves around implementing automatic text direction detection in Discourse based on the content itself, similar to Facebook’s behavior. Users Aymane_Shuichi and Aymane_Shuichi highlight the need for this feature, referencing a Facebook example and suggesting a solution using the dir="auto" HTML5 attribute. ibnesayeed points to an older topic on RTL support, while codinghorror encourages contributors to submit a pull request. hnaseri and hnaseri note the lack of updates and demonstrate that dir="auto" works in most cases, though it fails with <p> tags, requiring <div> tags instead. rassilon1963 confirms the issue persists, especially in mixed-language contexts, and shows that the problem is specific to English forums where Hebrew content is posted, as Hebrew locales handle directionality correctly. sam and sam discuss the issue’s context and confirm it’s mainly a problem in bilingual environments.

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.

https://github.com/hasenj/bidiweb

「いいね!」 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言語で書かれていても、自動的に配置されません。

Screenshot_20251114_122348
(これはエディターですが、右側のプレビューは最終製品の正確な表現です)
唯一機能する解決策は、<div> dir="auto"</div> タグを追加することです。@hnaseri が指摘したように、<p> は機能せず、<div> のみ機能します。
Screenshot_20251114_122656
Screenshot_20251114_122429

正直に言うと、これはかなりひどい状況です。ユーザーに <div> dir="auto"</div> を追加させるよりも、もっと良い方法があるはずです。実際、これは十分な解決策ではありません。div を開くだけで閉じないと、残りのテキストは段落ごとではなく、最初の行の方向に強制されます。段落ごとに <div> dir="auto"</div> を追加する必要があるのは、実際には解決策ではありません。
Screenshot_20251114_122937
Screenshot_20251114_122959

image

これは、ヘブライ語で投稿することもある英語フォーラムでの特定の問題ですか?(混合言語の場所)

ヘブライ語ロケールではすべて問題ないように思われるためです。

ここで役立つ可能性のあることの1つは次のとおりです。

image

ツールバーでそのボタンを有効にすると、これはるかに簡単になります。有効にするには、support mixed text direction 設定を有効にします。