Template:Formatnum
This template has been protected from editing to prevent vandalism. Please discuss changes on the talk page or request unprotection. |
Uses Lua: |
This template formats a number in the local format (local numerals, local thousands separator, decimal separator and the pattern of separators [some languages for example have a ten-thousands separator]) of the user's preferred language.
Usage
{{Formatnum |1= |2= |sep= |prec= }}
Template parameters
Parameter | Description | Default | Status | |
---|---|---|---|---|
1 number | number | Number that shall be formatted in local format (must be unformatted [without thousands separators]) | empty | required |
2 lang | language | Language code (only needs to be provided if the language shall be fixed and independent from the user's preferences) | {{int:lang}} | optional |
sep | without thousands separators | Set to any non-empty value to remove thousands separators (e.g. for dates) | empty | optional |
prec | precision | Decimal place, minimal number of bytes behind the decimal point to show (valid range: 0–14). This needs to be set if zeros at the end of the number shall be visible (otherwise e.g. 0.100 will be converted to 0.1) | empty | optional |
<templatedata>JSON</templatedata> ./. {{TemplateBox}}
TemplateData is a way to store information about template parameters (the description of those and of the whole template) for both humans and machines. It is used by VisualEditor and possibly other tools like Upload Wizard. Existing template documentation Newly created template documentation and imports Wikipedia's help about TemplateData • Commons-specific information This template formats a number in the local format (local numerals, local thousands separator, decimal separator and the pattern of separators [some languages for example have a ten-thousands separator]) of the user's preferred language.
|
Additional information
The template is intended to be used in the following namespaces: the Template namespace
The template is intended to be used by the following user groups: all users
Relies on:
Module:Formatnum
Localization
This template is not intended to be localized.
Internationalization is made using MediaWiki's built-in number formatter (except for some languages not yet supported in MediaWiki).
Examples
{{formatnum|100000}}
→ 100,000{{formatnum|100000|sep=0}}
→ 100,000{{formatnum|100000|sep=no}}
→ 100,000{{formatnum|12345.67}}
→ 12,345.67{{formatnum|-102}}
→ −102{{formatnum|1234567890|ar}}
→ ١٬٢٣٤٬٥٦٧٬٨٩٠
Remark
- It is not compatible with tables sorting. The value is not detected as a number.