TODO:
		all non-English text wrapped in ?
		distingush various scripts? Kanji is ja-Hani ...
		every child infobox should support translit / transcription parameter(s)
		every child infobox should have a literal meaning parameter
		revise parameter names to be IETF language code or obvious derivations thereof
		for error messaging create a separate ibox? else messages are not necessarily visible
]]

require('strict');
local data = mw.loadData ('Module:Infobox multi-lingual name/data');
local lang_mod = require ('Module:Lang');										-- for various functions and templates provided by Module:Lang
local getArgs = require ('Module:Arguments').getArgs;

----------------------------------------------------------------------------------------------

Returns true if argument is set; false otherwise. Argument is 'set' when it exists (not nil) or when it is not an empty string.


local function is_set( var )
	return not (var == nil or var == '');
end

--------------------------------------------------------------------------------------------

Returns true if any member of the table is set; false otherwise. Argument is 'set' when it exists (not nil) or when it is not an empty string.


local function any_set (t)
	for _, v in pairs (t) do
		if is_set (v) then
			return true;
		end
	end
	
	return false;
end

--showflag= parameter from the template . That template passes the
value to which calls this function. This function does not take any frame parameters
but it does require a copy of the frame so that it can expand . All arguments used by this function
come from the args table in the function call

returns a child infobox or an empty string


local function showflag 
	local show_flag = args.showflag; 

	if not is_set (show_flag) then
		return '';																-- |showflag= not set so nothing to do; return empty string
	end

	local infobox_args = {};													-- table to hold arguments for frame:expandTemplate
	
	infobox_args['child'] = 'yes';												-- showflag infoboxen are always children
	infobox_args['labelstyle'] = 'font-weight:normal';							-- and always have this label style

	if data.transl_map[show_flag] then
		local i=1;
		while (1) do
			local labeln = 'label' .. i;										-- make label index that matches |labeln= parameter 
			local datan = 'data' .. i;											-- make data index that matches |datan= parameter 
			if not data.transl_map[show_flag][labeln] then
				break;															-- not found then done
			end
			infobox_args[labeln] = data.label_map[data.transl_map[show_flag][labeln]];	-- add |labeln=
			infobox_args[datan] = args[data.transl_map[show_flag][datan]];		-- add |datan=}
			i = i + 1;															-- bump to next label / data pair
		end
	else
		return '';																-- |showflag= value invalid; TODO: return error message?
	end
	
	return frame:expandTemplate ;
	end

--------------------------------------------------------------------

Adds a label parameter and matching data parameter to infobox arguments table; bumps the enumerator on return


local function add_label_data_pair 
	if is_set (data) then
		infobox_args['label' .. i] = label;										-- make an enumerated label parameter
		infobox_args['data' .. i] = data;										-- make an enumerated data parameter
	
		return i + 1;															-- return bumped enumerator
	end

	return i;																	-- if here, no data so no need to add label or bump enumerator
end

--headern=, |labeln=, |datan=; in this application i continually
		increments; there are no gaps as there are in the original template
	lang - language code used by - must be valid IETF code

returns i for the next time this function is called


local function add_transcription 
	infobox_args['header' .. i] = show and data.xscript[idx].header;			-- if headers are displayed
	i = i + 1;																	-- bump the enumerator
	for _, v in ipairs (data.xscript[idx].t) do									-- each label / data pair in the xscript subtable
		i = add_label_data_pair (infobox_args, v[1], is_set (args[v[2]]) and lang_mod._transl , i);	-- enumerator is bumped here
	end
	
	return i;																	-- and done
end

------------------------------------------------------------------------

transcriptions support for . This function adds headers and label data pairs to
infobox_arg table according to which parameters are set

returns the enumerator in case it is needed


local function transcriptions_zh 
	if any_set  then
		i = add_transcription ;
	end

	if any_set  then
		i = add_transcription ;
	end
		
	if any_set  then					-- ???? ouji was not included here in original template; why?
		i = add_transcription ;
	end
	
	if is_set (args.gan) then
		i = add_transcription ;
	end
	
	if is_set (args.hsn) then
		i = add_transcription ;
	end

	if any_set  then
		i = add_transcription ;
	end

	if any_set  then	-- ???? sl, hk, mo not here in original; why?
		i = add_transcription ;
	end

	if is_set (args.toi) then
		i = add_transcription ;
	end

	if any_set  then	-- ???? bp not here in original; why?
		i = add_transcription ;
	end

	if is_set (args.buc) then
		i = add_transcription ;
	end

	if is_set (args.hhbuc) then
		i = add_transcription ;
	end

	if is_set (args.mblmc) then
		i = add_transcription ;
	end

	if is_set (args['phagspa-latin']) then										-- phagspa is a script
		i = add_transcription ;
	end

	if any_set  then
		i = add_transcription ;
	end

	if any_set  then
		i = add_transcription ;
	end

	return i;																	-- return current state of the enumerator
end

------------------------------------------------------------------------------

This function handles the transcription infobox called by various . Creates header and
label / data pairs according to the presence of certain parameters provided to 


local function transcriptions 
	if not args then
		args = frame.args;
	end
	local show = 'no' ~= args.hide or nil;										-- make boolean-ish for controlling display of headers; |hide=no means show transcriptions without collapsed header

	local infobox_args = {};													-- table to hold arguments for frame:expandTemplate
	local i = 1;																-- enumerator used with |headern=, |labeln=, and |datan= parameters

	if show then
		infobox_args['subbox'] = 'yes';
		infobox_args['above'] = 'Transcriptions';
	else
		infobox_args['child'] = 'yes';
	end
	
	infobox_args['bodyclass'] = 'collapsible collapsed';
	infobox_args['bodystyle'] = 'display:inline-table; text-align: left;';
	infobox_args['abovestyle'] = 'font-size: 100%; text-align: left; background-color: #f9ffbc;';	-- TODO: #define various colors in a common config location; and function?
	infobox_args['headerstyle'] = 'background-color: #dcffc9;';					-- TODO: #define various colors in a common config location; and function?
	infobox_args['labelstyle'] = 'font-weight:normal;';

	if 'zh' == lang then
		transcriptions_zh ;						-- special case because there are various headers etc
	else
		add_transcription ;			
	end

	return frame:expandTemplate ;		-- render the infobox and done
	end

--headercolor= is set to its default color in . Better here than there isn't it? less 
maintenence headache when a default value is set in only one place; override in the highest level appropriate
but leave the default here. in the higher-level template(s) remove |headercolor= default values


local function ibox_boilerplate 
	infobox_args['child'] = 'yes';
	local h_color;
	if is_set (args.headercolor) then
		h_color = args.headercolor;
	else
		h_color = '#b0c4de'														-- TODO: #define various colors in a common config location; and / or function?
	end
	
	infobox_args['headerstyle'] = 'background-color: ' .. h_color .. ';';
	
	if is_set (args.fontstyle) then												-- ???? |fontstyle= not a documented parameter; supported by and 
		infobox_args['labelstyle'] = 'font-weight:' .. fontstyle .. ';';
	else
		infobox_args['labelstyle'] = 'font-weight:normal;';
	end
	
end

------------------------------------------------------------------------------------

bypasses 

Module entry point



