To match PHP side.
Version: 1.22.0
Severity: normal
To match PHP side.
Version: 1.22.0
Severity: normal
The coding style that's emerged for this is mw.language.convertNumber.
// plain parameters mw.msg( key, thing ); //> "Hello $1" => "Hello Thing" // number parameter mw.msg( key, mw.language.convertNumber( edits ) ); //> "$1 edits" => "1,024 edits"
This separates the concerns of message formatting and value formatting, avoids extra dependencies, and I think is much easier to understand by not having to know the special method for a certain thing in addition to learning the "normal" way to do it for other scenarios.
If there was a common problem to avoid or some deeper integration that plain calls can't provide, I would agree there is added value, but in its current form, I think this is all we need?
If one first uses mw.language.convertNumber before passing to mw.msg like here, https://github.com/wikimedia/mediawiki-extensions-ContentTranslation/blob/a861b0256ae4999b6f5998fd3e40c44ee5deaf94/modules/tools/mw.cx.tools.IssueTrackingTool.js#L287-L292 will a plural message like {{PLURAL:$1|$1 warning|$1 warnings}} parse and analysis native digits like ۱ ۲ ۳ just like 1 2 3? The JS counterpart should've followed the same pattern as PHP one
Yes, that works correctly, as the parameter to {{PLURAL:}} in JavaScript is converted back to a plain number first, using mw.language.convertNumber( ..., true ): https://gerrit.wikimedia.org/g/mediawiki/core/+/5b6a8374360032a41832c2e9cb2cba6590a20fa7/resources/src/mediawiki.jqueryMsg/mediawiki.jqueryMsg.js#1232 (it's a bit inelegant that this is how it works, but… it works)
@matmarex I didn't know, it was surprising, thanks, uploaded a patch to use that then https://gerrit.wikimedia.org/r/c/mediawiki/extensions/ContentTranslation/+/1054064 😊