Module:Convert/text: Difference between revisions

"invalid option" is better than "unknown option" as it can be more than "unknown"; rework links in eng_scales
(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:
-- Some units can be qualified with one of the following prefixes, when linked.
local customary_units = {
'[[{ "US", link = "United States customary units|US]]" '},
'[[{ "U.S.", link = "United States customary units|U.S.]]" '},
'[[{ "imperial", link = "Imperial unit|imperial]]" '},
'[[{ "imp", link = "Imperial unit|imp]]" '},
}
 
-- Names when using engineering notation (a prefix of "eN" where N is a number).
-- key = { "name", "linkedlink name,= if link"article wantedtitle", exponent = key }
-- If lk=on and link is defined, the name of the number will appear as a link.
local eng_scales = {
["3"] = { "thousand", exponent = 3 },
["6"] = { "million", exponent = 6 },
["9"] = { "billion", link = "[[1000000000 (number)|billion]]", exponent = 9 },
["12"] = { "trillion", link = "[[1000000000000 (number)|trillion]]", exponent = 12 },
["15"] = { "quadrillion", link = "[[1000000000000000 (number)|quadrillion]]", exponent = 15 },
}
 
-- When appropriate, the following categories can be included in the output.
local all_categories = {
general = '"[[Category:Convert error]]'",
mismatch = '"[[Category:Convert dimension mismatch]]'",
option = '"[[Category:Convert unknowninvalid option]]'",
unknown = '"[[Category:Convert unknown unit]]'",
}
 
Line 71 ⟶ 72:
cvt_no_num2 = { 'Need second value', 'general' },
cvt_no_unit = { 'Need name of unit', 'unknown' },
cvt_unknown_option = { 'Ignored unknowninvalid option "%s"', 'option', warning = true },
cvt_should_be = { '%s', 'general', regex = unitcode_regex, replace = unitcode_replace },
cvt_sigfig_pos = { 'sigfig "%s" must be positive', 'general' },
Line 79 ⟶ 80:
-- Text to join input value/unit with output value/unit.
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.
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'"] = '"&nbsp;×&nbsp;'",
['"to(-)'"] = { ['"off'"] = '"&nbsp;to '", ['"on'"] = '"'" },
['"+/-'"] = { ['"off'"] = '"&nbsp;±&nbsp;'", ['"on'"] = '"&nbsp;±&nbsp;'", ['"adj'"] = '"&nbsp;±&nbsp;'" },
['"x'"] = { ['"off'"] = '" by '", ['"on'"] = '" ×&nbsp;'", is_range_x = true },
}
 
local range_aliases = {
['"and(-)'"] = '"and'",
['"&'"] = '"and'",
['"'"] = '"-'",
['"&ndash;'"] = '"-'",
['"to-'"] = '"to(-)'",
['"×'"] = '"x'",
['"±'"] = '"+/-'",
}
 
Anonymous user