hnaseri
(Hosein Naseri)
09.Февраль.2022 10:15:01
1
У меня форум на языке с направлением письма справа налево. Недавно цитаты отображают текст слева направо вместо справа налево.
pmusaraj
(Penar Musaraj)
09.Февраль.2022 11:32:35
2
У вас последняя версия Discourse? Я не могу воспроизвести это локально, например, при переключении моего языка на арабский.
hnaseri
(Hosein Naseri)
09.Февраль.2022 13:40:14
3
Я только что обновился до последней версии. Это не исправило проблему.
pmusaraj
(Penar Musaraj)
09.Февраль.2022 15:41:13
4
Это происходит на нескольких постах или только на этом конкретном? Вы также пробовали в безопасном режиме?
1 лайк
hnaseri
(Hosein Naseri)
10.Февраль.2022 06:44:53
5
Да, это происходит в нескольких постах. Также это случается в безопасном режиме.
1 лайк
pmusaraj
(Penar Musaraj)
10.Февраль.2022 07:58:52
6
Не могли бы вы отправить ссылку на ваш сайт, чтобы мы могли его посмотреть?
hnaseri
(Hosein Naseri)
10.Февраль.2022 08:26:46
7
1 лайк
pmusaraj
(Penar Musaraj)
10.Февраль.2022 09:40:23
8
Спасибо. Судя по исходному коду, кавычки там имеют атрибут dir="ltr". Я предполагаю, что у вас включена настройка «Смешанное направление текста». На самом деле, я могу воспроизвести вашу проблему, включив эту настройку локально.
Не уверен, работает ли это «как задумано» или здесь есть небольшая/серьёзная ошибка. @Osama , знакомы ли вы с этой частью приложения?
3 лайка
Osama
10.Февраль.2022 09:48:49
9
Действительно, похоже, у нас здесь ошибка. Я ожидал, что направление цитаты будет соответствовать направлению сайта. Я разберусь и выясню, что это вызывает!
4 лайка
Osama
20.Февраль.2022 20:07:10
11
После изучения вопроса я немного запутался: вы уверены, что раньше это работало правильно? Потому что в коде я не нашёл ничего, что обрабатывало бы цитаты с текстом RTL и именем пользователя на языке LTR. Я также попробовал версию 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)
Закрыл(а) тему
28.Февраль.2022 07:00:06
12
Эта тема была автоматически закрыта через 3 дня. Новые ответы больше не принимаются.