Modul:Convert/dok
![]() | To je dokumentacijska podstran za glavno stran Modul:Convert. Namenjena je shranjevanju navodil, kategorizaciji in drugi vsebini, ki ni del glavne strani. Predloga ima preizkušanju namenjen peskovnik. |
![]() | Ta modul je odvisen od zaščite strani. Je zelo viden modul, ki ga uporabljajo številne strani, ali pa je pogosto substituiran. Ker bi vandalizem ali napake vplivale na številne strani in bi lahko celo trivialno urejanje povzročilo veliko obremenitev strežnikov, je zaščiten pred urejanjem. |
This module converts a value from one unit of measurement to another. For example:
{{convert|123|lb|kg}}
→ 123 pounds (56 kg)
The module is called using a template—parameters passed to the template are used by this module to control how a conversion is performed. For example, units can be abbreviated (like kg
), or displayed as names (like kilogram
), and the output value can be rounded to a specified precision. For usage information, see Pomoč:Convert.
The template that invokes this module is:
The following modules are required:
- Modul:Convert – (this module) code to convert units
- Modul:Convert/data – unit definitions
- Modul:Convert/text – text messages, and parameter names and values
The following modules are optional and are used only if required and if the module exists:
- Modul:Convert/extra – extra (temporary) unit definitions; used if a unit is not found in Modul:Convert/data
- Modul:ConvertNumeric – code to spell an input value in words (only English is supported)
The following help pages are available:
- Pomoč:Convert – overview
- Pomoč:Convert sporočila – describes error and warning messages; messages link to this page so it is required when the module is copied to another wiki
- Pomoč:Enote Convert – overview of units
A page containing a convert error is added to one of the following categories, providing the page is in a specified namespace (articles, by default):
Units are defined in the wikitext of the master list of units.
- en:Module:Convert/documentation/conversion data/doc – master list of unit definitions
- Modul:Convert/makeunits – translates wikitext from the master list to Lua
- Pogovor o modulu:Convert/makeunits – makeunits results; copy the text to Modul:Convert/data
Modul:Convert/data is transcluded into every page using the convert module, so experimenting with a new unit in that module would involve a significant overhead. The Modul:Convert/extra module is an alternative which is only transcluded on pages with a unit that is not defined in the main data module.
Sandbox
When making a change, copy the current modules to the sandbox pages, then edit the sandbox copies:
- Modul:Convert/peskovnik
- Modul:Convert/data/sandbox
- Modul:Convert/text/sandbox
- Modul:Convert/extra/sandbox
Use the following template to test the results (example {{convert/sandbox|123|lb|kg}}
):
Predloga:Convert/peskovnik invokes Modul:Convert/peskovnik with parameter |sandbox=on
which causes convert to use the sandbox modules rather than the normal modules.
The following should be used to test the results of editing the convert modules.
- Modul:Convert/tester – module to run tests by comparing template output with fixed text
- Modul:Convert/sandbox/testcases – templates to be tested, with expected outputs (uses the tester module)
- Pogovor o modulu:Convert/sandbox/testcases – view test results
It is not necessary to save the testcases page before viewing test results. For example, Modul:Convert/sandbox/testcases could be edited to change the tests. While still editing that page, paste "Pogovor o modulu:Convert/sandbox/testcases
" (without quotes) into the page title box under "Preview page with this template", then click "Show preview".
Configuration
The template that invokes this module can define options to configure the module. For example:
{{#invoke:convert|convert|numdot=,|numsep=.}}
- Sets the decimal mark to be a comma, and the thousands separator to be a dot.
Other options, with default values, are:
maxsigfig = 14
– maximum number of significant figuresnscat = 0
– namespaces (comma separated) in which an error or warning adds a category to the pagewarnings = 0
– 0 (zero) disables warnings; 1 shows important warnings; 2 shows all warningssandbox = off
– on if the sandbox modules should be used
Other configuration is available in the translation_table
at Modul:Convert/text. For example, bn:Module:Convert/text uses:
group = 2
– group numbers 3 digits, then 2 digitsplural_suffix = ''
– disable plural unit names (do not append "s")- Tables to translate digits to and from the English digits used in calculations.
Modul:Convert/text contains all text used for input parameters and for output messages and categories. For example, lk=on
may be used at en.wikipedia to link each displayed unit to its article. The text module could be edited to replace "lk
" and "on
" with any desired text.