Template:Convert/doc: Difference between revisions

From Citizendium
Jump to navigation Jump to search
imported>Caesar Schinas
(correct SI/Metric)
imported>Daniel Mietchen
m (typo)
 
(17 intermediate revisions by 2 users not shown)
Line 1: Line 1:
This template is used in articles to easily convert one unit to another. This template will always be under construction, as we can’t possibly include conversions ‘’from’’ every possible unit ‘’to’’ every possible unit. However, whenever a conversion isn’t supported, [[User:Drew R. Smith|I]] or any of the other users who have worked on this template would be happy to add conversions when brought to our attention.
{{TOC|right}}
The goal of this template is to make [[Citizendium]] accessable to all readers regardless of nationality. Instead of only showing [[SI units|SI/Metric units]] or [[Imperial units]], {{tl|convert}} automatically converts a number from the specified unit to another unit and displays it as "'''Metric (Imperial)'''" or "'''Imperial (Metric)'''", depending on which unit was converted from.
This template is used in articles to easily convert one unit to another. This template will always be under construction, as we can’t possibly include conversions ''from'' every possible unit ''to'' every possible unit. Should you find a combination of unis which isn't supported but which you think should be, please {{plainlink|{{fullurl:{{TALKPAGENAME}}|action=edit&section=new}} leave a note on the talk page}} and it will be added.<br />
The goal of this template is to make the ''Citizendium'' accessible to all readers regardless of nationality. Instead of only showing [[SI units|SI/Metric units]] or [[Imperial units]], {{tl|convert}} automatically converts a number from the specified unit to another unit and displays it as "'''Metric (Imperial)'''" or "'''Imperial (Metric)'''", depending on which unit was converted from.


<div style="height: 400px; overflow: auto; padding: 3px; border:1px solid #AAAAAA; reflist4" >
== Usage ==
==Supported Conversions==
The template has five parameters - {{tlc|convert|number{{!}}from{{!}}to{{!}}precision{{!}}plain}}.
===Millimeters to...===
# ''required'' &mdash; The number to convert.
====Inches====
# ''required'' &mdash; The unit to convert ''from''.
:<nowiki>{{Convert|10|mm|in}}</nowiki> Produces {{Convert|10|mm|in}}.
# ''required'' &mdash; The unit to convert ''to''.
::Supported parameters include mm, millimetre, millimetres, millimeter, millimeters, in, inch, and inches.
# ''optional'' &mdash; The precision of the result. Positive values cause the specified number of [[decimal place]]s to be shown, whilst negative values cause the numbers to be rounded to the specified number of [[significant figures]]. The default value is ''2'' (2 decimal places).
====Feet====
# ''optional'' &mdash; set the 5th parameter to "plain" to make the template output a plain number, without units and without the input number. If this is used, the previous parameter must be given a value.
:<nowiki>{{Convert|10|mm|ft}}</nowiki> Produces {{Convert|10|mm|ft}}.
::Supported parameters include mm, millimetre, millimetres, millimeter, millimeters, ft, foot, and feet.


