Content deleted Content added
check for "empty_list_error" |
some simplifications |
||
(6 intermediate revisions by 3 users not shown) | |||
Line 68:
args_t.fontsize - deprecated alias of |parensize=
args_t.nolink - any value inhibits wikilinking of language name
args_t.suppress_empty_list_error - when set to 'yes', suppresses an 'empty' error message; mostly for use within another template
this function calls these functions in Module:lang:
Line 85 ⟶ 87:
local template = (args_t.template and args_t.template) or 'native name'; -- for error messaging; use 'native name list' when called from native_name_list(), etc
if not (args_t[1] or args_t[2]) and yes_no (args_t.suppress_empty_list_error) then
return ''; -- if empty list error is suppressed, return empty string
return error_msg ((args_t.index and messages_t.tag_required_idx) or messages_t.tag_required, template, args_t.index)
elseif not args_t[2] then
▲ if not args_t[2] then
return error_msg ((args_t.index and messages_t.name_required_idx) or messages_t.name_required, template, args_t.index)
end
Line 115 ⟶ 118:
if args_t.nolink then
table.insert (out_t, table.concat ({'(', lang_module._name_from_tag ({args_t[1], ['template']=template}), ')'}));
else
▲ if lang_module._is_ietf_tag (args_t[1]) then
▲ table.insert (out_t, table.concat ({'(', lang_module._name_from_tag ({args_t[1], ['link'] ='yes', ['template']=template}), ')'}));
▲ table.insert (out_t, '(language?)'); -- TODO: any reason to keep this?
end
Line 160 ⟶ 161:
also supports:
args_t.postfixn - wikitext to be appended to list item n (references other appropriate text)
args_t.suppress_empty_list_error - when set to 'yes', suppresses an 'empty list' error message; mostly for use within another template
]]
Line 168 ⟶ 170:
end
local unsorted_enumerators_t = {} -- unsorted k/v table of tagn and namen enumerators where k is the enumerator and v is always true
for param, _ in pairs (args_t) do -- loop through all parameters
local enumerator = mw.ustring.match (param, "^tag(%d+)$") -- is this a |tagn= parameter? extract enumerator if present
if enumerator then -- if there is an enumerator
unsorted_enumerators_t[tonumber(enumerator)] = true -- add enumerator to the table
else
local name_match = mw.ustring.match (param, "^name(%d+)$") -- is this a |tagn= parameter? extract enumerator if
if name_match then -- if there is an enumerator
end
end
end
local enumerators_t = {} -- will hold a sorted sequence of enumerators
for n, _ in pairs (
table.insert (
end
table.sort (
local list_t = {}; -- list of formatted native names goes here
for _, n in ipairs (
table.insert (list_t, table.concat ({
_native_name ({ -- go render the native name
args_t['tag'..n],
Line 206:
['template'] = 'native name list', -- for error messaging
['index'] = n, -- for error messaging
args_t['postfix'..n] or '',
}));
end
if 0
return (yes_no (args_t.suppress_empty_list_error) and '') or -- return empty string when error suppressed
if 1 < #list_t then▼
▲ return error_msg (messages_t.empty_list, 'native name list'); -- default return empty list error
else
return require ('Module:List').unbulleted (list_t); -- use unbulleted list from module
end
end
Line 277 ⟶ 268:
return table.concat ({value, error_msg (messages_t.malformed_param, 'native name checker')}, ' '); -- no {{lang}} or {{native_name}} template
end
if 1 < count
and value:find ('</div>$'))
then return table.concat ({value, error_msg (messages_t.list_markup, 'native name checker')}, ' '); end
|