Module:Convert/text: Difference between revisions

update from sandbox per Template talk:Convert#Module v2 soon
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:
--[[ 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.
Line 69 ⟶ 63:
-- Message format string, %s parameters: anchor, title, text, category.
-- 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">Convertconvert: %s</span>]]</i>]</sup>%s',
-- Each of following messages is a table:
-- { [1] = 'title', -- mouseover title text
Line 78 ⟶ 72:
-- replace = gsub_table,
-- } Mouseover title text Link text CatKey Anchor
cvt_bad_num = { 'Value "%s" must be a number' , 'Invalidinvalid number' , 'option', 'invalid_number' },
cvt_big_prec = { 'Precision "%s" is too large' , 'Precisionprecision too large' , 'option', 'precision_too_large' },
cvt_invalid_num = { 'Number has overflowed' , 'Numbernumber overflow' , 'option', 'number_overflow' },
cvt_no_num = { 'Needs the number to be converted' , 'Needsneeds a number' , 'option', 'needs_number' },
cvt_no_num2 = { 'Needs another number for a range' , 'Needsneeds another number', 'option', 'needs_another_number' },
cvt_bad_preccvt_bad_frac = { 'Precisionfrac "%s" must be an integer' above 1' , 'Invalidinvalid precisionfraction' , 'option', 'invalid_precisioninvalid_fraction' },
cvt_bad_sigfigcvt_bad_prec = { 'sigfigPrecision "%s" must be a positivean integer' , 'Invalid sigfig' , 'invalid precision' , 'option', 'invalid_sigfiginvalid_precision' },
cvt_empty_optioncvt_bad_sigfig = { 'Ignored empty optionsigfig "%s"' must be a positive integer' , 'Emptyinvalid optionsigfig' , 'option', 'empty_optioninvalid_sigfig' },
cvt_no_spell cvt_empty_option = { 'SpellingIgnored isempty notoption available"%s"' , 'Bug,empty option' ask for help' , 'option', 'ask_for_helpempty_option' },
cvt_unknown_optioncvt_no_spell = { 'IgnoredSpelling invalidis optionnot "%s"available' , 'Invalid option'bug, ask for help' , 'option', 'invalid_optionask_for_help' },
cvt_bad_default cvt_unknown_option = { 'UnitIgnored invalid option "%s"' has an invalid default' , 'Bug,invalid option' ask for help' , 'unitoption' , 'ask_for_helpinvalid_option' },
cvt_bad_unit cvt_bad_default = { 'Unit "%s" ishas an invalid heredefault' , 'bug, ask for help' , 'Unit invalid hereunit' , , 'unitask_for_help' , 'unit_invalid_here' },
cvt_no_defaultcvt_bad_unit = { 'Unit "%s" hasis invalid here' no default output unit' , 'Bug, ask for help' , 'unit invalid here' , , 'ask_for_helpunit' , 'unit_invalid_here' },
cvt_no_unit cvt_no_default = { 'Needs name of unit' Unit "%s" has no default output unit' , 'bug, ask for help' , 'Needs unit name' , , 'unitask_for_help' , 'needs_unit_name' },
cvt_unknowncvt_no_unit = { 'UnitNeeds name "%s"of unit' is not known' , 'Unknownneeds unit name' , 'unit' , 'unknown_unitneeds_unit_name' },
cvt_should_becvt_unknown = { 'Unit name "%s' " is not known' , 'Ambiguousunknown unit' , 'unit' , 'ambiguous_unitunknown_unit', regex = unitcode_regex, replace = unitcode_replace },
cvt_mismatch cvt_should_be = { 'Cannot convert "%s"' to "%s"' , 'Unitambiguous mismatchunit' , 'unit' , 'unit_mismatchambiguous_unit', regex = unitcode_regex, replace = unitcode_replace },
cvt_bug_convertcvt_mismatch = { 'Bug: Cannot convert between"%s" specifiedto units"%s"' , 'Bug,unit mismatch' ask for help' , 'unit' , 'ask_for_helpunit_mismatch' },
cvt_lookup cvt_bug_convert = { 'UnitBug: "%s"Cannot isconvert incorrectlybetween definedspecified units' , 'Bugbug, ask for help' , 'unit' , 'ask_for_help' },
cvt_lookup = { 'Unit "%s" is incorrectly defined' , 'bug, ask for help' , 'unit' , 'ask_for_help' },
}
 
Line 130 ⟶ 125:
["to"] = { off = " to " , on = " to " , exception = true },
["to(-)"] = { off = "&nbsp;to ", on = "–" },
["+/-"] = { off = "&nbsp;±&nbsp;", on = "&nbsp;±&nbsp;", adj = "&nbsp;±&nbsp;", is_range_change = true },
["x"] = { off = " by ", on = " ×&nbsp;", is_range_x = true },
["xx"] = "&nbsp;×&nbsp;",
Line 138 ⟶ 133:
local range_aliases = {
-- ["alternative name for a range"] = "standard range name"
["and(-)"] = "and",
["&"] = "and",
["–"] = "-",
["&ndash;"] = "-",
["to-"] = "to(-)",
["×"] = "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 = {
range_typestypes = range_types,
range_aliasesaliases = range_aliases,
words = range_words,
}
 
Line 151 ⟶ 158:
-- ["local text for option name"] = "en name used in this module"
["abbr"] = "abbr",
["adj"] = "adj",
["comma"] = {"comma",
["debug"] = "debug",
["disp"] = "disp",
["commafrac"] = "commafrac",
["lang"] = "lang",
["lk"] = "lk",
["near"] = "near",
["order"] = "order",
["round"] = "round",
["sigfig"] = "sigfig",
["sing"] = "adj", -- "sing" is an old alias for "adj"
Line 181 ⟶ 190:
["comma"] = "opt_nocomma", -- no numsep in input or output numbers
["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
["mos"] = "mos", -- in a range, repeat the input unit (no longer used)
Line 199 ⟶ 210:
["on"] = "opt_adjectival", -- unit name is singular and hyphenated
["pre"] = "opt_one_preunit", -- user-specified text before input unit
["5ri0"] = "opt_round5ri0", -- round outputinput valuewith toprecision nearest= 50
["ri1"] = "ri1", -- round input with precision = 1
["ri2"] = "ri2", -- round input with precision = 2
["ri3"] = "ri3", -- round input with precision = 3
},
["nearcomma"] = {
["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"] = {
Line 226 ⟶ 246:
["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 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",
["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"] = {
["en"] = "opt_lang_en", -- use en digits for output, regardless of local language
Line 248 ⟶ 256:
["lk"] = {
["in"] = "in", -- link LHS unit name or symbol
["off"] = "off", -- ignoreddo (offnot islink: thesame as default) except for hand unit
["on"] = "on", -- link all unit names or symbols (but not twice for the same unit)
["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
["sortable"] = {
["off"] = "", -- ignored (off is the default)
["onin"] = "opt_sortableopt_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"] = {
["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
["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
["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 ⟶ 293:
all_categories = all_categories,
all_messages = all_messages,
currency = { ['$'] = true, ['£'] = true },
customary_units = customary_units,
disp_joins = disp_joins,
Line 275 ⟶ 299:
en_option_value = en_option_value,
eng_scales = eng_scales,
ranges = ranges,
range_aliases = range_aliases,
range_types = range_types,
}
Anonymous user