Page MenuHomePhabricator

Reference card is initially shown empty in Section translation
Closed, ResolvedPublic


When editing a sentence with references in Section Translation, selecting the references shows a preview card as it is expected in Mobile Visual Editor. However, the card is shown empty.

I used as an example the translation of the "Formation" section of the Moon article from English to Spanish using Google Translate (example link). It seems to happen on all references but the video below shows the example for the first sentence of the section:

sx.wmflabs.org_index.php_Special_ContentTranslation_page=Moon&from=en&to=es&sx=true(iPhone 5_SE).png (1×640 px, 90 KB)
sx.wmflabs.org_index.php_Special_ContentTranslation_page=Moon&from=en&to=es&sx=true(iPhone 5_SE) (1).png (1×640 px, 121 KB)

Event Timeline

Pginer-WMF triaged this task as Medium priority.Nov 2 2021, 9:45 AM

Change 741102 had a related patch set uploaded (by Santhosh; author: Santhosh):

[mediawiki/extensions/ContentTranslation@master] Fix empty reference cards in visual editor

I debugged this issue and found that the preview element created by ve.ui.MWReferenceContextItem uses default arguments of ve.ui.MWPreviewElement. ve.ui.MWPreviewElement has useView configuration as false by default and causes not rendering the references from its DOM model as required for section translation.

As a workaround, I created a custom getRendering method in Section translation and use it as as override for ve.ui.MWReferenceContextItem.prototype.getRendering(see It fixed the issue, but I am not happy with this method as I am having a copy of ve.ui.MWReferenceContextItem.prototype.getRendering in SX detached from the updates in upstream.

@DLynch @matmarex Do you have any suggestions for better fix?

image.png (965×569 px, 65 KB)

Change 741102 merged by jenkins-bot:

[mediawiki/extensions/ContentTranslation@master] Fix empty reference cards in visual editor

Great! The details are showing in the card:

test.m.wikipedia.org_w_index.php_title=Special_ContentTranslation&page=Moon&from=en&to=es&sx=true(iPhone SE).png (1×750 px, 144 KB)

As I was testing this I noticed that the links in the card try to leave the editor instead of opening on a new window. So users cannot actually check them (otherwise they would lose their work). I created a separate task for this: T299755: Clicking a link in the reference inspector leaves the editor

Change 760901 had a related patch set uploaded (by Santhosh; author: Santhosh):

[mediawiki/extensions/ContentTranslation@master] CX: Avoid empty reference cards when clicked

Change 760901 merged by jenkins-bot:

[mediawiki/extensions/ContentTranslation@master] CX: Avoid empty reference cards when clicked