elseif lang_data.article_name[code] then -- is language tag in article name override?
language_name = make_wikilink (lang_data.article_name[code], label or language_name); -- language name with wikilink from override data
else
language_name = make_wikilink (substitute ('$1 $2', {language_name, cfg.misc_text_t.language}), label or language_name); -- language name with wikilink
end
end  
return language_name;
end  
----------------------------< N A M E _ F R O M _ T A G >----------------------------------------------------  
Module entry point from an .  
local function name_from_tag -- entry point from an
return _name_from_tag (getArgs) -- pass-on the args table, nothing else; getArgs so we also get parent
end  
----------------------------< _ T A G _ F R O M _ N A M E >--------------------------------------------------  
Returns the ietf language tag associated with the language name. Spelling of language name must be correct
according to the spelling in the source tables. When a standard language name has a parenthetical disambiguator,
that disambiguator must be omitted (they are not present in the data name-to-tag tables).  
Module entry point from another module.  
local function _tag_from_name (args) -- entry point from another module
local msg;  
if args[1] and '' ~= args[1] then
local data = mw.loadData ('Module:Lang/tag from name'); -- get the reversed data tables TODO: change when going live
local lang = args[1]:lower; -- allow any-case for the language name (speeling must till be correct)
local tag = data.rev_override_table[lang] or data.rev_lang_table[lang] or data.rev_lang_dep_table[lang]; -- get the code; look first in the override then in the standard  
if tag then
return tag, true; -- language name found so return tag and done; second return used by is_lang_name
else
msg = substitute (cfg.tag_from_name_t.lang_not_found, {args[1]}); -- language name not found, error message
end
else
msg = cfg.tag_from_name_t.missing_lang_name; -- language name not found, error message
end  
local template = '';
if args.template and '' ~= args.template then
template = table.concat ({': '}); -- make template name (if provided by the template)
end
return make_error_span (template, msg);  
end  
----------------------------< T A G _ F R O M _ N A M E >----------------------------------------------------  
Module entry point from an .  
local function tag_from_name -- entry point from an
local result, _ = _tag_from_name (getArgs) -- pass-on the args table, nothing else; getArgs so we also get parent ; supress second return used by is_lang_name
return result;
end  
----------------------------< I S _ L A N G _ N A M E >------------------------------------------------------  
Module entry point from an .  
local function is_lang_name
local _, result = _tag_from_name (getArgs) -- pass-on the args table, nothing else; getArgs so we also get parent ; supress second return used by tag_from_name
return result and true or nil;
end  
----------------------------< _ T R A N S L >----------------------------------------------------------------  
Module entry point from another module.  
local function _transl (args)
local title_table = lang_data.translit_title_table; -- table of transliteration standards and the language codes and scripts that apply to those standards
local language_name; -- language name that matches language code; used for tool tip
local translit; -- transliterated text to display
local script; -- IANA script
local msg; -- for when called functions return an error message
local template = args.template or cfg.templates_t.transliteration;  
maint_cats = {}; -- initialize because when this module required into another module, these only declared once so only initialzed once
maint_msgs = {};  
if is_set (args[3]) then -- [3] set when
args.text = args[3]; -- get the transliterated text
args.translit_std = args[2] and args[2]:lower; -- get the standard; lower case for table indexing  
if not title_table[args.translit_std] then
return make_error_msg (substitute (cfg.transl_t.unrecog_xlit_std, {args.translit_std}), args, template);
end
else
if is_set (args[2]) then -- [2] set when
args.text = args[2]; -- get the transliterated text
else
if args[1] and (args[1]:match ('^%a%a%a?%a?$') or -- args[2] missing; is args[1] a language or script tag or is it the transliterated text?
args[1]:match ('^%a%a%a?%-x%-')) then -- or is args[1] a private-use tag
return make_error_msg (cfg.transl_t.no_text, args, template); -- args[1] is a code so we're missing text
else
args.text = args[1]; -- args[1] is not a code so we're missing that; assign args.text for error message
return make_error_msg (cfg.transl_t.missing_lang_scr, args, template);
end
end
end  
if is_set (args[1]) then -- IANA language code used for html lang= attribute; or ISO 15924 script code
if args[1]:match ('^%a%a%a?%a?$') or args[1]:match ('^%a%a%a?%-x%-') then -- args[1] has correct form?
args.code = args[1]:lower; -- use the language/script code; only (2, 3, or 4 alpha characters) or private-use; lower case because table indexes are lower case
else
return make_error_msg (substitute (cfg.transl_t.unrecog_lang_scr, {args[1]}), args, template); -- invalid language / script code
end
else
return make_error_msg (cfg.transl_t.missing_lang_scr, args, template); -- missing language / script code so quit
end  
local is_latn_text, pos, char;
is_latn_text, args.text, pos, char= is_latin (args.text, args.code); -- is latn text? strip accept-as-written markup
if not is_latn_text then -- when text is not latn
return make_error_msg (substitute (cfg.lang_xx_t.translit_nonlatn, {pos, char}), args, template); -- abandon with error message
end  
args.italic, msg = validate_italic (args);
if msg then
return make_error_msg (msg, args, template);
end  
if 'italic' == args.italic then -- 'italic' when |italic=yes; because that is same as absent or not set and |italic=default
args.italic = nil; -- set to nil;
end  
args.engvar = cfg.engvar_sel_t[args.engvar] or cfg.default_engvar; -- |engvar= when valid; cfg.default_engvar else  
if override_table[args.code] then -- is code a language code defined in the override table?
language_name = override_table[args.code];
args.code = args.code:match ('^%a%a%a?'); -- if private use, strip all but language subtag
elseif lang_table[args.code] then -- is code a language code defined in the standard language code tables?
language_name = lang_table[args.code];
elseif lang_dep_table[args.code] then -- is code a language code defined in the deprecated language code tables?
language_name = lang_dep_table[args.code];
elseif script_table[args.code] then -- if here, code is not a language code; is it a script code?
language_name = script_table[args.code];
script = args.code; -- code was an ISO 15924 script so use that instead
args.code = ''; -- unset because not a language code
else
return make_error_msg (substitute (cfg.transl_t.unrecog_lang_scr, {args.code}), args, template); -- invalid language / script code
end
-- here only when all parameters passed to make_translit are valid
return make_translit (args.code, language_name, args.text, args.translit_std, script, args.italic, args.engvar);
end  
----------------------------< T R A N S L >------------------------------------------------------------------  
Module entry point from an .  
local function transl
return _transl (getArgs);
end  
----------------------------< C A T E G O R Y _ F R O M _ T A G >--------------------------------------------  
Returns category name associated with IETF language tag if valid; error message else.  
All code combinations supported by and the templates are supported by this function.  
Module entry point from another module.  
local function _category_from_tag (args_t)
local subtags = {}; -- IETF subtags script, region, variant, and private
local raw_code = args_t[1]; -- save a copy of the input IETF subtag
local link = cfg.keywords_t.affirmative == args_t.link; -- make a boolean
local label = args_t.label;