Page MenuHomePhabricator

PLURAL syntax validator gets confused by other uses of equals signs in the message, as seen at [[Wikimedia:Wikipedia-android-strings-year in review slide most read english articles body/de]]
Closed, ResolvedPublic1 Estimated Story PointsBUG REPORT

Description

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

  • Go to https://translatewiki.net/w/i.php?title=Wikimedia%3AWikipedia-android-strings-year+in+review+slide+most+read+english+articles+body%2Fde&action=edit
  • Try to save the German translation "{{PLURAL|one=Wenn Menschen etwas über unsere Welt erfahren möchten — über die guten, die schlechten, die seltsamen und die wilden Seiten — wenden sie sich an Wikipedia. Der %1$d am häufigsten besuchte Artikel der Englischsprachigen Wikipedia war: %2$s <br />Lies mehr dazu in unserem <a href="%3$s">Blogbeitrag</a>.|Wenn Menschen etwas über unsere Welt erfahren möchten — über die guten, die schlechten, die seltsamen und die wilden Seiten — wenden sie sich an Wikipedia. Die %1$d am häufigsten besuchten Artikel der Englischsprachigen Wikipedia waren: %2$s <br />Lies mehr dazu in unserem <a href="%3$s">Blogbeitrag</a>.}}"

What happens?: The edit is not accepted because of a syntax error

What should have happened instead?: Saving the edit should be possible because the syntax follows the original message in English.

Software version (on Special:Version page; skip for WMF-hosted wikis like Wikipedia):

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

Screenshot_20251109_100553_Chrome.jpg (1×909 px, 274 KB)

Screenshot_20251109_100503_Chrome.jpg (1×985 px, 413 KB)

Event Timeline

The same problem occurs when trying to provide a translation for [[Wikimedia:Wikipedia-android-strings-year in review slide bytes added body/de]].

Pppery subscribed.

Sidenote: that error message is really unhelpful. Validators should explain why they are failing rather than all failing with the same unhelpful error message.

If you use the new TUX ui rather than editing the page through the wikitext editor, you get a better error message:

"Plural forms should be defined as {{PLURAL|one=…|…}}. This translation contains {{PLURAL|one=…|href=…}}."

Apparently some regex used in valdating translations gets confused by the raw HTML in the message.

Pppery renamed this task from Providing a translation for [[Wikimedia:Wikipedia-android-strings-year in review slide most read english articles body/de]] is not possible to PLURAL syntax validator gets confused by other uses of equals signs in the message, as seen at [[Wikimedia:Wikipedia-android-strings-year in review slide most read english articles body/de]].Nov 9 2025, 5:40 PM

It looks like this can be worked-around by making sure the raw HTML is outside the PLURAL template, i.e. wrap the PLURAL template only around the minimum required text to be pluralized:
https://translatewiki.net/wiki/Wikimedia:Wikipedia-android-strings-year_in_review_slide_most_read_english_articles_body/de

Nikerabbit triaged this task as Medium priority.Nov 10 2025, 2:00 PM
Nikerabbit set the point value for this task to 1.
Nikerabbit subscribed.

https://gerrit.wikimedia.org/g/mediawiki/extensions/Translate/+/a8446a2457fa087bf227e9ff4b146404464b112b/src/Utilities/UnicodePlural.php#125 could be made more strict to avoid false positives with equals signs not close to a pipe. Just need to be careful to avoid letting true positives trough.

It looks like this can be worked-around by making sure the raw HTML is outside the PLURAL template, i.e. wrap the PLURAL template only around the minimum required text to be pluralized:
https://translatewiki.net/wiki/Wikimedia:Wikipedia-android-strings-year_in_review_slide_most_read_english_articles_body/de

Unfortunately, that will either not roundtrip, or even cause problems on export – the Android XML format doesn’t support the concept of “mostly the same, with one different sentence”; if it’s a plural message, it needs to be stored separately from the first character to the last, which corresponds to the whole message being in {{PLURAL}}.

https://gerrit.wikimedia.org/g/mediawiki/extensions/Translate/+/a8446a2457fa087bf227e9ff4b146404464b112b/src/Utilities/UnicodePlural.php#125 could be made more strict to avoid false positives with equals signs not close to a pipe. Just need to be careful to avoid letting true positives trough.

Actually, I think it’s a pretty easy change: adding an anchor at the beginning, i.e. changing ~\s*([a-z]+)\s*=(.+)~s to ~^\s*([a-z]+)\s*=(.+)~s. Everything that’s not at the beginning is not a plural form; and everything that’s HTML won’t be at the beginning (since the HTML tag will begin with a <, which isn’t matched by the regex, so the part matched by the regex won’t be at the beginning).

And looking at the code, I realized simply adding explicit |other= fixes the issue, maybe that could be mentioned in the error messages. (This may be something for T409665, though.)

It looks like this can be worked-around by making sure the raw HTML is outside the PLURAL template, i.e. wrap the PLURAL template only around the minimum required text to be pluralized:
https://translatewiki.net/wiki/Wikimedia:Wikipedia-android-strings-year_in_review_slide_most_read_english_articles_body/de

Unfortunately, that will either not roundtrip, or even cause problems on export – the Android XML format doesn’t support the concept of “mostly the same, with one different sentence”; if it’s a plural message, it needs to be stored separately from the first character to the last, which corresponds to the whole message being in {{PLURAL}}.

It should round trip fine, but please let us know if it doesn't. Maybe the code that supports that is broken.

Change #1204752 had a related patch set uploaded (by Wangombe; author: Wangombe):

[mediawiki/extensions/Translate@master] UnicodePlural: Make plural form regex more strict

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

It should round trip fine, but please let us know if it doesn't. Maybe the code that supports that is broken.

Ah, I wasn’t aware of rETRAe0afbd1eff5ff47688cb7b926a6f56d8227c5126. I don’t know of any actual breakage.

Wangombe changed the task status from Open to In Progress.Nov 17 2025, 7:30 AM
Wangombe claimed this task.
Wangombe moved this task from Ready for dev to In Progress on the LPL Essential (FY2025-26 Q2) board.

Change #1204752 merged by jenkins-bot:

[mediawiki/extensions/Translate@master] UnicodePlural: Make plural form regex stricter

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

Nikerabbit moved this task from Need QA to Done on the LPL Essential (FY2025-26 Q2) board.

image.png (484×1 px, 142 KB)

Looks good.

Change #1211039 had a related patch set uploaded (by Wangombe; author: Wangombe):

[mediawiki/extensions/Translate@master] Fix plural test case to handle zero item correctly

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

Change #1211039 merged by jenkins-bot:

[mediawiki/extensions/Translate@master] Cover more edge cases in plural tests

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