===Centimeters to...===
The names of the units can be specified as either abbreviations or full words, using either British or American spelling. The unit names in the output will be in the same format as the input.
====Inches====
:<nowiki>{{Convert|10|cm|in}}</nowiki> Produces {{Convert|10|cm|in}}.
::Supported parameters include cm, centimetre, centimetres, centimeter, centimeters, in, inch, and inches.
====Feet====
:<nowiki>{{Convert|10|cm|ft}}</nowiki> Produces {{Convert|10|cm|ft}}.
::Supported parameters include cm, centimetre, centimetres, centimeter, centimeters, ft, foot, and feet.
===Decimeters to...===
====Inches====
:<nowiki>{{Convert|10|dm|in}}</nowiki> Produces {{Convert|10|dm|in}}.
::Supported parameters include dm, decimetre, decimetres, decimeter, decimeters, in, inch, and inches.
====Feet====
:<nowiki>{{Convert|10|dm|ft}}</nowiki> Produces {{Convert|10|dm|ft}}.
::Supported parameters include dm, decimetre, decimetres, decimeter, decimeters, ft, foot, and feet.
===Meters to...===
====Inches====
:<nowiki>{{Convert|10|m|in}}</nowiki> Produces {{Convert|10|m|in}}.
::Supported parameters include m, metre, metres, meter, meters, in, inch, and inches.
====Feet====
:<nowiki>{{Convert|10|m|ft}}</nowiki> Produces {{Convert|10|m|ft}}.
::Supported parameters include m, metre, metres, meter, meters, ft, foot, and feet.
====Yards====
:<nowiki>{{Convert|10|m|yd}}</nowiki> Produces {{Convert|10|m|yd}}.
::Supported parameters include m, metre, metres, meter, meters, yd, yard, and yards.
====Miles====
:<nowiki>{{Convert|10|m|mi}}</nowiki> Produces {{Convert|10|m|mi}}.
::Supported parameters include m, metre, metres, meter, meters, mi, mile, miles.
====Nautical Miles====
:<nowiki>{{Convert|10|m|nmi}}</nowiki> Produces {{Convert|10|m|nmi}}.
::Supported parameters include m, metre, metres, meter, meters, nmi, nautical mile, nautical miles.
===Kilometers to...===
====Yards====
:<nowiki>{{Convert|10|km|yd}}</nowiki> Produces {{Convert|10|km|yd}}.
::Supported paramaters include km, kilometre, kilometres, kilometer, kilometers, yd, yard, and yards.
====Miles====
:<nowiki>{{Convert|10|km|mi}}</nowiki> Produces {{Convert|10|km|mi}}.
::Supported parameters include km, kilometre, kilometres, kilometer, kilometers, mi, mile, and miles.
====Nautical Miles====
:<nowiki>{{Conver|10|km|nmi}}</nowiki> Produces {{Convert|10|km|nmi}}.
::Supported parameters include km, kilometre, kilometres, kilometer, kilometers, nmi, nautical mile, nautical miles.


===Inches to...===
== Examples ==
====Millimetres====
:<nowiki>{{Convert|10|in|mm}}</nowiki> Produces {{Convert|10|in|mm}}.
::Supported parameters include in, inch, inches, mm, millimetre, and millimetres.
====Centimetres====
:<nowiki>{{Convert|10|in|cm}}</nowiki> Produces {{Convert|10|in|cm}}.
::Supported parameters include in, inch, inches, cm, centimetre, and centimetres.
====Decimetres====
:<nowiki>{{Convert|10|in|dm}}</nowiki> Produces {{Convert|10|in|dm}}.
::Supported parameters include in, inch, inches, dm, decimetre, and decimetres.
====Metres====
:<nowiki>{{Convert|10|in|m}}</nowiki> Produces {{Convert|10|in|m}}.
::Supported parameters include in, inch, inches, m, metre, and metres.
===Feet to...===
====Millimetres====
:<nowiki>{{Convert|10|ft|mm}}</nowiki> Produces {{Convert|10|ft|mm}}.
::Supported parameters include ft, foot, feet, mm, millimetre, and millimetres.
====Centimetres====
:<nowiki>{{Convert|10|ft|cm}}</nowiki> Produces {{Convert|10|ft|cm}}.
::Supported parameters include ft, foot, feet, cm, centimetre, and centimetres.
====Decimetres====
:<nowiki>{{Convert|10|ft|dm}}</nowiki> Produces {{Convert|10|ft|dm}}.
::Supported parameters include ft, foot, feet, dm, decimetre, and decimetres.
====Metres====
:<nowiki>{{Convert|10|ft|m}}</nowiki> Produces {{Convert|10|ft|m}}.
::Supported parameters include ft, foot, feet, m, metre, and metres.
====Kilometres====
:<nowiki>{{Convert|10|ft|km}}</nowiki> Produces {{Convert|10|ft|km}}.
::Supported parameters include ft, foot, feet, km, kilometre, and kilometres.
===Yards to...===
====Millimetres====
:<nowiki>{{Convert|10|yd|mm}}</nowiki> Produces {{Convert|10|yd|mm}}.
::Supported parameters include yd, yard, yards, mm, millimetre, and millimetres.
====Centimetres====
:<nowiki>{{Convert|10|yd|cm}}</nowiki> Produces {{Convert|10|yd|cm}}.
::Supported parameters include yd, yard, yards, cm, centimetre, and centimetres.
====Decimetres====
:<nowiki>{{Convert|10|yd|dm}}</nowiki> Produces {{Convert|10|yd|dm}}.
::Supported parameters include yd, yard, yards, dm, decimetre, and decimetres.
====Metres====
:<nowiki>{{Convert|10|yd|m}}</nowiki> Produces {{Convert|10|yd|m}}.
::Supported parameters include yd, yard, yards, m, metre, and metres.
====Kilometres====
:<nowiki>{{Convert|10|yd|km}}</nowiki> Produces {{Convert|10|yd|km}}.
::Supported parameters include yd, yard, yards, km, kilometre, and kilometres.
===Miles to...===
====Metres====
:<nowiki>{{Convert|10|mi|m}}</nowiki> Produces {{Convert|10|mi|m}}.
::Supported parameters include mi, mile, miles, m, metre, and metres.
====Kilometres====
:<nowiki>{{Convert|10|mi|km}}</nowiki> Produces {{Convert|10|mi|km}}.
::Supported parameters include mi, mile, miles, km, kilometre, and kilometres.
====Nautical Miles====
:<nowiki>{{Convert|10|mi|nmi}}</nowiki> Produces {{Convert|10|mi|nmi}}.
::Supported parameters include mi, mile, miles, nmi, nautical mile, and nautical miles.
===Nautical Miles to...===
====Metres====
:<nowiki>{{Convert|10|nmi|m}}</nowiki> Produces {{Convert|10|nmi|m}}.
::Supported parameters include nmi, nautical mile, nautical miles, m, metre, and metres.
====Kilometres====
:<nowiki>{{Convert|10|nmi|km}}</nowiki> Produces {{Convert|10|nmi|km}}.
::Supported parameters include nmi, nautical mile, nautical miles, km, kilometre, and kilometres.
====Miles====
:<nowiki>{{Convert|10|nmi|mi}}</nowiki> Produces {{Convert|10|nmi|mi}}.
::Supported parameters include nmi, nautical mile, nautical miles, mi, mile, and miles.
</div>
 
