This template shows measurement quantities as primary and converted secondary units (or ranges), with optional rounding, wikilinks, abbreviation, or US spellings, and various separators including: parentheses ( ), or, hyphens, comma, to or dashes.
This template employs intricate features of template syntax. You are encouraged to familiarise yourself with its setup and parser functions before editing the template. If your edit causes unexpected problems, please undo it quickly, as this template may appear on a large number of pages. Remember that you can conduct experiments, and should test all improvements, in either the general Template sandbox or your user space before changing anything here. |
This project or template has a transwiki guide to help editors adapt it to a remote wiki when this cannot be done by simply copying the codes of one single template. See Nodyn:Convert/Transwiki guide for instructions. |
The Template:Convert and most of its high-risk subtemplates have been protected so that only admins can edit them. Discuss proposed changes on the Convert talk-page. |
The can help users by generating correct conversions from one unit of measurement to another, particularly for more complex units. It's also useful by making the text adhere to the Manual of Style. The text the template generates does not differ from a plain text equivalent, however.
Styles include: distance "32 metre (105 ft)" and "32 metre or 105 feet"; temperature "18 °C (64 °F)"; mass "55.0 kg (121.3 lb)" or "65 to 80 kg (143 to 176 lb)"; etc. For units see: Convert/list of units.
Options include: | lk=in , abbr=on , abbr=off , sp=us , adj=on , adj=mid , disp=x , disp=table and sortable=on (explained below). By default, output is rounded to match the precision of input; alternatives include: sigfig=3 or using the end parameter, such as "|1 " to show tenths or "|-2 " to show full 100's, etc. |
Single value:
{{convert|value|in_unit|out_unit|round_to|...}}
Range of 2 values, or set of 3 or 4 (see below for list of range options):
{{{convert|val1|range|val2 |in_unit|out_unit|round_to|...}} {{{convert/3 |val1|range|val2|words|val3|in_unit|out_unit|round_to|...}} {{{convert/4 |val1|words|val2|words|val3|words|val4|in_unit|out_unit|...}}
oz
, for example, is for the avoirdupois ounce (a unit of mass), do not use this if you want fluid ounces. Note also that the code lb
gives pounds mass, for pounds force use lbf
.Input | Displays as |
{{convert|3.21|kg|lb}} | 3.21 kilogram (7.1 lb) |
{{convert|3.21|kg|lb|0}} | 3.21 kilogram (7 lb) |
{{convert|10|kg|lb|disp=or}} | 10 kilogram or 22 pound |
{{convert|6|ft|5|in|m}} | 6 feet 5 inches (1.96 m) |
{{convert|10|mi}} | 10 mile (16 km) |
{{convert|100|mpgus}} | 100 mile y US gallon (2.4 L/100 km; 120 mpg‑imp) |
{{convert|120|km/h}} | 120 kilometres per hour (75 mph) |
{{convert|18|°C|°F}} | 18 °C (64 °F) |
{{convert|1250|sqft|m2|lk=in|sigfig=2}} | 1,250 troedfedd sgwar (120 m2) Note 'lk=in' links only the input unit. This example is for illustration only, common units of measurement should not be linked. See: wp:overlink. |
{{convert|20.5|m3|cuyd|lk=out|abbr=on}} | 20.5 m3 (26.8 cu yd) Note 'lk=out' links only the output unit, cu yd. |
{{convert|641|acre|ha sqmi|lk=on}} | 641 acr (259 ha; 1.002 mi sgw) Note 'lk=on' links all units. Per guidelines, common units should not be linked. See: wp:overlink. |
{{convert|641|acre|ha sqmi|2|lk=on}} | 641 acr (259.40 ha; 1.00 mi sgw) Although 640 acres equals 1 square mile; 641 acres rounded to two decimal places equals 1.00 sq mi. |
Input | Displays as |
{{convert|60|and|170|kg|lb}} | 60 and 170 kilogram (130 and 370 lb) |
{{convert|60|to|170|kg|lb}} | 60 to 170 kilogram (130 to 370 lb) |
{{convert|60|to(-)|170|kg|lb}} | 60 to 170 kilogram (130–370 lb) |
{{convert|60|-|170|kg|lb}} | 60–170 kilogram (130–370 lb) |
{{convert|41|to|50|F|C}} | 41 to 50 °F (5 to 10 °C) |
{{convert|41|-|50|F|K}} | 41–50 °F (278–283 K) |
{{convert|60|x|120|m|ft}} | 60 by 120 metre (200 ft × 390 ft) |
{{convert|60|+/-|10|m|ft}} | 60 ± 10 metre (197 ± 33 ft) |
{{convert|19|to|27|L|USgal}} | 19 to 27 litre (5.0 to 7.1 US gal) |
{{convert|5|to|7|L|USgal|abbr=mos}} | 5 to 7 litre (1.3 to 1.8 US gal)* |
{{convert|4|-|9|L|USgal|abbr=off}} | 4–9 litre (1.1–2.4 US gallon) |
The following conversions are currently not available as a range of values:
Input | Displays as |
{{convert/3 |2|x|4|x|6|m|ft}} | 2×4×6 metre (6.6×13×20 ft) |
{{convert/3 |60|-|70|-|80|kg|lb}} | 60–70–80 kilogram (130–150–180 lb) |
{{convert/4 |60|-|70|-|80|-|90|kg|lb}} | Nodyn:Convert/4 |
{{convert/3 |60|to|80|or|85|m|ft}} | 60 to 80 or 85 metre (200 to 260 or 279 ft) |
{{convert/3 |11|by|15|rarely|16|ft|m}} | 11 by 15 rarely 16 feet (3.4 by 4.6 rarely 4.9 m) |
{{convert/3 |41|to|50|to|60|F|C}} | 41 to 50 to 60 °F (5 to 10 to 16 °C) |
{{convert/4 |2|to|12|, in summer|25|to|36|C|F}} | Nodyn:Convert/4 |
{{convert/3 |41|-|50|almost|51|F|K}} | 41–50 almost 51 °F (278–283 almost 284 K) |
For {{{convert/3}} or {{{convert/4}}, the separator words can be any text.
Parameters | |
---|---|
Use US spelling | attach |sp=us |
Make units linked | attach |lk=on to link all units (default: lk=off)attach |lk=in to link only the input unitsattach |lk=out to link only the output units(The manual of style suggests that you should not link common units of measurement). |
Use the adjective form, or insert mid-text words | attach |adj=on (e.g. "190-foot (58 m) bridge" instead of "190 feet...").
attach
Note 1: Any rounding-parameter should follow the mid-text: "text|0".
|
Abbreviate units, or not | attach |abbr=on to show unit symbolsattach |abbr=off to show all unit names in full wordsattach |abbr=in to abbreviate input unitsattach |abbr=out to abbreviate output unitsattach |abbr=values to suppress unit names & show only values. So, {{convert|6|mi|abbr=values}} gives: 6 (9.7). |
Change "( )" to display other separators | attach |disp=comma to put comma, not brackets/parenthesesattach |disp=or to put "or" between units.The default value is: disp=b for brackets/parentheses. |
Change "( )" to customized separators | attach |disp=x| (begin | end) to show "xx (begin yy end)" See example 1attach |disp=x|; to show "xx; yy" See example 2attach |disp=x| (same as |) to show "xx (same as yy)". See example 3Example 1: {{convert|9|km|mi|disp=x| [|]}}→9 kilometres [5.6 mi] (note space before [|) Example 2: {{convert|9|km|mi|disp=x|;}}→9 kilometres;5.6 mi Example 3: {{convert|10|km|mi|disp=x| (about |)}}→10 kilometres (about 6.2 mi) (note spaces used within the code). |
Display output only | attach |disp=output only to show result number & unitattach |disp=output number only to show just numberNote when using "disp=output only" then the unit name can still be shown as full words by abbr=off or linked by lk=on. |
Display units inverted as reverse order | attach |disp=flip to reverse the order & show output unit first.So, {{convert|6|km|disp=flip}} shows "3.7 miles (6 km)". To get symbol "mi" use abbr=in, to abbreviate the input unit (left-side unit). |
Display unit name (only) | attach |disp=unit to show the unit name for a symbolThe unit name will be plural when the amount is not 1, or hyphenated when adj=on. So, {{convert|2|cuyd|disp=unit}} shows "cubic yards" plural. |
Display amounts as table cells | attach |disp=table (or |disp=tablecen) Note: For use in tables, the template must start on a new line after a pipe. Only the number will be displayed unless you set |abbr=on , |lk=on , |lk=in or |lk=out . Example: here |
Round to a specified number of significant figures | attach |sigfig={some integer greater than zero} . In the case of temperatures Celsius or Fahrenheit this refers to the difference with the absolute-zero temperature. For example, at room temperature two significant digits means rounded to tens of degrees. |
Round by 5 | attach |disp=5 to round the output amount to the nearest 5 units. Not supported for all options. |
Let Convert decide the unit to convert to | skip the precision parameter (the 3rd or 4th unnamed parameter) e.g. {{convert|100|km|kn}} gives 100 kilometre ([convert: unit mismatch]) and {{convert|100|km}} gives 100 kilometre (62 mi). |
Display input value with a fraction | {{convert|3/8|in|mm|3|abbr=on}} → 3⁄8 in (9.525 mm) or {{convert|11+1/4|in|cm|2|abbr=on}} → 11 1⁄4 in (28.58 cm) For negative amounts, use two minus signs (hyphens): -11-1/4. |
Generate a hidden sort key for use with a sortable table | attach |sortable=on to generate a hidden sort key so that sortable tables will sort correctly. This uses Nodyn:Tp to generate a sort key from the first numeric value. It ignores any additional values, ie, if you use 6|ft|2|in as the value, it will only use the 6 for the sort key. This will cause numeric values to sort in numeric order, ie: 5, 10, 15 instead of 10, 15, 5. |
Parameters still under construction. May not work in all situations | |
---|---|
disp=5 | The output will be rounded to the nearest 5 units. Might not work when linking unit names. |
disp=tablecen | Similar to disp=table except that the values with be centered within the column. See the tables at La Nouvelle branch, BM-21 Grad for in use examples. |
disp=comma | The two values will be separated by a comma, for situations where the first value is already within parentheses. See the Geography tables on Labrador for an example. |
abbr=in | Abbreviates only the input unit. |
abbr=out | Abbreviates only the output unit. |
abbr=comma | "Abbreviates" (removes) commas. For ranges, using abbr=comma conflicts with internal options, so instead, append "nocomma" to a range-word: tonocomma, bynocomma, andnocomma, -nocomma & xnocomma. |
abbr=mos | For ranges, abbreviates with the input unit repeated, twice. Not to be confused with the specifications at MOS:NUM#Conventions. |
disp=br | This separates input and output units with a forced line break. This can be useful in tables with limited horizontal space. |
disp=sqbr | Shows square brackets "[ ]" instead of parentheses "( )" in output. Example: 55 miles [89 km]. This option can be used in direct quotes, to show conversions in editorial brackets. See: attach |disp=x|[|] , above, as another way of showing brackets "[ ]". |
Convert supports four types of rounding:
|sigfig={some integer greater than zero}
as noted above.Examples of default rounding | ||
---|---|---|
Input | Displays as | Note |
{{convert|550|ft|m|0}} | 550 feet (168 m) | Approximate value is 167.64 m |
{{convert|550|ft|m}} | 550 feet (170 m) | Rounds to 170, when approximate value is 167.64 m |
{{convert|500|ft|m|0}} | 500 feet (152 m) | Approximate value is 152.4 m |
{{convert|500|ft|m}} | 500 feet (150 m) | Rounds to 150, when approximate value is 152.4 m |
The table below lists units supported by this template. It is divided up according to the quantity being measured. Not all supported units are listed here; there are links to more complete lists for each quantity.
The codes listed in the code column (column 3) are accepted as input by the template. These can be used as the second or third unnamed parameter. For some units there exist alternative codes. These are listed in brackets and have been incorporated to make the code more flexible for editors, e.g. °F or F may be entered.
The codes listed in the combinations column (column 7) can be used to produce multiple conversions. They can only be used as the third unnamed parameter, e.g. {{convert|55|nmi|km mi}}
produces "55 nautical mile (102 km; 63 mi)".
Abridged list of units supported by {{Convert}} Nodyn:Convert/list of units/explanation Nodyn:Convert/list of units/length/short list | |||||||
---|---|---|---|---|---|---|---|
AREA (Rhestr lawn) | |||||||
system | unit | unit- code | abbrev- iation | notes | sample default conversion | combination output units | |
SI | square kilometre | km2 | km2 | US spelling: square kilometer | 1.0 km2 (0.39 mi sgw) |
| |
square metre | m2 | m2 | US spelling: square meter | 1.0 m2 (11 tr sg) |
| ||
square centimetre | cm2 | cm2 | US spelling: square centimeter | 1.0 cm2 (0.16 sq in) |
| ||
square millimetre | mm2 | mm2 | US spelling: square millimeter | 1.0 mm2 (0.0016 sq in) |
| ||
nid-SI metrig | hectar | ha | ha | 1.0 ha ([convert: unknown unit]) | |||
Imperial & US arferol | milltir sgwar | sqmi | mi sgw | 1.0 mi sgw (2.6 km2) |
| ||
acr | acre | (none) | 1.0 acr (0.40 ha) | ||||
llathen sgwar | sqyd | sq yd | 1.0 sq yd (0.84 m2) | ||||
troedfedd sgwar | sqft (sqfoot) | tr sg | Nodyn:Convert/list of units/foot note | 1.0 tr sg (0.093 m2) |
| ||
modfedd sgwar | sqin | sq in | 1.0 sq in (6.5 cm2) |
| |||
Arall | square nautical mile | sqnmi | sq nmi | 1.0 sq nmi (3.4 km2; 1.3 mi sgw) | |||
dunam | dunam | (none) | For alternative spellings and definitions see the full list | 1.0 dunam (0.0010 km2; 0.00039 mi sgw) | |||
tsubo | tsubo | (none) | 1.0 tsubo (3.3 m2) | Nodyn:Convert/list of units/volume/short list Nodyn:Convert/list of units/speed/short list Nodyn:Convert/list of units/force/short list Nodyn:Convert/list of units/energy/short list Nodyn:Convert/list of units/temperature/short list Nodyn:Convert/list of units/mass/short list Nodyn:Convert/list of units/torque/short list Nodyn:Convert/list of units/extra |
Mae'r ddogfennaeth uchod wedi ei thrawsgynnwys o Nodyn:Convert/doc. (golygu | hanes) Gall golygyddion arbrofi yn y tudalennau pwll tywod (creu | drych) a testcases (creu). Os gwelwch yn dda, ychwanegwch gategorïau a rhyngwicis at yr is-dudalen /doc. Is-dudalennau'r nodyn hwn. |