Module:Convert/text: Difference between revisions

Jump to navigation Jump to search
Content added Content deleted
(SIprefixes table moved from Module:Convert/data to here for translation on another wiki; precision=3 no longer accepted)
(new options for bn:: group 3-then-2; no plural unit names; new parameters: comma=5/gaps/gaps5)
Line 12: Line 12:
sigfig=3 To set number of output significant figures.
sigfig=3 To set number of output significant figures.
]]
]]

local translation_table = {
-- Tables to translate digits from/to en.
-- The to_en table can be calculated from the from_en table, but that
-- overhead seems excessive for each convert.
-- Will not try to put many languages here; this is mainly for testing.
test = {
-- For Johnuniq's test system; will remove later.
from_en = {
['0'] = '<0>',
['1'] = '<1>',
['2'] = '<2>',
['3'] = '<3>',
['4'] = '<4>',
['5'] = '<5>',
['6'] = '<6>',
['7'] = '<7>',
['8'] = '<8>',
['9'] = '<9>',
},
to_en = {
['<0>'] = '0',
['<1>'] = '1',
['<2>'] = '2',
['<3>'] = '3',
['<4>'] = '4',
['<5>'] = '5',
['<6>'] = '6',
['<7>'] = '7',
['<8>'] = '8',
['<9>'] = '9',
}
},
bn = {
-- Bengali (bn.wikipedia.org).
group = 2, -- group numbers 3 digits, then 2 digits
plural_suffix = '', -- disable plural unit names
from_en = {
['0'] = '০',
['1'] = '১',
['2'] = '২',
['3'] = '৩',
['4'] = '৪',
['5'] = '৫',
['6'] = '৬',
['7'] = '৭',
['8'] = '৮',
['9'] = '৯',
},
to_en = {
['০'] = '0',
['১'] = '1',
['২'] = '2',
['৩'] = '3',
['৪'] = '4',
['৫'] = '5',
['৬'] = '6',
['৭'] = '7',
['৮'] = '8',
['৯'] = '9',
},
}
}


-- Some units accept an SI prefix before the unit code, such as "kg" for kilogram.
-- Some units accept an SI prefix before the unit code, such as "kg" for kilogram.
Line 81: Line 144:
-- regex = gsub_regex,
-- regex = gsub_regex,
-- replace = gsub_table,
-- replace = gsub_table,
-- warning = true, -- omitted for an error message
-- warning = true, -- omitted for an error message; selects cvt_prefix_error or cvt_prefix_warning
-- }
-- }
cvt_bad_default = { 'Unit "%s" has an invalid default', 'unknown' },
cvt_bad_default = { 'Unit "%s" has an invalid default', 'unknown' },
Line 87: Line 150:
cvt_bad_num2 = { 'Second value "%s" must be a number', 'general' },
cvt_bad_num2 = { 'Second value "%s" must be a number', 'general' },
cvt_bad_prec = { 'Parameter precision "%s" must be an integer', 'general' },
cvt_bad_prec = { 'Parameter precision "%s" must be an integer', 'general' },
cvt_bad_sigfig = { 'Parameter sigfig "%s" must be an integer', 'general' },
cvt_bad_sigfig = { 'Parameter sigfig "%s" must be a positive integer', 'general' },
cvt_bad_unit = { 'Unit "%s" is invalid here', 'unknown' },
cvt_bad_unit = { 'Unit "%s" is invalid here', 'unknown' },
cvt_big_prec = { 'Precision "%s" is too large', 'general' },
cvt_big_prec = { 'Precision "%s" is too large', 'general' },
Line 100: Line 163:
cvt_unknown_option = { 'Ignored invalid option "%s"', 'option', warning = true },
cvt_unknown_option = { 'Ignored invalid option "%s"', 'option', warning = true },
cvt_should_be = { '%s', 'general', regex = unitcode_regex, replace = unitcode_replace },
cvt_should_be = { '%s', 'general', regex = unitcode_regex, replace = unitcode_replace },
cvt_sigfig_pos = { 'sigfig "%s" must be positive', 'general' },
cvt_unknown = { 'Unit "%s" is not known', 'unknown' },
cvt_unknown = { 'Unit "%s" is not known', 'unknown' },
}
}
Line 147: Line 209:
["adj"] = "adj",
["adj"] = "adj",
["disp"] = "disp",
["disp"] = "disp",
["comma"] = "comma",
["lang"] = "lang",
["lk"] = "lk",
["lk"] = "lk",
["sing"] = "sing",
["sing"] = "sing",
Line 197: Line 261:
["comma"] = "comma", -- join: ','
["comma"] = "comma", -- join: ','
["flip"] = "opt_flip", -- reverse order of input/output
["flip"] = "opt_flip", -- reverse order of input/output
["flip5"] = "special_flip5", -- combine disp=flip + disp=5
["flip5"] = "opt_flip:opt_round5", -- disp=flip + disp=5
["nocomma"] = "opt_nocomma", -- no numsep in input or output numbers
["nocomma"] = "opt_nocomma", -- no numsep in input or output numbers
["number"] = "opt_output_number_only",
["number"] = "opt_output_number_only",
Line 214: Line 278:
["unit2"] = "opt_output_unit_only",
["unit2"] = "opt_output_unit_only",
["x"] = "x", -- join: 'by...×'
["x"] = "x", -- join: 'by...×'
},
["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
},
["lang"] = {
["en"] = "opt_lang_en", -- use en digits for output, regardless of local language
},
},
["lk"] = {
["lk"] = {
Line 241: Line 313:
range_aliases = range_aliases,
range_aliases = range_aliases,
range_types = range_types,
range_types = range_types,
translation_table = translation_table,
}
}