local function ibox_mln_zh 
	if not args then
		args = frame.args;
	end
	local infobox_args = {};													-- table to hold arguments for frame:expandTemplate

	ibox_boilerplate 	

	if 'none' ~= args.header and 'none' ~= args.chinese_header then
		infobox_args['header1'] = args.header or args.chinese_header or 'Chinese name';
	end

	local i = 2;
	
	i = add_label_data_pair (infobox_args, 'Chinese', is_set (args.c) and lang_mod._lang , i)

	if 'st' == args.order then
		i = add_label_data_pair (infobox_args, 'Simplified Chinese', is_set (args.s) and lang_mod._lang , i)
		i = add_label_data_pair (infobox_args, 'Traditional&nbsp;Chinese', is_set (args.t) and lang_mod._lang , i)
	else
		i = add_label_data_pair (infobox_args, 'Traditional&nbsp;Chinese', is_set (args.t) and lang_mod._lang , i)
		i = add_label_data_pair (infobox_args, 'Simplified Chinese', is_set (args.s) and lang_mod._lang , i)
	end

	if is_set (args.phagspa) then												-- ???? this parameter isn't passed from to 
		i = add_label_data_pair (infobox_args, '\'Phags-pa script', frame:expandTemplate , i)
	end

	infobox_args['data' .. i] = showflag ;							-- needs frame so that it can frame:expandTemplate
	i = i + 1;
																				-- ???? why is this transliteration here and not part of the transcription list?
	i = add_label_data_pair (infobox_args, 'Postal', is_set (args.psp) and args.psp or nil, i)

	i = add_label_data_pair (infobox_args, 'Literal meaning', is_set (args.l) and args.l or nil, i)

	if 'no' == args.hide then
		infobox_args['rowstyle' .. i] = 'display:none;';
		infobox_args['rowcellstyle' .. i] = 'display:none;';
	end
	
	if any_set  then			-- ???? phagspa not passed into Why?
		infobox_args['data' .. i] = transcriptions ;			-- needs frame so that it can frame:expandTemplate
	end
	
	return frame:expandTemplate ;
	end

	
------------------------------------------------------------------------------------

implements 

Module entry point

Template:Infobox_Arabic_term/testcases

TODO: standardize on lowercase parameter names for transcriptions


local function ibox_mln_ar 
	if not args then
		args = getArgs (frame);													--, {removeBlanks = false}?
	end
	local infobox_args = {};													-- table to hold arguments for frame:expandTemplate

	ibox_boilerplate ;

	if 'none' ~= args.header and 'none' ~= args.arabic_header then
		infobox_args['header1'] = args.header or args.arabic_header or 'Arabic name';
	end
	
	local i = 2;

	i = add_label_data_pair (infobox_args, 'Arabic', is_set (args.arabic) and args.arabic or nil, i)
	i = add_label_data_pair (infobox_args, 'Romanization', is_set (args.arabic_rom) and args.arabic_rom or nil, i)
	i = add_label_data_pair (infobox_args, 'IPA', is_set (args.arabic_ipa) and args.arabic_ipa or nil, i)
	i = add_label_data_pair (infobox_args, 'Literal meaning', is_set (args.arabic_lit) and args.arabic_lit or nil, i)

	if any_set  then
		infobox_args['data' .. i] = transcriptions ;			-- needs frame so that it can frame:expandTemplate
	end

	return frame:expandTemplate ;
end

------------------------------------------------------------------------------

implements 

Module entry point



