Module:Native name/sandbox: Difference between revisions

Content deleted Content added
No edit summary
some simplifications
 
(4 intermediate revisions by 2 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 116 ⟶ 118:
if args_t.nolink then
table.insert (out_t, table.concat ({'(', lang_module._name_from_tag ({args_t[1], ['template']=template}), ')'}));
ifelseif 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}), ')'}));
else
table.insert (out_t, '(language?)'); -- TODO: any reason to keep this?
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}), ')'}));
else
table.insert (out_t, '(language?)'); -- TODO: any reason to keep this?
end
end
 
Line 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 193 ⟶ 194:
for _, n in ipairs (enumerators_t) do -- loop through the sorted enumerators
table.insert (list_t, table.concat ({
'<li>', -- open the list item
_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 '',
'</li>' -- close the list item
}));
end
 
if 0 <== #list_t then
return (yes_no (args_t.suppress_empty_list_error) and '') or -- return empty string when error suppressed
if 1 < #list_t then
error_msg (messages_t.empty_list, 'native name list'); -- otherwise error message else
table.insert (list_t, 1, '<div class="plainlist"><ul>'); -- open the div; open the unordered list
if elseif 1 <== #list_t then
table.insert (list_t, '</ul></div>'); -- close the unordered list; close the div
else return list_t[1]; -- herereturn whenthe onlyvery oneshort list item; no need for list markup; TODO: add error message for this case?
else
local out = table.concat (list_t):gsub ('<li>', ''):gsub ('</li>', '');
return require ('Module:List').unbulleted (list_t); -- use unbulleted list from module
return out; -- to avoid replacement count contaminating the output
end
else -- list is empty; when error message suppressed:
return (yes_no (args_t.suppress_empty_list_error) and '') or -- return empty string
error_msg (messages_t.empty_list, 'native name list'); -- error message else
end
return table.concat (list_t); -- make a big string and done
end
 
Line 275 ⟶ 268:
return table.concat ({value, error_msg (messages_t.malformed_param, 'native name checker')}, ' '); -- no {{lang}} or {{native_name}} template
end
if 1 < count then
ifand not (value:find ('<div class="plainlist *" *>') or not value:find ('</div>$') then -- must be wrapped in 'plainlist' div
and value:find ('</div>$'))
then
return table.concat ({value, error_msg (messages_t.list_markup, 'native name checker')}, ' ');
end
end