Module:Convert/text: Difference between revisions

Jump to navigation Jump to search
Content added Content deleted
m (Protected Module:Convert/text: High-risk Lua module ([Edit=Allow only template editors and admins] (indefinite) [Move=Allow only template editors and admins] (indefinite)))
(update from sandbox per Template talk:Convert#Module v2 soon)
Line 1: Line 1:
--[[ Text used by Module:Convert, for en.wikipedia.org (English).
-- Text used by Module:Convert, for en.wikipedia.org (English).
-- This is a separate module to simplify translation for use on another wiki.

This is a separate module to simplify translation for use on another wiki.
Module:Convert responds to text parameters, and can display text.
Nearly all that text is defined in:
* Module:Convert/data (unit definitions)
* Module:Convert/text (parameter and message definitions)
]]


-- Some units accept an SI prefix before the unit code, such as "kg" for kilogram.
-- Some units accept an SI prefix before the unit code, such as "kg" for kilogram.
Line 69: Line 63:
-- Message format string, %s parameters: anchor, title, text, category.
-- Message format string, %s parameters: anchor, title, text, category.
-- Each displayed message starts with "Convert:" so can easily locate by searching article.
-- Each displayed message starts with "Convert:" so can easily locate by searching article.
cvt_format = '<sup class="noprint Inline-Template" style="white-space:nowrap;">[<i>[[Help:Convert messages#%s|<span title="Convert: %s">Convert: %s</span>]]</i>]</sup>%s',
cvt_format = '<sup class="noprint Inline-Template" style="white-space:nowrap;">[<i>[[Help:Convert messages#%s|<span title="Convert: %s">convert: %s</span>]]</i>]</sup>%s',
-- Each of following messages is a table:
-- Each of following messages is a table:
-- { [1] = 'title', -- mouseover title text
-- { [1] = 'title', -- mouseover title text
Line 78: Line 72:
-- replace = gsub_table,
-- replace = gsub_table,
-- } Mouseover title text Link text CatKey Anchor
-- } Mouseover title text Link text CatKey Anchor
cvt_bad_num = { 'Value "%s" must be a number' , 'Invalid number' , 'option', 'invalid_number' },
cvt_bad_num = { 'Value "%s" must be a number' , 'invalid number' , 'option', 'invalid_number' },
cvt_big_prec = { 'Precision "%s" is too large' , 'Precision too large' , 'option', 'precision_too_large' },
cvt_big_prec = { 'Precision "%s" is too large' , 'precision too large' , 'option', 'precision_too_large' },
cvt_invalid_num = { 'Number has overflowed' , 'Number overflow' , 'option', 'number_overflow' },
cvt_invalid_num = { 'Number has overflowed' , 'number overflow' , 'option', 'number_overflow' },
cvt_no_num = { 'Needs the number to be converted' , 'Needs a number' , 'option', 'needs_number' },
cvt_no_num = { 'Needs the number to be converted' , 'needs a number' , 'option', 'needs_number' },
cvt_no_num2 = { 'Needs another number for a range' , 'Needs another number', 'option', 'needs_another_number' },
cvt_no_num2 = { 'Needs another number for a range' , 'needs another number', 'option', 'needs_another_number' },
cvt_bad_prec = { 'Precision "%s" must be an integer' , 'Invalid precision' , 'option', 'invalid_precision' },
cvt_bad_frac = { 'frac "%s" must be an integer above 1' , 'invalid fraction' , 'option', 'invalid_fraction' },
cvt_bad_sigfig = { 'sigfig "%s" must be a positive integer' , 'Invalid sigfig' , 'option', 'invalid_sigfig' },
cvt_bad_prec = { 'Precision "%s" must be an integer' , 'invalid precision' , 'option', 'invalid_precision' },
cvt_empty_option = { 'Ignored empty option "%s"' , 'Empty option' , 'option', 'empty_option' },
cvt_bad_sigfig = { 'sigfig "%s" must be a positive integer' , 'invalid sigfig' , 'option', 'invalid_sigfig' },
cvt_no_spell = { 'Spelling is not available' , 'Bug, ask for help' , 'option', 'ask_for_help' },
cvt_empty_option = { 'Ignored empty option "%s"' , 'empty option' , 'option', 'empty_option' },
cvt_unknown_option = { 'Ignored invalid option "%s"' , 'Invalid option' , 'option', 'invalid_option' },
cvt_no_spell = { 'Spelling is not available' , 'bug, ask for help' , 'option', 'ask_for_help' },
cvt_bad_default = { 'Unit "%s" has an invalid default' , 'Bug, ask for help' , 'unit' , 'ask_for_help' },
cvt_unknown_option = { 'Ignored invalid option "%s"' , 'invalid option' , 'option', 'invalid_option' },
cvt_bad_unit = { 'Unit "%s" is invalid here' , 'Unit invalid here' , 'unit' , 'unit_invalid_here' },
cvt_bad_default = { 'Unit "%s" has an invalid default' , 'bug, ask for help' , 'unit' , 'ask_for_help' },
cvt_no_default = { 'Unit "%s" has no default output unit' , 'Bug, ask for help' , 'unit' , 'ask_for_help' },
cvt_bad_unit = { 'Unit "%s" is invalid here' , 'unit invalid here' , 'unit' , 'unit_invalid_here' },
cvt_no_unit = { 'Needs name of unit' , 'Needs unit name' , 'unit' , 'needs_unit_name' },
cvt_no_default = { 'Unit "%s" has no default output unit' , 'bug, ask for help' , 'unit' , 'ask_for_help' },
cvt_unknown = { 'Unit name "%s" is not known' , 'Unknown unit' , 'unit' , 'unknown_unit' },
cvt_no_unit = { 'Needs name of unit' , 'needs unit name' , 'unit' , 'needs_unit_name' },
cvt_should_be = { '%s' , 'Ambiguous unit' , 'unit' , 'ambiguous_unit', regex = unitcode_regex, replace = unitcode_replace },
cvt_unknown = { 'Unit name "%s" is not known' , 'unknown unit' , 'unit' , 'unknown_unit' },
cvt_mismatch = { 'Cannot convert "%s" to "%s"' , 'Unit mismatch' , 'unit' , 'unit_mismatch' },
cvt_should_be = { '%s' , 'ambiguous unit' , 'unit' , 'ambiguous_unit', regex = unitcode_regex, replace = unitcode_replace },
cvt_bug_convert = { 'Bug: Cannot convert between specified units', 'Bug, ask for help' , 'unit' , 'ask_for_help' },
cvt_mismatch = { 'Cannot convert "%s" to "%s"' , 'unit mismatch' , 'unit' , 'unit_mismatch' },
cvt_lookup = { 'Unit "%s" is incorrectly defined' , 'Bug, ask for help' , 'unit' , 'ask_for_help' },
cvt_bug_convert = { 'Bug: Cannot convert between specified units', 'bug, ask for help' , 'unit' , 'ask_for_help' },
cvt_lookup = { 'Unit "%s" is incorrectly defined' , 'bug, ask for help' , 'unit' , 'ask_for_help' },
}
}


