Module:Convert/text: Difference between revisions

Jump to navigation Jump to search
>Johnuniq
(update from sandbox per Template talk:Convert#Module version 12)
>Johnuniq
(update from sandbox per Template talk:Convert#Module version 14)
Line 1: Line 1:
-- Text used by Module:Convert, for en.wikipedia.org (English).
-- Text used by Module:Convert for enwiki.
-- 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.
-- See [[:en:Template:Convert/Transwiki guide]] if copying to another wiki.
-- See [[:en:Template:Convert/Transwiki guide]] if copying to another wiki.
Line 50: Line 50:


-- One of the following categories is included in the text of each message.
-- One of the following categories is included in the text of each message.
-- Using the same category for each is simplest.
local all_categories = {
local all_categories = {
unit = "[[Category:Convert invalid units]]",
unit = "[[Category:Convert errors]]",
option = "[[Category:Convert invalid options]]",
option = "[[Category:Convert errors]]",
}
}


Line 62: Line 63:
-- All messages that may be displayed if a problem occurs.
-- All messages that may be displayed if a problem occurs.
local all_messages = {
local all_messages = {
-- Message format string, %s parameters: anchor, title, text, category.
-- Message format string: $1=title, $2=text, $3=category, $4=anchor.
-- Each displayed message starts with "Convert:" so can easily locate by searching article.
-- 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">convert: %s</span>]]</i>]</sup>%s',
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',
cvt_format2 = '<sup class="noprint Inline-Template" style="white-space:nowrap;">[[Help:Convert messages#%s|<span title="Convert: %s">%s</span>]]</sup>%s',
cvt_format2 = '<sup class="noprint Inline-Template" style="white-space:nowrap;">[[Help:Convert messages#$4|<span title="Convert: $1">$2</span>]]</sup>$3',
cvt_format_preview = '<strong class="error">Error in convert: $1 [[Help:Convert messages#$4|(help)]]</strong>$3',
-- Each of following messages is a table:
-- Each of following messages is a table:
-- { [1] = 'title',        -- mouseover title text
-- { [1] = 'title',        -- mouseover title text
Line 74: Line 76:
--  replace = gsub_table,
--  replace = gsub_table,
-- }                    Mouseover title text                          Link text              CatKey    Anchor
-- }                    Mouseover title text                          Link text              CatKey    Anchor
cvt_bad_num        = { 'Value "%s" must be a number'                , 'invalid number'      , 'option',  'invalid_number'      },
cvt_bad_input      = { 'input "$1" must be a number and unit'      , 'invalid input'      , 'option',  'invalid_input'        },
cvt_big_prec      = { 'Precision "%s" is too large'                , 'precision too large' , 'option',  'precision_too_large'  },
cvt_bad_num        = { 'Value "$1" must be a number'                , 'invalid number'      , 'option',  'invalid_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_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_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_no_num2        = { 'Needs another number for a range'          , 'needs another number', 'option',  'needs_another_number' },
cvt_bad_frac      = { 'frac "%s" must be an integer above 1'      , 'invalid fraction'    , 'option',  'invalid_fraction'    },
cvt_bad_frac      = { 'frac "$1" must be an integer above 1'      , 'invalid fraction'    , 'option',  'invalid_fraction'    },
cvt_bad_prec      = { 'Precision "%s" must be an integer'          , 'invalid precision'  , 'option',  'invalid_precision'    },
cvt_bad_prec      = { 'Precision "$1" must be an integer'          , 'invalid precision'  , 'option',  'invalid_precision'    },
cvt_bad_sigfig    = { 'sigfig "%s" must be a positive integer'    , 'invalid sigfig'      , 'option',  'invalid_sigfig'      },
cvt_bad_sigfig    = { 'sigfig "$1" must be a positive integer'    , 'invalid sigfig'      , 'option',  'invalid_sigfig'      },
cvt_empty_option  = { 'Ignored empty option "%s"'                  , 'empty option'        , 'option',  'empty_option'        },
cvt_empty_option  = { 'Ignored empty option "$1"'                  , 'empty option'        , 'option',  'empty_option'        },
cvt_deprecated    = { 'Option "%s" is deprecated'                  , '*'                  , 'option',  'deprecated_option', format = 'cvt_format2' },
cvt_deprecated    = { 'Option "$1" is deprecated'                  , '*'                  , 'option',  'deprecated_option', format = 'cvt_format2' },
cvt_no_spell      = { 'Spelling is not available'                  , 'bug, ask for help'  , 'option',  'ask_for_help'        },
cvt_no_spell      = { 'Spelling is not available'                  , 'bug, ask for help'  , 'option',  'ask_for_help'        },
cvt_unknown_option = { 'Ignored invalid option "%s"'                , 'invalid option'      , 'option',  'invalid_option'      },
cvt_unknown_option = { 'Ignored invalid option "$1"'                , 'invalid option'      , 'option',  'invalid_option'      },
cvt_bad_default    = { 'Unit "%s" has an invalid default'          , 'bug, ask for help'  , 'unit'  ,  'ask_for_help'        },
cvt_wd_fail        = { 'Unable to access Wikidata'                  , 'wikidata problem'    , 'option',  'wikidata_problem'    },
cvt_bad_unit      = { 'Unit "%s" is invalid here'                  , 'unit invalid here'  , 'unit'  ,  'unit_invalid_here'    },
cvt_bad_default    = { 'Unit "$1" has an invalid default'          , 'bug, ask for help'  , 'unit'  ,  'ask_for_help'        },
cvt_no_default    = { 'Unit "%s" has no default output unit'      , 'bug, ask for help'  , 'unit'  ,  'ask_for_help'        },
cvt_bad_unit      = { 'Unit "$1" is invalid here'                  , 'unit invalid here'  , 'unit'  ,  '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_no_unit        = { 'Needs name of unit'                        , 'needs unit name'    , 'unit'  ,  'needs_unit_name'      },
cvt_unknown        = { 'Unit name "%s" is not known'                , 'unknown unit'        , 'unit'  ,  'unknown_unit'        },
cvt_unknown        = { 'Unit name "$1" is not known'                , 'unknown unit'        , 'unit'  ,  'unknown_unit'        },
cvt_should_be      = { '%s'                                        , 'ambiguous unit'      , 'unit'  ,  'ambiguous_unit', regex = unitcode_regex, replace = unitcode_replace },
cvt_should_be      = { '$1'                                        , 'ambiguous unit'      , 'unit'  ,  'ambiguous_unit', regex = unitcode_regex, replace = unitcode_replace },
cvt_mismatch      = { 'Cannot convert "%s" to "%s"'                , 'unit mismatch'      , 'unit'  ,  'unit_mismatch'        },
cvt_mismatch      = { 'Cannot convert "$1" to "$2"'                , 'unit mismatch'      , 'unit'  ,  'unit_mismatch'        },
cvt_bug_convert    = { 'Bug: Cannot convert between specified units', 'bug, ask for help'  , 'unit'  ,  'ask_for_help'        },
cvt_bug_convert    = { 'Bug: Cannot convert between specified units', 'bug, ask for help'  , 'unit'  ,  'ask_for_help'        },
cvt_lookup        = { 'Unit "%s" is incorrectly defined'          , 'bug, ask for help'  , 'unit'  ,  'ask_for_help'        },
cvt_lookup        = { 'Unit "$1" is incorrectly defined'          , 'bug, ask for help'  , 'unit'  ,  'ask_for_help'        },
}
}


Line 176: Line 180:
["disp"] = "disp",
["disp"] = "disp",
["frac"] = "frac",
["frac"] = "frac",
["input"] = "input",
["lang"] = "lang",
["lang"] = "lang",
["lk"] = "lk",
["lk"] = "lk",
["near"] = "near",
["near"] = "near",
["order"] = "order",
["order"] = "order",
["qid"] = "qid",
["round"] = "round",
["round"] = "round",
["sigfig"] = "sigfig",
["sigfig"] = "sigfig",
Line 193: Line 199:
-- Convention: parms.opt_xxx refers to an option that is set here
-- Convention: parms.opt_xxx refers to an option that is set here
-- (not intended to be set by the template which invokes this module).
-- (not intended to be set by the template which invokes this module).
-- Example: At en.wiki, "abbr" includes:
-- Example: At enwiki, "abbr" includes:
--    ["comma"] = "opt_nocomma"
--    ["comma"] = "opt_nocomma"
-- As a result, if the template uses abbr=comma, this script sets:
-- As a result, if the template uses abbr=comma, Module:Convert sets:
--    parms["opt_nocomma"] = true
--    parms["opt_nocomma"] = true
--    parms["abbr"] = nil
--    parms["abbr"] = nil
Line 272: Line 278:
},
},
-- frac=x is handled as a special case: x must be an integer (possibly in local language) = 2 or more
-- 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)
["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
["en"] = "opt_lang_en",        -- use en digits for numbers, regardless of local language
Line 288: Line 295:
["flip"] = "opt_flip",          -- reverse order of input/output
["flip"] = "opt_flip",          -- reverse order of input/output
},
},
-- qid=x is handled as a special case: x should be a Wikidata Q item identifier.
["round"] = {
["round"] = {
["0.5"] = "opt_round=0.5",      -- round output value to nearest 0.5
["0.5"] = "opt_round=0.5",      -- round output value to nearest 0.5
Anonymous user

Navigation menu