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)

بعد سنوات، لا تزال هذه مشكلة. حتى عندما تتم كتابة منشور بالكامل بلغة من اليمين إلى اليسار، فإنه لا يتم محاذاته تلقائيًا.

Screenshot_20251114_122348
(هذه هي المحررة، لكن المعاينة على اليمين تمثل بدقة المنتج النهائي)
الحل الوحيد العامل هو إضافة علامات <div> dir="auto". كما لاحظ @hnaseri، فإن <p> لا تعمل، فقط <div> تعمل.
Screenshot_20251114_122656
Screenshot_20251114_122429

يجب أن أكون صريحًا، هذا سيء للغاية. بالتأكيد هناك طريقة أفضل من مطالبة المستخدمين بإضافة <div> dir="auto". في الواقع، هذا ليس حلاً جيدًا بما فيه الكفاية، لأنه إذا فتحت الـ div الخاص بك ولكن لم تغلقه، فسيتم إجبار بقية النص على اتجاه السطر الأول، بدلاً من أن يكون على أساس فقرة تلو الأخرى. الحاجة إلى إضافة `

dir=“auto” أخرى قبل كل فقرة ليست حلاً في الواقع.
Screenshot_20251114_122937
Screenshot_20251114_122959

image

هل هذا الأمر يخص منتديات اللغة الإنجليزية فقط حيث تنشر أحيانًا باللغة العبرية؟ (أماكن مختلطة اللغات)

لأن كل شيء يبدو على ما يرام في الإعدادات المحلية للغة العبرية.

هناك شيء قد يساعد هنا:

image

مع تمكين هذا الزر في شريط الأدوات، يصبح الأمر أسهل بكثير للمساعدة هنا. لتمكينه، ستقوم بتمكين الإعداد support mixed text direction