Line 130: Line 125:
["to"] = { off = " to " , on = " to " , exception = true },
["to"] = { off = " to " , on = " to " , exception = true },
["to(-)"] = { off = "&nbsp;to ", on = "–" },
["to(-)"] = { off = "&nbsp;to ", on = "–" },
["+/-"] = { off = "&nbsp;±&nbsp;", on = "&nbsp;±&nbsp;", adj = "&nbsp;±&nbsp;" },
["+/-"] = { off = "&nbsp;±&nbsp;", on = "&nbsp;±&nbsp;", adj = "&nbsp;±&nbsp;", is_range_change = true },
["x"] = { off = " by ", on = " ×&nbsp;", is_range_x = true },
["x"] = { off = " by ", on = " ×&nbsp;", is_range_x = true },
["xx"] = "&nbsp;×&nbsp;",
["xx"] = "&nbsp;×&nbsp;",
Line 138: Line 133:
local range_aliases = {
local range_aliases = {
-- ["alternative name for a range"] = "standard range name"
-- ["alternative name for a range"] = "standard range name"
["and(-)"] = "and",
["and(-)"] = "and",
["&"] = "and",
["&"] = "and",
["–"] = "-",
["–"] = "-",
["&ndash;"] = "-",
["&ndash;"] = "-",
["to-"] = "to(-)",
["to-"] = "to(-)",
["×"] = "x",
["×"] = "x",
["±"] = "+/-",
["&times;"] = "x",
["±"] = "+/-",
["&plusmn;"] = "+/-",
}

-- The following "words" are accepted to make a simple range, for example, {{convert|1-2|ft}}.
-- Words must be in correct order for searching, for example, '-' after '+/-' and 'x' after 'xx'.
local range_words = { '+/-', 'to(-)', '-', 'xx', 'x', '*', 'by', 'to', 'or' }

local ranges = {
types = range_types,
aliases = range_aliases,
words = range_words,
}
}


