Changes

Template:Convert/doc

8,267 bytes removed, 14:44, 11 April 2020
no edit summary
=== Usage ===<!-- EDIT TEMPLATE DOCUMENTATION BELOW THIS LINE -->This template can be used to show measurement quantities as primary and converted secondary units (or ranges), with optional rounding, wikilinks, abbreviation, or US spellings, and various separators including:&nbsp; parentheses, slash, "or", hyphens, comma, "to" or dashes. Styles include: distance "{{convert|32.0|m|ft}}" and "{{convert|32.0|m|ft|disp=or}}"; temperature "{{convert|18|°C|°F}}" or "{{convert|18|°C|°F|disp=s}}"; weight "{{convert|55.0|kg|lb|abbr=on}}" or "{{convert|65|to|80|kg|lb|abbr=on}}"; etc. For units see: [[Template:Convert/list of units|Convert/list of units]].__NOTOC__{||- bgcolor="#FAFEFF" valign=top|Options&nbsp;include:&nbsp;||[[#lk_in|<code>lkPurpose=in</code>]], [[#abbr_on|<code>abbr=on</code>]], [[#sp_us|<code>sp=us</code>]], [[#adj_on|<code>adj=on</code>]], [[#disp_or|<code>disp=or</code>]], [[#disp_table|<code>disp=table</code>]] and [[#sortable_on|<code>sortable=on</code>]] (explained below). By default, output is [[#Rounding|rounded]] to match the precision of input; alternatives include: <code>sigfig=3</code> or using the end parameter, e.g. appending <code>-2</code> to show full hundreds.|}'''Single value''': <tt><nowiki>{{</nowiki>convert|''original_value''|''original_unit''|''conversion_unit''|''round_to''<nowiki>|...}}</nowiki></tt>
'''Range of values''' (see below for list of ''range'' options): <tt><nowiki>To show quantities in a primary and secondary display, such as {{</nowiki>convert|''orig_val1''32|''range''m|orig_val2ft|''original_unit''1}}, or {{convert|''conversion_unit''18|''round_to''<nowiki>°C|...°F|1}}</nowiki></tt>.
* Numbers must be entered in unformatted form (without commas). == Usage == For negative numbers (i.e. temperatures or precision) use a hyphen as the minus sign for the input number. Values output by the template will be displayed formatted and with a true minus sign where appropriate. To specify with commas, re-code a number as <tt><nowiki>{{formatnum:9,000,500|R}}</nowiki> (becomes 9000500).* Optional parameters, in examples below, allow abbreviated units (abbr=on), or US spellings (sp=us for convert|''meteroriginal_value''), or slash separation (disp=s), or hyphenation (adj=on), etc.* For this template many levels of [[Wikipedia:Template substitution|substitution]] are possible, hence doing this fully, step by step, is cumbersome, use [[Special:ExpandTemplates]] instead.* The template has no in-built capacity for [[dimensional analysis]]. It is therefore up to the user to ensure that the input and output units are compatible. Do not, for example, attempt to convert barrels to tonnes (but see {{tl''original_unit''|bbl to t''conversion_unit''|''round_to''<nowiki>}}). Also beware of units with similar names; the code <code/nowiki>oz</codett>, for example, is for the avoirdupois ounce (a unit of mass), do not use this if you want fluid ounces.* An attempt to convert a unit to itself (e.g. km to km), will result in a template loop.* The range functionality is not fully implemented for all units, so experimentation may be required.* This documentation page tends to lag behind in terms of what the template can do. For details see the talk page and its archives.
===Examples=======Single value====
{| class="wikitable"
|'''Input'''||'''Displays as'''
|-
|<nowiki>{{convert|3.2132|kgm|lbft|0}}</nowiki>||{{convert|3.2132|m|kgft|lb0}}
|-
|<nowiki>{{convert|3.2118|kg°C|lb°F|01}}</nowiki>||{{convert|3.2118|kg°C|lb°F|01}}
|-
|<nowiki>{{convert|10|kg mi|lb km|disp=or0}}</nowiki>||{{convert|10|kg mi|lb km|disp=or0}}
|-
|<nowiki>{{convert|625|ftkm|5mi|in|m0}}</nowiki>||{{convert|625|ftkm|5mi|in|m0}}<!--This is currently broken, see talk page
|-
|<nowiki>{{convert|21|mlb|ftinkg|0}}</nowiki>||{{convert|21|mlb|ftinkg|0}}-->
|-
|<nowiki>{{convert|101250|misqft|sqm|1|lk=on}}</nowiki>||{{convert|101250|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|miabbr=on}}
|-
|<nowiki>{{convert|100641|mpgusacre|sqmi|3|lk=on|abbr=on}}</nowiki>||{{convert|100641|acre|sqmi|3|lk=on|mpgusabbr=on}}
|-
|<nowiki>{{convert''However''|120|km/h}}</nowiki>||{{convert|120|km/h}}
|-
|<nowiki>{{convert|18641|°Cacre|°F}}</nowiki>sqmi||{{convert|18|°C|°F}}|-| <nowiki>{{convert|1250|sqft|m2|lk=in|sigfig=2}}</nowiki> ||{{convert|1250|sqft|m2|lk=in|sigfig=2}}<br/>Note 'lk=in' links only the input unit. This example is for illustration only, common units of measurement should not be linked. See: [[Wikipedia:Only make links that are relevant to the context|wp:overlink]].|- |<nowiki>{{convert|20.5|m3|cuyd|lk=out|abbr=on}}</nowiki>||{{convert|20.5|m3|cuyd|1|lk=out|abbr=on}}<br/>Note 'lk=out' links only the output unit, [[cu yd]].|-|<nowiki>{{convert|641|acre|km2 sqmi|lk=on}}</nowiki>||{{convert|641|acre|km2 sqmi|lk=on}}<br/>Note 'lk=on' links all units. Per guidelines, common units should not be linked. See: [[Wikipedia:Only make links that are relevant to the context|wp:overlink]].|-|<nowiki>{{convert|641|acre|km2 sqmi|2|lk=on}}</nowiki>||{{convert|641|acre|km2 sqmi|2|lkabbr=on}}<br/> Although because 640 acres equals 1 one square mile; 641 acres rounded to two decimal places equals 2 would equal 1.00&nbsp;sq&nbsp;mi. Therefore it is displayed as 1&nbsp;sq&nbsp;mi.
|}
===Tricks=Range of values====:''Note: not yet operational for all units''
{| class="wikitable"
|'''Input'''||'''Displays as'''
|-
! colspan="2" |<nowikibig>{{convert|60|and|170|kg|lb}}'''In order to...'''</nowikibig>||{{convert|60|and|170|kg|lb}}
|-
|Use [[United States|U.S.]] spelling || attach <code><nowiki>{{convert|60|to|170|kg|lb}}sp=us</nowiki>||{{convert|60|to|170|kg|lb}}</code>
|-
|<nowiki>{{convert|60|toMake units [[Wikipedia:Manual of Style (-links)|170wikilinked]] |kg|lb}}attach <code><nowiki>|lk=on</nowiki></code> (The [[WP:MOS||{{convert|60|to(-manual of style]] suggests that you only link the first instance)|170|kg|lb}}.
|-
|Use the singular for grammar || attach <code><nowiki>{{convert|60|-|170|kg|lb}}sing=on</nowiki>||{{convert|60|-|170|kg|lb}}</code> (ex: "The 190 foot (58 m) bridge" as opposed to "feet")
|-
|Abbreviate all units || attach <code><nowiki>{{convert|41|to|50|F|C}}abbr=on</nowiki>||{{convert|41|to|50|F|C}}</code>
|-
|<nowiki>{{convertUse a / instead ( ) |41|-|50 |F|K}}attach </nowikicode>||{{convert|41|-|50 |F|K}}|-|<nowiki>{{convert|60|by|120|m|ft}}disp=slash</nowiki>||{{convert|60|by|120|m|ft}}|-|<nowiki>{{convert|60|x|120|m|ft}}</nowikicode>||{{convert|60|x|120|m|ft}}|-|(or shorthand: <nowikicode>{{convert|60|+/-|10|m|ft}}</nowiki>||{{convert|60|+disp=/-|10|m|ft}}|-|<nowiki>{{convert|19|to|27|L|USgal}}</nowiki>||{{convert|19|to|27|L|USgal}}|-|<nowiki>{{convert|5|to|7|L|USgal|abbr=mos}}</nowikicode>||{{convert|5|to|7|L|USgal|abbr=mos}}|-|<nowiki>{{convert|4|-|9|L|USgal|abbr=none}}<) (ex: 190&nbsp;foot/nowiki>||{{convert|4|-|9|L|USgal|abbr=none}}58&nbsp;m)|}<!--NOTE: rows require "nowiki", using &#123;{ disappears. -->
===Rounding===The following conversions are currently not available as a range number given for rounding rounds off the result to the power of values:*Some imperial 1/10 the rounding number. For instance, if the result is 8621 and US gallonthe round number is '-based units*Fuel consumption units (mpg2', L/100km)<!-- except with <code>|abbr=on</code> no links the result will be 8600. If the result is '234.0283043' and default <code>|disp=</code> -->*Large scale units (e3the round number is '0', e6, e9)*Combination-based units (ft&in, st&lb, lb&oz) due to complexity of the conversionresult will be 234.
===Parameters=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"
|-
! colspan="25" | Parameters<big>Units supported by {{tl|convert}}</big>
|-
| {{anchor'''system''' || '''unit''' || '''abbreviation ''used in coding'''''<br> (alternative abbreviations) || '''abbreviation ''printed''''' ||sp_us}}Use [[Image:Flag of the United States.svg|US20px]] '''US spelling || attach ''' <code><nowiki>|sp=us</nowiki></code>
|-
! colspan="5" style="font-size: 110%; text-align: left;" | {{anchor'''Area'''|lk_in}}Make units - style="font-size: 90%;"| style="text-align: center;" | '''[[Wikipedia:Manual International System of Style (links)Units|wikilinkedSI]] ''' || attach <code><nowiki>[[square metre]] |lk| sqm || m² || square meter|- style=on</nowiki></code> "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.&nbsp; to link all units{{in5Customary]]''' |31}}| [[acre]] || acre || acre (defaultor acres) |||- style="font-size: <tt>lk90%; background-color: #FFFFFF;"| style=off</tt>)<br> attach <code><nowiki>"text-align: center;" |lk→ || [[square foot]] ||sqft || sq&nbsp;ft |||- style=in</nowiki></code> "font-size: 90%; background-color: #FFFFFF;"| style="text-align: center;" | → || [[square yard]] ||sqyd || sq&nbsp; to link only the input units<br> attach <code><nowiki>yd |lk||- style=out</nowiki></code>"font-size: 90%; background-color: #FFFFFF;"| style="text-align: center;" | → || [[square mile]] || sqmi || sq&nbsp; to link only the output units<br>(The mi |||- style="font-size: 90%; background-color: #FFFFFF;"| style="text-align: center;" | → || [[Wikipediasquare nautical mile]] || sqnmi || sq&nbsp;nmi |||- style="font-size:Only make links that are relevant to the context90%;"|manual of style="text-align: center;" | '''old metric''' || [[hectare]] suggests that you should not link common units of measurement).|| ha || ha ||
|-
! colspan="5" style="font-size: 110%; text-align: left;" | {{anchor'''Length'''|adj_on}}Use the adjective form - style="font-size: 90%;"|style="text-align: center;" | attach <code><nowiki>'''SI''' |adj| [[millimetre]] || mm || mm || millimeter|- style=on</nowiki></code> (e"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.gS. &nbsp;Customary''' || [[inch]] || in || in |||- style="The 190font-size: 90%; background-color: #FFFFFF;"| style="text-align: center;" | → || [[foot (58 munit of length) bridge|foot]] || ft || ft |||- style=" as opposed to font-size: 90%; background-color: #FFFFFF;"The 190 feet...| style="). This produces the adjective form—the unit name in the singular with a hyphen (according to the text-align: center;" | → || [[WPyard]] || yd || yd |||- style="font-size:HYPHEN90%; background-color: #FFFFFF;"|Manual of Stylestyle="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;" | {{anchor'''Speed'''|abbr_on}}Abbreviate units, or none - style="font-size: 90%;"|style="text-align: center;" | attach <code><nowiki>'''SI''' |abbr=on<| [[metres per second]] || m:s (m/nowiki><s) || m/code>{{in5s |7}}to show unit symbols{{in5|10}}(defaultmeter per second|- style="font-size: <tt>abbr90%;"| style=off<"text-align: center;" | → || [[kilometres per hour]] || km:h (km/tt>h ''or'' kph)<br> attach <code><nowiki>|abbr=none</nowiki><| km/code> 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.&nbsp; to show all units in full words<br> attach <code><nowiki>Customary''' |abbr=in<| [[feet per second]] || ft:s (ft/nowiki><s) || ft/code> {{in5}} to abbreviate input units<br> attach <code><nowiki>s |abbr||- style=out<"font-size: 90%;"| style="text-align: center;" | → || [[miles per hour]] || mi:h (mph ''or'' mi/nowiki></code>{{in5}}to abbreviate output units.h) || mph ||
|-
| Change display option from ! colspan="( )5" || attach <code>&#124;dispstyle=comma</code>{{in5|4}}to put comma, not parentheses<br> attach <code>&#124;disp=or</code>{{in5|10}}to put "or" between units<br> attach <code>&#124font-size: 110%;disp=s</code> (or <code><nowiki>|disp=/</nowiki></code>) for slash (e.g. 190&nbsp;foot/58&nbsp;metre). The default value istext-align:&nbspleft; disp=b for parentheses." | '''Temperature'''|-| Display output only || attach <code>&#124;dispstyle=output only</code> {{in5|15}} to show result number & unit<br> attach <code>&#124"font-size: 90%;disp=output number only</code>{{in5"|3}}to show just number<br>Note when using "dispstyle=output only" then the unit name can still be shown as full words by abbr=none, or linked by lk=on.|text-align: center;" | Display unit name (only) '''SI''' || attach <code>&#124;disp=unit</code> {{in5[[kelvin]] |7}} to show the unit name for a symbol<br>The unit name will be plural when the amount is not 1, or hyphenated when adj=on. So, <nowiki>{{convert|2K |cuyd|dispK |||- style=unit}}</nowiki> shows "cubic yardsfont-size: 90%;" plural.|style="text-align: center;" | {{anchor|disp_table}}Display amounts as table cells |[[degrees Celsius]] | attach <tt>&#124;disp=table</tt> | °C (or <tt>&#124;disp=tablecen</tt>C) 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 <code><nowiki>|abbr=on</nowiki></code>, <code><nowiki>|lk=on</nowiki></code>, <code><nowiki>°C |lk=in</nowiki></code> or <code><nowiki>|lk=out</nowiki></code>. Example: [[Phnom_Penh#Highways_in_Phnom_Penh|here]]|-| Round to a specified number of significant figures|| attach <code><nowiki>|sigfigstyle={some non"font-negative integer}</nowiki></code>. In the case of temperatures Celsius or Fahrenheit this refers to the difference with the absolutesize: 90%; background-zero temperature. For example, at room temperature two significant digits means rounded to tens of degrees.color: #FFFFFF;"|style="text-align: center;" | Let ''Convert'' decide the unit to convert to|| skip the ''convert to'' parameter (which would otherwise be third unnamed parameter) eImperial & U.gS. <code><nowiki>{{convert|100|mi|0}}</nowiki></code> gives &nbsp;Customary'''{{convert|100|mi[[degrees Rankine]] |0}}''.|-|Display input value as a fraction<br/>°R (still in prototype stage: limited functionalityR)|| <nowiki>{{convert°R |3/8|in|mm|3|abbr- style=on}}</nowiki><"font -size: 90%; background-color=blue>'''→'''</font> {{convert: #FFFFFF;"|3/8|in|mm|3|abbrstyle=on}} or <nowiki>{{convert"text-align: center;" |11+1/4|in|cm|2|abbr=on}}</nowiki><font color=blue>''''''</font>{{convert|11+1/4|in|cm|2|abbr=on}}|-|{{anchor|sortable_on}}Generate a [[Help:Sorting#Sorting with hidden sortkey|hidden sort keydegrees Fahrenheit]] for use with a [[Help:Sorting|sortable table]]|| attach <code><nowiki>|sortable=on</nowiki></code> to generate a [[Help:Sorting#Sorting with hidden sortkey|hidden sort key]] °F (in the form of <code><nowiki><span style="display:none">00000005</span></nowiki></code>F) so that [[Help:Sorting|sortable tables]] will sort correctly. This takes the first numeric value and left pads it with zeros to 16 places. It ignores any additional values, ie, if you use <code>6|ft°F |2|in</code> 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===={| class="wikitable"|-! colspan="2" | Parameters still under construction. May not work in all situations|-|disp=tablecen||Similar to disp=table except that the values with be centered within the column. See the tables at [[La Nouvelle branch]] for in use examples.|-|disp=comma||Similar to disp=s except 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. This is a limited, temporary option, until comma=off can be implemented. 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 as in [[WP:MOS]], with the input unit repeated, twice.|} ===Rounding===''Convert'' supports four types of rounding:;Rounding to a given precision :Specify the desired precision with the fourth unnamed parameter or third unnamed parameter in the case where the ''convert to'' parameter is skipped (see above). The conversion is rounded off to the nearest power of 1Example/10 this 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. ;Rounding to a given number of significant figures:Specify the desired number of significant figures using <code><nowiki>|sigfig={some non-negative integer}</nowiki></code> as noted above. ;Combine both of the above:If both the desired precision and the desired number of significant figures are specified, the conversion will be rounded to the least precise of these. ;Default rounding:If neither the desired precision nor the desired number of significant figures are specified, the conversion will be rounded either to a comparable precision as the input value (the number of digits after the decimal point—or the negative of the number of non-significant zeroes before the point—is increased by one if the conversion is a multiplication by a number between 0.02 and 0.2, remains the same if the factor is between 0.2 and 2, is decreased by 1 if it is between 2 and 20, and so on) or to two significant figures, whichever is the most precise. An exception to this is temperature wherein the conversion will be rounded either to precision comparable to that of the input value or to that which would give three significant figures when expressed in kelvins, whichever is the most precise. === Units supported === {{selfref|See also: [[Template:Convert/list of units|Convert/list of units]]}}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 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. <code><nowiki>{{convert|55|nmi|km mi}}</nowiki></code> produces "{{convert|55|nmi|km mi}}". <div style="height: 400px; overflow: auto; padding: 3px; border: 1px solid #aaa;">{{Convert/list of units}}</div> ===Examples=monitor page==* Monitor quality or look at examples at {{tl|[[Template:Convert/check}}. ===See also===* {{tl|convinfobox}} for use in infoboxes* {{tl|bbl to t}} for converting barrel of oil to tonnes* {{tl|CwtQtrLb to kg}} for converting long hundred weights, quarters and pounds into kilograms* {{tl|DMS2Deg}} for converting degrees, minutes and seconds to decimal degrees* {{tl|HMS2Deg}} for converting [[hour angle]]s, given in hours, minutes and seconds, to decimal degrees* {{t1|height}} for converting and displaying a person's height* {{tl|miles-chains}} for converting miles and chains to kilometres linking "chains"* {{tl|pop density}} for converting a population and area to a density* {{tl|Inflation}} for calculating inflated prices* {{tl|metricate}}
<includeonly>
{{pp-template}}
<!-- ADD CATEGORIES BELOW THIS LINE -->
[[Category:SI unit templates|{{PAGENAME}}]]
[[Category:Conversion templates| ]]
 
<!-- ADD INTERWIKIS BELOW THIS LINE -->
[[es:Plantilla:Convert]]
[[bn:template:Convert]]
[[fr:Modèle:Conversion]]
[[id:Templat:Convert]]
[[it:Template:Converti]]
[[ja:Template:Convert]]
[[no:Mal:Convert]]
[[pt:Predefinição:Convert]]
[[th:แม่แบบ:Convert]]
[[zh:Template:Convert]]
 
</includeonly>