Anonymous user
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:
--
-- 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.
-- 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">
-- 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' , '
cvt_big_prec = { 'Precision "%s" is too large' , '
cvt_invalid_num = { 'Number has overflowed' , '
cvt_no_num = { 'Needs the number to be converted' , '
cvt_no_num2 = { 'Needs another number for a range' , '
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 = " to ", on = "–" },
["+/-"] = { off = " ± ", on = " ± ", adj = " ± ", is_range_change = true },
["x"] = { off = " by ", on = " × ", is_range_x = true },
["xx"] = " × ",
Line 138 ⟶ 133:
local range_aliases = {
-- ["alternative name for a range"] = "standard range name"
["and(-)"] = "and",
["&"] = "and",
["–"] = "-",
["–"] = "-",
["to-"] = "to(-)",
["×"] = "x",
["
["±"] = "+/-",
["±"] = "+/-",
}
-- 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 = {
words = range_words,
}
Line 151 ⟶ 158:
-- ["local text for option name"] = "en name used in this module"
["abbr"] = "abbr",
["adj"]
["debug"] = "debug",
["disp"] = "disp",
["
["lang"]
["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
["ri1"] = "ri1", -- round input with precision = 1
["ri2"] = "ri2", -- round input with precision = 2
["ri3"] = "ri3", -- round input with precision = 3
},▼
["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",
["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)
["
["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
["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,
}
|