local function ibox_mln_blank 
	if not args then
		args = frame.args;
	end
	local infobox_args = {};													-- table to hold arguments for frame:expandTemplate
	
	ibox_boilerplate ;

	local ietf_tag = lang_mod._is_ietf_tag (args.lang);
	local name_from_tag = ietf_tag and lang_mod._name_from_tag ({args.lang}) or nil;

	if 'none' ~= args.lang_hdr and 'none' ~= args.header and 'none' ~= args.blank_header then
		if is_set (args.lang_hdr) or is_set (args.header) or is_set (args.blank_header) then				-- if one of these
			infobox_args['header1'] = args.lang_hdr or args.header or args.blank_header;			-- make a header from it
		elseif ietf_tag then
			infobox_args['header1'] = name_from_tag .. ' name';				-- make a header from the language name
		else
			infobox_args['header1'] = args.lang .. ' name';						-- not a code so use whatever text is in }
		end
	end
	
	local i = 2;
	local label;
	local data;
	
	if name_from_tag then
		if is_set (args.lang_article) then
			label = table.concat ({												-- make a linked label from provided article name
				'',
				args.lang_label or name_from_tag,
				''
		else
			label = args.lang_label or lang_mod._name_from_tag 	-- let lang module make the correct linked label
		end
	
		data = lang_mod._lang ;	
	else
		label = args.lang_label or args.lang;									-- fall back
		data = args.lang_content;
	end
	
	i = add_label_data_pair ;
	if is_set (args.lang_rom) and ietf_tag then
		i = add_label_data_pair (infobox_args, args.lang_std or 'Romanization', lang_mod._transl , i);
	end
	i = add_label_data_pair ;
	i = add_label_data_pair ;

	return frame:expandTemplate ;
end

------------------------------------------------------------------------------------

implements 

Module entry point



local function ibox_mln_bo 
	if not args then
		args = frame.args;
	end
	local infobox_args = {};													-- table to hold arguments for frame:expandTemplate
	
	ibox_boilerplate ;

	if 'none' ~= args.header and 'none' ~= args.tibetan_header then
		infobox_args['header1'] = args.header or args.tibetan_header or 'Tibetan name';
	end
	
	local i = 2;

	i = add_label_data_pair (infobox_args, 'Tibetan', is_set (args.tib) and frame:expandTemplate  or nil, i)
	i = add_label_data_pair (infobox_args, 'Literal meaning', is_set (args.literal_tibetan) and args.literal_tibetan or nil, i)

	if any_set  then
		infobox_args['data' .. i] = transcriptions ;			-- needs frame so that it can frame:expandTemplate
	end

	return frame:expandTemplate ;
end

----------------------------------------------------------------------------------

implements 

Module entry point



local function ibox_mln_dng 
	if not args then
		args = frame.args;
	end
	local infobox_args = {};													-- table to hold arguments for frame:expandTemplate
	
	ibox_boilerplate ;

	if 'none' ~= args.header and 'none' ~= args.dunganese_header then
		infobox_args['header1'] = args.header or args.dunganese_header or 'Dunganese name';
	end
	
	local i = 2;

	i = add_label_data_pair (infobox_args, 'Dungan', is_set (args.dungan) and args.dungan or nil, i)
	i = add_label_data_pair (infobox_args, 'Xiao\'erjing', is_set (args['dungan-xej']) and args['dungan-xej'] or nil, i)
	i = add_label_data_pair (infobox_args, 'Romanization', is_set (args['dungan-latin']) and args['dungan-latin'] or nil, i)
	i = add_label_data_pair (infobox_args, 'Hanzi', is_set (args['dungan-han']) and args['dungan-han'] or nil, i)

	return frame:expandTemplate ;
end

--------------------------------------------------------------------------

implements 

Module entry point

Template:Infobox Hokkien name/testcases


local function ibox_mln_hokkien 
	if not args then
		args = getArgs (frame);													--, {removeBlanks = false}?
	end
	local show = 'no' ~= args.hide or nil;										-- make boolean-ish for controlling display of headers; |hide=no means show transcriptions without collapsed header
	local infobox_args = {};													-- table to hold arguments for frame:expandTemplate
	
	ibox_boilerplate ;

	if 'none' ~= args.header and 'none' ~= args.hokkien_header then
		infobox_args['header1'] = args.header or args.hokkien_header or 'Hokkien name';
	end
	
	local i = 2;
	
	i = add_label_data_pair (infobox_args, 'Hàn-jī', is_set (args.hanji) and lang_mod._lang  or nil, i);
	i = add_label_data_pair (infobox_args, 'Pe̍h-ōe-jī', is_set (args.poj) and lang_mod._lang  or nil, i);
	i = add_label_data_pair (infobox_args, 'Hàn-lô', is_set (args.hanlo) and lang_mod._lang  or nil, i);
	i = add_label_data_pair (infobox_args, 'Literal meaning', is_set (args.lm) and args.lm or nil, i)

	if show then
		if any_set  then
			infobox_args['data' .. i] = transcriptions ;	-- needs frame so that it can frame:expandTemplate
		end
	else
		i = add_label_data_pair (infobox_args, 'Tâi-lô', is_set (args.tl) and args.tl or nil, i)
		i = add_label_data_pair (infobox_args, 'Bbánpìng', is_set (args.bp) and args.bp or nil, i)
		i = add_label_data_pair (infobox_args, 'IPA', is_set (args.hokkienipa) and args.hokkienipa or nil, i)
	end

	return frame:expandTemplate ;
end

------------------------------------------------------------------------------------

implements 

Module entry point



local function ibox_mln_ja 
	if not args then
		args = frame.args;
	end
	local infobox_args = {};													-- table to hold arguments for frame:expandTemplate
	
	ibox_boilerplate ;

	if 'none' ~= args.header and 'none' ~= args.japanese_header then
		infobox_args['header1'] = args.header or args.japanese_header or 'Japanese name';
	end
	
	local i = 2;
	
	i = add_label_data_pair (infobox_args, 'Kanji', is_set (args.kanji) and lang_mod._lang  or nil, i)
	i = add_label_data_pair (infobox_args, 'Kana', is_set (args.kana) and lang_mod._lang  or nil, i)
	i = add_label_data_pair (infobox_args, 'Hiragana', is_set (args.hiragana) and lang_mod._lang  or nil, i)
	i = add_label_data_pair (infobox_args, 'Katakana', is_set (args.katakana) and lang_mod._lang  or nil, i)
	i = add_label_data_pair (infobox_args, 'Kyūjitai', is_set (args.kyujitai) and lang_mod._lang  or nil, i)
	i = add_label_data_pair (infobox_args, 'Shinjitai', is_set (args.shinjitai) and lang_mod._lang  or nil, i)
	i = add_label_data_pair (infobox_args, 'Literal meaning', is_set (args.lja) and lang_mod._lang  or nil, i)

	if any_set  then
		infobox_args['data' .. i] = transcriptions ;			-- needs frame so that it can frame:expandTemplate
	end

	return frame:expandTemplate ;
end

------------------------------------------------------------------------------------

implements 

Module entry point



local function ibox_mln_ko 
	if not args then
		args = frame.args;
	end
	local show = 'no' ~= args.hide or nil;										-- make boolean-ish for controlling display of headers; |hide=no means show transcriptions without collapsed header
	local infobox_args = {};													-- table to hold arguments for frame:expandTemplate
	
	ibox_boilerplate ;

	if 'none' ~= args.header and 'none' ~= args.korean_header then
		infobox_args['header1'] = args.header or args.korean_header or 'Korean name';
	end
	
	local i = 2;
	
	if 'yes' == args.northkorea then
		i = add_label_data_pair (infobox_args, 'Chosŏn\'gŭl', is_set (args.hangul) and lang_mod._lang  or nil, i)
	elseif 'old' == args.northkorea then
		i = add_label_data_pair (infobox_args, 'Hunminjeongeum', is_set (args.hangul) and lang_mod._lang  or nil, i)
	else
		i = add_label_data_pair (infobox_args, 'Hangul', is_set (args.hangul) and lang_mod._lang  or nil, i)
	end

	if 'yes' == args.northkorea then
		i = add_label_data_pair (infobox_args, 'Hancha', is_set (args.hanja) and lang_mod._lang  or nil, i)
	else
		i = add_label_data_pair (infobox_args, 'Hanja', is_set (args.hanja) and lang_mod._lang  or nil, i)
	end
	
	i = add_label_data_pair (infobox_args, 'Literal meaning', is_set (args.lk) and args.lk or nil, i)

	if show then
		if any_set  then
			infobox_args['data' .. i] = transcriptions ;		-- needs frame so that it can frame:expandTemplate
		end
	else
		i = add_label_data_pair (infobox_args, 'Revised Romanization', is_set (args.rr) and lang_mod._transl  or nil, i)
		i = add_label_data_pair (infobox_args, 'McCune–Reischauer', is_set (args.mr) and lang_mod._transl  or nil, i)
		i = add_label_data_pair (infobox_args, 'IPA', is_set (args.koreanipa) and args.koreanipa or nil, i)
	end
	
	return frame:expandTemplate ;
end

------------------------------------------------------------------------------------

implements 

Module entry point



local function ibox_mln_mn 
	if not args then
		args = frame.args;
	end
	local infobox_args = {};													-- table to hold arguments for frame:expandTemplate
	
	ibox_boilerplate ;

	if 'none' ~= args.header and 'none' ~= args.mongolian_header then
		infobox_args['header1'] = args.header or args.mongolian_header or 'Mongolian name';
	end
	
	local i = 2;
	
	i = add_label_data_pair (infobox_args, 'Mongolian Cyrillic',
		is_set (args.mon) and lang_mod._lang  or nil, i)
--	i = add_label_data_pair (infobox_args, 'Mongolian',	-- TODO: weird construct in original template; is this one required?
--		is_set (args.mong) and lang_mod._lang ({'mn', frame:expandTemplate  }) or nil, i)
	i = add_label_data_pair (infobox_args, 'Mongolian script',
		is_set (args.mong) and lang_mod._lang ({'mn', frame:expandTemplate  }) or nil, i)

	if is_set (args.monr) then
		infobox_args['data' .. i] = transcriptions ;			-- needs frame so that it can frame:expandTemplate
	end

	return frame:expandTemplate ;
end

----------------------------------------------------------------------------------

implements 

Module entry point



local function ibox_mln_mnc 
	if not args then
		args = frame.args;
	end
	local infobox_args = {};													-- table to hold arguments for frame:expandTemplate
	
	ibox_boilerplate ;

	if 'none' ~= args.header and 'none' ~= args.manchu_header then
		infobox_args['header1'] = args.header or args.manchu_header or 'Manchu name';
	end
	
	local i = 2;
	
	i = add_label_data_pair (infobox_args, 'Manchu script', is_set (args.mnc) and frame:expandTemplate  or nil, i)
	i = add_label_data_pair (infobox_args, 'Romanization', is_set (args.mnc_rom) and args.mnc_rom or nil, i)
	i = add_label_data_pair (infobox_args, 'Abkai', is_set (args.mnc_a) and args.mnc_a or nil, i)
	i = add_label_data_pair (infobox_args, 'Möllendorff', is_set (args.mnc_v) and args.mnc_v or nil, i)

	return frame:expandTemplate ;
end

------------------------------------------------------------------------------------

implements 

Module entry point



local function ibox_mln_my 
	if not args then
		args = frame.args;
	end
	local infobox_args = {};													-- table to hold arguments for frame:expandTemplate
	
	ibox_boilerplate ;

	if 'none' ~= args.header and 'none' ~= args.burmese_header then
		infobox_args['header1'] = args.header or args.burmese_header or 'Burmese name';
	end
	
	local i = 2;

	i = add_label_data_pair (infobox_args, 'Burmese', is_set (args.my) and args.my or nil, i)
	i = add_label_data_pair (infobox_args, 'IPA', is_set (args.bi) and args.bi or nil, i)

	return frame:expandTemplate ;
end

------------------------------------------------------------------------------------

implements 

Module entry point



local function ibox_mln_ru 
	if not args then
		args = getArgs (frame);
	end
	local infobox_args = {};													-- table to hold arguments for frame:expandTemplate
	
	ibox_boilerplate ;

	if 'none' ~= args.header and 'none' ~= args.russian_header then
		infobox_args['header1'] = args.header or args.russian_header or 'Russian name';
	end
	
	local i = 2;
	
	i = add_label_data_pair (infobox_args, 'Russian', is_set (args.rus) and lang_mod._lang  or nil, i);
	i = add_label_data_pair (infobox_args, 'Romanization', is_set (args.rusr) and lang_mod._lang  or nil, i);	--TODO: use transl instead?
	i = add_label_data_pair (infobox_args, 'IPA', is_set (args.rusipa) and args.rusipa or nil, i);
	i = add_label_data_pair (infobox_args, 'Literal meaning', is_set (args.ruslit) and args.ruslit or nil, i);

	if any_set  then
		infobox_args['data' .. i] = transcriptions ;			-- needs frame so that it can frame:expandTemplate
	end

	return frame:expandTemplate ;
end

------------------------------------------------------------------------------------

implements 

Module entry point



local function ibox_mln_th 
	if not args then
		args = frame.args;
	end
	local infobox_args = {};													-- table to hold arguments for frame:expandTemplate
	
	ibox_boilerplate ;

	if 'none' ~= args.header and 'none' ~= args.thai_header then
		infobox_args['header1'] = args.header or args.thai_header or 'Thai name';
	end
	
	local i = 2;

	i = add_label_data_pair (infobox_args, 'Thai', (is_set (args.th) or is_set (args.tha)) and lang_mod._lang  or nil, i)
	i = add_label_data_pair (infobox_args, 'RTGS', is_set (args.rtgs) and lang_mod._transl  or nil, i)
	i = add_label_data_pair (infobox_args, 'Romanization', is_set (args.rom) and lang_mod._transl  or nil, i)
	i = add_label_data_pair (infobox_args, 'IPA', is_set (args.ipa) and args.ipa, i)
	i = add_label_data_pair (infobox_args, 'Literal meaning', is_set (args.lit) and args.lit, i)

	return frame:expandTemplate ;
end

------------------------------------------------------------------------------------

implements 

Module entry point



local function ibox_mln_ug 
	if not args then
		args = frame.args;
	end
	local infobox_args = {};													-- table to hold arguments for frame:expandTemplate
	
	ibox_boilerplate ;

	if 'none' ~= args.header and 'none' ~= args.uyghur_header then
		infobox_args['header1'] = args.header or args.uyghur_header or 'Uyghur name';
	end
	
	local i = 2;
	
	i = add_label_data_pair (infobox_args, 'Uyghur', is_set (args.uig) and frame:expandTemplate  or nil, i)
	i = add_label_data_pair (infobox_args, 'Literal meaning', is_set (args.lu) and args.lu or nil, i)

	if any_set  then
		infobox_args['data' .. i] = transcriptions ;			-- needs frame so that it can frame:expandTemplate
	end

	return frame:expandTemplate ;
end

------------------------------------------------------------------------------------

implements 

Module entry point



local function ibox_mln_vi 
	if not args then
		args = frame.args;
	end
	local infobox_args = {};													-- table to hold arguments for frame:expandTemplate
	
	ibox_boilerplate ;

	if 'none' ~= args.header and 'none' ~= args.vietnamese_header then
		infobox_args['header1'] = args.header or args.vietnamese_header or 'Vietnamese name';
	end
	
	local i = 2;

	i = add_label_data_pair (infobox_args, 'Vietnamese', is_set (args.vie) and lang_mod._lang  or nil, i)
	i = add_label_data_pair (infobox_args, 'Vietnamese alphabet', is_set (args.qn) and lang_mod._lang  or nil, i)
	i = add_label_data_pair (infobox_args, 'Hán-Nôm', is_set (args.hn) and lang_mod._lang  or nil, i)
	i = add_label_data_pair (infobox_args, 'Chữ Hán', is_set (args.chuhan) and lang_mod._lang  or nil, i)
	i = add_label_data_pair (infobox_args, 'Chữ Nôm', is_set (args.chunom) and lang_mod._lang  or nil, i)
	i = add_label_data_pair (infobox_args, 'Literal meaning', is_set (args.lqn) and args.lqn or nil, i)

	return frame:expandTemplate ;
end

------------------------------------------------------------------------------------

implements 

Module entry point



local function ibox_mln_za 
	if not args then
		args = frame.args;
	end
	local infobox_args = {};													-- table to hold arguments for frame:expandTemplate
	
	ibox_boilerplate ;

	if 'none' ~= args.header and 'none' ~= args.zhuang_header then
		infobox_args['header1'] = args.header or args.zhuang_header or 'Zhuang name';
	end
	
	local i = 2;

	i = add_label_data_pair (infobox_args, 'Zhuang', is_set (args.zha) and ('') or nil, i)
	i = add_label_data_pair (infobox_args, '1957 orthography', is_set (args.zha57) and args.zha57 or nil, i)
	i = add_label_data_pair (infobox_args, 'Sawndip', is_set (args.sd) and args.sd or nil, i)

	return frame:expandTemplate ;
end

----------------------------------------------------------------------------

bypasses 

Module entry point



local function ibox_mln_header 
	if not args then
		args = getArgs (frame);
	end
	local infobox_args = {};													-- table to hold arguments for frame:expandTemplate

	infobox_args['decat'] = 'yes';
	infobox_args['child'] = is_set (args.child) and args.child or 'yes';
--	infobox_args['bodystyle'] = is_set (args.float) and 'float: left; clear: left; margin: 0 1em 1em 0;' or nil;
--	infobox_args['bodyclass'] = is_set (args.collapse) and ('collapsible' .. ('yes' == args.collapse and ' collapsed' or '')) or nil;

	local h_color;
	if is_set (args.headercolor) then
		h_color = args.headercolor;
	else
		h_color = '#b0c4de'														-- TODO: #define various colors in a common config location; and function?
	end

--	infobox_args['subheaderstyle'] = 'font-size: 125%; background-color:' .. h_color .. ';';
--	infobox_args['subheader'] = is_set (args.title) and args.title or mw.title.getCurrentTitle.text;
	infobox_args['image'] = frame:callParserFunction ({name = '#invoke:InfoboxImage',
		args =
			'InfoboxImage',
			image = args.pic,
			sizedefault = 'frameless',
			size = args.picsize,
			upright = args.picupright,
			alt = args.picalt or args.pictooltip

	infobox_args['caption'] = is_set (args.piccap) and args.piccap or nil;

	infobox_args['image2'] = frame:callParserFunction ({name = '#invoke:InfoboxImage',
		args =
			'InfoboxImage',
			image = args.pic2,
			sizedefault = 'frameless',
			size = args.picsize2,
			upright = args.picupright2,
			alt = args.picalt2 or args.pictooltip2

	infobox_args['caption2'] = is_set (args.piccap2) and args.piccap2 or nil;
	
	infobox_args['headerstyle'] = 'background-color:' .. h_color;
	infobox_args['headerstyle'] = 'width: 50%; white-space: nowrap';

	return frame:expandTemplate ;
end	

----------------------------------------------------------------------------

bypasses 

Module entry point



local function ibox_mln_footer 
	if not args then
		args = frame.args;
	end
	local infobox_args = {};													-- table to hold arguments for frame:expandTemplate
	infobox_args['decat'] = 'yes';
	infobox_args['child'] = is_set (args.child) and args.child or 'yes';
	infobox_args['bodystyle'] = '';												-- present in wikisource template but not assigned a value there
	infobox_args['below'] = args.footnote;
	
	return frame:expandTemplate ;
end

-------------------------------------------------------


local function ibox_zhzh_enum_params_get 
	local ibox_args = {};
	local count = 0;															-- counts how many args got added to ibox_args {}

	for _, v in ipairs (data.ibox_zhzh_enum_params) do							-- add enumerated parameters
		if args[v .. i] then													-- only when there is an assigned value
			ibox_args[v] = args[v .. i];										-- add
			count = count + 1;													-- and tally
		end
	end

	return 0 ~= count and ibox_args or nil;										-- if table is empty return nil as a flag
end

------------------------------------------------------------------------------------------------------



local function ar 
	if is_set  then
		local ibox_args = {
			['arabic_header'] = args['arabic_header'] or 'Arabic name',
			['headercolor'] = args['child-hdr-color'] or args.headercolor,
			['arabic'] = args.arabic,
			['arabic_rom'] = args.arabic_rom,
			['arabic_ipa'] = args.arabic_ipa,
			['arabic_lit'] = args.arabic_lit or args['literal meaning'],		-- 'literal meaning' is from ; itis param name a good idea? TODO: unify parameter names
			['chat'] = args.chat or args.Chat,									-- TODO: unify parameter names
			['ala-lc'] = args['ala-lc'] or args['ALA-LC'],						-- TODO: unify parameter names
			['iso'] = args.iso or args.ISO,										-- TODO: unify parameter names
			['din'] = args.din or args.DIN										-- TODO: unify parameter names
			
		return ibox_mln_ar ;
	end
end

------------------------------------------------------------------------------------------------------



local function as 
	if args.as or args.asm then
		local ibox_args = {
			['lang_hdr'] = args['as-hdr'],
			['headercolor'] = args['child-hdr-color'] or args.headercolor,
			['lang'] = 'as',
			['lang_content'] = args.as or args.asm,
			['lang_ipa'] = args['as-ipa'],
			['lang_rom'] = args['as-rom'],
			['lang_std'] = args['as-std'],
			['lang_lit'] = args['as-lit'],
			
		return ibox_mln_blank ;
	end
end

------------------------------------------------------------------------------------------------------



local function bn 
	if args.bn or args.ben then
		local ibox_args = {
			['lang_hdr'] = args['bn-hdr'],
			['headercolor'] = args['child-hdr-color'] or args.headercolor,
			['lang'] = 'bn',
			['lang_content'] = args.bn or args.ben,
			['lang_ipa'] = args['bn-ipa'],
			['lang_rom'] = args['bn-rom'],
			['lang_std'] = args['bn-std'],
			['lang_lit'] = args['bn-lit'],
			
		return ibox_mln_blank ;
	end
end

------------------------------------------------------------------------------------------------------



local function bo 
	if any_set  then
		local ibox_args = {
			['tibetan_header'] = args['tibetan_header'] or 'Tibetan name',
			['headercolor'] = args['child-hdr-color'] or args.headercolor,
			['hide'] = args.hide,
			['tib'] = args.tib,
			['wylie'] = args.wylie,
			['thdl'] = args.thdl,
			['zwpy'] = args.zwpy,
			['lhasa'] = args.lhasa,
			
		return ibox_mln_bo ;
	end
end

----------------------------------------------------------------------------------------------------



local function dng 
	if any_set  then
		local ibox_args = {
			['dunganese_header'] = args['dunganese_header'] or 'Dunganese name',
			['headercolor'] = args['child-hdr-color'] or args.headercolor,
			['dungan'] = args.dungan,
			['dungan-xej'] = args['dungan-xej'],
			['dungan-han'] = args['dungan-han'],
			['dungan-latin'] = args['dungan-latin'],
			
		return ibox_mln_dng ;
	end
end

------------------------------------------------------------------------------------------------------



local function hi 
	if args.hi or args.hin then
		local ibox_args = {
			['lang_hdr'] = args['hi-hdr'],
			['headercolor'] = args['child-hdr-color'] or args.headercolor,
			['lang'] = 'hi',
			['lang_content'] = args.hi or args.hin,
			['lang_ipa'] = args['hi-ipa'],
			['lang_rom'] = args['hi-rom'],
			['lang_std'] = args['hi-std'],
			['lang_lit'] = args['hi-lit'],
			
		return ibox_mln_blank ;
	end
end

------------------------------------------------------------------------------------------------------



local function id 
	if args.id or args.ind then
		local ibox_args = {
			['lang_hdr'] = args['id-hdr'],
			['headercolor'] = args['child-hdr-color'] or args.headercolor,
			['lang'] = 'id',
			['lang_content'] = args.id or args.ind,
			['lang_ipa'] = args['id-ipa'],
			['lang_rom'] = args['id-rom'],
			['lang_std'] = args['id-std'],
			['lang_lit'] = args['id-lit'],
			
		return ibox_mln_blank ;
	end
end

------------------------------------------------------------------------------------------------------



local function ja 
	local children = {};
	if any_set  then
		local ibox_args = {
			['japanese_header'] = args['japanese_header'] or 'Japanese name',
			['headercolor'] = args['child-hdr-color'] or args.headercolor,
			['hide'] = args.hide,
			['kanji'] = args.kanji,
			['kyujitai'] = args.kyujitai,
			['shinjitai'] = args.shinjitai,
			['kana'] = args.kana,
			['hiragana'] = args.hiragana,
			['katakana'] = args.katakana,
			['romaji'] = args.romaji,
			['revhep'] = args.revhep,
			['tradhep'] = args.tradhep,
			['kunrei'] = args.kunrei,
			['nihon'] = args.nihon,
			['lja'] = args.lja
			
		table.insert (children, ibox_mln_ja );
	end
	for i=2, 6 do
		if any_set  then
			local ibox_args = {
				['japanese_header'] = args['japanese_header'..i] or 'Alternative Japanese name',
				['headercolor'] = args['child-hdr-color'] or args.headercolor,
				['hide'] = args.hide,
				['kanji'] = args['kanji'..i],
				['kyujitai'] = args['kyujitai'..i],
				['shinjitai'] = args['shinjitai'..i],
				['kana'] = args['kana'..i],
				['hiragana'] = args['hiragana'..i],
				['katakana'] = args['katakana'..i],
				['romaji'] = args['romaji'..i],
				['revhep'] = args['revhep'..i],
				['tradhep'] = args['tradhep'..i],
				['kunrei'] = args['kunrei'..i],
				['nihon'] = args['nihon'..i],
				['lja'] = args['lja'..i]

				
			table.insert (children, ibox_mln_ja );
		end
	end
	return table.concat (children) or '';										-- big string of ja infoboxen or an empty string if nothing was done here
end

------------------------------------------------------------------------------------------------------



local function km 
	if args.km or args.khm then
		local ibox_args = {
			['lang_hdr'] = args['km-hdr'],
			['headercolor'] = args['child-hdr-color'] or args.headercolor,
			['lang'] = 'km',
			['lang_content'] = args.km or args.khm,
			['lang_ipa'] = args['km-ipa'],
			['lang_rom'] = args['km-rom'],
			['lang_std'] = args['km-std'],
			['lang_lit'] = args['km-lit'],
			
		return ibox_mln_blank ;
	end
end

----------------------------------------------------------------------------------------------------

TODO: handle ko same way as enumerated zh?


local function ko1 	
	local children = {};
	if any_set  then
		local ibox_args = {
			['korean_header'] = args['korean_header'] or 'Korean name',									
			['headercolor'] = args['child-hdr-color'] or args.headercolor,
			['hide'] = args.hide,
			['hangul'] = args.hangul,
			['hanja'] = args.hanja,
			['rr'] = args.rr,
			['mr'] = args.mr,
			['northkorea'] = args.northkorea,
			['lk'] = args.lk,
			
		table.insert (children, ibox_mln_ko );
	end
	for i=2, 6 do
		if any_set  then
			local ibox_args = {
				['korean_header'] = args['korean_header'..i] or 'Alternative Korean name',									
				['headercolor'] = args['child-hdr-color'] or args.headercolor,
				['hide'] = args['hide'],
				['hangul'] = args['hangul'..i],
				['hanja'] = args['hanja'..i],
				['rr'] = args['rr'..i],
				['mr'] = args['mr'..i],
				['northkorea'] = args['northkorea'..i],
				['lk'] = args['lk'..i],
				
			table.insert (children, ibox_mln_ko );
		end
	end
	return table.concat (children) or '';				
end

----------------------------------------------------------------------------------------------------

TODO: handle ko same way as enumerated zh?


local function ko2 
	local children = {};
	if any_set  then
		local ibox_args = {
			['korean_header'] = args['cnkorean_header'] or 'Chinese Korean name',									
			['headercolor'] = args['child-hdr-color'] or args.headercolor,
			['hide'] = args.hide,
			['hangul'] = args.cnhangul,
			['hanja'] = args.cnhanja,
			['rr'] = args.cnrr,
			['mr'] = args.cnmr,
			['northkorea'] = 'yes',
			['lk'] = args.cnlk,
			
		table.insert (children, ibox_mln_ko );
	end
	for i=2, 6 do
		if any_set  then
			local ibox_args = {
				['korean_header'] = args['cnkorean_header'..i] or 'Alternative Chinese Korean namee',									
				['headercolor'] = args['child-hdr-color'] or args.headercolor,
				['hide'] = args['hide'],
				['hangul'] = args['cnhangul'..i],
				['hanja'] = args['cnhanja'..i],
				['rr'] = args['cnrr'..i],
				['mr'] = args['cnmr'..i],
				['northkorea'] = 'yes',
				['lk'] = args['cnlk'..i],
				
			table.insert (children, ibox_mln_ko );
		end
	end
	return table.concat (children) or '';		
end

----------------------------------------------------------------------------------------------------

TODO: handle ko same way as enumerated zh?


local function ko3 
	local children = {};
	if any_set  then
		local ibox_args = {
			['korean_header'] = args['nkkorean_header'] or 'North Korean name',									
			['headercolor'] = args['child-hdr-color'] or args.headercolor,
			['hide'] = args.hide,
			['hangul'] = args.nkhangul,
			['hanja'] = args.nkhanja,
			['rr'] = args.nkrr,
			['mr'] = args.nkmr,
			['northkorea'] = 'yes',
			['lk'] = args.nklk,
			
		table.insert (children, ibox_mln_ko );
	end
	for i=2, 6 do
		if any_set  then
			local ibox_args = {
				['korean_header'] = args['nkkorean_header'..i] or 'Alternative North Korean name',									
				['headercolor'] = args['child-hdr-color'] or args.headercolor,
				['hide'] = args['hide'],
				['hangul'] = args['nkhangul'..i],
				['hanja'] = args['nkhanja'..i],
				['rr'] = args['nkrr'..i],
				['mr'] = args['nkmr'..i],
				['northkorea'] = 'yes',
				['lk'] = args['nklk'..i],
				
			table.insert (children, ibox_mln_ko );
		end
	end
	return table.concat (children) or '';									
end

----------------------------------------------------------------------------------------------------

TODO: handle ko same way as enumerated zh?


local function ko4 
	local children = {};
	if any_set  then
		local ibox_args = {
			['korean_header'] = args['skkorean_header'] or 'South Korean name',									
			['headercolor'] = args['child-hdr-color'] or args.headercolor,
			['hide'] = args.hide,
			['hangul'] = args.skhangul,
			['hanja'] = args.skhanja,
			['rr'] = args.skrr,
			['mr'] = args.skmr,
			['northkorea'] = nil,
			['lk'] = args.sklk,
			
		table.insert (children, ibox_mln_ko );
	end
	for i=2, 6 do
		if any_set  then
			local ibox_args = {
				['korean_header'] = args['skkorean_header'..i] or 'Alternative South Korean name',									
				['headercolor'] = args['child-hdr-color'] or args.headercolor,
				['hide'] = args['hide'],
				['hangul'] = args['skhangul'..i],
				['hanja'] = args['skhanja'..i],
				['rr'] = args['skrr'..i],
				['mr'] = args['skmr'..i],
				['northkorea'] = nil,
				['lk'] = args['sklk'..i],
				
			table.insert (children, ibox_mln_ko );
		end
	end
	return table.concat (children) or '';			
end

------------------------------------------------------------------------------------------------------



local function lo 
	if args.lo or args.lao then
		local ibox_args = {
			['lang_hdr'] = args['lo-hdr'],
			['headercolor'] = args['child-hdr-color'] or args.headercolor,
			['lang'] = 'lo',
			['lang_content'] = args.lo or args.lao,
			['lang_ipa'] = args['lo-ipa'],
			['lang_rom'] = args['lo-rom'],
			['lang_std'] = args['lo-std'],
			['lang_lit'] = args['lo-lit'],
			
		return ibox_mln_blank ;
	end
end

------------------------------------------------------------------------------------------------------



local function mn 
	if any_set  then
		local ibox_args = {
			['mongolian_header'] = args['mongolian_header'] or 'Mongolian name',						
			['headercolor'] = args['child-hdr-color'] or args.headercolor,
			['hide'] = args.hide,
			['mon'] = args.mon,
			['mong'] = args.mong,
			['monr'] = args.monr,
			
		return ibox_mln_mn ;
	end
end

----------------------------------------------------------------------------------------------------



local function mnc 
	if any_set  then
		local ibox_args = {
			['manchu_header'] = args['manchu_header'] or 'Manchu name',
			['headercolor'] = args['child-hdr-color'] or args.headercolor,
			['mnc'] = args.mnc,
			['mnc_rom'] = args.mnc_rom,
			['mnc_a'] = args.mnc_a,
			['mnc_v'] = args.mnc_v,
			
		return ibox_mln_mnc ;
	end
end

------------------------------------------------------------------------------------------------------



local function ms 
	if args.ms or args.msa then
		local ibox_args = {
			['lang_hdr'] = args['ms-hdr'],
			['headercolor'] = args['child-hdr-color'] or args.headercolor,
			['lang'] = 'ms',
			['lang_content'] = args.ms or args.msa,
			['lang_ipa'] = args['ms-ipa'],
			['lang_rom'] = args['ms-rom'],
			['lang_std'] = args['ms-std'],
			['lang_lit'] = args['ms-lit'],
			
		return ibox_mln_blank ;
	end
end

------------------------------------------------------------------------------------------------------



local function my 
	if args.my then
		local ibox_args = {
			['burmese_header'] = args['burmese_header'] or 'Burmese name',								
			['headercolor'] = args['child-hdr-color'] or args.headercolor,
			['my'] = args.my,
			['bi'] = args.bi,
			
		return ibox_mln_my ;
	end
end

------------------------------------------------------------------------------------------------------



local function ne 
	if args.ne or args.nep then
		local ibox_args = {
			['lang_hdr'] = args['ne-hdr'],
			['headercolor'] = args['child-hdr-color'] or args.headercolor,
			['lang'] = 'ne',
			['lang_content'] = args.ne or args.nep,
			['lang_ipa'] = args['ne-ipa'],
			['lang_rom'] = args['ne-rom'],
			['lang_std'] = args['ne-std'],
			['lang_lit'] = args['ne-lit'],
			
		return ibox_mln_blank ;
	end
end

------------------------------------------------------------------------------------------------------



local function pi 
	if args.pi or args.pli then
		local ibox_args = {
			['lang_hdr'] = args['pi-hdr'],
			['headercolor'] = args['child-hdr-color'] or args.headercolor,
			['lang'] = 'pi',
			['lang_content'] = args.pi or args.pli,
			['lang_ipa'] = args['pi-ipa'],
			['lang_rom'] = args['pi-rom'],
			['lang_std'] = args['pi-std'],
			['lang_lit'] = args['pi-lit'],
			
		return ibox_mln_blank ;
	end
end

------------------------------------------------------------------------------------------------------



local function pt 
	if args.pt or args.por then
		local ibox_args = {
			['lang_hdr'] = args['pt-hdr'],
			['headercolor'] = args['child-hdr-color'] or args.headercolor,
			['lang'] = 'pt',
			['lang_lbl'] = args['pt-label'],
			['lang_content'] = args.pt or args.por,
			['lang_ipa'] = args['pt-ipa'],
			['lang_rom'] = args['pt-rom'],
			['lang_std'] = args['pt-std'],
			['lang_lit'] = args['pt-lit'],
			['lang_lit'] = args['pt-lit'],
			
		return ibox_mln_blank ;
	end
end

----------------------------------------------------------------------------------------------------



local function pra 
	if args.pra then
		local ibox_args = {
			['lang_hdr'] = args['pra-hdr'],
			['headercolor'] = args['child-hdr-color'] or args.headercolor,
			['lang'] = 'pra',
			['lang_content'] = args.pra,
			['lang_ipa'] = args['pra-ipa'],
			['lang_rom'] = args['pra-rom'],
			['lang_std'] = args['pra-std'],
			['lang_lit'] = args['pra-lit'],
			
		return ibox_mln_blank ;
	end
end

------------------------------------------------------------------------------------------------------



local function ru 
	if any_set  then									-- TODO: unify parameter names
		local ibox_args = {
			['russian_header'] = args['russian_header'] or 'Russian name',		
			['headercolor'] = args['child-hdr-color'] or args.headercolor,
			['rus'] = args.rus or args.russian,
			['rusr'] = args.rusr,
			['rusipa'] = args.rusipa or args['native pronunciation'],			-- TODO: unify parameter names
			['ruslit'] = args.ruslit or args['literal meaning'],				-- TODO: unify parameter names
			['scientific'] = args.scientific,
			['iso'] = args.iso,
			['gost'] = args.gost,
			['bgn/pcgn'] = args['bgn/pcgn'],
			
		return ibox_mln_ru ;
	end
end

------------------------------------------------------------------------------------------------------



local function sa 
	if args.sa or args.san then
		local ibox_args = {
			['lang_hdr'] = args['sa-hdr'],
			['headercolor'] = args['child-hdr-color'] or args.headercolor,
			['lang'] = 'sa',
			['lang_content'] = args.sa or args.san,
			['lang_ipa'] = args['sa-ipa'],
			['lang_rom'] = args['sa-rom'],
			['lang_std'] = args['sa-std'],
			['lang_lit'] = args['sa-lit'],
			
		return ibox_mln_blank ;
	end
end

------------------------------------------------------------------------------------------------------



local function ta 
	if args.ta or args.tam then
		local ibox_args = {
			['lang_hdr'] = args['ta-hdr'],
			['headercolor'] = args['child-hdr-color'] or args.headercolor,
			['lang'] = 'ta',
			['lang_content'] = args.ta or args.tam,
			['lang_ipa'] = args['ta-ipa'],
			['lang_rom'] = args['ta-rom'],
			['lang_std'] = args['ta-std'],
			['lang_lit'] = args['ta-lit'],
			
		return ibox_mln_blank ;
	end
end

----------------------------------------------------------------------------------------------------



local function tet 
	if args.tet then
		local ibox_args = {
			['lang_hdr'] = args['tet-hdr'],
			['headercolor'] = args['child-hdr-color'] or args.headercolor,
			['lang'] = 'tet',
			['lang_content'] = args.tet,
			['lang_ipa'] = args['tet-ipa'],
			['lang_rom'] = args['tet-rom'],
			['lang_std'] = args['tet-std'],
			['lang_lit'] = args['tet-lit'],
			
		return ibox_mln_blank ;
	end
end

------------------------------------------------------------------------------------------------------



local function th 
	if args.th or args.tha then
		local ibox_args = {
			['thai_header'] = args['thai_header'] or 'Thai name',							
			['headercolor'] = args['child-hdr-color'] or args.headercolor,
			['header'] = args['th-hdr'],
			['th'] = args.th or args.tha,
			['rtgs'] = args.rtgs,
			['ipa'] = args['th-ipa'],
			['rom'] = args['th-rom'],
			['std'] = args['th-std'],
			['lit'] = args['th-lit'],
		return ibox_mln_th ;
	end
end

------------------------------------------------------------------------------------------------------



local function tl 
--	if args.tl or args.tgl then
	if args.tgl then
		local ibox_args = {
--			['blank_header'] = 'Filipino name',
			['lang_hdr'] = args['tl-hdr'] or 'Filipino name',
			['headercolor'] = args['child-hdr-color'] or args.headercolor,
			['lang'] = 'tl',
--			['lang_content'] = args.tl or args.tgl,								-- tl is used for Taiwanese Romanization System of Hokkien
			['lang_content'] = args.tgl,
			['lang_ipa'] = args['tl-ipa'],
			['lang_rom'] = args['tl-rom'],
			['lang_std'] = args['tl-std'],
			['lang_lit'] = args['tl-lit'],
			
		return ibox_mln_blank ;
	end
end

------------------------------------------------------------------------------------------------------



local function ug 
	if args.uig then
		local ibox_args = {
			['uyghur_header'] = args['uyghur_header'] or 'Uyghur name',									
			['headercolor'] = args['child-hdr-color'] or args.headercolor,
			['hide'] = args.hide,
			['uig'] = args.uig,
			['lu'] = args.lu,
			['uly'] = args.uly,
			['uyy'] = args.uyy,
			['sgs'] = args.sgs,
			['usy'] = args.usy,
			['uipa'] = args.uipa,
			
		return ibox_mln_ug ;
	end
end

------------------------------------------------------------------------------------------------------



local function vi 
	if any_set  then
		local ibox_args = {
			['vietnamese_header'] = args['vietnamese_header'] or 'Vietnamese name',							
			['headercolor'] = args['child-hdr-color'] or args.headercolor,
			['vie'] = args.vie,
			['qn'] = args.qn,
			['hn'] = args.hn,
			['chuhan'] = args.chuhan,
			['chunom'] = args.chunom,
			['lqn'] = args.lqn,
			
		return ibox_mln_vi ;
	end
end

------------------------------------------------------------------------------------------------------

 

local function za 
	if args.zha then
		local ibox_args = {
			['zhuang_header'] = args['zhuang_header'] or 'Zhuang name',									
			['headercolor'] = args['child-hdr-color'] or args.headercolor,
			['hide'] = args.hide,
			['zha'] = args.zha,
			['zha57'] = args.zha57,
			['sd'] = args.sd,
			
		return ibox_mln_za ;
	end
end

------------------------------------------------------------------------------------------------------



local function zh 
	local children = {};
	
	if any_set  then							-- first infobox zh/zh
		local ibox_args = ibox_zhzh_enum_params_get ;					-- get the enumerated parameters (here enumerator is empty string)

		if ibox_args then
			ibox_args['hide'] = args.hide; 
			ibox_args['showflag'] = args.showflag;
			ibox_args['order'] = args.order;

			ibox_args['p'] = args.p or args.hp;									-- add special case parameters
			ibox_args['xej'] = args.xej and lang_mod._lang ;

			if 'yes' == args.child then
				ibox_args['chinese_header'] = args['chinese_header'] or args.name1;						-- show the header name from parameter or default name from ibox_mln_zh
			elseif any_set ({													-- when any of these are set there will be other child infoboxen so ...
					args.hangul, args.hanja, args.kana, args.kanji, args.hiragana,
					args.katakana, args.kyujitai, args.shinjitai, args.tam, args.hin,
					args.san, args.pli, args.tgl, args.msa, args.mnc, args.mon, args.mong,
					args.por, args.rus, args.tha, args.tib, args.qn, args.uig, args.vie,
					args.chuhan, args.chunom, args.hn, args.zha, args['dungan-xej'],
					args.dungan, args.lao, args.khm, args.tet, args.lang1, args.lang2,
					args.lang3, args.lang4, args.lang5, args.lang6, args.lang7, args.lang8,
					args.lang9, args.lang10, args.lang11, 
						ibox_args['chinese_header'] = args['chinese_header'] or args.name1;				-- ... show the header name from parameter or default name from ibox_mln_zh
			else
				ibox_args['chinese_header'] = args['chinese_header'] or args.name1 or 'none';				-- show the header name from parameter or no header (args.name1 missing or 'empty' - nil)
			end

			ibox_args['headercolor'] = args['child-hdr-color'] or args.headercolor;

			table.insert (children, ibox_mln_zh );
		end
	end
	
	for i=2, 6 do
		if any_set  then
			local ibox_args = ibox_zhzh_enum_params_get ;				-- get the enumerated parameters

			if ibox_args then
				ibox_args['hide'] = args.hide;
				ibox_args['showflag'] = args.showflag;
				ibox_args['order'] = args.order; 

				ibox_args['p'] = args['p'..i] or args['hp'..i];					-- add special case parameters
				ibox_args['xej'] = args['xej'..i] and lang_mod._lang ;

				if args[data.zh_hdr_names[i][1]] then
					ibox_args['chinese_header'] = args[data.zh_hdr_names[i][1]];	-- use value from parameter
				else
					ibox_args['chinese_header'] = args['chinese_header'..i] or data.zh_hdr_names[i][2];		-- use the default
				end

				ibox_args['headercolor'] = args['child-hdr-color'] or args.headercolor;
				
				table.insert (children, ibox_mln_zh );
			end
		end
	end
	
	return table.concat (children) or '';										-- big string of zh infoboxen or an empty string if nothing was done here
end

--name1= present with
empty string or whitespace as assigned value)


local function ibox_mln (frame)
	local args = getArgs(frame);												-- also gets parent frame params (there are no frame params for this function) TODO:, {removeBlanks = false}?
	local infobox_args = {};													-- table to hold arguments for ibox_mln frame:expandTemplate
	local children = {};														-- table of returned infoboxen text

	infobox_args['child'] = args.child;
	infobox_args['rowstyle1'] = 'display:none;';
	if 'yes' ~= args.child then
		local hdr_args = {
			['title'] = args.title or mw.title.getCurrentTitle.text:gsub ;	-- mimic (template not magic word)
			['headercolor'] = args.headercolor,
			['float'] = args.float,
			['collapse'] = args.collapse,
			['pic'] = args.pic or args.image,									-- TODO: unify parameter names
			['picsize'] = args.picsize or args.imgwidth,						-- TODO: unify parameter names
			['picupright'] = args.picupright,
			['picalt'] = args.picalt,
			['pictooltip'] = args.pictooltip,
			['piccap'] = args.piccap or args.caption,							-- TODO: unify parameter names
			['pic2'] = args.pic2,
			['picsize2'] = args.picsize2,
			['picupright2'] = args.picupright2,
			['picalt2'] = args.picalt2,
			['pictooltip2'] = args.pictooltip2,
			['piccap2'] = args.piccap2,
		table.insert (children, ibox_mln_header );
	end

	local lang_iboxen = {														-- table of codes used in |ibox-order= and their matching function pointers
		['ar'] = ar, ['as'] = as, ['bn'] = bn, ['bo'] = bo, ['dng'] = dng,
		['hi'] = hi, ['id'] = id, ['ja'] = ja, ['km'] = km, ['ko1'] = ko1,
		['ko2'] = ko2, ['ko3'] = ko3, ['ko4'] = ko4, ['lo'] = lo, ['mn'] = mn,
		['mnc'] = mnc, ['ms'] = ms, ['my'] = my, ['ne'] = ne, ['pi'] = pi,
		['pra'] = pra, ['pt'] = pt, ['ru'] = ru, ['sa'] = sa, ['ta'] = ta,
		['tet'] = tet, ['th'] = th, ['tl'] = tl, ['ug'] = ug, ['vi'] = vi,
		['za'] = za, ['zh'] = zh

	local lang_ibox_order = {													-- default list of lang ibox calling functions as used by legacy 
		zh, my, bo, dng, vi, th, za, ko1, ko2, ko3, ko4, mn, ja, ms, id, tl,
		 ug, mnc, bn, as, ne, pra, ta, hi, sa, pi, pt, ru, lo, km, tet
	
	if args['ibox-order'] then														-- parameter value is comma-separated list of lang iboxen to render and their order
		local t = mw.text.split 					-- make a table from the list
		lang_ibox_order = {};													-- reset; don't use default list
		for _, v in ipairs (t) do												-- spin through the lang_ibox_order list in order and 
			if lang_iboxen[v] then												-- if there is a matching ibox function
				table.insert ;					-- add it to the list of functions to call; TODO: error message when specified language does not exist?
			end
		end
	end	

	for _, ibox_func in ipairs (lang_ibox_order) do								-- call each function in the list in the list order
		table.insert (children, ibox_func  or '');					-- add ibox string (or empty string when there is no ibox string)
	end

	local i = 1;																-- blank ibox enumerator
	while args['lang' .. i] and (args['lang-content' .. i] or args['lang' .. i .. '_content']) do		-- for as many ibox blank as there are ...
		local ibox_args = {
			['lang_hdr'] = args['lang-hdr' .. i],
			['headercolor'] = args['child-hdr-color'] or args.headercolor,
			['lang'] = args['lang' .. i],
			['lang_label'] = args['lang-lbl' .. i],
			['lang_content'] = args['lang-content' .. i] or args['lang' .. i .. '_content'],
			['lang_ipa'] = args['lang-ipa' .. i],
			['lang_rom'] = args['lang-rom' .. i],
			['lang_std'] = args['lang-std' .. i],
			['lang_lit'] = args['lang-lit' .. i],
			
		table.insert (children, ibox_mln_blank );
		i = i + 1;																-- bump the enumerator
	end

	if 'yes' ~= args.child then
		table.insert (children, ibox_mln_footer );
	end

	return table.concat (children);												-- concatenate all of the children together into a ginormous string
end

----------------------------------------------------------------------

these not used outside of old :
	ibox_mln_dng = ibox_mln_dng,												-- 
	ibox_mln_mn = ibox_mln_mn,													-- 
	ibox_mln_mnc = ibox_mln_mnc,												-- 
	ibox_mln_my = ibox_mln_my,													-- 
	ibox_mln_th = ibox_mln_th,													-- 
	ibox_mln_ug = ibox_mln_ug,													-- 
	ibox_mln_za = ibox_mln_za,													-- 

these templates require parameter-name unification before they can directly use this module (and avoid the subtemplates):


return {
	ibox_mln = ibox_mln,														-- 
	ibox_mln_ar = ibox_mln_ar,													-- (used in Template:Infobox Arabic term)
	ibox_mln_blank = ibox_mln_blank,											-- 
	ibox_mln_bo = ibox_mln_bo,													-- 
	ibox_mln_footer = ibox_mln_footer,											-- 
	ibox_mln_header = ibox_mln_header,											-- 
	ibox_mln_hokkien = ibox_mln_hokkien,										-- (used in Template:Infobox Hokkien name)
	ibox_mln_ja = ibox_mln_ja,													-- 
	ibox_mln_ko = ibox_mln_ko,													-- 
	ibox_mln_ru = ibox_mln_ru,													-- (used in Template:Infobox Russian term)
	ibox_mln_vi = ibox_mln_vi,													-- (used in Template:Infobox Vietnamese)
	ibox_mln_zh = ibox_mln_zh,													--