Module:Convert/text: Difference between revisions

m
1 revision imported
(update from sandbox per Template talk:Convert#Module version 4)
m (1 revision imported)
 
(19 intermediate revisions by 4 users not shown)
Line 1:
-- Text used by Module:Convert, for en.wikipedia.org (English)enwiki.
-- This is a separate module to simplify translation for use on another wiki.
-- See [[:en:Template:Convert/Transwiki guide]] if copying to another wiki.
Line 19:
['c'] = { exponent = -2, name = 'centi', },
['m'] = { exponent = -3, name = 'milli', },
['μ'] = { exponent = -6, name = 'micro', prefix = 'µ' }, -- key = 'GREEK SMALL LETTER MU' (U+03BC) utf-8 CE BC
['µ'] = { exponent = -6, name = 'micro', prefix = 'μ' }, -- key = 'MICRO SIGN' (U+00B5) utf-8 C2 B5
['u'] = { exponent = -6, name = 'micro', prefix = 'µμ' }, -- not an SI prefix, but allow for people typing this
['n'] = { exponent = -9, name = 'nano' , },
['p'] = { exponent =-12, name = 'pico' , },
Line 34:
{ "US", link = "United States customary units" },
{ "U.S.", link = "United States customary units" },
{ "imperial", link = "Imperial unitunits" },
{ "imp", link = "Imperial unitunits" },
}
 
Line 49:
}
 
-- One of the following categories is included in the text of each message.
local all_categories = {
unit = "[[Category:Convert invalid unitserrors]]",
option = "[[Category:Convert invalid optionserrors]]",
warning = '[[Category:Convert invalid options]]',
tracking = '[[Category:Convert tracking]]',
}
 
