The {{convert}} plugin is an implementation of the Wikipedia template of the same name, and can be used in much the same way to convert units in one measurement to another, as in miles to kilometres for instance.
Examples and parameters
The plugin is invoked by inserting {{convert|some arguments}} into the text of an article. It accepts an amount in one unit of measurement and converts it to another, inserting the formatted result into the body of the article. {{convert}} takes two mandatory parameters, separated by the “|” character: the quantity to be converted and the code for the units of that quantity; all other parameters are optional.
Units to convert
- {{convert|1000|acre|sqkm}} → 1000 acres (4 km2)
The output unit of measurement can usually be omitted, as each input unit of measurement has an associated default to be converted to. In the case of acres the default is hectares, but that can be overridden and specified explicitly as above:
- {{convert|1000|acre}} → 1000 acres (405 ha)
Unit name or abbreviation in output
By default, the first quantity shows the full name of the unit, the second shows the symbol (or abbreviation):
- {{convert|1|lb}} → 1 pound (0.45 kg)
Using |abbr=on results in the input unit of measurement being abbreviated:
- {{convert|1|lb|abbr=on}} → 1 lb (0.45 kg)
Adjective: a 10-mile distance
Use |adj=on to produce the adjectival (hyphenated) form:
- A {{convert|10|mi|adj=on}} distance → A 10-mile (16 km) distance.
The output is hyphenated only if the input unit of measurement is not abbreviated:
- {{convert|10|mi|abbr=on|adj=on}} → 10 mi (16 km)
Rounding
By default the number of decimal places in the output will be the same as that of the input:
- {{convert|10.5|km}} → 10.5 kilometres (6.5 mi)
This default behaviour can be overridden by using the |r parameter to specify the required number of decimal places:
- {{convert|10.5|km|r=0}} → 10.5 kilometres (7 mi)
- {{convert|10.5|km|r=2}} → 10.5 kilometres (6.52 mi)
Spell out numbers: ten miles
To display a number in words use |spell=in:
- {{convert|100|mi|spell=in}} → one hundred miles (161 km)
If the output from {{convert}} begins a sentence, as in “Twenty-five miles (40 km) down the road …”, and |spell=in has been set, then the leading character can be capitalised with |sentence=on:
- {{convert|25|mi|spell=in|sentence=on}} → Twenty-five miles (40 km)
Units
Conversions can only be carried out between units of the same type, e.g. length or area. It would be meaningless, for instance, to attempt to convert between degrees celsius and kilograms.
Length
System | Unit | Code | Abbreviation | Default conversion |
SI | millimetre | mm | mm | mm => in |
centimetre | cm | cm | cm => in | |
metre | m | m | m => ft | |
kilometre | km | km | km => mi | |
Imperial | inch | in | in | in => cm |
foot | ft | ft | ft => m | |
yard | yd | yd | yd => m | |
mile | mi | mi | mi => km | |
fathom | fathom | fathom | fathom => m | |
furlong | furlong | furlong | furlong=>m |
Area
System | Unit | Code | Abbreviation | Default conversion |
SI | square metre | sqm | m2 | sqm => sqft |
square kilometre | sqkm | km2 | sqkm => sqmi | |
non-SI metric | hectare | ha | ha | ha => acre |
Imperial | square foot | sqft | ft2 | sqft => sqm |
square yard | sqyd | yd2 | sqyd => sqm | |
square mile | sqmi | mi2 | sqmi => sqkm | |
acre | acre | acre | acre => ha |
Weight
System | Unit | Code | Abbreviation | Default conversion |
SI | gram | g | g | g => oz |
kilogram | kg | kg | kg => lb | |
Imperial | ounce | oz | oz | oz => g |
pound | lb | lb | lb => kg | |
hundredweight | cwt | cwt | cwt => kg | |
Troy pound | tlb | t lb | tlb => g |
Speed
System | Unit | Code | Abbreviation | Default conversion |
SI | kilometres per hour | km/h | km/h | km/h => mph |
Imperial | miles per hour | mph | mph | mph => km/h |
Volume
System | Unit | Code | Abbreviation | Default conversion |
SI | litre | l | L | l => impgal |
cubic centimetre | cc | cc | cc => cuin | |
cubic metre | cum | m3 | cum => cuft | |
Imperial | pint | pt | pt | pt => l |
gallon | impgal | Gal | impgal => l | |
cubic inch | cuin | in3 | cuin => cc | |
cubic foot | cuft | ft3 | cuft => cum |