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:

To reproduce:

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

Event Timeline

matmarex created this task.Oct 10 2017, 3:07 PM
Restricted Application added a project: Collaboration-Team-Triage. · View Herald TranscriptOct 10 2017, 3:07 PM
Restricted Application added a subscriber: Aklapper. · View Herald Transcript
matmarex claimed this task.Oct 10 2017, 3:26 PM

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

Etonkovidova added a subscriber: Etonkovidova.EditedOct 19 2017, 11:26 PM

@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 Normal priority.Jan 2 2018, 2:57 PM
Tgr awarded a token.Jan 7 2018, 12:00 AM
Amire80 moved this task from Untriaged to Digit localization on the I18n board.Feb 4 2018, 10:45 AM

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

matmarex closed this task as Resolved.Mar 23 2018, 7:41 PM
matmarex removed a project: Patch-For-Review.