Help:Number formatting
Semantic extension(s): | Semantic MediaWiki |
Further extension(s): | NumberFormat |
Keyword(s): | numbers · formatting |
Description:
You can build great collaborative databases with SMW, but it currently lacks when it comes to actually getting the data out exactly as desired - for example in the area of number formatting.
There is currently no way to tell SMW to print out numbers with, say, two decimal places - as it is custom for monetary amounts (see this bug report). As a workaround for this problem, the NumberFormat extension can be used.
Basically you use e.g. 'format=template' or 'format=sum' in inline queries and wrap the NUMBER parameters in "#number_format:
" parser function calls. It is important to switch off MediaWiki's (rudimentary) number formatting by using core MediaWiki's "formatnum:
" parser function for the numbers you pass through.
- Example to format numbers in "German style"
{{#number_format: {{formatnum: {{#ask: [[Category:Payments]] |?Payment amount |format=sum }} |R }} |2 |, |. |, }}
- Result
12345,67 becomes 12.345,67 on a German language instance