else
args.link = args.link or args.links; -- prefer args.link
end  
validate_cat_args (args); -- determine if categorization should be suppressed  
args.rtl = args.rtl == cfg.keywords_t.affirmative; -- convert to boolean: 'yes' -> true, other values -> false  
code, subtags.script, subtags.region, subtags.variant, subtags.private, msg = get_ietf_parts (args.code, args.script, args.region, args.variant); -- private omitted because private  
if msg then -- if an error detected then there is an error message
return make_error_msg (msg, args, template);
end  
if args.translit then
local latn, pos, char;
latn, args.translit, pos, char = is_latin (args.translit, (('' ~= subtags.private) and (code .. '-x-' .. subtags.private)) or code);
if not latn then
return make_error_msg (substitute (cfg.lang_xx_t.translit_nonlatn, {pos, char}), args, template);
end
end  
local is_latn_text, text, pos, char = is_latin (args.text, code); -- make a boolean
args.text = text; -- may have been modified (accept-as-written markup removed)  
msg = text_script_match_test (subtags.script, is_latn_text, pos, char)
if msg then -- if an error detected then there is an error message
return make_error_msg (msg, args, template);
end  
args.italic, msg = validate_italic (args);
if msg then
return make_error_msg (msg, args, template);
end  
if cfg.templates_t.langx == base_template then -- auto-italics for templates; adapted from (no support for poem tag)
if nil == args.italic then -- nil when |italic= absent or not set or |italic=default; args.italic controls
if ('latn' == subtags.script) or -- script is latn
(this_wiki_lang_tag ~= code and not is_set (subtags.script) and is_latn_text) then -- text is not this wiki's language, no script specified and is wholly latn script (auto-italics)
args.italic = 'italic'; -- set font-style:italic
else
args.italic = 'inherit'; -- italic not set; script not latn; inherit current style
end
end  
else -- does not do auto italics; retained for those wikis that don't support
if nil == args.italic then -- args.italic controls
if is_set (subtags.script) then
if 'latn' == subtags.script then
args.italic = 'italic'; -- |script=Latn; set for font-style:italic
else
args.italic = initial_style_state; -- italic not set; script is not latn; set for font-style:<initial_style_state>
end
else
args.italic = initial_style_state; -- here when |italic= and |script= not set; set for font-style:<initial_style_state>
end
end
end  
if is_set (subtags.script) then -- if script set override rtl setting
if in_array (subtags.script, lang_data.rtl_scripts) then
args.rtl = true; -- script is an rtl script
else
args.rtl = false; -- script is not an rtl script
end
end  
args.proto, msg = validate_proto (args.proto); -- return boolean, or nil, or nil and error message flag
if msg then
return make_error_msg (substitute (cfg.lang_t.invalid_proto, {args.proto}), args, template);
end  
args.code = format_ietf_tag (code, subtags.script, subtags.region, subtags.variant, subtags.private); -- format to recommended subtag styles
language_name = language_name_get (args.code, code, true); -- get language name; try ietf tag first, then code w/o variant then code w/ variant  
category_name = language_name; -- category names retain IANA parenthetical diambiguators (if any)
language_name = language_name:gsub ('%s+%b', ''); -- remove IANA parenthetical disambiguators or qualifiers from names that have them  
if args.label then
if '' ~= args.label then
table.insert (out, table.concat ({args.label, ': '})); -- custom label
end
else
if cfg.keywords_t.negative == args.link then
table.insert (out, language_name); -- language name without wikilink
else
if mw.ustring.find (language_name, 'languages', 1, true) then
table.insert (out, make_wikilink (language_name)); -- collective language name uses simple wikilink
elseif lang_data.article_name[args.code:lower] then -- is ietf tag in article name over ride?
table.insert (out, make_wikilink (lang_data.article_name[args.code:lower], language_name)); -- language name with wikilink from override data
elseif lang_data.article_name[code] then -- is language tag in article override
table.insert (out, make_wikilink (lang_data.article_name[code], language_name)); -- language name with wikilink from override data
else
table.insert (out, make_wikilink (substitute ('$1 $2', {language_name, cfg.misc_text_t.language}), language_name)); -- language name with wikilink
end
end
table.insert (out, ': '); -- separator
end  
if cfg.keywords_t.invert == args.italic then
args.text = invert_italics (args.text)
end  
args.text = proto_prefix (args.text, language_name, args.proto); -- prefix proto-language text with a splat  
table.insert (out, make_text_html (args.code, args.text, tag, args.rtl, args.italic, args.size, ('' == args.label) and language_name or nil))  
if is_set (args.translit) and not is_latn_text then -- transliteration; not supported when args.text is wholly latn text (this is an imperfect test)
table.insert (out, ', '); -- comma to separate text from translit
if '' ~= args.label then
table.insert (out, '<small>');
if script_table[args['translit-script']] then -- when |translit-script= is set, try to use the script's name
translit_script_name = script_table[args['translit-script']];
else
translit_script_name = language_name; -- fall back on language name
end  
local translit_title_obj = mw.title.makeTitle (0, substitute ('$1 $2',{cfg.lang_xx_t.romanization, translit_script_name})); -- make a title object; no engvar, article titles use US spelling
if translit_title_obj.exists and (cfg.keywords_t.negative ~= args.link) then
table.insert (out, make_wikilink (substitute ('$1 $2', {cfg.lang_xx_t.romanization, translit_script_name or language_name}),
substitute ('$1', {cfg.engvar_t[args.engvar]['romanisz_pt']})) .. ':'); -- make a wikilink if there is an article to link to; engvar the display text  
else
table.insert (out, substitute ('$1:', {cfg.engvar_t[args.engvar]['romanisz_pt']})); -- else plain text per engvar  
end
table.insert (out, '&nbsp;</small>'); -- close the small tag
end  
translit = make_translit (args.code, language_name, args.translit, args['translit-std'], args['translit-script'], nil, args.engvar)
if is_set (translit) then
table.insert (out, translit);
else
return make_error_msg (substitute ('$1: $2', {cfg.lang_xx_t.invalid_xlit_std, args['translit-std'] or '[missing]'}), args, template);
end  
elseif is_set (args.translit) and is_latn_text then -- when creating a transliteration of Latn script <text>
return make_error_msg (cfg.lang_xx_t.xlit_of_latn, args, template); -- emit error message and abandon
end  
if is_set (args.translation) then -- translation (not supported in )
table.insert (out, translation_make (args));
end  
table.insert (out, make_category (code, category_name, args.nocat));
table.insert (out, render_maint(args.nocat)); -- maintenance messages and categories  
return table.concat (out); -- put it all together and done
end  
----------------------------< L A N G _ X X _ A R G S _ G E T >----------------------------------------------  
Common function to get args table from templates.  
Returns table of args.  
Text positional parameters are not trimmed here but are selectively trimmed at html_tag_select.  
local function lang_xx_args_get (, base_template)
local args_t = getArgs(,
{
parentFirst= true, -- parameters in the template override parameters set in the
valueFunc = function (key, value)
if ((cfg.templates_t.langx == base_template) and 2 or 1) == key then -- the 'text' positional parameter; 1 for , 2 for ; do not trim wite space
return value; -- return untrimmed 'text' positional parameter
elseif value then -- all other values: if the value is not nil
value = mw.text.trim (value); -- trim whitespace
if '' ~= value then -- empty string when value was only whitespace
return value;
end
end
return nil; -- value was empty or contained only whitespace
end -- end of valueFunc
});  
return args_t;
end