Line 151: Line 158:
-- ["local text for option name"] = "en name used in this module"
-- ["local text for option name"] = "en name used in this module"
["abbr"] = "abbr",
["abbr"] = "abbr",
["adj"] = "adj",
["adj"] = "adj",
["comma"] = "comma",
["debug"] = "debug",
["debug"] = "debug",
["disp"] = "disp",
["disp"] = "disp",
["comma"] = "comma",
["frac"] = "frac",
["lang"] = "lang",
["lang"] = "lang",
["lk"] = "lk",
["lk"] = "lk",
["near"] = "near",
["near"] = "near",
["order"] = "order",
["order"] = "order",
["round"] = "round",
["sigfig"] = "sigfig",
["sigfig"] = "sigfig",
["sing"] = "adj", -- "sing" is an old alias for "adj"
["sing"] = "adj", -- "sing" is an old alias for "adj"
Line 181: Line 190:
["comma"] = "opt_nocomma", -- no numsep in input or output numbers
["comma"] = "opt_nocomma", -- no numsep in input or output numbers
["def"] = "", -- ignored (some wrapper templates call convert with "abbr=def" to mean "default abbreviation")
["def"] = "", -- ignored (some wrapper templates call convert with "abbr=def" to mean "default abbreviation")
["h"] = "on", -- abbr=on + use "h" for hand unit (default)
["hh"] = "opt_hand_hh", -- abbr=on + use "hh" for hand unit
["in"] = "in", -- use symbol for LHS unit
["in"] = "in", -- use symbol for LHS unit
["mos"] = "mos", -- in a range, repeat the input unit (no longer used)
["mos"] = "mos", -- in a range, repeat the input unit (no longer used)
Line 199: Line 210:
["on"] = "opt_adjectival", -- unit name is singular and hyphenated
["on"] = "opt_adjectival", -- unit name is singular and hyphenated
["pre"] = "opt_one_preunit", -- user-specified text before input unit
["pre"] = "opt_one_preunit", -- user-specified text before input unit
["ri0"] = "ri0", -- round input with precision = 0
["ri1"] = "ri1", -- round input with precision = 1
["ri1"] = "ri1", -- round input with precision = 1
["ri2"] = "ri2", -- round input with precision = 2
["ri2"] = "ri2", -- round input with precision = 2
["ri3"] = "ri3", -- round input with precision = 3
["ri3"] = "ri3", -- round input with precision = 3
},
["comma"] = {
["5"] = "opt_comma5", -- only use numsep grouping if 5 or more digits
["gaps"] = "opt_gaps", -- use gaps, not numsep, to separate groups of digits
["gaps5"] = "opt_gaps, opt_comma5", -- opt_gaps + opt_comma5
},
["debug"] = {
["yes"] = "opt_sortable_debug", -- make the normally hidden sort key visible
},
},
["disp"] = {
["disp"] = {
Line 226: Line 246:
["u2"] = "opt_output_unit_only", -- display output symbol/name (not input, and not output value)
["u2"] = "opt_output_unit_only", -- display output symbol/name (not input, and not output value)
["unit"] = "opt_input_unit_only", -- display input symbol/name (not output, and not input value)
["unit"] = "opt_input_unit_only", -- display input symbol/name (not output, and not input value)
["unit or text"] = "opt_input_unit_only, opt_ignore_error", -- display input symbol/name, or given unit code if not known
["unit2"] = "opt_output_unit_only",
["unit2"] = "opt_output_unit_only",
["x"] = "x", -- join: <first>...<second> (user-specified text)
["x"] = "x", -- join: <first>...<second> (user-specified text)
},
},
-- frac=x is handled as a special case: x must be an integer (possibly in local language) = 1 or more
["near"] = {
["5"] = "opt_round5", -- round output value to nearest 5
},
["order"] = {
["flip"] = "opt_flip", -- reverse order of input/output
},
["comma"] = {
["5"] = "opt_comma5", -- only use numsep grouping if 5 or more digits
["gaps"] = "opt_gaps", -- use gaps, not numsep, to separate groups of digits
["gaps5"] = "opt_gaps, opt_comma5", -- opt_gaps + opt_comma5
},
["debug"] = {
["yes"] = "opt_sortable_debug", -- make the normally hidden sort key visible
},
["lang"] = {
["lang"] = {
["en"] = "opt_lang_en", -- use en digits for output, regardless of local language
["en"] = "opt_lang_en", -- use en digits for output, regardless of local language
Line 248: Line 256:
["lk"] = {
["lk"] = {
["in"] = "in", -- link LHS unit name or symbol
["in"] = "in", -- link LHS unit name or symbol
["off"] = "", -- ignored (off is the default)
["off"] = "off", -- do not link: same as default except for hand unit
["on"] = "on", -- link all unit names or symbols (but not twice for the same unit)
["on"] = "on", -- link all unit names or symbols (but not twice for the same unit)
["out"] = "out", -- link RHS unit name or symbol
["out"] = "out", -- link RHS unit name or symbol
},
["near"] = {
["5"] = "opt_round5", -- round output value to nearest 5
},
["order"] = {
["flip"] = "opt_flip", -- reverse order of input/output
},
["round"] = {
["5"] = "opt_round5", -- round output value to nearest 5
["25"] = "opt_round25", -- round output value to nearest 25
["each"] = "opt_round_each", -- using default precision in a range, round each output separately (default uses highest precision of each item in range)
},
},
-- sigfig=x is handled as a special case: x must be an integer (possibly in local language) = 1 or more
-- sigfig=x is handled as a special case: x must be an integer (possibly in local language) = 1 or more
["sortable"] = {
["sortable"] = {
["off"] = "", -- ignored (off is the default)
["off"] = "", -- ignored (off is the default)
["on"] = "opt_sortable", -- output numeric hidden sort field for use in a sortable table
["in"] = "opt_sortable_in", -- output numeric hidden sort field for use in a sortable table, based on input
["on"] = "opt_sortable_in", -- same
["out"] = "opt_sortable_out", -- same, based on output
},
},
["sp"] = {
["sp"] = {
["us"] = "opt_sp_us", -- use U.S. spelling (like "meter" instead of default "metre")
["us"] = "opt_sp_us", -- use U.S. spelling (like "meter" instead of default "metre")
},
},
["spell"] = { -- only English spelling is supported; only for input; not scientific notation; only some fractions
["spell"] = { -- only English spelling is supported; not scientific notation; only some fractions
["in"] = "opt_spell_in", -- spell input value in words
["in"] = "opt_spell_in", -- spell input value in words
["In"] = "opt_spell_in, opt_spell_upper", -- spell input value in words with first letter uppercase
["In"] = "opt_spell_in, opt_spell_upper", -- spell input value in words with first letter uppercase
["on"] = "opt_spell_in, opt_spell_out", -- spell input and output values in words
["On"] = "opt_spell_in, opt_spell_out, opt_spell_upper", -- same, with first letter of first word in result uppercase
},
},
}
}
Line 270: Line 293:
all_categories = all_categories,
all_categories = all_categories,
all_messages = all_messages,
all_messages = all_messages,
currency = { ['$'] = true, ['£'] = true },
customary_units = customary_units,
customary_units = customary_units,
disp_joins = disp_joins,
disp_joins = disp_joins,
Line 275: Line 299:
en_option_value = en_option_value,
en_option_value = en_option_value,
eng_scales = eng_scales,
eng_scales = eng_scales,
ranges = ranges,
range_aliases = range_aliases,
range_types = range_types,
}
}