Movatterモバイル変換


[0]ホーム

URL:


Jump to content
WikipediaThe Free Encyclopedia
Search

Module:Convert/extra

Permanently protected module
From Wikipedia, the free encyclopedia
<Module:Convert
Module documentation[view] [edit] [history] [purge]
WarningThis Lua module is used onapproximately 210 pages and changes may be widely noticed. Test changes in the module's/sandbox or/testcases subpages, or in your ownmodule sandbox. Consider discussing changes on thetalk page before implementing them.

This module can be used to quickly add a new unit for use with{{convert}}. When satisfied that a unit is working correctly, ask atModule talk:Convert for the unit to be moved to the permanent list of units.

SeeTemplate:Convert/unit sandbox for a good way to prepare unit definitions that can be copied into this page.

The following extracts fromModule: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.

Examples for additions toModule:Convert/extra(For the actual module code seebelow)
-- These are EXAMPLES on the documentation page. Scroll down to see the module content.localextra_units={-- Similar to a redirect: "sqm" is an alias for "m2".-- {{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)["sqm"]={target="m2",},-- A simple unit, showing the minimum that is required.-- The "ha" is the unit code used to identify the unit:-- {{convert|1.5|ha}} → 1.5 hectares (3.7 acres)["ha"]={name1="hectare",symbol="ha",utype="area",scale=10000,default="acre",},-- A unit which accepts an SI prefix. There is no "name1" field because it-- has to be constructed (mJ gives "millijoule"; MJ gives "megajoule").-- {{convert|125|kJ}} → 125 kilojoules (30,000 cal)["J"]={_name1="joule",_symbol="J",utype="energy",scale=1,prefixes=1,default="cal",link="Joule",},-- A unit where US and plural names are required.-- {{convert|125|cm/s2}} → 125 centimetres per second squared (4.1 ft/s²)["cm/s2"]={name1="centimetre per second squared",name1_us="centimeter per second squared",name2="centimetres per second squared",name2_us="centimeters per second squared",symbol="cm/s<sup>2</sup>",utype="acceleration",scale=0.01,default="ft/s2",link="Gal (unit)",},-- A "per" unit is defined as the ratio of two other units.-- {{convert|125|g/cm3}} → 125 grams per cubic centimetre (4.5 lb/cu in)["g/cm3"]={per={"g","cm3"},utype="density",default="lb/cuin",},-- If the automatic "per" 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]]["g/m3"]={per={"g","m3"},utype="density",default="lb/cuyd",link="density",},-- Characters "$" and "£" are recognized as currency symbols.-- {{convert|125|$/acre}} → $125 per acre ($310/ha)["$/acre"]={per={"$","acre"},utype="cost $ per unit area",default="$/ha",},-- 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 "+":-- {{convert|1.2|acre|ft2+yd2+m2}} → 1.2 acres (52,000 sq ft; 5,800 sq yd; 4,900 m²)["ft2 m2"]={combination={"ft2","m2"},utype="area",},-- 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)["ydftin"]={combination={"in","ft","yd"},multiple={12,3},utype="length",},}
FieldDescription
symbolUnit identifier used whenabbr=on is in effect.
name1Singular name of the unit used whenabbr=off is in effect.
name2Plural name of the unit; not required if it is the same asname1 plus "s".
name1_usSingular name whensp=us is in effect; not required if the same asname1.
name2_usPlural name whensp=us is in effect; not required if the same asname1_us plus "s".
utypeUnit type; must be exactly the same as theutype of any other unit used in a conversion.
scaleNumber of base units in the unit being defined.
defaultUnit code of the default output used when no output unit is specified in a conversion.
targetUnit code of an existing unit (the unit being defined "redirects" to the existing unit).
prefixesUse 1 if an SI prefix is accepted; 2 is used form2, and 3 is used form3.
linkArticle title used whenlk=on is in effect; not required if it is the same asname1.

The abovedocumentation istranscluded fromModule:Convert/extra/doc.(edit |history)
Editors can experiment in this module'ssandbox(edit |diff) and testcases(create) pages.
Subpages of this module.

-- 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]].localextra_units={["bit"]={_name1="bit",_symbol="bit",utype="information",scale=0.125,prefixes=1,default="B",link="Bit",},["per-km2"]={name1="per square kilometre",name1_us="per square kilometer",name2="per square kilometre",name2_us="per square kilometer",symbol="per&nbsp;km<sup>2</sup>",utype="per unit area",scale=1e-6,default="/sqmi",link="Square kilometre",},["tmcft"]={name2="tmcft",symbol="tmcft",utype="volume",scale=28316846.592,default="km3",},["Tmcft"]={name1="thousand million cubic feet",name2="thousand million cubic feet",symbol="tmcft",utype="volume",scale=28316846.592,default="km3",link="Tmcft",},}return{extra_units=extra_units}
Retrieved from "https://en.wikipedia.org/w/index.php?title=Module:Convert/extra&oldid=1312720423"
Hidden category:

[8]ページ先頭

©2009-2025 Movatter.jp