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.

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> 标签。正如 @hnaseri 指出的那样,<p> 不起作用,只有 <div> 才起作用。
Screenshot_20251114_122656
Screenshot_20251114_122429

我必须说实话,这太糟糕了。肯定有更好的方法,而不是要求用户添加 <div>。事实上,这并不是一个足够好的解决方案,因为如果你只打开你的 div 但不关闭它,其余的文本将被强制到第一行的方向,而不是逐段进行。需要在每个段落前添加另一个 <div> 并不是真正的解决方案。
Screenshot_20251114_122937
Screenshot_20251114_122959

image

只是确认一下,这是否尤其是在您偶尔会用希伯来语发帖的英文论坛上出现的问题?(混合语言区域)

因为在希伯来语区域设置下,一切似乎都正常。

有一件事可能对此有帮助:

image

在工具栏中启用该按钮后,会更容易获得帮助。要启用它,您需要启用设置 支持混合文本方向