Page MenuHomePhabricator

Sidebar donate link targets are always in English
Closed, ResolvedPublic

Description

The sidebar donation links are defined in the message sitesupport-url as
https://donate.wikimedia.org/?wmf_source=donate&wmf_medium=sidebar&wmf_campaign={{SERVERNAME}}&uselang={{USERLANGUAGE}}

e.g. https://fr.wikipedia.org/wiki/MediaWiki:Sitesupport-url where it appears correctly with uselang=fr

However the actual links in the sidebar/top menu always have uselang=en resulting in the English language donation page being shown. This occurs:

  • on all projects, not just wikipedias
  • on both desktop and mobile sites
  • logged out or logged in
  • regardless of my browser language settings

Requirement

The uselang parameter in the donation link (sitesupport-url) should reflect the current user interface language ({{USERLANGUAGE}}) rather than defaulting to English (en). This ensures that users are directed to a donation page localized to their language across all Wikimedia projects and platforms (desktop and mobile), regardless of login status or browser settings.

BDD

Feature: Correct language parameter in sidebar donate link

Scenario: Logged-out user sees localized donate link
  Given I am a logged-out user on any Wikimedia project
  And the interface language is set to a non-English language
  When I inspect the donate link in the sidebar or top menu
  Then the URL contains "uselang=<user language>"

Test Steps

