Page MenuHomePhabricator

The lang and directionality attributes of the source selector is not updated when language changed
Open, LowPublic

Description

Steps to reproduce:

  1. Choose Hebrew as source language, and select some title.
  2. Change the source language to English
  3. Type Curiosity (rover) in the source title field. Observe its rendering

image.png (203×1 px, 35 KB)

The RTL directionality is not updated along with language change.

<a class="cx-selected-source-page__link" lang="he" dir="rtl" href="https://en.wikipedia.org/wiki/Curiosity_(rover)" title="Curiosity (rover)" target="_blank">Curiosity (rover)</a>

Event Timeline

I'm not sure I understand the steps to reproduce. Point 3 as it's written now requires reopening the selector, so everything is rebuilt anyway. It's possible that I misunderstand it.

However, I do see an issue here. Try the following:

  1. Select Hebrew as the source language.
  2. Type "מדונה". (This is "Madonna". In Hebrew it's the article about the singer, and it doesn't have parentheses in the title.)
  3. Change the source language to English. The title auto-changes to "Madonna (entertainer)".

Observed:

  1. lang="he" dir="rtl" on the <a> element with the title.
  2. In Chrome, the parentheses appear broken, like "(Madonna (entertainer". (This doesn't happen in Firefox, because it implements the part of the Unicode bidi algorithm that auto-fixes the parentheses.)

Expected:

  1. lang="en" dir="ltr" on the <a> element with the title.
  2. Parentheses must appear correctly in all browsers.

lang and dir attributes of source page title are still not updated and wrong when switching source language.

However, Chrome (haven't checked Chromium) seems to have implemented part of bidi algorithm which auto-fixes parentheses. @Amire80 do you happen to know if this is true?
This now ends up being only semantically wrong, without affecting the visuals.

I've tried to reproduce, and here's what happens:

  1. I go to https://en.wikipedia.org/wiki/Special:ContentTranslation .
  2. I click "New translation".
  3. I click the language button in the end of the article selector and select Hebrew.
  4. I type חוף התופים and click it.
    1. Observed in DOM inspector: lang="he" dir="rtl" on the article title, as I would expect.
    2. Observed in rendering: the language button says עברית > English, as I would expect.
  5. I click the עברית in the source language selector to change the source language to English, as suggested in step 2.
    1. Observed: I see a ULS panel only with Hebrew. I cannot select another language. Typing anything in the language search box shows no results. This is a bit useless, but it's a different issue.
  6. Second attempt to select English as the source language: Click the X in the article selector. Click "New translation". Click עברית. Select "English" in the ULS panel.
  7. Here's the craziest part:
    1. Sometimes it changes the attributes correctly to lang="en" dir="ltr" and sometimes it doesn't! I tried reproducing several times.
    2. Sometimes it flips the whole dashboard, including the article selector, and sets dir="rtl" on the <html> element! See the screenshot:

Screenshot_2020-01-20 Translate page - Note This utility is currently restricted to extended confirmed editors on the Engli[...].png (1×2 px, 387 KB)

All of it is very strange. I can do it live with someone else for a demo, if anyone is interested.