hnaseri
(Hosein Naseri)
9 Febrero, 2022 10:15
1
Tengo un foro en idioma rtl. Recientemente, las citas muestran texto en dirección ltr en lugar de rtl.
pmusaraj
(Penar Musaraj)
9 Febrero, 2022 11:32
2
¿Estás en la última versión de Discourse? No puedo reproducirlo localmente cuando cambio mi configuración regional a árabe, por ejemplo.
hnaseri
(Hosein Naseri)
9 Febrero, 2022 13:40
3
Acabo de actualizar a la última versión. No solucionó el problema.
pmusaraj
(Penar Musaraj)
9 Febrero, 2022 15:41
4
¿Esto ocurre en varias publicaciones o solo en esa específica? ¿También has probado en modo seguro?
1 me gusta
hnaseri
(Hosein Naseri)
10 Febrero, 2022 06:44
5
Sí, ocurre en varias publicaciones. Y también ocurre en modo seguro.
1 me gusta
pmusaraj
(Penar Musaraj)
10 Febrero, 2022 07:58
6
¿Puedes publicar un enlace a tu sitio para que podamos echar un vistazo?
pmusaraj
(Penar Musaraj)
10 Febrero, 2022 09:40
8
Gracias, al mirar el código fuente, las comillas allí tienen un atributo dir="ltr". Supongo que has habilitado la configuración mixed text direction. De hecho, puedo reproducir tu problema cuando habilito esa configuración localmente.
No estoy seguro de si esto es “funciona según lo diseñado” o si hay un error pequeño/grande aquí. @Osama , ¿estás familiarizado con esta parte de la aplicación?
3 Me gusta
Osama
10 Febrero, 2022 09:48
9
Ciertamente parece que tenemos un error aquí. Esperaría que la dirección de la cita coincida con la dirección del sitio. ¡Investigaré y veré qué está causando esto!
4 Me gusta
Osama
20 Febrero, 2022 20:07
11
Después de investigar esto, estoy un poco confundido, ¿estás seguro de que esto solía renderizarse correctamente? Porque no pude ver nada en el código para manejar texto citado RTL con un nombre de usuario en un idioma LTR. También probé una versión de Discourse de hace más de un año y la cita tampoco se renderizó correctamente.
De todos modos, aquí hay una PR para manejar esto correctamente:
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 Me gusta
pmusaraj
(Penar Musaraj)
Cerrado
28 Febrero, 2022 07:00
12
Este tema se cerró automáticamente después de 3 días. Ya no se permiten nuevas respuestas.