Module:Convert/extra
Jump to navigation
Jump to search
This module can be used to quickly add a new unit for use with {{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.
Field | Description |
---|---|
symbol |
Unit identifier used when abbr=on is in effect.
|
name1 |
Singular name of the unit used when abbr=off is in effect.
|
name2 |
Plural name of the unit; not required if it is the same as name1 plus "s".
|
name1_us |
Singular name when sp=us is in effect; not required if the same as name1 .
|
name2_us |
Plural name when sp=us is in effect; not required if the same as name1_us plus "s".
|
utype |
Unit type; must be exactly the same as the utype of any other unit used in a conversion.
|
scale |
Number of base units in the unit being defined. |
default |
Unit code of the default output used when no output unit is specified in a conversion. |
target |
Unit code of an existing unit (the unit being defined "redirects" to the existing unit). |
prefixes |
Use 1 if an SI prefix is accepted; 2 is used for m2 , and 3 is used for m3 .
|
link |
Article title used when lk=on is in effect; not required if it is the same as name1 .
|
-- Extra conversion data used by Module:Convert.
--
-- [[Module:Convert/data]] defines all units and is transcluded in all pages
-- where [[Module:Convert]] is used. Testing new units by editing that module
-- would invalidate the cache for all affected pages.
--
-- For quick changes and experiments with new units, this module can be edited.
-- Since this module is transcluded in only a small number of pages, changes
-- should cause little server overhead and should propagate quickly.
--
-- If a unit is defined in the data module, any definition here is ignored,
-- so defining the same unit in both modules is not an error.
-- A unit defined here can refer to units that are also defined here, and
-- can refer to units defined in the data module.
--
-- Periodically, those extra units that are wanted permanently can be removed
-- from here after being added to [[Module:Convert/data]].
local extra_units = {
["100mi"] = {
target = "mi",
multiplier= 100,
},
["100miles"] = {
target = "mi",
symbol = "miles",
multiplier= 100,
},
["g0-temp"] = { -- test how g0 will work in next release; the zero is not in italics
name1 = "standard gravity",
name2 = "standard gravities",
symbol = "''g''<sub>0</sub>",
utype = "acceleration",
scale = 9.80665,
default = "m/s2",
},
["g-force"] = {
name2 = "''g''",
symbol = "''g''",
utype = "acceleration",
scale = 9.80665,
default = "m/s2",
link = "g-force",
},
["kpm"] = {
name1 = "kilopond metre",
name1_us = "kilopond meter",
symbol = "kp⋅m",
utype = "torque",
scale = 9.80665,
default = "Nm lbft",
link = "Kilogram metre (torque)",
},
["miyd"] = {
combination= { "yd", "mi" },
multiple = { 1760 },
utype = "length",
},
["scf2"] = {
name1 = "standard cubic foot",
name2 = "standard cubic feet",
symbol = "scf",
utype = "energy",
scale = 2869.2044809344,
default = "kJ",
link = "Standard cubic foot",
},
["scfoot2"] = {
name1 = "standard cubic foot",
name2 = "standard cubic foot",
symbol = "scf",
utype = "energy",
scale = 2869.2044809344,
default = "kJ",
link = "Standard cubic foot",
},
["mi/kWh"] = {
name1 = "miles per kiloWatt hour",
per = { "mi", "kWh" },
utype = "Energy per unit length",
invert = -1,
default = "kWh/100km",
},
}
return { extra_units = extra_units }