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.2.0 (2010-02-16) | ||
| License | Public Domain | ||
| Download | Download snapshot Subversion [Help] |
||
|
|||
|
Check usage (experimental) |
|||
Extension FormatNum makes it easier to format numbers in the style you want, independent of language settings.
- Usage
{{#formatnum:number|number of decimals|decimal separator|thousand separator}}
- Example
- {{#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 there can be also used the following parameters
- n – will be
- t – will be
[edit] Installation
Download the files from SVN. But them in /extensions/FormatNum and but the following to your LocalSettings.php
require_once( "$IP/extensions/FormatNum/FormatNum.php" );
[edit] Use Example
On Wikipedia formatting of numbers is done with complex templates like this. With the #formatnum parser this would be a lot easier.