Test Case 1: Logged-out user sees localized donate link

  1. Open a private/incognito window.
  2. Navigate to a Wikimedia project with a non-English language interface (e.g., https://fr.wikipedia.org).
  3. Inspect the “Donate” link in the sidebar (desktop) or top menu (mobile).
  4. AC1: Confirm the uselang parameter in the URL matches the site language (e.g., uselang=fr), not uselang=en.

QA Results - Prod

ACStatusDetails
1T393601#10842279

Event Timeline

Jdlrobson-WMF subscribed.

I can replicate this locally but haven't got to bottom of it. Right now I'm suspecting something might have broken in the core localization. I don't see anything obvious at the Minerva or WikimediaMessages layer.

The message wikimedia-skin-minerva-donate-banner-url is defined in WikimediaMessages as https://donate.wikimedia.org/?wmf_source=donate&wmf_medium=sidebar&wmf_campaign={{SERVERNAME}}&uselang={{USERLANGUAGE}}&wmf_key=minerva

The message is defined as a template message: skin-minerva-donate-banner-url:
https://github.com/wikimedia/mediawiki-skins-MinervaNeue/blob/f9f0598a07571d6e7107583a7e98089839022fb3/skin.json#L168

These are always parsed as text:
https://github.com/wikimedia/mediawiki/blob/master/includes/skins/SkinMustache.php#L150

Noting there is also {{PAGELANGUAGE}} in https://www.mediawiki.org/wiki/Help:Magic_words#Localization_variables but that doesn't work either.

Jdlrobson-WMF changed the task status from Open to In Progress.May 7 2025, 5:29 PM
Jdlrobson-WMF claimed this task.

Change #1143149 had a related patch set uploaded (by Jdlrobson; author: Jdlrobson):

[mediawiki/core@master] Revert "language: When using a fallback message, parse with the fallback's language"

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

Jdlrobson-WMF added a subscriber: tstarling.

@tstarling I assume reverting this is not the ideal solution since the patch is pretty large but could you advise on what the appropriate fix here would be?

wikimedia-skin-minerva-donate-banner-url is technically always in English (it has a {{notranslate}} tag), it relies on {{USERLANGUAGE}} to generate the correct URL, and since now the parser switches language when falling back, I guess that switches the value of that magic word as well? (Confusingly, on most wikis {{USERLANGUAGE}} doesn't actually return the user language, but rather the target language of the parser, as a performance optimization. For content, that's the wiki language; for interface messages, it used to be the user language, but the patch changed it to be the language of the message, which makes much more sense.)

The donation link (in the sidebar + Minerva footer) seems to be the only thing using {{USERLANGUAGE}} (codesearch, global search).

Maybe the solution is to change {{USERLANGUAGE}} to return the actual user language when parsing with the interface message flag? Or would that require varying the parser cache key on that flag?

Change #1143189 had a related patch set uploaded (by Jdlrobson; author: Jdlrobson):

[mediawiki/extensions/WikimediaMessages@master] Use CONTENTLANGUAGE rather than USERLANGUAGE

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

The issue also exists with {{PAGELANGUAGE}}but not {{CONTENTLANGUAGE}}. I think the latter would be an improvement but ideally this would be in the user language but I think that would be an acceptable compromise solution here.

The donation link (in the sidebar + Minerva footer) seems to be the only thing using {{USERLANGUAGE}} (codesearch, global search).

Perhaps an indication this code should be removed, particularly since it's now broken?

The issue also exists with {{PAGELANGUAGE}}but not {{CONTENTLANGUAGE}}. I think the latter would be an improvement but ideally this would be in the user language but I think that would be an acceptable compromise solution here.

Yeah, {{PAGELANGUAGE}} and {{USERLANGUAGE}} are the same when $wgParserEnableUserLanguage is false, which is most Wikimedia wikis. {{CONTENTLANGUAGE}} is always the same though, it's not affected by which language the parser is parsing in. So that seems like a good first approximation of a fix, at least.

The donation link (in the sidebar + Minerva footer) seems to be the only thing using {{USERLANGUAGE}} (codesearch, global search).

Perhaps an indication this code should be removed, particularly since it's now broken?

For Minerva, yeah, IIUC you could just pass in the user language as a message parameter and that seems much more straightforward.

For the other skins, where the donation link is just one of the sidebar items and MediaWiki doesn't know anything about its semantics, I'm not sure there's an easy replacement.

Change #1143224 had a related patch set uploaded (by Tim Starling; author: Jdlrobson):

[mediawiki/extensions/WikimediaMessages@wmf/1.44.0-wmf.27] Use CONTENTLANGUAGE rather than USERLANGUAGE

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

Change #1143225 had a related patch set uploaded (by Tim Starling; author: Jdlrobson):

[mediawiki/extensions/WikimediaMessages@wmf/1.44.0-wmf.28] Use CONTENTLANGUAGE rather than USERLANGUAGE

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

@abi_ was my reviewer on T268492 so should be in the loop.

Maybe the solution is to change {{USERLANGUAGE}} to return the actual user language when parsing with the interface message flag? Or would that require varying the parser cache key on that flag?

I tried this, but there are a lot of annoying details, so I'm working on a patch which would go out with the train. I'm deploying the {{CONTENTLANGUAGE}} patch as a temporary fix.

Change #1143189 merged by jenkins-bot:

[mediawiki/extensions/WikimediaMessages@master] Use CONTENTLANGUAGE rather than USERLANGUAGE

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

Change #1143224 merged by jenkins-bot:

[mediawiki/extensions/WikimediaMessages@wmf/1.44.0-wmf.27] Use CONTENTLANGUAGE rather than USERLANGUAGE

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

Change #1143225 merged by jenkins-bot:

[mediawiki/extensions/WikimediaMessages@wmf/1.44.0-wmf.28] Use CONTENTLANGUAGE rather than USERLANGUAGE

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

Mentioned in SAL (#wikimedia-operations) [2025-05-08T01:06:06Z] <tstarling@deploy1003> Started scap sync-world: Backport for [[gerrit:1143224|Use CONTENTLANGUAGE rather than USERLANGUAGE (T393601)]], [[gerrit:1143225|Use CONTENTLANGUAGE rather than USERLANGUAGE (T393601)]]

Mentioned in SAL (#wikimedia-operations) [2025-05-08T01:37:42Z] <tstarling@deploy1003> tstarling: Backport for [[gerrit:1143224|Use CONTENTLANGUAGE rather than USERLANGUAGE (T393601)]], [[gerrit:1143225|Use CONTENTLANGUAGE rather than USERLANGUAGE (T393601)]] synced to the testservers (https://wikitech.wikimedia.org/wiki/Mwdebug)

Mentioned in SAL (#wikimedia-operations) [2025-05-08T01:52:18Z] <tstarling@deploy1003> Finished scap sync-world: Backport for [[gerrit:1143224|Use CONTENTLANGUAGE rather than USERLANGUAGE (T393601)]], [[gerrit:1143225|Use CONTENTLANGUAGE rather than USERLANGUAGE (T393601)]] (duration: 46m 12s)

I found some ways to get the wrong link after the deployment finished, some due to the sidebar cache and some due to the CDN. After the sidebar cache expiry of 24 hours, incorrect links should be rare.

Change #1143497 had a related patch set uploaded (by Tim Starling; author: Tim Starling):

[mediawiki/core@master] Add ParserOptions::isMessage()

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

Change #1143498 had a related patch set uploaded (by Tim Starling; author: Tim Starling):

[mediawiki/core@master] In messages, make {{USERLANGUAGE}} always return the user's language

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

Jdlrobson-WMF added a project: Essential-Work.

This is now fixed in production. Thanks a bunch @tstarling

Change #1143149 abandoned by Jdlrobson:

[mediawiki/core@master] Revert "language: When using a fallback message, parse with the fallback's language"

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

Change #1143497 merged by jenkins-bot:

[mediawiki/core@master] Add ParserOptions::isMessage()

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

Edtadros added a project: Verified.
Edtadros subscribed.

Test Steps

Status: ✅ PASS
Environment: Prod
OS: macOS
Browser: Chrome
Device: MS

Test Case 1: Logged-out user sees localized donate link

  1. Open a private/incognito window.
  2. Navigate to a Wikimedia project with a non-English language interface (e.g., https://fr.wikipedia.org).
  3. Inspect the “Donate” link in the sidebar (desktop) or top menu (mobile).
  4. AC1: Confirm the uselang parameter in the URL matches the site language (e.g., uselang=fr), not uselang=en.

I couldn't find the donate link on Minerva

screenshot 339.png (955×1 px, 394 KB)

Change #1143498 merged by jenkins-bot:

[mediawiki/core@master] In messages, make {{USERLANGUAGE}} always return the user's language

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