Module:Convert/extra/doc
This module can be used to quickly add a new unit for use with {{tl|convert}}. When satisfied that a unit is working correctly, ask at [[Module talk:Convert]] for the unit to be moved to the permanent list of units.
 
 See [[Template:Convert/unit sandbox]] for a good way to prepare unit definitions that can be copied into this page.
 
 The following extracts from [[Module:Convert/data]] show examples that could be used to define a new unit. Any number of spaces can be used where blanks are shown in the following.
 
 {{collapse top|title=Examples for additions to &lt;code&gt;Module:Convert/extra&lt;/code&gt; &lt;small&gt;(For the actual module code see [[#EndOfDoc|below]])&lt;/small&gt;|bg=#CEF2E0|b-color=#A3BFB1|bg2=#F5FFFA|expand=true}}
 
 &lt;syntaxhighlight lang=&quot;lua&quot; highlight=&quot;1&quot;&gt;
 -- These are EXAMPLES on the documentation page. Scroll down to see the module content.
 local extra_units = {
     -- Similar to a redirect: &quot;sqm&quot; is an alias for &quot;m2&quot;.
     -- {{convert|1.5|m2|sp=us}}  → 1.5 square meters (16 sq ft)
     -- {{convert|1.5|sqm|sp=us}} → 1.5 square meters (16 sq ft)
     [&quot;sqm&quot;] = {
         target   = &quot;m2&quot;,
     },
     -- A simple unit, showing the minimum that is required.
     -- The &quot;ha&quot; is the unit code used to identify the unit:
     -- {{convert|1.5|ha}} → 1.5 hectares (3.7 acres)
     [&quot;ha&quot;] = {
         name1    = &quot;hectare&quot;,
         symbol   = &quot;ha&quot;,
         utype    = &quot;area&quot;,
         scale    = 10000,
         default  = &quot;acre&quot;,
     },
     -- A unit which accepts an SI prefix. There is no &quot;name1&quot; field because it
     -- has to be constructed (mJ gives &quot;millijoule&quot;; MJ gives &quot;megajoule&quot;).
     -- {{convert|125|kJ}} → 125 kilojoules (30,000 cal)
     [&quot;J&quot;] = {
         _name1   = &quot;joule&quot;,
         _symbol  = &quot;J&quot;,
         utype    = &quot;energy&quot;,
         scale    = 1,
         prefixes = 1,
         default  = &quot;cal&quot;,
         link     = &quot;Joule&quot;,
     },
     -- A unit where US and plural names are required.
     -- {{convert|125|cm/s2}} → 125 centimetres per second squared (4.1 ft/s²)
     [&quot;cm/s2&quot;] = {
         name1    = &quot;centimetre per second squared&quot;,
         name1_us = &quot;centimeter per second squared&quot;,
         name2    = &quot;centimetres per second squared&quot;,
         name2_us = &quot;centimeters per second squared&quot;,
         symbol   = &quot;cm/s&lt;sup&gt;2&lt;/sup&gt;&quot;,
         utype    = &quot;acceleration&quot;,
         scale    = 0.01,
         default  = &quot;ft/s2&quot;,
         link     = &quot;Gal (unit)&quot;,
     },
     -- A &quot;per&quot; unit is defined as the ratio of two other units.
     -- {{convert|125|g/cm3}} → 125 grams per cubic centimetre (4.5 lb/cu in)
     [&quot;g/cm3&quot;] = {
         per      = { &quot;g&quot;, &quot;cm3&quot; },
         utype    = &quot;density&quot;,
         default  = &quot;lb/cuin&quot;,
     },
     -- If the automatic &quot;per&quot; link is not wanted, a link can be specified.
     -- {{convert|125|g/cm3|lk=on|disp=unit}} → [[gram]]s per [[cubic centimetre]]
     -- {{convert|125|g/m3|lk=on|disp=unit}} → [[density|grams per cubic metre]]
     [&quot;g/m3&quot;] = {
  per  = { &quot;g&quot;, &quot;m3&quot; },
  utype  = &quot;density&quot;,
  default  = &quot;lb/cuyd&quot;,
  link  = &quot;density&quot;,
     },
     -- Characters &quot;$&quot; and &quot;£&quot; are recognized as currency symbols.
     -- {{convert|125|$/acre}} → $125 per acre ($310/ha)
     [&quot;$/acre&quot;] = {
         per      = { &quot;$&quot;, &quot;acre&quot; },
         utype    = &quot;cost $ per unit area&quot;,
         default  = &quot;$/ha&quot;,
     },
     -- An output unit can be defined as a combination of existing units.
     -- {{convert|2|ha|ft2 m2}} → 2 hectares (220,000 sq ft; 20,000 m²)
     -- Any number of output units can be specified.
     -- NOTE: There may be no need to define a combination because a convert
     --       can specify the output by joining unit codes with &quot;+&quot;:
     -- {{convert|1.2|acre|ft2+yd2+m2}} → 1.2 acres (52,000 sq ft; 5,800 sq yd; 4,900 m²)
     [&quot;ft2 m2&quot;] = {
         combination = { &quot;ft2&quot;, &quot;m2&quot; },
         utype    = &quot;area&quot;,
     },
     -- An output unit can be defined using subunits (from least to most significant).
     -- {{convert|90|in|ydftin}} → 90 inches (2 yd 1 ft 6 in)
     [&quot;ydftin&quot;] = {
         combination = { &quot;in&quot;, &quot;ft&quot;, &quot;yd&quot; },
         multiple = { 12, 3 },
         utype    = &quot;length&quot;,
     },
 }
 &lt;/syntaxhighlight&gt;
 
 {{collapse bottom}}
 
 {| class=&quot;wikitable&quot;
 ! Field !! Description
 |-
 | &lt;code&gt;symbol&lt;/code&gt; || Unit identifier used when &lt;code&gt;abbr=on&lt;/code&gt; is in effect.
 |-
 | &lt;code&gt;name1&lt;/code&gt; || Singular name of the unit used when &lt;code&gt;abbr=off&lt;/code&gt; is in effect.
 |-
 | &lt;code&gt;name2&lt;/code&gt; || Plural name of the unit; not required if it is the same as &lt;code&gt;name1&lt;/code&gt; plus &quot;s&quot;.
 |-
 | &lt;code&gt;name1_us&lt;/code&gt; || Singular name when &lt;code&gt;sp=us&lt;/code&gt; is in effect; not required if the same as &lt;code&gt;name1&lt;/code&gt;.
 |-
 | &lt;code&gt;name2_us&lt;/code&gt; || Plural name when &lt;code&gt;sp=us&lt;/code&gt; is in effect; not required if the same as &lt;code&gt;name1_us&lt;/code&gt; plus &quot;s&quot;.
 |-
 | &lt;code&gt;utype&lt;/code&gt; || Unit type; must be exactly the same as the &lt;code&gt;utype&lt;/code&gt; of any other unit used in a conversion.
 |-
 | &lt;code&gt;scale&lt;/code&gt; || Number of base units in the unit being defined.
 |-
 | &lt;code&gt;default&lt;/code&gt; || Unit code of the default output used when no output unit is specified in a conversion.
 |-
 | &lt;code&gt;target&lt;/code&gt; || Unit code of an existing unit (the unit being defined &quot;redirects&quot; to the existing unit).
 |-
 | &lt;code&gt;prefixes&lt;/code&gt; || Use 1 if an SI prefix is accepted; 2 is used for &lt;code&gt;m&lt;sup&gt;2&lt;/sup&gt;&lt;/code&gt;, and 3 is used for &lt;code&gt;m&lt;sup&gt;3&lt;/sup&gt;&lt;/code&gt;.
 |-
 | &lt;code&gt;link&lt;/code&gt; || Article title used when &lt;code&gt;lk=on&lt;/code&gt; is in effect; not required if it is the same as &lt;code&gt;name1&lt;/code&gt;.
 |}