==Rounding==
{{tl|Convert}} has an additional parameter that controls roundin. More specifically, it controls how many places after the decimal are displayed. To use this feature, add a value in the fourth parameter. For example <nowiki>{{Convert|10|km|mi|5}}</nowiki> shows up to the fifth decimal place, displaying as {{Convert|10|km|mi|5}}.
===Examples===
<nowiki>{{Convert|547.3|km|mi|0}}</nowiki> hides the decimals, displaying as {{Convert|547.3|km|mi|0}}.
 
<nowiki>{{Convert|547.3|km|mi|1}}</nowiki> shows one decimal, displaying as {{Convert|547.3|km|mi|1}}
 
<nowiki>{{Convert|547.3|km|mi|2}}</nowiki> shows two decimals, displaying as {{Convert|547.3|km|mi|2}}
 
<nowiki>{{Convert|547.3|km|mi|3}}</nowiki> shows three decimals, displaying as {{Convert|547.3|km|mi|3}}
 
<nowiki>{{Convert|547.3|km|mi|10}}</nowiki> shows ten decimals, displaying as {{Convert|547.3|km|mi|10}}
 
==Parameters That Need to be Created==
Add units of measurement, and their conversion formulas, that still need to be created here


{| class="wikitable"
! Code !! Result !! Notes
|-
|{{tlc|convert|123.4{{!}}km{{!}}mi}}
|{{convert|123.4|km|mi}}
|Simple conversion of 123.4 kilometres to miles.
|-
|{{tlc|convert|12{{!}}in{{!}}cm{{!}}0}}
|{{convert|12|in|cm|0}}
|Convert 12 in to cm, rounding to the nearest whole cm.
|-
|{{tlc|convert|60{{!}}nmi{{!}}mi{{!}}6}}
|{{convert|60|nmi|mi|6}}
|Convert 60 nautical miles to statute miles, showing the result to 6 decimal places.
|-
|{{tlc|convert|60{{!}}nautical miles{{!}}miles{{!}}-1}}
|{{convert|60|nautical miles|miles|-1}}
|Convert 60 nautical miles to statute miles, and round the result to one significant figure.
|}


