Last modified: 2012-05-08 13:54:57 UTC

Wikimedia Bugzilla is closed!

Wikimedia migrated from Bugzilla to Phabricator. Bug reports are handled in Wikimedia Phabricator.
This static website is read-only and for historical purposes. It is not possible to log in and except for displaying bug reports and their history, links might be broken. See T37922, the corresponding Phabricator task for complete and up-to-date bug report information.
Bug 35922 - formatnum can deformat numbers only if they're in English format
formatnum can deformat numbers only if they're in English format
Status: REOPENED
Product: MediaWiki
Classification: Unclassified
Internationalization (Other open bugs)
unspecified
All All
: Low enhancement (vote)
: ---
Assigned To: Nobody - You can work on this!
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2012-04-12 18:39 UTC by Strainu
Modified: 2012-05-08 13:54 UTC (History)
4 users (show)

See Also:
Web browser: ---
Mobile Platform: ---
Assignee Huggle Beta Tester: ---


Attachments

Description Strainu 2012-04-12 18:39:25 UTC
When using the Romanian locale, inputing an already formatted number converts it to English separators (i.e. replaces dots with commas and commas with dots).

On mediawiki.org it is recommended to use formatnum twice in you don't know the input.

See https://ro.wikipedia.org/wiki/Utilizator:Strainu/formatnum for some examples
Comment 1 Niklas Laxström 2012-04-13 07:29:14 UTC
Garbage in, garbage out. There is no way knowing whether 4,456 is a big or small number.

I would not recommended using formatnum twice.
Comment 2 Strainu 2012-04-13 08:05:04 UTC
(In reply to comment #1)
> There is no way knowing whether 4,456 is a big or
> small number.
> 

I disagree. The locale should prevail. So in Romanian, 4,456 is about 4 and a half and in English it's 4 thousands 4 hundred and fifty six. 

(In reply to comment #1)
> I would not recommended using formatnum twice.

Then the docs should be updated.
Comment 3 Strainu 2012-04-13 08:07:14 UTC
This is particularly useful for formatnum used inside templates - the user writes 4.456 without knowing there is a formatnum somewhere inside and the totally unexpected result is 4,456.
Comment 4 Nemo 2012-04-13 08:11:41 UTC
(In reply to comment #2)
> (In reply to comment #1)
> > There is no way knowing whether 4,456 is a big or
> > small number.
> > 
> 
> I disagree. The locale should prevail. So in Romanian, 4,456 is about 4 and a
> half and in English it's 4 thousands 4 hundred and fifty six. 
> 
> (In reply to comment #1)
> > I would not recommended using formatnum twice.
> 
> Then the docs should be updated.

That line has been added only recently and is not a "recommendation" but the documentation of a hack, not recommended nor reliable as Niklas says. If this is not clear please change its language.
http://mediawiki.org/wiki/Help:Magic_words
Comment 5 Strainu 2012-04-13 08:19:52 UTC
This is still not a reason to close the bug as invalid. There are algorithms (and not that complicated) to determine the value of a number.
Comment 6 Niklas Laxström 2012-04-13 08:58:41 UTC
I do not know who changed the bug title but it is misleading. Formatnum is always able to reverse the formatting of a properly formatted number, but it only works with one locale at a time.

The only valid input for formatnum is plain whole or decimal number. Output for everything else can be anything as far as I am concerned. Formatnum is and will stay as a simple number formatter, mainly to be used in interface message translations. Anything more complicated should be implemented somewhere else.
Comment 7 Strainu 2012-04-13 09:08:24 UTC
Nemo changed it. I've done some more testing at https://ro.wikipedia.org/wiki/Utilizator:Strainu/formatnum and in order to obtain what I want, I have to do {{formatnum:{{formatnum:1,234.56|R}}}}

So, I propose the following:
1. Name the bug "formatnum should reverse formatting on the input before processing the number"
2. mark it as an enhancement
3. update http://mediawiki.org/wiki/Help:Magic_words to mention this instead of the "hack" that I still don't see when it works.
Comment 8 Nemo 2012-04-13 09:29:23 UTC
(In reply to comment #6)
> I do not know who changed the bug title but it is misleading. Formatnum is
> always able to reverse the formatting of a properly formatted number, but it
> only works with one locale at a time.

What do you mean? And are we talking of the function or of the magic word?
The new summary may be misleading, what I mean is that currently there's no way to use the magic word to reverse the formatting of a number which is in the format used by formatnum e.g. on fr and it (spaces or points between thousands), it can only deformat from English locale. Is the new summary better?

(In reply to comment #7)
> 1. Name the bug "formatnum should reverse formatting on the input before
> processing the number"

Doesn't look like a good idea.
Comment 9 Strainu 2012-04-13 09:32:00 UTC
(In reply to comment #8)
> (In reply to comment #7)
> > 1. Name the bug "formatnum should reverse formatting on the input before
> > processing the number"
> 
> Doesn't look like a good idea.

Why not? This way, numbers in the current locale will be handled correctly, while numbers in other locale will be GIGO and will stand out when viewing the page, increasing the chances of being fixed.

Note You need to log in before you can comment on or make changes to this bug.


Navigation
Links