Page MenuHomePhabricator

Change default locale for {{formatnum:}} parser function
Closed, ResolvedPublic

Description

Author: OnTheWhite

Description:
Hi

is possible to change settings in parser function {{formatnum:}} to matching local (italian) conventions, which are different from the default's? In particular, I wish to change decimal separator from the actual dot (.) into comma (,), and digit group separators from the actual comma into   ( ). I hope to have done everything in the correct way

Thanks
Lenore


Version: unspecified
Severity: enhancement
URL: http://it.wikipedia.org

Details

Reference
bz17659

Event Timeline

bzimport raised the priority of this task from to Medium.Nov 21 2014, 10:31 PM
bzimport set Reference to bz17659.
bzimport added a subscriber: Unknown Object (MLST).

On it.wikipedia it looks like the decimal separator already is ",", and the thousands separator is ".". It should be possible to change $separatorTransformTable in MessagesIt.php to use &thinsp instead.

(Changing component, since formatnum is not in the ParserFunctions extension)

OnTheWhite wrote:

(In reply to comment #1)

On it.wikipedia it looks like the decimal separator already is ",", and the
thousands separator is ".". It should be possible to change
$separatorTransformTable in MessagesIt.php to use &thinsp instead.

(Changing component, since formatnum is not in the ParserFunctions extension)

In effect, there's something strange in this function. Some examples

{{formatnum:299792458,56789}} gives 299.792.458.56.789
{{formatnum:299792458.56789}} gives 299.792.458,56789
{{formatnum:299.792.458.56.789|R}} gives 29979245856789
{{formatnum:299.792.458,56789|R}} gives 299792458.56789

it seems to recognize dot as decimal separator and then, effectively, changes it in a comma. Instead it should be (at the moment)

{{formatnum:299792458,56789}} gives 299.792.458,56789

right?

Formatnum is designed for formatting numbers in interface elements with correct decimal and thousand separators given a number in PHP's format "12345.12". It cannot be used to prettyprint already formatted numbers. Except if you run them through |R first.

OnTheWhite wrote:

(In reply to comment #3)

Formatnum is designed for formatting numbers in interface elements with correct
decimal and thousand separators given a number in PHP's format "12345.12". It
cannot be used to prettyprint already formatted numbers. Except if you run them
through |R first.

Ah, ok. So, it should to be changed thousands separator only; bug reopened

(In reply to comment #4)

Ah, ok. So, it should to be changed thousands separator only

I'm unable to parse that sentence.

OnTheWhite wrote:

(In reply to comment #5)

(In reply to comment #4)

Ah, ok. So, it should to be changed thousands separator only

I'm unable to parse that sentence.

Only thousands separator should need to be changed; sorry

The CLDR database says that number format for Italian is 12.345,679
Can you provide a reason why this should be changed against the standard?

OnTheWhite wrote:

(In reply to comment #7)

The CLDR database says that number format for Italian is 12.345,679
Can you provide a reason why this should be changed against the standard?

Sure. If you see [[it:Manuale di stile#Cifre e altri caratteri dei numeri|italian manual of style]], you'll see the correct italian form (corretto): 453&#160;340,53 (&#160;=&nbsp;, but I suppose, for graphical convenience, that the use of &thinsp; would be better. Not-breaking space can be included in a template like this <span style="white-space:nowrap">{{formatnum:}}</span>, right?)

OnTheWhite wrote:

(In reply to comment #8)

(In reply to comment #7)

The CLDR database says that number format for Italian is 12.345,679
Can you provide a reason why this should be changed against the standard?

Sure. If you see [[it:Manuale di stile#Cifre e altri caratteri dei
numeri|italian manual of style]], you'll see the correct italian form
(corretto): 453&#160;340,53 (&#160;=&nbsp;, but I suppose, for graphical
convenience, that the use of &thinsp; would be better. Not-breaking space can
be included in a template like this <span
style="white-space:nowrap">{{formatnum:}}</span>, right?)

Wikilink doesn't work. URL: http://it.wikipedia.org/wiki/Aiuto:Manuale_di_stile#Cifre_e_altri_caratteri_dei_numeri

Changing thousand separator for it would affect everything in MediaWiki in all MediaWiki installations. I don't quite buy it that itwiki style guide would take precedence over other standards.

OnTheWhite wrote:

(In reply to comment #10)

Changing thousand separator for it would affect everything in MediaWiki in all
MediaWiki installations. I don't quite buy it that itwiki style guide would
take precedence over other standards.

Sorry, on meta I read about formatnum (http://meta.wikimedia.org/wiki/Help:Magic_words): "Changes the decimal separator and adds digit group separators (before the decimal separator only) according to the wiki's default locale". From this, I understood that every wiki had its own default for formatnum

Indeed, it is only per language. I'll mark this bug as duplicate of 16273, where more flexible number formatting is requested.

  • This bug has been marked as a duplicate of bug 16273 ***

Bug 16273 has been marked as a duplicate of bug 13025.

  • This bug has been marked as a duplicate of bug 13025 ***