Page MenuHomePhabricator

mw.language.convertNumber() behavior for four-digit numbers incorrect for Polish
Closed, ResolvedPublic

Description

mw.language.convertNumber() behavior for four-digit numbers is incorrect for Polish. The parser function {{formatnum:}} functions correctly. Four-digit numbers should not have a thousands separator (space) inserted after the first digit, only five-digit numbers (and longer).

I originally noticed this in the new RC filters:

image.png (980×1 px, 283 KB)

To reproduce:

console.log( mw.language.convertNumber( 1000 ) );
InputExpected resultCurrent result
101010
100100100
100010001 000← WRONG
1000010 00010 000

Event Timeline

Restricted Application added a subscriber: Aklapper. · View Herald Transcript

The PHP code's behavior is apparently implemented by custom code in LanguagePl::commafy(). We don't have any such system in the JS code yet. It seems that the same code block is copy-pasted to a dozen other languages too. Perhaps there is a sensible way to generalize this.

Change 383443 had a related patch set uploaded (by Bartosz Dziewoński; owner: Bartosz Dziewoński):
[mediawiki/core@master] Add test cases for digit grouping (commafy) in Polish

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

Change 383444 had a related patch set uploaded (by Bartosz Dziewoński; owner: Bartosz Dziewoński):
[mediawiki/core@master] Generalize non-digit-grouping of four-digit numbers

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

Change 383445 had a related patch set uploaded (by Bartosz Dziewoński; owner: Bartosz Dziewoński):
[mediawiki/core@master] mediawiki.language: Implement non-digit-grouping of four-digit numbers

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

Change 383443 merged by jenkins-bot:
[mediawiki/core@master] Add test cases for digit grouping (commafy) in Polish

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

@matmarex
Checked plwiki (wmf.4) - the fix is not there?

Btw, Preferences-Recent Changes "Number of edits to show" option verifies user input efficiently - giving warnings for negative, more than 1,000, or non-numeric values.

It is not fixed yet. Santhosh proposed a bigger rewrite of this code and I haven't had time to review it yet.

Change 383444 merged by jenkins-bot:
[mediawiki/core@master] Generalize non-digit-grouping of four-digit numbers

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

Patch https://gerrit.wikimedia.org/r/383445 is still waiting for review. The other two were preparation/refactoring, this one is needed to fix this.

Nemo_bis triaged this task as Medium priority.Jan 2 2018, 2:57 PM

Change 383445 merged by jenkins-bot:
[mediawiki/core@master] mediawiki.language: Implement non-digit-grouping of four-digit numbers

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