Line 62 ⟶ 63:
-- All messages that may be displayed if a problem occurs.
local all_messages = {
-- Message format string, %s parameters: anchor, $1=title, $2=text, $3=category, $4=anchor.
-- 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$4|<span title="Convert: %s$1">convert: %s$2</span>]]</i>]</sup>%s$3<span class="error"></span>',
cvt_format2 = '<sup class="noprint Inline-Template" style="white-space:nowrap;">[[Help:Convert messages#$4|<span title="Convert: $1">$2</span>]]</sup>$3<span class="error"></span>',
cvt_format_preview = '<strong class="error">Error in convert: $1 [[Help:Convert messages#$4|(help)]]</strong>$3',
-- Each of following messages is a table:
-- { [1] = 'title', -- mouseover title text
Line 73 ⟶ 76:
-- replace = gsub_table,
-- } Mouseover title text Link text CatKey Anchor
cvt_bad_num cvt_bad_input = { 'Valueinput "%s$1" must be a number' and unit' , 'invalid numberinput' , 'option', 'invalid_numberinvalid_input' },
cvt_big_preccvt_bad_num = { 'PrecisionValue "%s$1" ismust toobe largea number' , 'precisioninvalid too largenumber' , 'option', 'precision_too_largeinvalid_number' },
cvt_big_prec = { 'Precision "$1" is too large' , 'precision too large' , 'option', 'precision_too_large' },
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_num2 = { 'Needs another number for a range' , 'needs another number', 'option', 'needs_another_number' },
cvt_bad_frac = { 'frac "%s$1" must beneeds an integer above 1' , 'invalid fraction' , 'option', 'invalid_fraction' },
cvt_bad_prec = { 'Precision "%s$1" must be an integer' , 'invalid precision' , 'option', 'invalid_precision' },
cvt_bad_sigfig = { 'sigfig "%s$1" must beneeds a positive integer' , 'invalid sigfig' , 'option', 'invalid_sigfig' },
cvt_empty_option = { 'Ignored empty option "%s$1"' , 'empty option' , 'option', 'empty_option' },
cvt_deprecated = { 'Option "$1" is deprecated' , '*' , 'option', 'deprecated_option', format = 'cvt_format2', nowarn = true },
cvt_no_spell = { 'Spelling is not available' , 'bug, ask for help' , 'option', 'ask_for_help' },
cvt_unknown_option = { 'Ignored invalid option "%s$1"' , 'invalid option' , 'option', 'invalid_option' },
cvt_bad_defaultcvt_wd_fail = { 'UnitUnable "%s"to hasaccess an invalid defaultWikidata' , 'bug, ask for help' , 'unitwikidata problem' , , 'ask_for_helpoption', 'wikidata_problem' },
cvt_bad_unit cvt_bad_default = { 'Unit "%s$1" ishas an invalid heredefault' , 'bug, ask for help' , 'unit invalid here' , , 'unitask_for_help' , 'unit_invalid_here' },
cvt_no_defaultcvt_bad_unit = { 'Unit "%s$1" hasis invalid here' no default output unit' , 'bug, ask for help' , 'unit invalid here' , , 'ask_for_helpunit' , 'unit_invalid_here' },
cvt_no_default = { 'Unit "$1" has no default output unit' , 'bug, ask for help' , 'unit' , 'ask_for_help' },
cvt_no_unit = { 'Needs name of unit' , 'needs unit name' , 'unit' , 'needs_unit_name' },
cvt_unknown = { 'Unit name "%s$1" is not known' , 'unknown unit' , 'unit' , 'unknown_unit' },
cvt_should_be = { '%s$1' , 'ambiguous unit' , 'unit' , 'ambiguous_unit', regex = unitcode_regex, replace = unitcode_replace },
cvt_mismatch = { 'Cannot convert "%s$1" to "%s$2"' , 'unit mismatch' , 'unit' , 'unit_mismatch' },
cvt_bug_convert = { 'Bug: Cannot convert between specified units', 'bug, ask for help' , 'unit' , 'ask_for_help' },
cvt_lookup = { 'Unit "%s$1" is incorrectly defined' , 'bug, ask for help' , 'unit' , 'ask_for_help' },
}
 
-- Text to join input value/unit with output value/unit.
local disp_joins = {
-- Position: [1]=before output, [2]=after between (wrt output;, "[3]=between" isoutputs forin a combination; default "; ").
-- [wantname] gives default abbr=off
["or"] = { " or " , "" , " or ", wantname = true },
["sqbr-sp"] = { " [" , "]" },
["sqbr-nbsp"] = { "&nbsp;[" , "]" },
["comma"] = { ", " , "" , ", " },
["slash-sp"] = { " / " , "" , wantname = true },
["slash-nbsp"] = { "&nbsp;/ ", "" , wantname = true },
["slash-nosp"] = { "/" , "" , wantname = true },
["b"] = { " (" , ")" },
["(or)"] = { " (" , ")", " or " },
["br"] = { "<br />" , "" , wantname = true },
["br()"] = { "<br />(" , ")", wantname = true },
}
 
-- Text to separate values in a range.
local range_types = {
-- Specifying a table requires "off" and "on" values (for "abbr=off" and "abbr=on");either:
-- * "off" and "on" values (for "abbr=off" and "abbr=on"), or
-- * "input" and "output" values (for LHS and RHS);
-- other fields are optional.
-- When "adj=on|abbr=off" applies, spaces in range text are replaced with hyphens.
Line 125 ⟶ 135:
["to about"] = " to about ",
["and"] = { off = " and ", on = " and ", exception = true },
["and(-)"] = { offinput = " and ", onoutput = "–" },
["or"] = { off = " or " , on = " or " , exception = true },
["to"] = { off = " to " , on = " to " , exception = true },
["to(-)"] = { offinput = "&nbsp;to ", onoutput = "–" },
["+/-"] = { off = "&nbsp;±&nbsp;", on = "&nbsp;±&nbsp;", adj = "&nbsp;±&nbsp;", is_range_change = true },
["by(x)"] = { offinput = " by ", onoutput = " ×&nbsp;", is_range_xout_range_x = true },
["x"] = { off = " by ", on = " ×&nbsp;", abbr_range_x = true },
["xx"] = "&nbsp;×&nbsp;",
["&*"] = "and×",
["*"] = "×", -- use "*" to replace "x" in {{convert/2}} which is different from "x" in old {{convert}}
["/"] = "&thinsp;/&thinsp;", -- for a table of high/low temperatures with {{convert|83|/|63|F|disp=br()|abbr=values}}
}
 
local range_aliases = {
-- ["alternative name for a range"] = "standard range name"
["&"] = "and",
["–"] = "-",
["&ndash;"] = "-",
["to-"] = "to(-)",
["×"] = "x",
["&times;"] = "x",
Line 147 ⟶ 157:
}
 
-- TheConvert followingaccepts "words"range aretext accepteddelimited towith make a simple rangewhitespace, for example, {{convert|1- to 2|ft}}.
-- WordsIn mustaddition, bethe infollowing correct"words" orderare foraccepted without searchingspaces, for example, '{{convert|1-' after '+/-' and 'x' after 'xx'2|ft}}.
-- Words must be in correct order for searching, for example, 'x' after 'xx'.
-- Put '-' last so can have a simple range with negative values as in {{convert|-5 to -1|C}}.
local range_words = { '+/-', 'to(-)', 'xx', 'x', '*', 'to', 'or', 'by', '–' , '-' }
 
