Template:Convert/doc

From Uncyclopedia, the content-free encyclopedia
Jump to navigation Jump to search
This is a documentation subpage for Template:Convert.
It contains usage information, categories and other content that is not part of the original template page.
To view the template page itself, see Template:Convert.

Synopsis

  • {{convert|original_value|original_unit|conversion_unit|round_to}}
  • {{convert|orig_val1|range|orig_val2|original_unit|conversion_unit|round_to}}

Examples of the above:

  • {{convert|100|lb|kg|2}}100 pounds (45.36 kg)
  • {{convert|1|-|2|km|mi|1}}1–2 kilometres (0.6–1.2 mi)

Use it within articles when expressing units of length, or within infoboxes asking for heights and weights. This template may not be directly funny, but can be handy; 22.86 Centimetre Nails probably involved a calculator in its writing: {{convert|22.86|cm|in}}22.86 centimetres (9.00 in)

Usage

Further information: wikipedia:Template:Convert

This template can be used to show measurement quantities as primary and converted secondary units (or ranges) comprising distance, temperature, weight, etc. It supports a lot of options not covered here.

  • Numbers must be entered without commas. A leading hyphen represents negative numbers
  • For temperature, you can enter C or F without the °
  • Use |sp=us for American English (e.g. meter). The default is British English (e.g. metre)
  • Ensure that the input and output units are compatible. Do not, for example, attempt to convert inches to pounds. Also beware of units with similar names; the code oz, for example, is for the avoirdupois ounce (a unit of mass), do not use this if you want fluid ounces. Check the manual for accepted units if you're working with something unusual
  • An attempt to convert a unit to itself (e.g. km to km), will result in a template loop. That's a bad thing
  • Preview edits before saving them — this template isn't perfect, and an error should display with a link to the relevant Wikipedia help guide

Tips and tricks

  • By default, output is rounded to match the precision of input. The round value can be negative, e.g. -2 to show full hundreds. This works with temperature conversion, implemented as rounding performed on the absolute-zero temperature scale
  • When used as an adjective, the plural looks incorrect e.g. The 190 feet bridge. Instead use:
    • The {{convert|adj=on|190|ft|m}} bridgeThe 190-foot (58 m) bridge
  • Abbreviations can be turned off: attach |abbr=off
  • Change "( )" to display other separators: values can be /, comma, or or
    • e.g. {{convert|1|yd|m|disp=or}}1 yard or 0.91 metres
  • Display output:
    • attach |disp=output only to show result number and unit
      • attach |abbr=none to show unit name as full words
    • attach |disp=output number only to show just number
    • attach |disp=table (or |disp=tablecen) to show as a table cell[note 1]
    • attach |order=flip to flip output order:
    • e.g. {{convert|6|km|order=flip}} → 3.7 miles (6 km)
  • Let Convert decide the unit to convert to: put zero (0) or skip the convert to parameter (the 3rd unnamed parameter):
    • e.g. {{convert|100|mi|0}}100 miles (161 km)
  • Display input value with a fraction:
    • e.g. {{convert|3/8|in|mm|3|abbr=on}}38 in (9.525 mm)
    • for negative amounts, use 2 minus signs: -11-1/4

  1. 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. Example: here

Examples

Single value

Input Displays as
{{convert|3.21|kg|lb}} 3.21 kilograms (7.1 lb)
{{convert|3.21|kg|lb|0}} 3.21 kilograms (7 lb)
{{convert|10|kg|lb|disp=or}} 10 kilograms or 22 pounds
{{convert|6|ft|5|in|m}} 6 feet 5 inches (1.96 m)
{{convert|2|m|ftin}} 2 metres (6 ft 7 in)
{{convert|10|mi}} 10 miles (16 km)
{{convert|100|mpgus}} 100 miles per 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|sigfig=2}} 1,250 square feet (120 m2)
{{convert|20.5|m3|cuyd|abbr=on}} 20.5 m3 (26.8 cu yd)
{{convert|641|acre|km2 sqmi}} 641 acres (2.59 km2; 1.002 sq mi)
{{convert|641|acre|km2 sqmi|2}} 641 acres (2.59 km2; 1.00 sq mi)[note 1]
  1. Although 640 acres equals 1 square mile; 641 acres rounded to two decimal places equals 1.00 sqmi.

Range of values

Input Displays as
{{convert|60|and|170|kg|lb}} 60 and 170 kilograms (130 and 370 lb)
{{convert|60|to|170|kg|lb}} 60 to 170 kilograms (130 to 370 lb)
{{convert|60|to(-)|170|kg|lb}} 60 to 170 kilograms (130–370 lb)
{{convert|60|-|170|kg|lb}} 60–170 kilograms (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 metres (200 ft × 390 ft)
{{convert|60|+/-|10|m|ft}} 60 ± 10 metres (197 ± 33 ft)
{{convert|19|to|27|L|USgal}} 19 to 27 litres (5.0 to 7.1 US gal)
{{convert|4|-|9|L|USgal|abbr=none}} 4–9 litres (1.1–2.4 US gallons)

History

This template used to be written in pure wikicode, but was thrown off by mismatched parameters even for extremely simple cases. It's been revamped by using wikipedia:Template:Convert/Transwiki guide.

It has a bunch of useless features in Module:Convert/data that will never be used. The Lua table code "pondemaat" is only relevant to talking about ponds in the Netherlands. Because Module:Convert has checks if a table entry exists, removing pondemaat would be straightforward and should only fail with convert: unknown unit.

However, maintenance can be kept low by varying from Wikipedia as little as possible. That is, rather than do the work ourselves, it's smart to pass the buck and steal from Wikipedia, which Wikipedia is super okay with—the documentation remains relevant, and if this breaks, a copy-paste of Wikipedia's modules per their instructions should be sufficient to update code here.