Difference between revisions of "Template:Convert/doc"
(4 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
− | < | + | <!-- EDIT TEMPLATE DOCUMENTATION BELOW THIS LINE --> |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
__NOTOC__ | __NOTOC__ | ||
− | + | ==Purpose== | |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | To show quantities in a primary and secondary display, such as {{convert|32|m|ft|1}}, or {{convert|18|°C|°F|1}}. | |
− | + | == Usage == | |
+ | <tt><nowiki>{{</nowiki>convert|''original_value''|''original_unit''|''conversion_unit''|''round_to''<nowiki>}}</nowiki></tt> | ||
− | + | == Examples == | |
− | + | ||
− | + | ||
− | == | + | |
− | + | ||
{| class="wikitable" | {| class="wikitable" | ||
− | + | |'''Input'''||'''Displays as''' | |
− | + | ||
− | | | + | |
− | || | + | |
|- | |- | ||
− | + | |<nowiki>{{convert|32|m|ft|0}}</nowiki>||{{convert|32|m|ft|0}} | |
|- | |- | ||
− | + | |<nowiki>{{convert|18|°C|°F|1}}</nowiki>||{{convert|18|°C|°F|1}} | |
|- | |- | ||
− | + | |<nowiki>{{convert|10|mi|km|0}}</nowiki>||{{convert|10|mi|km|0}} | |
|- | |- | ||
− | + | |<nowiki>{{convert|25|km|mi|0}}</nowiki>||{{convert|25|km|mi|0}} | |
|- | |- | ||
− | + | |<nowiki>{{convert|1|lb|kg|0}}</nowiki>||{{convert|1|lb|kg|0}} | |
|- | |- | ||
− | | | + | | <nowiki>{{convert|1250|sqft|sqm|1|lk=on}}</nowiki> ||{{convert|1250|sqft|sqm|1|lk=on}} |
+ | |- | ||
+ | |<nowiki>{{convert|20.5|sqkm|sqmi|1|lk=on|abbr=on}}</nowiki>||{{convert|20.5|sqkm|sqmi|1|lk=on|abbr=on}} | ||
|- | |- | ||
− | + | |<nowiki>{{convert|641|acre|sqmi|3|lk=on|abbr=on}}</nowiki>||{{convert|641|acre|sqmi|3|lk=on|abbr=on}} | |
|- | |- | ||
− | | | + | |''However''|| |
|- | |- | ||
− | + | |<nowiki>{{convert|641|acre|sqmi|2|lk=on|abbr=on}}</nowiki>||{{convert|641|acre|sqmi|2|lk=on|abbr=on}} because 640 acres equals one square mile; 641 acres rounded to 2 would equal 1.00 sq mi. Therefore it is displayed as 1 sq mi. | |
|} | |} | ||
− | |||
− | |||
− | |||
− | + | ===Tricks=== | |
− | + | ||
{| class="wikitable" | {| class="wikitable" | ||
− | |||
|- | |- | ||
− | |< | + | ! colspan="2" | <big>'''In order to...'''</big> |
|- | |- | ||
− | |<nowiki> | + | | Use [[United States|U.S.]] spelling || attach <code><nowiki>|sp=us</nowiki></code> |
|- | |- | ||
− | | | + | | Make units [[Wikipedia:Manual of Style (links)|wikilinked]] || attach <code><nowiki>|lk=on</nowiki></code> (The [[WP:MOS|manual of style]] suggests that you only link the first instance). |
|- | |- | ||
− | |<nowiki> | + | | Use the singular for grammar || attach <code><nowiki>|sing=on</nowiki></code> (ex: "The 190 foot (58 m) bridge" as opposed to "feet") |
|- | |- | ||
− | |<nowiki> | + | | Abbreviate all units || attach <code><nowiki>|abbr=on</nowiki></code> |
|- | |- | ||
− | | | + | | Use a / instead ( ) || attach <code><nowiki>|disp=slash</nowiki></code> (or shorthand: <code><nowiki>|disp=/</nowiki></code>) (ex: 190 foot/58 m) |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | = | + | |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
|} | |} | ||
− | == | + | ===Rounding=== |
− | + | The number given for rounding rounds off the result to the power of 1/10 the rounding number. For instance, if the result is 8621 and the round number is '-2', the result will be 8600. If the result is '234.0283043' and the round number is '0', the result will be 234. | |
− | + | == Conversions == | |
− | + | The abbreviations to the right of the units are the abbreviations that can be entered when using the template. Through various revisions of this template, some units have incorporated multiple abbreviations to make the code more flexible for editors, e.g. °F ''or'' F may be entered. Though they may not be the correct abbreviations, the ''correct abbreviation'' will always be displayed when you use {{tl|convert}}. | |
− | + | ---- | |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
{| class="wikitable" | {| class="wikitable" | ||
|- | |- | ||
− | ! colspan=" | + | ! colspan="5" | <big>Units supported by {{tl|convert}}</big> |
|- | |- | ||
− | | | + | | '''system''' || '''unit''' || '''abbreviation ''used in coding'''''<br> (alternative abbreviations) || '''abbreviation ''printed''''' || [[Image:Flag of the United States.svg|20px]] '''US spelling''' <code><nowiki>|sp=us</nowiki></code> |
|- | |- | ||
− | | | + | ! colspan="5" style="font-size: 110%; text-align: left;" | '''Area''' |
+ | |- style="font-size: 90%;" | ||
+ | | style="text-align: center;" | '''[[International System of Units|SI]]''' || [[square metre]] || sqm || m² || square meter | ||
+ | |- style="font-size: 90%;" | ||
+ | | style="text-align: center;" | → || [[square kilometre]] || sqkm || km² || square kilometer | ||
+ | |- style="font-size: 90%; background-color: #FFFFFF;" | ||
+ | | style="text-align: center;" | '''[[Imperial system|Imperial]] & [[United States customary units|U.S. Customary]]''' || [[acre]] || acre || acre (or acres) || | ||
+ | |- style="font-size: 90%; background-color: #FFFFFF;" | ||
+ | | style="text-align: center;" | → || [[square foot]] ||sqft || sq ft || | ||
+ | |- style="font-size: 90%; background-color: #FFFFFF;" | ||
+ | | style="text-align: center;" | → || [[square yard]] ||sqyd || sq yd || | ||
+ | |- style="font-size: 90%; background-color: #FFFFFF;" | ||
+ | | style="text-align: center;" | → || [[square mile]] || sqmi || sq mi || | ||
+ | |- style="font-size: 90%; background-color: #FFFFFF;" | ||
+ | | style="text-align: center;" | → || [[square nautical mile]] || sqnmi || sq nmi || | ||
+ | |- style="font-size: 90%;" | ||
+ | | style="text-align: center;" | '''old metric''' || [[hectare]] || ha || ha || | ||
|- | |- | ||
− | | | + | ! colspan="5" style="font-size: 110%; text-align: left;" | '''Length''' |
+ | |- style="font-size: 90%;" | ||
+ | | style="text-align: center;" | '''SI''' || [[millimetre]] || mm || mm || millimeter | ||
+ | |- style="font-size: 90%;" | ||
+ | | style="text-align: center;" | → || [[centimetre]] || cm || cm || centimeter | ||
+ | |- style="font-size: 90%;" | ||
+ | | style="text-align: center;" | → || [[metre]] || m || m || meter | ||
+ | |- style="font-size: 90%;" | ||
+ | | style="text-align: center;" | → || [[kilometre]] || km || km || kilometer | ||
+ | |- style="font-size: 90%; background-color: #FFFFFF;" | ||
+ | | style="text-align: center;" | '''Imperial & U.S. Customary''' || [[inch]] || in || in || | ||
+ | |- style="font-size: 90%; background-color: #FFFFFF;" | ||
+ | | style="text-align: center;" | → || [[foot (unit of length)|foot]] || ft || ft || | ||
+ | |- style="font-size: 90%; background-color: #FFFFFF;" | ||
+ | | style="text-align: center;" | → || [[yard]] || yd || yd || | ||
+ | |- style="font-size: 90%; background-color: #FFFFFF;" | ||
+ | | style="text-align: center;" | → || [[mile]] || mi || mi || | ||
+ | |- style="font-size: 90%; background-color: #FFFFFF;" | ||
+ | | style="text-align: center;" | → || [[nautical mile]] || nmi || nmi || | ||
+ | |- style="font-size: 90%;" | ||
+ | | style="text-align: center;" | '''Other''' || [[astronomical unit]] || AU || AU || | ||
|- | |- | ||
− | | | + | ! colspan="5" style="font-size: 110%; text-align: left;" | '''Speed''' |
− | |- | + | |- style="font-size: 90%;" |
− | | | + | | style="text-align: center;" | '''SI''' || [[metres per second]] || m:s (m/s) || m/s || meter per second |
− | |- | + | |- style="font-size: 90%;" |
− | | | + | | style="text-align: center;" | → || [[kilometres per hour]] || km:h (km/h ''or'' kph)|| km/h || kilometer per hour |
− | |- | + | |- style="font-size: 90%; background-color: #FFFFFF;" |
− | | | + | | style="text-align: center;" | '''Accepted ''non''-SI''' || [[knot (speed)|knot]] || knot || kt || |
+ | |- style="font-size: 90%;" | ||
+ | | style="text-align: center;" | '''Imperial & U.S. Customary''' || [[feet per second]] || ft:s (ft/s) || ft/s || | ||
+ | |- style="font-size: 90%;" | ||
+ | | style="text-align: center;" | → || [[miles per hour]] || mi:h (mph ''or'' mi/h) || mph || | ||
|- | |- | ||
− | | | + | ! colspan="5" style="font-size: 110%; text-align: left;" | '''Temperature''' |
+ | |- style="font-size: 90%;" | ||
+ | | style="text-align: center;" | '''SI''' || [[kelvin]] || K || K || | ||
+ | |- style="font-size: 90%;" | ||
+ | | style="text-align: center;" | → || [[degrees Celsius]] || °C (C) || °C || | ||
+ | |- style="font-size: 90%; background-color: #FFFFFF;" | ||
+ | | style="text-align: center;" | '''Imperial & U.S. Customary''' || [[degrees Rankine]] || °R (R) || °R || | ||
+ | |- style="font-size: 90%; background-color: #FFFFFF;" | ||
+ | | style="text-align: center;" | → || [[degrees Fahrenheit]] || °F (F) || °F || | ||
|} | |} | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
==Example/monitor page== | ==Example/monitor page== | ||
Monitor quality or look at examples at [[Template:Convert/check]] | Monitor quality or look at examples at [[Template:Convert/check]] | ||
− | |||
− | |||
− | |||
<includeonly> | <includeonly> | ||
− | + | <!-- ADD CATEGORIES BELOW THIS LINE --> | |
− | + | [[Category:SI unit templates|{{PAGENAME}}]] | |
− | + | [[Category:Conversion templates| ]] | |
− | + | <!-- ADD INTERWIKIS BELOW THIS LINE --> | |
− | <!-- | + | [[no:Mal:Convert]] |
− | {{ | + | [[zh:Template:Convert]] |
− | + | ||
− | [[Category: | + | |
− | [[ | + | |
− | [[ | + | |
</includeonly> | </includeonly> |
Latest revision as of 15:44, 11 April 2020
Purpose
To show quantities in a primary and secondary display, such as 32 metres (105 ft), or 18 °C (64.4 °F).
Usage
{{convert|original_value|original_unit|conversion_unit|round_to}}
Examples
Input | Displays as |
{{convert|32|m|ft|0}} | 32 metres (105 ft) |
{{convert|18|°C|°F|1}} | 18 °C (64.4 °F) |
{{convert|10|mi|km|0}} | 10 miles (16 km) |
{{convert|25|km|mi|0}} | 25 kilometres (16 mi) |
{{convert|1|lb|kg|0}} | 1 (Expression error: Unexpected round operator. ) |
{{convert|1250|sqft|sqm|1|lk=on}} | 1,250 square feet (116.1 m²) |
{{convert|20.5|sqkm|sqmi|1|lk=on|abbr=on}} | 20.5 km² (7.9 sq mi) |
{{convert|641|acre|sqmi|3|lk=on|abbr=on}} | 641 acres (1.002 sq mi) |
However | |
{{convert|641|acre|sqmi|2|lk=on|abbr=on}} | 641 acres (1 sq mi) because 640 acres equals one square mile; 641 acres rounded to 2 would equal 1.00 sq mi. Therefore it is displayed as 1 sq mi. |
Tricks
In order to... | |
---|---|
Use U.S. spelling | attach |sp=us
|
Make units wikilinked | attach |lk=on (The manual of style suggests that you only link the first instance).
|
Use the singular for grammar | attach |sing=on (ex: "The 190 foot (58 m) bridge" as opposed to "feet")
|
Abbreviate all units | attach |abbr=on
|
Use a / instead ( ) | attach |disp=slash (or shorthand: |disp=/ ) (ex: 190 foot/58 m)
|
Rounding
The number given for rounding rounds off the result to the power of 1/10 the rounding number. For instance, if the result is 8621 and the round number is '-2', the result will be 8600. If the result is '234.0283043' and the round number is '0', the result will be 234.
Conversions
The abbreviations to the right of the units are the abbreviations that can be entered when using the template. Through various revisions of this template, some units have incorporated multiple abbreviations to make the code more flexible for editors, e.g. °F or F may be entered. Though they may not be the correct abbreviations, the correct abbreviation will always be displayed when you use {{convert}}.
Units supported by {{convert}} | ||||
---|---|---|---|---|
system | unit | abbreviation used in coding (alternative abbreviations) |
abbreviation printed | 20px US spelling |sp=us
|
Area | ||||
SI | square metre | sqm | m² | square meter |
→ | square kilometre | sqkm | km² | square kilometer |
Imperial & U.S. Customary | acre | acre | acre (or acres) | |
→ | square foot | sqft | sq ft | |
→ | square yard | sqyd | sq yd | |
→ | square mile | sqmi | sq mi | |
→ | square nautical mile | sqnmi | sq nmi | |
old metric | hectare | ha | ha | |
Length | ||||
SI | millimetre | mm | mm | millimeter |
→ | centimetre | cm | cm | centimeter |
→ | metre | m | m | meter |
→ | kilometre | km | km | kilometer |
Imperial & U.S. Customary | inch | in | in | |
→ | foot | ft | ft | |
→ | yard | yd | yd | |
→ | mile | mi | mi | |
→ | nautical mile | nmi | nmi | |
Other | astronomical unit | AU | AU | |
Speed | ||||
SI | metres per second | m:s (m/s) | m/s | meter per second |
→ | kilometres per hour | km:h (km/h or kph) | km/h | kilometer per hour |
Accepted non-SI | knot | knot | kt | |
Imperial & U.S. Customary | feet per second | ft:s (ft/s) | ft/s | |
→ | miles per hour | mi:h (mph or mi/h) | mph | |
Temperature | ||||
SI | kelvin | K | K | |
→ | degrees Celsius | °C (C) | °C | |
Imperial & U.S. Customary | degrees Rankine | °R (R) | °R | |
→ | degrees Fahrenheit | °F (F) | °F |
Example/monitor page
Monitor quality or look at examples at Template:Convert/check