Module:Convert/text: Difference between revisions

large refactor of messages: less visible, link to help
(put a space (actually " " so it sticks to the convert output) before warnings, per DePiep's suggestion)
(large refactor of messages: less visible, link to help)
Line 54:
}
 
-- One of the following categories is included in the text of each error or warning message.
local all_categories = {
general = "[[Category:Convert error]]",
Line 65:
-- each unit code marked like '...%{ft%}...'.
local unitcode_regex = '%%([{}])'
local unitcode_replace = { ['{'] = '<code style="background:transparent;">', ['}'] = '</code>"' } -- no longer need the more elaborate substitute used before 2013-09-28
 
-- All messages that may be displayed if a problem occurs.
local all_messages = {
-- Message format string, %s parameters: anchor, title, text, category.
-- One of the following prefixes is inserted before each message.
cvt_prefix_errorcvt_format = '<spansup class="noprint Inline-Template" style="backgroundwhite-space:#ffcc69nowrap;">&#91;<i>[[Module talkHelp:Convert#%s|Conversion<span errortitle="%s">%s</span>]]:</i>&#93;</sup>%s',
cvt_prefix_warning = '&nbsp;<span class="noprint" style="background:peachpuff;">[[Module talk:Convert|Conversion warning]]:',
-- Each of following messages is a table:
-- { [1] = 'error texttitle', -- mouseover title text
-- [2] = 'category keytext', -- keydisplay text (each starts with "convert:" so can toeasily lookuplocate categoryby insearching all_categoriesarticle)
-- [3] = 'category key', -- key to lookup category in all_categories
-- [4] = 'anchor', -- anchor for link to relevant section on help page
-- regex = gsub_regex,
-- replace = gsub_table,
-- warning = true, -- omitted for an error message; selects cvt_prefix_error or cvt_prefix_warning
-- }
cvt_bad_default = { 'Unit "%s" has an invalid default' , 'convert: bug' , 'unknown' , 'should_not_occur' },
cvt_bad_num = { 'Value "%s" must be a number' , 'convert: invalid number' , 'general' , 'must_be_number' },
cvt_bad_prec = { 'Parameter precisionPrecision "%s" must be an integer' , 'generalconvert: invalid precision' , 'option' , 'precision_must_be' },
cvt_bad_sigfig = { 'Parameter sigfig "%s" must be a positive integer' , 'generalconvert: invalid sigfig' , warning'option' , 'sigfig_must_be' = true },
cvt_bad_unit = { 'Unit "%s" is invalid here' , 'convert: invalid unit' , 'unknown' , 'unit_invalid_here' },
cvt_big_prec = { 'Precision "%s" is too large' , 'convert: precision too large', 'general' , 'precision_too_large'},
cvt_bug_convert = { 'Bug: Cannot convert between specified units', 'convert: bug' , 'general' , 'should_not_occur' },
cvt_empty_option = { 'Ignored empty option "%s"' , 'convert: empty option' , warning'option' , 'empty_option' = true },
cvt_invalid_num = { 'Number is too large or too small' , 'convert: too large' , 'general' , 'too_large' },
cvt_lookup = { 'Unit "%s" is incorrectly defined' , 'convert: bug' , 'general' , 'should_not_occur' },
cvt_mismatch = { 'Cannot convert "%s" to "%s"' , 'convert: dimension mismatch' , 'mismatch', 'dimension_mismatch' },
cvt_no_default = { 'Unit "%s" has no default output unit' , 'convert: bug' , 'unknown' , 'should_not_occur' },
cvt_no_num = { 'Need value' , 'convert: need value' , 'general' , 'need_value' },
cvt_no_num2 = { 'Need another value' , 'convert: need another value' , 'general' , 'need_another_value' },
cvt_no_unit = { 'Need name of unit' , 'convert: need unit' , 'unknown' , 'need_unit' },
cvt_should_be = { '%s' , 'convert: ambiguous unit' , 'general' , 'x_should_be_y', regex = unitcode_regex, replace = unitcode_replace },
cvt_spell_unavailablecvt_no_spell = { 'Spelling is not available' , 'convert: bug' , 'option' , warning ='should_not_occur' true },
cvt_unknown = { 'Unit "%s" is not known' , 'convert: unknown unit' , 'unknown' , 'unit_not_known' },
cvt_unknown_option = { 'Ignored invalid option "%s"' , 'convert: invalid option' , warning'option' , 'invalid_option' = true },
}
 
Anonymous user