Module:Convert: Difference between revisions

handle exceptions as a property of a unit; allows localization for other wikis
(clean up, typos fixed: , → , (3) using AWB)
(handle exceptions as a property of a unit; allows localization for other wikis)
Line 19:
local en_option_name, en_option_value, eng_scales, range_aliases, range_types
local group_method = 3 -- code for how many digits are in a group
local per_word = 'per' -- for units like "miles per gallon"
local plural_suffix = 's' -- only other useful value is probably '' to disable plural unit names
local from_en_table -- to translate an output string of en digits to local language
Line 116 ⟶ 117:
if translation.group then
group_method = translation.group
end
if translation.per_word then
per_word = translation.per_word
end
if translation.plural_suffix then
Line 938 ⟶ 942:
-- 2 + 3 / 8 2.375, '2(3/8)' -1.625, '−2(−3/8)'
-- 2 - 3 / 8 1.625, '2(−3/8)' -2.375, '−2(3/8)'
-- 1 + 20/8 3.5 , '1/(20/8)' 1.5 , '−1/(−20/8)'
-- 1 - 20/8 -1.5., '1(−20/8)' -3.5 , '−1(20/8)'
-- Wherever an integer appears above, numbers like 1.25 or 12.5e-3
-- (which may be negative) are also accepted (like old template).
Line 1,568 ⟶ 1,572:
prec = prec - exponent
end
if in_current.istemperature and out_current.istemperature then
local exception = (utype == 'temperature' and not
-- Converting between common temperatures (°C, °F, °R, K); not keVT, MK.
(in_current.exception == 'temperature' or out_current.exception == 'temperature'))
if exception then
-- Kelvin value can be almost zero, or small but negative due to precision problems.
-- Also, an input value like -300 C (below absolute zero) gives negative kelvins.
Line 1,970 ⟶ 1,973:
result = '/'
elseif unit1 then
result = ' per' .. per_word .. ' '
else
result = per_word .. 'per '
end
if unit1 then
Line 1,981 ⟶ 1,984:
if multiplier then
-- A multiplier (like "100" in "100km") forces the unit to be plural.
multiplier = from_en(multiplier)
if abbr_on then
multiplier = multiplier .. ' '
Line 2,088 ⟶ 2,092:
want_name = true
end
if unit_table.utype == 'temperature' or unit_table.utype == 'temperature change'usesymbol then
if not (unit_table.exceptionwant_name == 'temperature') thenfalse
want_name = false
end
end
end
Anonymous user