==Supported Conversions==
<small>Transcluded from [[Template:Convert/doc/conversions]] ({{plainlink|{{fullurl:Template:Convert/doc/conversions|action=edit}} edit}})</small>
{{box|style=height:35em; overflow:auto;|
{{Convert/doc/conversions}}
}}
[[Template:Convert/doc/conversions/detail|For in-depth information, see the detailed list.]]
{{br|3}}
<includeonly>[[Category:Conversion templates]]</includeonly>
<includeonly>[[Category:Conversion templates]]</includeonly>

Latest revision as of 08:14, 16 June 2009

This template is used in articles to easily convert one unit to another. This template will always be under construction, as we can’t possibly include conversions from every possible unit to every possible unit. Should you find a combination of unis which isn't supported but which you think should be, please leave a note on the talk page and it will be added.
The goal of this template is to make the Citizendium accessible to all readers regardless of nationality. Instead of only showing SI/Metric units or Imperial units, {{convert}} automatically converts a number from the specified unit to another unit and displays it as "Metric (Imperial)" or "Imperial (Metric)", depending on which unit was converted from.

Usage

The template has five parameters - {{convert|number|from|to|precision|plain}}.

  1. required — The number to convert.
  2. required — The unit to convert from.
  3. required — The unit to convert to.
  4. optional — The precision of the result. Positive values cause the specified number of decimal places to be shown, whilst negative values cause the numbers to be rounded to the specified number of significant figures. The default value is 2 (2 decimal places).
  5. optional — set the 5th parameter to "plain" to make the template output a plain number, without units and without the input number. If this is used, the previous parameter must be given a value.

The names of the units can be specified as either abbreviations or full words, using either British or American spelling. The unit names in the output will be in the same format as the input.

Examples

Code Result Notes
{{convert|123.4|km|mi}} 123.4 km (76.68 mi) Simple conversion of 123.4 kilometres to miles.
{{convert|12|in|cm|0}} 12 in (30 cm) Convert 12 in to cm, rounding to the nearest whole cm.
{{convert|60|nmi|mi|6}} 60 nmi (69.046767 mi) Convert 60 nautical miles to statute miles, showing the result to 6 decimal places.
{{convert|60|nautical miles|miles|-1}} 60 nautical miles (70 miles) Convert 60 nautical miles to statute miles, and round the result to one significant figure.

Supported Conversions

Transcluded from Template:Convert/doc/conversions (edit)

Length Conversions

Metric to Imperial

Inches (in) Feet (ft) Yards (yd) Miles (mi) Nautical Miles (nmi)
Millimetres (mm) Yes Yes No No No
Centimetres (cm) Yes Yes No No No
Decimetres (dm) Yes Yes No No No
Metres (m) Yes Yes Yes Yes Yes
Kilometres (km) No No Yes Yes Yes

Imperial to Metric

Millimetres (mm) Centimetres (cm) Decimetres (dm) Metres (m) Kilometres (km)
Inches (in) Yes Yes Yes Yes No
Feet (ft) Yes Yes Yes Yes Yes
Yards (yd) Yes Yes Yes Yes Yes
Miles (mi) No No No Yes Yes
Nautical Miles (nmi) No No No Yes Yes

Imperial to Imperial

Miles (mi) Nautical Miles (nmi)
Miles (mi) - Yes
Nautical Miles (nmi) Yes -

Weight Conversions

Kilogrammes (kg) Grammes (g) Pounds (lbs) Ounces (oz)
Kilogrammes (kg) - No Yes Yes
Grammes (g) No - Yes Yes
Pounds (lbs) Yes Yes - No
Ounces (oz) Yes Yes No -

Temperature Conversions

Celsius (°C) Kelvin (°K) Fahrenheit (°F) Rankine (°R)
Celsius (°C) - Yes Yes Yes
Kelvin (°K) Yes - Yes No
Fahrenheit (°F) Yes Yes - Yes
Rankine (°R) Yes No Yes -

For in-depth information, see the detailed list.