else
args.italic = 'inherit'; -- italic not set; script not latn; inherit current style
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.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  
if cfg.keywords_t.invert == args.italic and 'span' == tag then -- invert only supported for in-line content
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, language_name));
table.insert (out, make_category (code, language_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 >----------------------------------------------------------------------  
Entry point for .  
There should be no reason to set parameters in the
<includeonly></includeonly>  
Parameters are received from the template's (parent ).  
local function lang
local args_t = getArgs (, { -- this code so that we can detect and handle wiki list markup in text
valueFunc = function (key, value)
if 2 == key or 'text' == key then -- the 'text' parameter; do not trim wite space
return value; -- return untrimmed 'text'
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
});  
args_t.fn = nil; -- unset because not supported but this function might have been called by  
local msg = parameter_validate (args_t, cfg.templates_t.lang); -- verify that all supplied parameters are supported by
if msg then
return make_error_msg (msg, args_t, cfg.templates_t.lang); -- when template has unsupported params, abandon with error message
end  
return _lang (args_t);
end  
----------------------------< T R A N S L A T I O N _ M A K E >----------------------------------------------  
Stand-alone function to create literal translation of main text.  
Also used by .  
local function translation_make (args_t)
local translation_t = {', '}; -- initialize output  
if '' ~= args_t.label then -- if we want a label
table.insert (translation_t, '<small>'); -- open the <small> html tag
if cfg.keywords_t.negative == args_t.link then
table.insert (translation_t, substitute ('<abbr title="$1">$2</abbr>', {cfg.translation_make_t.lit_xlation, cfg.translation_make_t.lit_abbr})); -- unlinked form
else
table.insert (translation_t, make_wikilink (cfg.translation_make_t.lit_xlation, cfg.translation_make_t.lit_abbr)); -- linked form
end
table.insert (translation_t, "&thinsp;</small>"); -- close the <small> html tag
end
table.insert (translation_t, table.concat ({'&#39;', args_t.translation, '&#39;'})); -- use html entities to avoid wiki markup confusion
return table.concat (translation_t); -- make a big string and done
end  
--script= as well.  
For each template choose the appropriate entry-point function so that this function knows the default
styling that should be applied to text.  
For normal, upright style:
<includeonly></includeonly>
For italic style:
<includeonly></includeonly>  
All other parameters should be received from the template's (parent )  
Supported parameters are:
|code = (required) the IANA language code
|script = IANA script code; especially for use with languages that use multiple writing systems
|region = IANA region code
|variant = IANA variant code
|text = (required) the displayed text in language specified by code
|link = boolean false ('no') does not link code-spcified language name to associated language article
|rtl = boolean true ('yes') identifies the language specified by code as a -to- language
|nocat = boolean true ('yes') inhibits normal categorization; error categories are not affected
|cat = boolian false ('no') opposite form of |nocat=
|italic = boolean true ('yes') renders displayed text in italic font; boolean false ('no') renders displayed text in normal font; not set renders according to initial_style_state
|lit = text that is a literal translation of text
|label = '' to suppress all labeling (language name, 'translit.', 'lit.')
any other text replaces language-name label - automatic wikilinking disabled  
for those templates that support transliteration (those templates where |text= is not entirely latn script):
|translit = text that is a transliteration of text
|translit-std = the standard that applies to the transliteration
|translit-script = ISO 15924 script name; falls back to code  
For , the positional parameters are:
} text
} transliterated text
} literal translation text
no other positional parameters are allowed  
local function _lang_xx (args, base_template) -- base_template will be either of 'Langx' or 'Lang-xx'
local out = {};
local language_name; -- used to make display text, article links
local category_name; -- same as language_name except that it retains any parenthetical disambiguators (if any) from the data set
local subtags = {}; -- IETF subtags script, region, and variant
local code; -- the language code  
local translit_script_name; -- name associated with IANA (ISO 15924) script code
local translit;
local msg; -- for error messages
local tag = 'span'; -- initial value for make_text_html
local template = args.template or base_template;  
maint_cats = {}; -- initialize because when this module required into another module, these only declared once so only initialzed once
maint_msgs = {};  
local text_idx = (cfg.templates_t.langx == base_template) and 2 or 1; -- for 'text' positional parameter is '2'
local translit_idx = (cfg.templates_t.langx == base_template) and 3 or 2;
local xlate_idx = (cfg.templates_t.langx == base_template) and 4 or 3;  
if args[text_idx] and args.text then
return make_error_msg (substitute (cfg.lang_t.conflict_n_param, {translit_idx, cfg.lang_t.conflict_n_param_types.text}), args, template);
else
args.text = args[text_idx] or args.text; -- prefer positional 'text' parameter
end  
msg = validate_text (template, args); -- ensure that |text= is set, does not contain italic markup and is protected from improper bolding
if is_set (msg) then
return msg;
end  
args.text, tag = html_tag_select (args.text); -- inspects text; returns appropriate html tag with text trimmed accordingly  
if args[translit_idx] and args.translit then
return make_error_msg (substitute (cfg.lang_t.conflict_n_param, {translit_idx, cfg.lang_t.conflict_n_param_types.translit}), args, template);  
else
args.translit = args[translit_idx] or args.translit -- prefer positional 'translit' parameter
end  
args.engvar = cfg.engvar_sel_t[args.engvar] or cfg.default_engvar; -- |engvar= when valid; cfg.default_engvar else  
if args[xlate_idx] and (args.translation or args.lit) then
return make_error_msg (substitute (cfg.lang_xx_t.conflict_n_lit, {translit_idx}), args, template);
elseif args.translation and args.lit then
return make_error_msg (cfg.lang_xx_t.conflict_lit, args, template);
else
args.translation = args[xlate_idx] or args.translation or args.lit; -- prefer positional 'translation' parameter
end  
if args.links and args.link then
return make_error_msg (cfg.lang_xx_t.conflict_link, args, template);
else
args.link = args.link or args.links; -- prefer args.link
end  
validate_cat_args (args); -- determine if categorization should be suppressed