local ranges = {
Line 161 ⟶ 171:
local en_option_name = {
-- ["local text for option name"] = "en name used in this module"
["to-$"] = "to(-)$",
["abbr"] = "abbr",
["adj"] = "adj",
Line 167 ⟶ 178:
["disp"] = "disp",
["frac"] = "frac",
["nearinput"] = "nearinput",
["lang"] = "lang",
["lk"] = "lk",
["near"] = "near",
["order"] = "order",
["nearqid"] = {"qid",
["qual"] = "qual",
["qualifier"] = "qual",
["round"] = "round",
["sigfig"] = "sigfig",
Line 177 ⟶ 191:
["sp"] = "sp",
["spell"] = "spell",
["stylein"] = "stylein",
["styleout"] = "styleout",
["tracking"] = "tracking",
}
 
Line 182 ⟶ 199:
-- Convention: parms.opt_xxx refers to an option that is set here
-- (not intended to be set by the template which invokes this module).
-- Example: At en.wikienwiki, "abbr" includes:
-- ["comma"] = "opt_nocomma"
-- As a result, if the template uses abbr=comma, this scriptModule:Convert sets:
-- parms["opt_nocomma"] = true
-- parms["abbr"] = nil
-- Therefore parms.abbr will be nil, or will have one of the listed values
-- that do not start with "opt_".
-- An option value of form "xxx?" is the same as "xxx" but shows the input as deprecated.
local en_option_value = {
-- $=x is handled as a special case: x should be a currency symbol that will be used instead of "$"
["abbr"] = {
-- ["local text for option value"] = "en value used in this module"
["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)
["none"] = "off", -- old name for "off"
["off"] = "off", -- use name for all units
["on"] = "on", -- use symbol for all units
["out"] = "out", -- use symbol for RHS unit (default)
["unit"] = "unit", -- abbr=on but abbreviate units only: e6km → million km (not ×10⁶ km)
["values"] = "opt_values", -- show only input and output numbers, not units
["~"] = "opt_also_symbol", -- show input unit symbol as well as name
},
["adj"] = {
["1"] = "opt_singular", -- unit name is singular when value satisfies: (-1 <= v and v < 0) or (0 < v and v <= 1)
["flip"] = "opt_flip", -- reverse order of input/output
["j"] = "opt_use_nbsp", -- "join": use "&nbsp;" instead of " " between value and unit name
["mid"] = "opt_adjectival, opt_adj_mid", -- adj=on with user-specified text after input unit (between input and output)
["nocomma"] = "opt_nocomma", -- no numsep in input or output numbers
["off"] = "", -- ignored (off is the default)
["on"] = "opt_adjectival", -- unit name is singular and hyphenated
["pre"] = "opt_one_preunit", -- user-specified text before input unit
["ri0"] = "ri0opt_ri=0", -- round input with precision = 0
["ri1"] = "ri1opt_ri=1", -- round input with precision = 1
["ri2"] = "ri2opt_ri=2", -- round input with precision = 2
["ri3"] = "ri3opt_ri=3", -- 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
["gaps5gaps3"] = "opt_gaps, opt_comma5opt_gaps3", -- opt_gapsgroup only in threes rather than default of no gap before a single digit after +decimal opt_comma5mark
["commaoff"] = "opt_nocomma", -- no numsep in input or output numbers
},
["debug"] = {
Line 228 ⟶ 243:
},
["disp"] = {
["/5"] = "slashopt_round=5?", -- round output value to nearest -- join: '/'5
["2"] = "opt_output_only", -- display only output value and symbol/name (not input)
["5"] = "opt_round5", -- round output value to nearest 5
["b"] = "b", -- join: '(...)'
["(or)"] = "(or)", -- join: '(...)' with 'or' between outputs in a combination
["br"] = "br", -- join: '<br />'
["sbr()"] = "slashbr()", -- join: '<br />(...)'
["comma"] = "comma", -- join: ','
["flip"] = "opt_flip", -- reverse order of input/output
["flip5"] = "opt_flip, opt_round5", -- disp=flip + disp=5
["nocomma"] = "opt_nocomma", -- no numsep in input or output numbers
["number"] = "opt_output_number_only", -- display output value (not input, and not output symbol/name)
["or"] = "or", -- join: 'or'
Line 244 ⟶ 256:
["output only"] = "opt_output_only",
["preunit"] = "opt_two_preunits", -- user-specified text before input and output units
["s"] = "slash", -- join: '/'
["slash"] = "slash", -- join: '/'
["sqbr"] = "sqbr", -- join: '[...]'
["table"] = "opt_table", -- output is suitable for a table cell with align="right"
["tablecen"] = "opt_tablecen", -- output is suitable for a table cell with align="center"
["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
Line 256 ⟶ 265:
},
-- frac=x is handled as a special case: x must be an integer (possibly in local language) = 2 or more
-- input=x is handled as a special case: x should be <value><space><unitcode> or <wikidata-property-id>
["lang"] = { -- language for output digits (both en and local digits are always accepted for input)
["en"] = "opt_lang_en", -- use en digits for numbers, regardless of local language
["local"] = "opt_lang_local", -- use local digits for numbers (default, although config can change default to en)
Line 265 ⟶ 275:
["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
["out"] = "opt_order_out", -- do not show input; instead, use order in output combination, with the first output shown as the input
},
-- qid=x is handled as a special case: x should be a Wikidata Q item identifier.
-- qual=x is handled as a special case: x should be a Wikidata Q item identifier.
["round"] = {
["0.5"] = "opt_round5opt_round=0.5", -- round output value to nearest 0.5
["255"] = "opt_round25opt_round=5", -- round output value to nearest 255
["10"] = "opt_round=10", -- round output value to nearest 10 (same as but clearer than "|-1")
["525"] = "opt_round5opt_round=25", -- round output value to nearest 525
["550"] = "opt_round5opt_round=50", -- round output value to nearest 550
["each"] = "opt_round_each", -- using default precision in a range, round each output separately (default uses highest precision of each item in range)
},
Line 280 ⟶ 293:
["sortable"] = {
["off"] = "", -- ignored (off is the default)
["inon"] = "opt_sortable_inopt_sortable_on", -- output numeric hidden sort fieldkey for use in a sortable table, based on inputvalue from converting to a standard base unit
["on"] = "opt_sortable_in", -- same
["out"] = "opt_sortable_out", -- same, based on output
},
["sp"] = {
Line 293 ⟶ 304:
["On"] = "opt_spell_in, opt_spell_out, opt_spell_upper", -- same, with first letter of first word in result uppercase
},
-- stylein=x is handled as a special case: x can be any text
-- styleout=x is handled as a special case: x can be any text
-- tracking=x is handled as a special case: x can be any text
}
 
Line 299 ⟶ 313:
all_categories = all_categories,
all_messages = all_messages,
currency = { ['$'] = true, ['£'] = true, ['€'] = true, ['₱'] = true, ['₽'] = true, ['¥'] = true },
customary_units = customary_units,
disp_joins = disp_joins,