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  
----------------------------< L A N G _ X X _ I T A L I C >--------------------------------------------------  
Entry point for those templates that call lang_xx_italic. Sets the initial style state to italic.  
local function lang_xx_italic
local args = lang_xx_args_get (, cfg.templates_t.langxx);
args.fn = nil; -- unset because not supported but this function might have been called by  
local msg = parameter_validate (args, cfg.templates_t.langxx); -- verify that all supplied parameters are supported by
if msg then
return make_error_msg (msg, args, cfg.templates_t.langxx); -- when template has unsupported params, abandon with error message
end  
initial_style_state = 'italic';
return _lang_xx (args, cfg.templates_t.langxx) .. ''; -- temporary category
end  
----------------------------< _ L A N G _ X X _ I T A L I C >------------------------------------------------  
Entry point from another module. Sets the initial style state to italic.  
local function _lang_xx_italic (args)
initial_style_state = 'italic';
return _lang_xx (args, cfg.templates_t.langxx);
end  
----------------------------< L A N G _ X X _ I N H E R I T >------------------------------------------------  
Entry point for those templates that call lang_xx_inherit. Sets the initial style state to inherit.  
local function lang_xx_inherit
local args = lang_xx_args_get (, cfg.templates_t.langxx);
args.fn = nil; -- unset because not supported but this function might have been called by  
local msg = parameter_validate (args, cfg.templates_t.langxx); -- verify that all supplied parameters are supported by
if msg then
return make_error_msg (msg, args, cfg.templates_t.langxx); -- when template has unsupported params, abandon with error message
end  
initial_style_state = 'inherit';
return _lang_xx (args, cfg.templates_t.langxx) .. ''; -- temporary category
end  
----------------------------< _ L A N G _ X X _ I N H E R I T >----------------------------------------------  
Entry point from another module. Sets the initial style state to inherit.  
local function _lang_xx_inherit (args)
initial_style_state = 'inherit';
return _lang_xx (args, cfg.templates_t.langxx);
end  
----------------------------< _ L A N G X >------------------------------------------------------------------  
Entry point from another module.  
local function _langx (args_t)
local langx_data = mw.loadData ('Module:Lang/langx'); -- get necessary data
local rtl_t = langx_data.rtl_t; -- get list of language tags for languages that are rendered -to-
local link_t = langx_data.link_t; -- get list of language tags for templates that set |link=<something>
local size_t = langx_data.size_t; -- get list of language tags for templates that set |size=<something>  
local msg = parameter_validate (args_t, cfg.templates_t.langx);
if msg then
return make_error_msg (msg, args_t, cfg.templates_t.langx);
end  
args_t.code = args_t[1] or args_t.code; -- get the language tag; must be } or |code=
if not args_t.code then
return make_error_msg (cfg.get_ietf_parts_t.missing_lang_tag, args_t, cfg.templates_t.langx);
end  
args_t.rtl = args_t.rtl or (rtl_t[args_t.code] and cfg.keywords_t.affirmative); -- prefer |rtl= in template call, use rtl_t else
args_t.link = args_t.link or link_t[args_t.code]; -- prefer |link= in template call, use link_t felse
args_t.size = args_t.size or size_t[args_t.code]; -- prefer |size= in template call, use size_t else  
args_t[1] = nil; -- unset to mimic templates which set |code=xx  
local lang_subtag = args_t.code; -- use only the base language subtag for unsupported tag test; some args_t.code are modified by |script= etc
return _lang_xx (args_t, cfg.templates_t.langx);
end  
-- 1 | 2 | 3 | 4  
The calls to lang_xx_args_get and _lang_xx use 'Langx' as a flag for those functions to select the proper
positional parameters.  
depends on the calling template to select 'inherit' or 'italic' to establish the default rendering.  
can't do that. The initial version of relied on a list of language tags (inherit_t in ~/langx)
scraped from those templates that call lang_xx_inherit to render text in upright font. Langx now
uses auto-italics code adapted from (doesn't support poem tags).  
local function langx
local args_t = lang_xx_args_get (, cfg.templates_t.langx); -- get the arguments; 'Langx' is the <base_template> used to decide which positional param is 'text', 'translit', 'lit'  
return _langx (args_t);
end  
----------------------------< _ I S _ I E T F _ T A G >------------------------------------------------------  
Returns true when a language name associated with IETF language tag exists; nil else. IETF language tag must be valid.  
All code combinations supported by and the templates are supported by this function.  
Module entry point from another module.  
local function _is_ietf_tag (tag) -- entry point when this module is required into another
local c, s, r, v, p, err; -- code, script, region, variant, private, error message
c, s, r, v, p, err = get_ietf_parts (tag); -- disassemble tag into constituent part and validate  
return ((c and not err) and true) or nil; -- return true when code portion has a value without error message; nil else
end  
----------------------------< I S _ I E T F _ T A G >--------------------------------------------------------  
Module entry point from an .  
local function is_ietf_tag
return _is_ietf_tag (getArgs [1]); -- args[1] is the ietf language tag to be tested; also get parent
end  
----------------------------< I S _ I E T F _ T A G _ F R A M E >--------------------------------------------  
Module entry point from an ; same as is_ietf_tag except does not get parameters from the parent
(template) . This function not useful when called by because <tag>
is in the parent .  
local function is_ietf_tag_frame
return _is_ietf_tag (getArgs (, {frameOnly = true,})[1]); -- args[1] is the ietf language tag to be tested; do not get parent
end  
--link= parameter to yes to get wikilinked version of the language name.  
Module entry point from another module.  
local function _name_from_tag (args)
local subtags = {}; -- IETF subtags script, region, variant, and private
local raw_code = args[1]; -- save a copy of the input IETF subtag
local link = cfg.keywords_t.affirmative == args['link']; -- make a boolean
local label = args.label;
local code; -- the language code
local msg; -- gets an error message if IETF language tag is malformed or invalid
local language_name = '';  
code, subtags.script, subtags.region, subtags.variant, subtags.private, msg = get_ietf_parts (raw_code);
if msg then
local template = (args['template'] and table.concat ({': '})) or ''; -- make template name (if provided by the template)
return make_error_span (template, msg);
end  
raw_code = format_ietf_tag (code, subtags.script, subtags.region, subtags.variant, subtags.private); -- format to recommended subtag styles; private omitted because private
language_name = language_name_get (raw_code, code); -- get language name; try ietf tag first, then code w/o variant then code w/ variant  
if 'yes' ~= args.raw then
language_name = language_name:gsub ('%s+%b', ''); -- remove IANA parenthetical disambiguators or qualifiers from names that have them
end  
if link then -- when |link=yes, wikilink the language name
if mw.ustring.find (language_name, 'languages', 1, true) then
language_name = make_wikilink (language_name, label); -- collective language name uses simple wikilink
elseif lang_data.article_name[raw_code:lower] then -- is ietf tag in article name override?
language_name = make_wikilink (lang_data.article_name[raw_code:lower], label or language_name); -- language name with wikilink from override data
elseif lang_data.article_name[code] then -- is language tag in article name override?