Page MenuHomePhabricator

Missing translate button on foundationwiki
Closed, ResolvedPublic2 Estimated Story PointsBUG REPORT

Description

Steps to replicate the issue (include links if applicable):

What happens?:
You do not have any possibility to directly translate from that page and you need to go back to the translatable page to contribute translations (e.g. https://foundation.wikimedia.org/wiki/Home)

What should have happened instead?:
In the upper right corner there should be a button ''translate'' like in other wikis (e.g. https://meta.wikimedia.org/wiki/Main_Page/de)

Software version (skip for WMF-hosted wikis like Wikipedia):

Other information (browser name/version, screenshots, etc.):

Event Timeline

This is unrelated to the codebase of the Translate extension.

Why do you think so? It’s Translate that normally turns edit tabs of translated pages into translate tabs.

@Tacsipacsi - thank you for reporting this issue. I am not able to replicate it on my end as the translate tab I think you are referring to appears for me:

Screenshot 2023-04-11 at 3.14.23 PM.png (666×1 px, 377 KB)

Can you help me with troubleshooting a bit? Two quick questions:

  1. Are you logged into the wiki (you are able to use your usual Wikimedia wiki account)?
  2. Are you otherwise able to translate these pages via other methods?

Again, thank you!

Translation from the base page (e.g. https://foundation.wikimedia.org/wiki/Home) works fine.

Maybe you see the translate button because you have the necessary rights to edit these pages as well. Normal users cannot edit in this namespace, they can just contribute translations.

Logged in:

Screenshot_20230411_221521_Chrome.jpg (834×1 px, 196 KB)

Ahhh - I see what you mean. So basically if the person is able to translate but not edit the page, the translate tab does not appear correctly. Interesting - curious if @Nikerabbit or @abi_ has any thoughts on if this is a "bug" or something we intentionally want. I could see an argument either way. I can appreciate the logic suggesting that if you are able to translate, the tab would appear - even if you are not able to edit the source language page. I also agree this relates to the Translate extension and while most noticeable on this wiki - could occur elsewhere. I wonder what happens if the page is fully-protected. Hmmm...

@Ameisenigel do you run into the same issue with this page on Meta-Wiki: https://meta.wikimedia.org/wiki/User:GVarnum-WMF/sandbox1/pl
And for sake of testing baseline - any different outcome on this Meta-Wiki page: https://meta.wikimedia.org/wiki/User:GVarnum-WMF/sandbox2/pl

Thank you!

The translate button is visible for me on both pages.

Logged in:

Screenshot_20230411_221521_Chrome.jpg (834×1 px, 196 KB)

Ahhh - I see what you mean. So basically if the person is able to translate but not edit the page, the translate tab does not appear correctly. Interesting - curious if @Nikerabbit or @abi_ has any thoughts on if this is a "bug" or something we intentionally want. I could see an argument either way. I can appreciate the logic suggesting that if you are able to translate, the tab would appear - even if you are not able to edit the source language page. I also agree this relates to the Translate extension and while most noticeable on this wiki - could occur elsewhere. I wonder what happens if the page is fully-protected. Hmmm...

The logic in the the Translate code piggy-backs on the edit tab, and transforms it to "Translate". The edit tab will not be present if the user does not have permissions to edit the page.

I think if a user has permission to translate a translatable page, then the translate tab should appear. In my opinion this is a bug.

Change 908190 had a related patch set uploaded (by Abijeet Patro; author: Abijeet Patro):

[mediawiki/extensions/Translate@master] Display translate tab if user has permission to translate

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

abi_ triaged this task as Medium priority.
abi_ set the point value for this task to 2.

Change 908190 merged by jenkins-bot:

[mediawiki/extensions/Translate@master] Display translate tab if user has permission to translate

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

@Ameisenigel This should be fixed now. Can you confirm that the things work as expected now?

Unfortunately this is still not working for me.

Unfortunately this is still not working for me.

Just to confirm, you still do not see the translate button appear?

Some notes from debugging via shell.php on foundationwiki:

# Some setup
> $mainTitle = \Title::newFromText( 'Home' );
> use MediaWiki\MediaWikiServices;
> $permManager = MediaWikiServices::getInstance()->getPermissionManager();
> $user = User::newFromName( 'Ameisenigel' );

Try to run PermissionManager::userCan

> $permManager->userCan( 'translate', $user, $mainTitle );
= false 
# Was expecting to return true above

Find out why PermissionManager::userCan returns false:

> $permManager->getPermissionErrors( 'translate', $user, $mainTitle );
= [
    [
      "namespaceprotected",
      "Page",
      "translate",
    ],
  ]

Change 924532 had a related patch set uploaded (by Abijeet Patro; author: Abijeet Patro):

[mediawiki/extensions/Translate@master] Use User::isAllowed when deciding whether to display translate tab

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

Change 924532 merged by jenkins-bot:

[mediawiki/extensions/Translate@master] Use User::isAllowed when deciding whether to display translate tab

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

@Ameisenigel Hopefully this should be fixed now after our latest changes. Can you please check again when you have time?

Yes, this is resolved. Thank you!

There are two issues:

  • The tabs are Read View source View history Translate. They should be Read Translate View history instead (no View source, Translate between Read and View history).
  • The Translate tab appears even when logged out. Tux also appears to be functional, but it cannot actually save changes as anonymous users cannot edit. https://foundation.wikimedia.org/w/index.php?title=Translations:Home/1/de&action=edit correctly doesn’t let me edit without logging in. The Translate tab should only appear if one can edit translations (i.e. the Translations: namespace), and even if one manually navigates to Tux, it should be read-only.

Change 929300 had a related patch set uploaded (by Abijeet Patro; author: Abijeet Patro):

[mediawiki/extensions/Translate@master] Display translate tab only if user is registered

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

Thanks for checking this.

There are two issues:

  • The tabs are Read View source View history Translate. They should be Read Translate View history instead (no View source, Translate between Read and View history).

There does not appear to be a straightforward approach to change the order. The tabs array has a string based key and I'm not sure how it decides the order of the display of the tabs. If I were to guess, I'd say its based on the way the keys are added to the array.

  • The Translate tab appears even when logged out. Tux also appears to be functional, but it cannot actually save changes as anonymous users cannot edit. https://foundation.wikimedia.org/w/index.php?title=Translations:Home/1/de&action=edit correctly doesn’t let me edit without logging in. The Translate tab should only appear if one can edit translations (i.e. the Translations: namespace), and even if one manually navigates to Tux, it should be read-only.

I've fixed this in the latest patch.

There does not appear to be a straightforward approach to change the order.

Just like it works for the Edit tab, it should be possible to make it work for the View source tab as well. I think you should simply use $action = 'viewsource' if it exists (and the user is likely to be able to translate).

The tabs array has a string based key and I'm not sure how it decides the order of the display of the tabs. If I were to guess, I'd say its based on the way the keys are added to the array.

This is quite likely, as PHP arrays are ordered (even those that contain string keys), and the default ordering is the order keys were added.

Change 932171 had a related patch set uploaded (by Tacsipacsi; author: Tacsipacsi):

[mediawiki/extensions/Translate@master] Show Translate tab at the right place on protected pages

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

Change 929300 merged by jenkins-bot:

[mediawiki/extensions/Translate@master] Check namespace restrictions when displaying the Translate tab

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

Change 932171 merged by jenkins-bot:

[mediawiki/extensions/Translate@master] Show Translate tab at the right place on protected pages

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

Tested on Foundation wiki today:

  1. Location of the translate tab is fixed
  2. Translate tab still appears for a non-logged in user.
  3. As a non logged in user, translating the content yields the following error message: Publishing the translation failed: The action you have requested is limited to users in one of the groups: [[Wikimedia:Users|Users]], [[Wikimedia:Editor|Editors]].

There is divergence between who sees the Translate button and who can actually perform translations.

Change 934258 had a related patch set uploaded (by Abijeet Patro; author: Abijeet Patro):

[mediawiki/extensions/Translate@master] Check for blocks when displaying the translate tabs

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

Change 934258 merged by jenkins-bot:

[mediawiki/extensions/Translate@master] Check for blocks when displaying the translate tabs

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

abi_ moved this task from In Review to Done on the Language-Team (Language-2023-July-September) board.

This is done. Moving to previous quarter since all the work was done there.