Page MenuHomePhabricator

Additional "Edit" tab appears on translation pages with VisualEditor when viewing a diff
Closed, ResolvedPublic

Description

Splitting this off from T246518.

On translation pages, there is supposed to only be a single tab labelled "Translate", as they can't be edited normally (only by translating).

This seems to almost always work correctly, except if you're viewing a diff without the page contents.

This works, there is only one tab "Translate":

This does not work, there are two tabs, "Translate" and "Edit" (which doesn't work):


There is a "Edit" tab on the left side of "Translate" tab now.
The tab will be hidden when ".ve-not-available" class is inserted to <html> tag. ve.init.mw.DesktopArticleTarget.noscript.css#10
This is controlled by ve.init.mw.DesktopArticleTarget.init.js#1154
I found there is "ve-available" class when I logged in to one of my accounts.
This is because mw.config.get( 'wgTranslatePageTranslation' ) returns null in ve.init.mw.DesktopArticleTarget.init.js#1082
And the variable is inserted by PageTranslationHooks.php#163

Event Timeline

I think the Translate extension is using the wrong hook. 'OutputPageBeforeHTML' is only called when adding a parser output to the page. As there is no parser output when viewing a diff without the page contents, it never gets called and the 'wgTranslatePageTranslation' config variable is never set. (I am not sure why this works when viewing the history, because it seems like it shouldn't.)

I think it should be using 'BeforePageDisplay' instead.

Change 605676 had a related patch set uploaded (by Bartosz Dziewoński; owner: Bartosz Dziewoński):
[mediawiki/extensions/Translate@master] Use BeforePageDisplay instead of OutputPageBeforeHTML for setting metadata

https://gerrit.wikimedia.org/r/605676

Change 605676 merged by jenkins-bot:
[mediawiki/extensions/Translate@master] Use BeforePageDisplay instead of OutputPageBeforeHTML for setting metadata

https://gerrit.wikimedia.org/r/605676