hnaseri
(Hosein Naseri)
2월 9, 2022, 10:15오전
1
RTL 언어로 된 포럼을 운영하고 있습니다. 최근 인용문(quote)이 RTL이 아니라 LTR 방향으로 텍스트가 표시됩니다.
pmusaraj
(Penar Musaraj)
2월 9, 2022, 11:32오전
2
최신 버전의 Discourse를 사용하고 계신가요? 예를 들어 제 로케일을 아랍어로 변경해도 로컬에서 재현할 수 없습니다.
hnaseri
(Hosein Naseri)
2월 9, 2022, 1:40오후
3
방금 최신 버전으로 업데이트했습니다. 문제가 해결되지 않았습니다.
pmusaraj
(Penar Musaraj)
2월 9, 2022, 3:41오후
4
이 문제가 여러 게시물에서 발생하나요, 아니면 특정 게시물에서만 발생하나요? 안전 모드에서도 시도해 보셨나요?
1개의 좋아요
hnaseri
(Hosein Naseri)
2월 10, 2022, 6:44오전
5
네, 여러 게시물에서 발생하고 있습니다. 그리고 안전 모드에서도 발생합니다.
1개의 좋아요
pmusaraj
(Penar Musaraj)
2월 10, 2022, 7:58오전
6
사이트 링크를 올려주시면 확인해 볼 수 있을까요?
pmusaraj
(Penar Musaraj)
2월 10, 2022, 9:40오전
8
감사합니다. 소스 코드를 살펴보니 해당 인용문에 dir="ltr" 속성이 있습니다. 혼합된 텍스트 방향 설정을 활성화하신 것으로 추측됩니다. 실제로 저는 해당 설정을 로컬에서 활성화했을 때 문제를 재현할 수 있었습니다.
이것이 의도된 동작인지, 아니면 작은/큰 버그인지 확실하지 않습니다. @Osama 이 앱의 해당 부분에 대해 알고 계신가요?
3개의 좋아요
Osama
2월 10, 2022, 9:48오전
9
여기서 버그가 있는 것 같습니다. 인용 방향이 사이트 방향과 일치해야 한다고 생각했거든요. 원인을 찾아보겠습니다!
4개의 좋아요
Osama
2월 20, 2022, 8:07오후
11
이 문제를 조사해 본 결과, 약간 혼란스럽습니다. 이전에 이 인용문이 올바르게 렌더링되었던 것이 확실합니까? LTR 언어에서 사용자 이름이 포함된 RTL 인용문 텍스트를 처리하는 코드를 찾지 못했기 때문입니다. 또한 1년 전 이상의 Discourse 버전을 시도해 보았지만, 그때도 인용문이 올바르게 렌더링되지 않았습니다.
어쨌든, 이를 올바르게 처리하기 위한 PR을 공유합니다:
main ← fix/quoted-rtl-text
merged 07:26AM - 23 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개의 좋아요
pmusaraj
(Penar Musaraj)
에 닫힘
2월 28, 2022, 7:00오전
12
이 주제는 3일 후 자동으로 닫혔습니다. 더 이상 답변을 남길 수 없습니다.