https://de.wikipedia.org/w/index.php?action=history&feed=atom&title=Modul%3AConvert%2FtextModul:Convert/text - Versionsgeschichte2025-06-11T06:21:52ZVersionsgeschichte dieser Seite in WikipediaMediaWiki 1.45.0-wmf.4https://de.wikipedia.org/w/index.php?title=Modul:Convert/text&diff=178362620&oldid=prevNov3rd17: aus engl. Wikipedia, benötigt für Modul Val2018-06-16T08:17:40Z<p>aus engl. Wikipedia, benötigt für Modul Val</p>
<p><b>Neue Seite</b></p><div>-- Text used by Module:Convert for enwiki.<br />
-- This is a separate module to simplify translation for use on another wiki.<br />
-- See [[:en:Template:Convert/Transwiki guide]] if copying to another wiki.<br />
<br />
-- Some units accept an SI prefix before the unit code, such as "kg" for kilogram.<br />
local SIprefixes = {<br />
-- The prefix field is what the prefix should be, if different from the prefix used.<br />
['Y'] = { exponent = 24, name = 'yotta', },<br />
['Z'] = { exponent = 21, name = 'zetta', },<br />
['E'] = { exponent = 18, name = 'exa' , },<br />
['P'] = { exponent = 15, name = 'peta' , },<br />
['T'] = { exponent = 12, name = 'tera' , },<br />
['G'] = { exponent = 9, name = 'giga' , },<br />
['M'] = { exponent = 6, name = 'mega' , },<br />
['k'] = { exponent = 3, name = 'kilo' , },<br />
['h'] = { exponent = 2, name = 'hecto', },<br />
['da']= { exponent = 1, name = 'deca' , name_us = 'deka' },<br />
['d'] = { exponent = -1, name = 'deci' , },<br />
['c'] = { exponent = -2, name = 'centi', },<br />
['m'] = { exponent = -3, name = 'milli', },<br />
['μ'] = { exponent = -6, name = 'micro', }, -- key = 'GREEK SMALL LETTER MU' (U+03BC) utf-8 CE BC<br />
['µ'] = { exponent = -6, name = 'micro', prefix = 'μ' }, -- key = 'MICRO SIGN' (U+00B5) utf-8 C2 B5<br />
['u'] = { exponent = -6, name = 'micro', prefix = 'μ' }, -- not an SI prefix, but allow for people typing this<br />
['n'] = { exponent = -9, name = 'nano' , },<br />
['p'] = { exponent =-12, name = 'pico' , },<br />
['f'] = { exponent =-15, name = 'femto', },<br />
['a'] = { exponent =-18, name = 'atto' , },<br />
['z'] = { exponent =-21, name = 'zepto', },<br />
['y'] = { exponent =-24, name = 'yocto', },<br />
}<br />
<br />
-- Some units can be qualified with one of the following prefixes, when linked.<br />
local customary_units = {<br />
{ "US", link = "United States customary units" },<br />
{ "U.S.", link = "United States customary units" },<br />
{ "imperial", link = "Imperial units" },<br />
{ "imp", link = "Imperial units" },<br />
}<br />
<br />
-- Names when using engineering notation (a prefix of "eN" where N is a number; example "e6km").<br />
-- key = { "name", link = "article title", exponent = numeric_key_value }<br />
-- If lk=on and link is defined, the name of the number will appear as a link.<br />
local eng_scales = {<br />
["3"] = { "thousand", exponent = 3 },<br />
["6"] = { "million", exponent = 6 },<br />
["9"] = { "billion", link = "1000000000 (number)", exponent = 9 },<br />
["12"] = { "trillion", link = "1000000000000 (number)", exponent = 12 },<br />
["15"] = { "quadrillion", link = "1000000000000000 (number)", exponent = 15 },<br />
}<br />
<br />
local all_categories = {<br />
unit = "[[Category:Convert errors]]",<br />
option = "[[Category:Convert errors]]",<br />
warning = '[[Category:Convert invalid options]]',<br />
tracking = '[[Category:Convert tracking]]',<br />
}<br />
<br />
-- For some error messages, the following puts the wanted style around<br />
-- each unit code marked like '...%{ft%}...'.<br />
local unitcode_regex = '%%([{}])'<br />
local unitcode_replace = { ['{'] = '"', ['}'] = '"' } -- no longer need the more elaborate substitute used before 2013-09-28<br />
<br />
-- All messages that may be displayed if a problem occurs.<br />
local all_messages = {<br />
-- Message format string: $1=title, $2=text, $3=category, $4=anchor.<br />
-- Each displayed message starts with "Convert:" so can easily locate by searching article.<br />
cvt_format = '<sup class="noprint Inline-Template" style="white-space:nowrap;">[<i>[[Help:Convert messages#$4|<span title="Convert: $1">convert: $2</span>]]</i>]</sup>$3<span class="error"></span>',<br />
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>',<br />
cvt_format_preview = '<strong class="error">Error in convert: $1 [[Help:Convert messages#$4|(help)]]</strong>$3',<br />
-- Each of following messages is a table:<br />
-- { [1] = 'title', -- mouseover title text<br />
-- [2] = 'text', -- link text displayed in article<br />
-- [3] = 'category key', -- key to lookup category in all_categories<br />
-- [4] = 'anchor', -- anchor for link to relevant section on help page<br />
-- regex = gsub_regex,<br />
-- replace = gsub_table,<br />
-- } Mouseover title text Link text CatKey Anchor<br />
cvt_bad_input = { 'input "$1" must be a number and unit' , 'invalid input' , 'option', 'invalid_input' },<br />
cvt_bad_num = { 'Value "$1" must be a number' , 'invalid number' , 'option', 'invalid_number' },<br />
cvt_big_prec = { 'Precision "$1" is too large' , 'precision too large' , 'option', 'precision_too_large' },<br />
cvt_invalid_num = { 'Number has overflowed' , 'number overflow' , 'option', 'number_overflow' },<br />
cvt_no_num = { 'Needs the number to be converted' , 'needs a number' , 'option', 'needs_number' },<br />
cvt_no_num2 = { 'Needs another number for a range' , 'needs another number', 'option', 'needs_another_number' },<br />
cvt_bad_frac = { '"$1" needs an integer above 1' , 'invalid fraction' , 'option', 'invalid_fraction' },<br />
cvt_bad_prec = { 'Precision "$1" must be an integer' , 'invalid precision' , 'option', 'invalid_precision' },<br />
cvt_bad_sigfig = { '"$1" needs a positive integer' , 'invalid sigfig' , 'option', 'invalid_sigfig' },<br />
cvt_empty_option = { 'Ignored empty option "$1"' , 'empty option' , 'option', 'empty_option' },<br />
cvt_deprecated = { 'Option "$1" is deprecated' , '*' , 'option', 'deprecated_option', format = 'cvt_format2', nowarn = true },<br />
cvt_no_spell = { 'Spelling is not available' , 'bug, ask for help' , 'option', 'ask_for_help' },<br />
cvt_unknown_option = { 'Ignored invalid option "$1"' , 'invalid option' , 'option', 'invalid_option' },<br />
cvt_wd_fail = { 'Unable to access Wikidata' , 'wikidata problem' , 'option', 'wikidata_problem' },<br />
cvt_bad_default = { 'Unit "$1" has an invalid default' , 'bug, ask for help' , 'unit' , 'ask_for_help' },<br />
cvt_bad_unit = { 'Unit "$1" is invalid here' , 'unit invalid here' , 'unit' , 'unit_invalid_here' },<br />
cvt_no_default = { 'Unit "$1" has no default output unit' , 'bug, ask for help' , 'unit' , 'ask_for_help' },<br />
cvt_no_unit = { 'Needs name of unit' , 'needs unit name' , 'unit' , 'needs_unit_name' },<br />
cvt_unknown = { 'Unit name "$1" is not known' , 'unknown unit' , 'unit' , 'unknown_unit' },<br />
cvt_should_be = { '$1' , 'ambiguous unit' , 'unit' , 'ambiguous_unit', regex = unitcode_regex, replace = unitcode_replace },<br />
cvt_mismatch = { 'Cannot convert "$1" to "$2"' , 'unit mismatch' , 'unit' , 'unit_mismatch' },<br />
cvt_bug_convert = { 'Bug: Cannot convert between specified units', 'bug, ask for help' , 'unit' , 'ask_for_help' },<br />
cvt_lookup = { 'Unit "$1" is incorrectly defined' , 'bug, ask for help' , 'unit' , 'ask_for_help' },<br />
}<br />
<br />
-- Text to join input value/unit with output value/unit.<br />
local disp_joins = {<br />
-- [1]=before output, [2]=after output, [3]=between outputs in a combination; default "; "<br />
-- [wantname] gives default abbr=off<br />
["or"] = { " or " , "" , " or ", wantname = true },<br />
["sqbr-sp"] = { " [" , "]" },<br />
["sqbr-nbsp"] = { "&nbsp;[" , "]" },<br />
["comma"] = { ", " , "" , ", " },<br />
["slash-sp"] = { " / " , "" , wantname = true },<br />
["slash-nbsp"] = { "&nbsp;/ ", "" , wantname = true },<br />
["slash-nosp"] = { "/" , "" , wantname = true },<br />
["b"] = { " (" , ")" },<br />
["(or)"] = { " (" , ")", " or " },<br />
["br"] = { "<br />" , "" , wantname = true },<br />
["br()"] = { "<br />(" , ")", wantname = true },<br />
}<br />
<br />
-- Text to separate values in a range.<br />
local range_types = {<br />
-- Specifying a table requires either:<br />
-- * "off" and "on" values (for "abbr=off" and "abbr=on"), or<br />
-- * "input" and "output" values (for LHS and RHS);<br />
-- other fields are optional.<br />
-- When "adj=on|abbr=off" applies, spaces in range text are replaced with hyphens.<br />
-- With "exception = true", that also occurs with "adj=on|abbr=on".<br />
-- If "adj" is defined here, that text (unchanged) is used with "adj=on".<br />
["+"] = " + ",<br />
[","] = ",&nbsp;",<br />
[", and"] = ", and ",<br />
[", or"] = ", or ",<br />
["by"] = " by ",<br />
["-"] = "–",<br />
["to about"] = " to about ",<br />
["and"] = { off = " and ", on = " and ", exception = true },<br />
["and(-)"] = { input = " and ", output = "–" },<br />
["or"] = { off = " or " , on = " or " , exception = true },<br />
["to"] = { off = " to " , on = " to " , exception = true },<br />
["to(-)"] = { input = "&nbsp;to ", output = "–" },<br />
["+/-"] = { off = "&nbsp;±&nbsp;", on = "&nbsp;±&nbsp;", adj = "&nbsp;±&nbsp;", is_range_change = true },<br />
["by(x)"] = { input = " by ", output = " ×&nbsp;", out_range_x = true },<br />
["x"] = { off = " by ", on = " ×&nbsp;", abbr_range_x = true },<br />
["xx"] = "&nbsp;×&nbsp;",<br />
["*"] = "×",<br />
["/"] = "&thinsp;/&thinsp;", -- for a table of high/low temperatures with {{convert|83|/|63|F|disp=br()|abbr=values}}<br />
}<br />
<br />
local range_aliases = {<br />
-- ["alternative name for a range"] = "standard range name"<br />
["–"] = "-",<br />
["&ndash;"] = "-",<br />
["×"] = "x",<br />
["&times;"] = "x",<br />
["±"] = "+/-",<br />
["&plusmn;"] = "+/-",<br />
}<br />
<br />
-- Convert accepts range text delimited with whitespace, for example, {{convert|1 to 2|ft}}.<br />
-- In addition, the following "words" are accepted without spaces, for example, {{convert|1-2|ft}}.<br />
-- Words must be in correct order for searching, for example, 'x' after 'xx'.<br />
local range_words = { '-', '–', 'xx', 'x', '*' }<br />
<br />
local ranges = {<br />
types = range_types,<br />
aliases = range_aliases,<br />
words = range_words,<br />
}<br />
<br />
-- Valid option names.<br />
local en_option_name = {<br />
-- ["local text for option name"] = "en name used in this module"<br />
["$"] = "$",<br />
["abbr"] = "abbr",<br />
["adj"] = "adj",<br />
["comma"] = "comma",<br />
["debug"] = "debug",<br />
["disp"] = "disp",<br />
["frac"] = "frac",<br />
["input"] = "input",<br />
["lang"] = "lang",<br />
["lk"] = "lk",<br />
["order"] = "order",<br />
["qid"] = "qid",<br />
["qual"] = "qual",<br />
["qualifier"] = "qual",<br />
["round"] = "round",<br />
["sigfig"] = "sigfig",<br />
["sing"] = "adj", -- "sing" is an old alias for "adj"<br />
["sortable"] = "sortable",<br />
["sp"] = "sp",<br />
["spell"] = "spell",<br />
["stylein"] = "stylein",<br />
["styleout"] = "styleout",<br />
["tracking"] = "tracking",<br />
}<br />
<br />
-- Valid option values.<br />
-- Convention: parms.opt_xxx refers to an option that is set here<br />
-- (not intended to be set by the template which invokes this module).<br />
-- Example: At enwiki, "abbr" includes:<br />
-- ["comma"] = "opt_nocomma"<br />
-- As a result, if the template uses abbr=comma, Module:Convert sets:<br />
-- parms["opt_nocomma"] = true<br />
-- parms["abbr"] = nil<br />
-- Therefore parms.abbr will be nil, or will have one of the listed values<br />
-- that do not start with "opt_".<br />
-- An option value of form "xxx?" is the same as "xxx" but shows the input as deprecated.<br />
local en_option_value = {<br />
-- $=x is handled as a special case: x should be a currency symbol that will be used instead of "$"<br />
["abbr"] = {<br />
-- ["local text for option value"] = "en value used in this module"<br />
["def"] = "", -- ignored (some wrapper templates call convert with "abbr=def" to mean "default abbreviation")<br />
["h"] = "on", -- abbr=on + use "h" for hand unit (default)<br />
["hh"] = "opt_hand_hh", -- abbr=on + use "hh" for hand unit<br />
["in"] = "in", -- use symbol for LHS unit<br />
["none"] = "off", -- old name for "off"<br />
["off"] = "off", -- use name for all units<br />
["on"] = "on", -- use symbol for all units<br />
["out"] = "out", -- use symbol for RHS unit (default)<br />
["unit"] = "unit", -- abbr=on but abbreviate units only: e6km → million km (not ×10⁶ km)<br />
["values"] = "opt_values", -- show only input and output numbers, not units<br />
["~"] = "opt_also_symbol", -- show input unit symbol as well as name<br />
},<br />
["adj"] = {<br />
["mid"] = "opt_adjectival, opt_adj_mid", -- adj=on with user-specified text after input unit (between input and output)<br />
["off"] = "", -- ignored (off is the default)<br />
["on"] = "opt_adjectival", -- unit name is singular and hyphenated<br />
["pre"] = "opt_one_preunit", -- user-specified text before input unit<br />
["ri0"] = "opt_ri=0", -- round input with precision = 0<br />
["ri1"] = "opt_ri=1", -- round input with precision = 1<br />
["ri2"] = "opt_ri=2", -- round input with precision = 2<br />
["ri3"] = "opt_ri=3", -- round input with precision = 3<br />
},<br />
["comma"] = {<br />
["5"] = "opt_comma5", -- only use numsep grouping if 5 or more digits<br />
["gaps"] = "opt_gaps", -- use gaps, not numsep, to separate groups of digits<br />
["gaps3"] = "opt_gaps, opt_gaps3", -- group only in threes rather than default of no gap before a single digit after decimal mark<br />
["off"] = "opt_nocomma", -- no numsep in input or output numbers<br />
},<br />
["debug"] = {<br />
["yes"] = "opt_sortable_debug", -- make the normally hidden sort key visible<br />
},<br />
["disp"] = {<br />
["5"] = "opt_round=5?", -- round output value to nearest 5<br />
["b"] = "b", -- join: '(...)'<br />
["(or)"] = "(or)", -- join: '(...)' with 'or' between outputs in a combination<br />
["br"] = "br", -- join: '<br />'<br />
["br()"] = "br()", -- join: '<br />(...)'<br />
["comma"] = "comma", -- join: ','<br />
["flip"] = "opt_flip", -- reverse order of input/output<br />
["number"] = "opt_output_number_only", -- display output value (not input, and not output symbol/name)<br />
["or"] = "or", -- join: 'or'<br />
["out"] = "opt_output_only",<br />
["output number only"] = "opt_output_number_only",<br />
["output only"] = "opt_output_only",<br />
["preunit"] = "opt_two_preunits", -- user-specified text before input and output units<br />
["sqbr"] = "sqbr", -- join: '[...]'<br />
["table"] = "opt_table", -- output is suitable for a table cell with align="right"<br />
["tablecen"] = "opt_tablecen", -- output is suitable for a table cell with align="center"<br />
["unit"] = "opt_input_unit_only", -- display input symbol/name (not output, and not input value)<br />
["unit or text"] = "opt_input_unit_only, opt_ignore_error", -- display input symbol/name, or given unit code if not known<br />
["unit2"] = "opt_output_unit_only",<br />
["x"] = "x", -- join: <first>...<second> (user-specified text)<br />
},<br />
-- frac=x is handled as a special case: x must be an integer (possibly in local language) = 2 or more<br />
-- input=x is handled as a special case: x should be <value><space><unitcode> or <wikidata-property-id><br />
["lang"] = { -- language for output digits (both en and local digits are always accepted for input)<br />
["en"] = "opt_lang_en", -- use en digits for numbers, regardless of local language<br />
["local"] = "opt_lang_local", -- use local digits for numbers (default, although config can change default to en)<br />
},<br />
["lk"] = {<br />
["in"] = "in", -- link LHS unit name or symbol<br />
["off"] = "off", -- do not link: same as default except for hand unit<br />
["on"] = "on", -- link all unit names or symbols (but not twice for the same unit)<br />
["out"] = "out", -- link RHS unit name or symbol<br />
},<br />
["order"] = {<br />
["flip"] = "opt_flip", -- reverse order of input/output<br />
["out"] = "opt_order_out", -- do not show input; instead, use order in output combination, with the first output shown as the input<br />
},<br />
-- qid=x is handled as a special case: x should be a Wikidata Q item identifier.<br />
-- qual=x is handled as a special case: x should be a Wikidata Q item identifier.<br />
["round"] = {<br />
["0.5"] = "opt_round=0.5", -- round output value to nearest 0.5<br />
["5"] = "opt_round=5", -- round output value to nearest 5<br />
["10"] = "opt_round=10", -- round output value to nearest 10 (same as but clearer than "|-1")<br />
["25"] = "opt_round=25", -- round output value to nearest 25<br />
["50"] = "opt_round=50", -- round output value to nearest 50<br />
["each"] = "opt_round_each", -- using default precision in a range, round each output separately (default uses highest precision of each item in range)<br />
},<br />
-- sigfig=x is handled as a special case: x must be an integer (possibly in local language) = 1 or more<br />
["sortable"] = {<br />
["off"] = "", -- ignored (off is the default)<br />
["on"] = "opt_sortable_on", -- output sort key for use in a sortable table, based on value from converting to a standard base unit<br />
},<br />
["sp"] = {<br />
["us"] = "opt_sp_us", -- use U.S. spelling (like "meter" instead of default "metre")<br />
},<br />
["spell"] = { -- only English spelling is supported; not scientific notation; only some fractions<br />
["in"] = "opt_spell_in", -- spell input value in words<br />
["In"] = "opt_spell_in, opt_spell_upper", -- spell input value in words with first letter uppercase<br />
["on"] = "opt_spell_in, opt_spell_out", -- spell input and output values in words<br />
["On"] = "opt_spell_in, opt_spell_out, opt_spell_upper", -- same, with first letter of first word in result uppercase<br />
},<br />
-- stylein=x is handled as a special case: x can be any text<br />
-- styleout=x is handled as a special case: x can be any text<br />
-- tracking=x is handled as a special case: x can be any text<br />
}<br />
<br />
return {<br />
SIprefixes = SIprefixes,<br />
all_categories = all_categories,<br />
all_messages = all_messages,<br />
currency = { ['$'] = true, ['£'] = true, ['€'] = true, ['₱'] = true, ['₽'] = true, ['¥'] = true },<br />
customary_units = customary_units,<br />
disp_joins = disp_joins,<br />
en_option_name = en_option_name,<br />
en_option_value = en_option_value,<br />
eng_scales = eng_scales,<br />
ranges = ranges,<br />
}</div>Nov3rd17