Module:Convert/text: Difference between revisions
Jump to navigation
Jump to search
Content added Content deleted
(add sortable=on, sp=us, customary_units; tweak) |
("invalid option" is better than "unknown option" as it can be more than "unknown"; rework links in eng_scales) |
||
Line 16: | Line 16: | ||
-- Some units can be qualified with one of the following prefixes, when linked. |
-- Some units can be qualified with one of the following prefixes, when linked. |
||
local customary_units = { |
local customary_units = { |
||
{ "US", link = "United States customary units" }, |
|||
{ "U.S.", link = "United States customary units" }, |
|||
{ "imperial", link = "Imperial unit" }, |
|||
{ "imp", link = "Imperial unit" }, |
|||
} |
} |
||
-- Names when using engineering notation (a prefix of "eN" where N is a number). |
-- Names when using engineering notation (a prefix of "eN" where N is a number). |
||
-- key = { "name", |
-- key = { "name", link = "article title", exponent = key } |
||
-- If lk=on and link is defined, the name of the number will appear as a link. |
|||
local eng_scales = { |
local eng_scales = { |
||
["3"] = { "thousand", exponent = 3 }, |
["3"] = { "thousand", exponent = 3 }, |
||
["6"] = { "million", exponent = 6 }, |
["6"] = { "million", exponent = 6 }, |
||
["9"] = { "billion", " |
["9"] = { "billion", link = "1000000000 (number)", exponent = 9 }, |
||
["12"] = { "trillion", " |
["12"] = { "trillion", link = "1000000000000 (number)", exponent = 12 }, |
||
["15"] = { "quadrillion", " |
["15"] = { "quadrillion", link = "1000000000000000 (number)", exponent = 15 }, |
||
} |
} |
||
-- When appropriate, the following categories can be included in the output. |
-- When appropriate, the following categories can be included in the output. |
||
local all_categories = { |
local all_categories = { |
||
general = |
general = "[[Category:Convert error]]", |
||
mismatch = |
mismatch = "[[Category:Convert dimension mismatch]]", |
||
option = |
option = "[[Category:Convert invalid option]]", |
||
unknown = |
unknown = "[[Category:Convert unknown unit]]", |
||
} |
} |
||
Line 71: | Line 72: | ||
cvt_no_num2 = { 'Need second value', 'general' }, |
cvt_no_num2 = { 'Need second value', 'general' }, |
||
cvt_no_unit = { 'Need name of unit', 'unknown' }, |
cvt_no_unit = { 'Need name of unit', 'unknown' }, |
||
cvt_unknown_option = { 'Ignored |
cvt_unknown_option = { 'Ignored invalid option "%s"', 'option', warning = true }, |
||
cvt_should_be = { '%s', 'general', regex = unitcode_regex, replace = unitcode_replace }, |
cvt_should_be = { '%s', 'general', regex = unitcode_regex, replace = unitcode_replace }, |
||
cvt_sigfig_pos = { 'sigfig "%s" must be positive', 'general' }, |
cvt_sigfig_pos = { 'sigfig "%s" must be positive', 'general' }, |
||
Line 79: | Line 80: | ||
-- Text to join input value/unit with output value/unit. |
-- Text to join input value/unit with output value/unit. |
||
local disp_joins = { |
local disp_joins = { |
||
[ |
["or"] = { " or " , "" }, |
||
[ |
["sqbr-sp"] = { " [" , "]" }, |
||
[ |
["sqbr-nbsp"] = { " [" , "]" }, |
||
[ |
["comma"] = { ", " , "" }, |
||
[ |
["slash-sp"] = { " / " , "" }, |
||
[ |
["slash-nbsp"] = { " / ", "" }, |
||
[ |
["slash-nosp"] = { "/" , "" }, |
||
[ |
["b"] = { " (" , ")" }, |
||
[ |
["br"] = { "<br/>" , "" }, |
||
} |
} |
||
-- Text to separate values in a range. |
-- Text to separate values in a range. |
||
local range_types = { |
local range_types = { |
||
[ |
["by"] = " by ", |
||
[ |
["-"] = "–", |
||
[ |
["to about"] = " to about ", |
||
[ |
["and"] = { ["off"] = " and ", ["on"] = " and ", exception = true }, |
||
[ |
["or"] = { ["off"] = " or " , ["on"] = " or " , exception = true }, |
||
[ |
["to"] = { ["off"] = " to " , ["on"] = " to " , exception = true }, |
||
[ |
["xx"] = " × ", |
||
[ |
["to(-)"] = { ["off"] = " to ", ["on"] = "–" }, |
||
[ |
["+/-"] = { ["off"] = " ± ", ["on"] = " ± ", ["adj"] = " ± " }, |
||
[ |
["x"] = { ["off"] = " by ", ["on"] = " × ", is_range_x = true }, |
||
} |
} |
||
local range_aliases = { |
local range_aliases = { |
||
[ |
["and(-)"] = "and", |
||
[ |
["&"] = "and", |
||
[ |
["–"] = "-", |
||
[ |
["–"] = "-", |
||
[ |
["to-"] = "to(-)", |
||
[ |
["×"] = "x", |
||
[ |
["±"] = "+/-", |
||
} |
} |
||