hnaseri
(Hosein Naseri)
9. Februar 2022 um 10:15
1
Ich habe ein Forum in einer RTL-Sprache. Kürzlich werden Zitate anstelle von RTL in LTR-Richtung angezeigt.
pmusaraj
(Penar Musaraj)
9. Februar 2022 um 11:32
2
Sind Sie auf der neuesten Discourse-Version? Ich kann es lokal nicht reproduzieren, wenn ich meine Sprache beispielsweise auf Arabisch umstelle.
hnaseri
(Hosein Naseri)
9. Februar 2022 um 13:40
3
Ich habe gerade auf die neueste Version aktualisiert. Das Problem wurde dadurch nicht behoben.
pmusaraj
(Penar Musaraj)
9. Februar 2022 um 15:41
4
Tritt dies bei mehreren Beiträgen auf oder nur bei diesem speziellen? Haben Sie es auch im abgesicherten Modus versucht?
1 „Gefällt mir“
hnaseri
(Hosein Naseri)
10. Februar 2022 um 06:44
5
Ja, das passiert in mehreren Beiträgen. Und es passiert auch im abgesicherten Modus.
1 „Gefällt mir“
pmusaraj
(Penar Musaraj)
10. Februar 2022 um 07:58
6
Können Sie einen Link zu Ihrer Website posten, damit wir sie uns ansehen können?
pmusaraj
(Penar Musaraj)
10. Februar 2022 um 09:40
8
Danke, wenn ich mir den Quellcode ansehe, haben die Zitate dort ein dir="ltr"-Attribut. Ich vermute, Sie haben die Einstellung mixed text direction aktiviert. Tatsächlich kann ich Ihr Problem reproduzieren, wenn ich diese Einstellung lokal aktiviere.
Ich bin mir nicht sicher, ob dies „wie vorgesehen funktioniert“ oder ob hier ein kleiner/großer Fehler vorliegt. @Osama , sind Sie mit diesem Teil der App vertraut?
3 „Gefällt mir“
Osama
10. Februar 2022 um 09:48
9
Es fühlt sich definitiv so an, als hätten wir hier einen Fehler. Ich würde erwarten, dass die Zitatrichtung mit der Site-Richtung übereinstimmt. Ich werde mich darum kümmern und sehen, was das verursacht!
4 „Gefällt mir“
Osama
20. Februar 2022 um 20:07
11
Nachdem ich mir das angesehen habe, bin ich etwas verwirrt. Sind Sie sicher, dass dies früher korrekt gerendert wurde? Denn ich konnte nichts im Code finden, das die Behandlung von zitiertem RTL-Text mit einem Benutzernamen in einer LTR-Sprache ermöglicht. Ich habe auch eine Discourse-Version von vor über einem Jahr ausprobiert und das Zitat wurde auch nicht korrekt gerendert.
Wie auch immer, hier ist ein PR, um dies korrekt zu behandeln:
main ← fix/quoted-rtl-text
opened 08:02PM - 20 Feb 22 UTC
Meta topic: https://meta.discourse.org/t/rtl-direction-is-broken-in-quotes/21763… 9?u=osama.
Posts in Discourse are by default always rendered in the same direction as the rest of site, for example if the site is RTL, a post in that site is always rendered RTL even if it's made of an LTR language entirely. However, this behavior can be changed by enabling the `support mixed text direction` site setting which makes our posts rendering engine consider each "paragraph" in the post and apply an appropriate direction (using the `dir` attribute) on it based on its content/language.
I put paragraph in quotes because technically we only loop through the immediate children of the HTML element that contains the post cooked HTML and do this direction check on them. Most of the time the immediate children are actually paragraphs, but not always. The direction of an element is determined by checking its `textContent` property against a regular expression that checks all characters are RTL characters and based on the regular expression result the `dir` attribute is set on the element.
This technique doesn't work so well on quotes because they may contain multiple paragraphs which may be in different languages/directions. For example:

In this screenshot, the site's language is Arabic (RTL language) and the `support mixed text direction` setting is enabled. The paragraphs outside the quotes are rendered as expected with the right direction, however the paragraphs within the quote aren't; both the Arabic and English paragraphs are rendered LTR. Additionally, the avatar in the quote is misplaced; it should always be on the right hand site in RTL sites.
The reason for this is that when we're determining the direction for the quote, it's considered as one element and the direction is set on the whole quote. But for complex quotes like the one above, we need to be more surgical and apply direction on elements within the quote.
This PR adds special handling for quotes to ensure that:
* the quote title (the avatar plus the chevron and arrow) always match the site direction
* each immediate paragraph (`<p>` elements) under `<blockquote>` in the quote gets a direction based on its content.
Screenshot of the above quote with this PR:

5 „Gefällt mir“
pmusaraj
(Penar Musaraj)
Geschlossen,
28. Februar 2022 um 07:00
12
Dieses Thema wurde nach 3 Tagen automatisch geschlossen. Neue Antworten sind nicht mehr möglich.