Template:Convert/doc
This is a documentation subpage for Template:Convert. It contains usage information, categories and other content that is not part of the original template page. |
This template uses Lua: |
Template {{convert}} calculates a measurement value (number × unit) into the same measurement by a different unit, and then presents the results, formatted. The complete list of unit symbols recognized by the template is here.
For example:
{{convert|2|km|mi}}
→ 2 kilometres (1.2 mi) (km entered, converted into miles){{convert|7|mi|km}}
→ 7 miles (11 km) (mi entered, converted into km)
Numbers can be rounded, units can be abbreviated into symbols:
{{convert|2|km|mi|2|abbr=on}}
→ 2 km (1.24 mi){{convert|7|mi|km|2|abbr=on}}
→ 7 mi (11.27 km)
Value ranges can be entered using |to|...
or |-|...
:
{{convert|2|to|5|km|mi}}
→ 2 to 5 kilometres (1.2 to 3.1 mi){{convert|2|-|5|km|mi}}
→ 2–5 kilometres (1.2–3.1 mi)
Combined effect example:
{{convert|2|-|5|km|mi|2|abbr=on}}
→ 2–5 km (1.24–3.11 mi){{convert|2|and|5|km|mi|sigfig=3|abbr=off}}
→ 2 and 5 kilometres (1.24 and 3.11 miles)
TemplateData[edit source]
Converts measurements to other units.
Parameter | Description | Type | Status | |
---|---|---|---|---|
Value | 1 | The value to convert. | Number | required |
From unit | 2 | The unit for the provided value.
| String | required |
To units | 3 | The units to convert into. Separate units by a space for multiple outputs. In an output unit, use + for a multiplication space.
| String | suggested |
Precision or suffix | 4 | Significant digits after decimal dot or, if negative, exponent of ten. | Number | optional |
Link units | lk | Indication of what units to apply wikilinks to. Use “on” for all, “in” for the input unit, “out” for the output units, or “off” for none of the units. For more fine-grained control over which units to link, use the template multiple times.
| String | optional |
Abbreviation | abbr | Display for the units: “on” to display all units using their unit symbols, “off” to display all units in full words, “in” to display the unit symbol for the input unit, “out” to display the unit symbols for the output units, “unit” to display unit symbols for both input and output units when using scientific notation, “values” for no units at all (neither unit symbols nor full words of units).
| String | suggested |
Spelling | sp | Spelling of units. Use “us” to display unit names using U.S. spelling.
| String | optional |
Adjective | adj | Whether to use adjectival form. Use “on” for singular unit name appended by a hyphen, “mid” to put conversion at end, or “off” (default) for no adjectival form.
| Unbalanced wikitext | optional |
Conversion | disp | Display conversion result: “or”: after ‘or’, “x”: with custom prefix and suffix, “b”: in parentheses, “table”/“tablecen”, “output only”: alone, “output number only”: alone and without unit, “unit”: not at all but input unit; if the value is a number it is used as precision.
| String | optional |
Ordering | order | “flip” returns converted value first, input value second.
| String | optional |
Significant figures | sigfig | Indicates the number of significant figures to be used in rounding. | Number | optional |
Rounding output | round | The type of rounding. “5” rounds the output number to nearest multiple of 5, “25” to nearest multiple of 25, “each” rounds each number in a range. | Number | optional |
Thousands separator | comma | Sets or suppresses the use of thousands separators in the numbers. “off”: no separator; “gaps”: use space instead of comma as thousands separator; “5”: only add thousands separator when the integral part of the number uses 5 positions or more (10,000 or more; if using comma as thousands separator, 1234 would produce '1234', 12345 would produce '12,345').
| Boolean | optional |
Sort key | sortable | “on” generates a hidden sort key
| Boolean | optional |
Spell numbers? | spell | If used, spells input or input and output numbers in words, optionally capitalizing the first
| String | optional |
Singular? | sing | If 'yes', uses singular form of units (deprecated)
| Boolean | deprecated |
Fraction? | frac | fraction as rounding unit | Number | optional |
Currency symbol | $ | sets currency symbol in both units
| String | optional |
Mach altitude (ft) | altitude_ft | Mach (speed) depends on altitide
| Number | optional |
Mach altitude (m) | altitude_m | Mach (speed) depends on altitude | Number | optional |
WD property | input | Reads the property value of the item (article), then converts it
| String | optional |