Extension:FormatNum
From MediaWiki.org
|
FormatNum Release status: stable |
|||
|---|---|---|---|
| Implementation | Parser function | ||
| Description | Passes number formating instruction to PHP function number_format | ||
| Author(s) | DaSch | ||
| Last version | 0.5.1 (2012-08-27) | ||
| License | GPL | ||
| Download | github | ||
|
|||
| Check usage and version matrix | |||
Extension FormatNum makes it easier to format numbers in the style you want, independent of language settings. For input "english" format is used with point as decimal separator.
Contents |
Usage [edit]
- {{#formatnum:number|number of decimals|decimal separator|thousand separator|old thousand separator}}
- {{#formatnum:number|decs=number of decimals|dsep=decimal separator|tsep=thousand separator|otsep=old thousand separator|format=DIN or ISO|mint=minimal number to separate thousands}}
- otsep: thousands separator in the number given, that will be removed. For example when having a number like 123.456.789,123 and setting otsep=. will remove all points from the number before converting.
- mint: the minimal number given to separate thousands. For example when setting to 4 the number 1234 will remain as is and 12345 will be separated to 12 345.
Examples [edit]
- {{#formatnum: 2300.123|2|,|_}}
- result: 2 300,12
- {{#formatnum: 2300.123|2|.|,}}
- result: 2,300.12
- {{#formatnum: 2300.123|2}}
- result: 2,300.12
- {{#formatnum: 2300.123|2|,|t}}
- result: 2 300,12
As thousand separator the following parameters can be also used
- n – will be
- t – will be  
Repository [edit]
Download [edit]
- Git Download (clone)
git clone https://github.com/DaSchTour/FormatNum.git
Installation [edit]
Download the files from github. Put them in /extensions/FormatNum and add the following to your LocalSettings.php
require_once( "$IP/extensions/FormatNum/FormatNum.php" );
Use Example [edit]
On Wikipedia formatting of numbers is done with complex templates like this. With the #formatnum parser this would be a lot easier.
See also [edit]
- Extension:NumberFormat
- Bugzilla:40422 - review and deployment request