--
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:Langlocal getArgs = require ('Module:Arguments').getArgs;
----------------------------< I S _ S E T >------------------------------------------------------------------
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
);end
----------------------------< A N Y _ S E T >----------------------------------------------------------------
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 thevalue to
which calls this function. This function does not take any frame parametersbut it does require a copy of the frame so that it can expand
. All arguments used by this functioncome from the args table in the function call
returns a child infobox or an empty string
local function showflag (frame, args) 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=
----------------------------< A D D _ L A B E L _ D A T A _ P A I R >----------------------------------------
Adds a label parameter and matching data parameter to infobox arguments table; bumps the enumerator on return
local function add_label_data_pair (infobox_args, label, data, i) 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 enumeratorend
--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, args, idx, show, i, lang) 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 doneend
----------------------------< T R A N S C R I P T I O N S _ Z H >--------------------------------------------
transcriptions support for
. This function adds headers and label data pairs toinfobox_arg table according to which parameters are set
returns the enumerator in case it is needed
local function transcriptions_zh (infobox_args, args, show, i) if any_set then i = add_transcription (infobox_args, args, 'standard mandarin', show, i, 'zh'); end
if any_set then i = add_transcription (infobox_args, args, 'other mandarin', show, i, 'zh'); end if any_set then -- ???? ouji was not included here in original template; why? i = add_transcription (infobox_args, args, 'wu', show, i, 'wuu'); end if is_set (args.gan) then i = add_transcription (infobox_args, args, 'gan', show, i, 'gan'); end if is_set (args.hsn) then i = add_transcription (infobox_args, args, 'xiang', show, i, 'hsn'); end
if any_set then i = add_transcription (infobox_args, args, 'hakka', show, i, 'hak'); end
if any_set then -- ???? sl, hk, mo not here in original; why? i = add_transcription (infobox_args, args, 'yue cantonese', show, i, 'yue'); end
if is_set (args.toi) then i = add_transcription (infobox_args, args, 'other yue', show, i, 'yue'); end
if any_set then -- ???? bp not here in original; why? i = add_transcription (infobox_args, args, 'southern min', show, i, 'nan'); end
if is_set (args.buc) then i = add_transcription (infobox_args, args, 'eastern min', show, i, 'cdo'); end
if is_set (args.hhbuc) then i = add_transcription (infobox_args, args, 'pu-xian min', show, i, 'cpx'); end
if is_set (args.mblmc) then i = add_transcription (infobox_args, args, 'northern min', show, i, 'mnp'); end
if is_set (args['phagspa-latin']) then -- phagspa is a script i = add_transcription (infobox_args, args, 'old mandarin', show, i, 'zh'); end
if any_set then i = add_transcription (infobox_args, args, 'middle chinese', show, i, 'ltc'); end
if any_set then i = add_transcription (infobox_args, args, 'old chinese', show, i, 'och'); end
return i; -- return current state of the enumeratorend
----------------------------< T R A N S C R I P T I O N S >--------------------------------------------------
This function handles the transcription infobox called by various
. Creates header andlabel / data pairs according to the presence of certain parameters provided to
local function transcriptions (frame, args, lang) 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'] = 'mw-collapsible mw-collapsed'; infobox_args['bodystyle'] = 'display:inline-table; text-align: left;'; infobox_args['abovestyle'] = 'font-size: 100%; text-align: left;color: #202122; background-color: #f9ffbc;'; -- TODO: #define various colors in a common config location; and function? infobox_args['headerstyle'] = 'color: #202122;background-color: #dcffc9;'; -- TODO: #define various colors in a common config location; and function? infobox_args['labelstyle'] = 'font-weight:normal;';
if 'zh'
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 appropriatebut leave the default here. in the higher-level template(s) remove |headercolor= default values
local function ibox_boilerplate (infobox_args, args) 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'] = 'color: #202122;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
--ibox_mln_zh}}
local function ibox_mln_zh (frame, args) if not args then args = frame.args; end local infobox_args = ; -- table to hold arguments for frame:expandTemplate
ibox_boilerplate (infobox_args, args)
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'
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 (frame, args); -- 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'
Why? infobox_args['data' .. i] = transcriptions (frame, args, 'zh'); -- needs frame so that it can frame:expandTemplate end return frame:expandTemplate ; end
--ibox_mln_ar}}
Template:Infobox_Arabic_term/testcases
TODO: standardize on lowercase parameter names for transcriptions
local function ibox_mln_ar (frame, args) if not args then args = getArgs (frame); --, ? end local infobox_args = ; -- table to hold arguments for frame:expandTemplate
ibox_boilerplate (infobox_args, args);
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 (frame, args, 'ar'); -- needs frame so that it can frame:expandTemplate end
return frame:expandTemplate ;end
--ibox_mln_blank}}
local function ibox_mln_blank (frame, args) if not args then args = frame.args; end local infobox_args = ; -- table to hold arguments for frame:expandTemplate ibox_boilerplate (infobox_args, args);
local ietf_tag = lang_mod._is_ietf_tag (args.lang); local name_from_tag = ietf_tag and lang_mod._name_from_tag 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 ; 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 (infobox_args, label, data, i); 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 (infobox_args, 'IPA', args.lang_ipa, i); i = add_label_data_pair (infobox_args, 'Literal meaning', args.lang_lit, i);
return frame:expandTemplate ;end
--ibox_mln_bo}}
local function ibox_mln_bo (frame, args) if not args then args = frame.args; end local infobox_args = ; -- table to hold arguments for frame:expandTemplate ibox_boilerplate (infobox_args, args);
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 (frame, args, 'bo'); -- needs frame so that it can frame:expandTemplate end
return frame:expandTemplate ;end
--ibox_mln_dng}}
local function ibox_mln_dng (frame, args) if not args then args = frame.args; end local infobox_args = ; -- table to hold arguments for frame:expandTemplate ibox_boilerplate (infobox_args, args);
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
--ibox_mln_hokkien}}
Template:Infobox Hokkien name/testcases
local function ibox_mln_hokkien (frame, args) if not args then args = getArgs (frame); --, ? 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 (infobox_args, args);
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 (frame, args, 'hokkien'); -- 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
--ibox_mln_ja}}
local function ibox_mln_ja (frame, args) if not args then args = frame.args; end local infobox_args = ; -- table to hold arguments for frame:expandTemplate ibox_boilerplate (infobox_args, args);
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 (frame, args, 'ja'); -- needs frame so that it can frame:expandTemplate end
return frame:expandTemplate ;end
--ibox_mln_ko}}
local function ibox_mln_ko (frame, args) 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 (infobox_args, args);
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, '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'
if show then if any_set then infobox_args['data' .. i] = transcriptions (frame, args, 'ko'); -- 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
--ibox_mln_mn}}
local function ibox_mln_mn (frame, args) if not args then args = frame.args; end local infobox_args = ; -- table to hold arguments for frame:expandTemplate ibox_boilerplate (infobox_args, args);
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 or nil, i) i = add_label_data_pair (infobox_args, 'Mongolian script', is_set (args.mong) and lang_mod._lang or nil, i)
if is_set (args.monr) then infobox_args['data' .. i] = transcriptions (frame, args, 'mn'); -- needs frame so that it can frame:expandTemplate end
return frame:expandTemplate ;end
--ibox_mln_mnc}}
local function ibox_mln_mnc (frame, args) if not args then args = frame.args; end local infobox_args = ; -- table to hold arguments for frame:expandTemplate ibox_boilerplate (infobox_args, args);
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
--ibox_mln_my}}
local function ibox_mln_my (frame, args) if not args then args = frame.args; end local infobox_args = ; -- table to hold arguments for frame:expandTemplate ibox_boilerplate (infobox_args, args);
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
--ibox_mln_ru}}
local function ibox_mln_ru (frame, args) if not args then args = getArgs (frame); end local infobox_args = ; -- table to hold arguments for frame:expandTemplate ibox_boilerplate (infobox_args, args);
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 (frame, args, 'ru'); -- needs frame so that it can frame:expandTemplate end
return frame:expandTemplate ;end
--ibox_mln_th}}
local function ibox_mln_th (frame, args) if not args then args = frame.args; end local infobox_args = ; -- table to hold arguments for frame:expandTemplate ibox_boilerplate (infobox_args, args);
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
--ibox_mln_ug}}
local function ibox_mln_ug (frame, args) if not args then args = frame.args; end local infobox_args = ; -- table to hold arguments for frame:expandTemplate ibox_boilerplate (infobox_args, args);
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 (frame, args, 'ug'); -- needs frame so that it can frame:expandTemplate end
return frame:expandTemplate ;end
--ibox_mln_vi}}
local function ibox_mln_vi (frame, args) if not args then args = frame.args; end local infobox_args = ; -- table to hold arguments for frame:expandTemplate ibox_boilerplate (infobox_args, args);
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
--ibox_mln_za}}
local function ibox_mln_za (frame, args) if not args then args = frame.args; end local infobox_args = ; -- table to hold arguments for frame:expandTemplate ibox_boilerplate (infobox_args, args);
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 ('
' .. args.zha .. '') 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
--ibox_mln_header}}
local function ibox_mln_header (frame, args) 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'
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%; color: #202122;background-color:' .. h_color .. ';';-- infobox_args['subheader'] = is_set (args.title) and args.title or mw.title.getCurrentTitle.text; infobox_args['image'] = frame:callParserFunction ;
infobox_args['caption'] = is_set (args.piccap) and args.piccap or nil;
infobox_args['image2'] = frame:callParserFunction ;
infobox_args['caption2'] = is_set (args.piccap2) and args.piccap2 or nil; infobox_args['headerstyle'] = 'color: #202122;background-color:' .. h_color; infobox_args['headerstyle'] = 'width: 50%; white-space: nowrap'; -- always display the background of the image in light mode, see -- -- FIXME: define new names for image arguments and migrate existing uses -- to those names, so that we can use skin-invert instead for characters infobox_args['imagestyle'] = 'background-color: #f8f9fa;' infobox_args['imageclass'] = 'notheme'
return frame:expandTemplate ;end
--ibox_mln_footer}}
local function ibox_mln_footer (frame, args) 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
---------------------------< I B O X _ Z H Z H _ E N U M _ P A R A M S _ G E T >----------------------------
local function ibox_zhzh_enum_params_get (args, i) 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 flagend
----------------------------< A R >--------------------------------------------------------------------------
----< A R A B I C >----
local function ar (frame, args) if is_set then local ibox_args = return ibox_mln_ar (frame, ibox_args); endend
----------------------------< A S >--------------------------------------------------------------------------
----< A S S A M E S E >----
local function as (frame, args) if args.as or args.asm then local ibox_args = return ibox_mln_blank (frame, ibox_args); endend
----------------------------< B N >--------------------------------------------------------------------------
----< B E N G A L I >----
local function bn (frame, args) if args.bn or args.ben then local ibox_args = return ibox_mln_blank (frame, ibox_args); endend
----------------------------< B O >--------------------------------------------------------------------------
----< T I B E T A N >----
local function bo (frame, args) if any_set then local ibox_args = return ibox_mln_bo (frame, ibox_args); endend
----------------------------< D N G >------------------------------------------------------------------------
----< D U N G A N E S E >----
local function dng (frame, args) if any_set then local ibox_args = return ibox_mln_dng (frame, ibox_args); endend
----------------------------< H I >--------------------------------------------------------------------------
----< H I N D I >----
local function hi (frame, args) if args.hi or args.hin then local ibox_args = return ibox_mln_blank (frame, ibox_args); endend
----------------------------< I D >--------------------------------------------------------------------------
----< I N D O N E S I A N >----
local function id (frame, args) if args.id or args.ind then local ibox_args = return ibox_mln_blank (frame, ibox_args); endend
----------------------------< J A >--------------------------------------------------------------------------
----< J A P A N E S E >----
local function ja (frame, args) local children = ; if any_set then local ibox_args = table.insert (children, ibox_mln_ja (frame, ibox_args)); end for i=2, 6 do if any_set then local ibox_args = table.insert (children, ibox_mln_ja (frame, ibox_args)); end end return table.concat (children) or ; -- big string of ja infoboxen or an empty string if nothing was done hereend
----------------------------< K M >--------------------------------------------------------------------------
----< K H M E R >----
local function km (frame, args) if args.km or args.khm then local ibox_args = return ibox_mln_blank (frame, ibox_args); endend
--
local function ko1 (frame, args) local children = ; if any_set then local ibox_args = table.insert (children, ibox_mln_ko (frame, ibox_args)); end for i=2, 6 do if any_set then local ibox_args = table.insert (children, ibox_mln_ko (frame, ibox_args)); end end return table.concat (children) or ; end
--
local function ko2 (frame, args) local children = ; if any_set then local ibox_args = table.insert (children, ibox_mln_ko (frame, ibox_args)); end for i=2, 6 do if any_set then local ibox_args = table.insert (children, ibox_mln_ko (frame, ibox_args)); end end return table.concat (children) or ; end
--
local function ko3 (frame, args) local children = ; if any_set then local ibox_args = table.insert (children, ibox_mln_ko (frame, ibox_args)); end for i=2, 6 do if any_set then local ibox_args = table.insert (children, ibox_mln_ko (frame, ibox_args)); end end return table.concat (children) or ; end
--
local function ko4 (frame, args) local children = ; if any_set then local ibox_args = table.insert (children, ibox_mln_ko (frame, ibox_args)); end for i=2, 6 do if any_set then local ibox_args = table.insert (children, ibox_mln_ko (frame, ibox_args)); end end return table.concat (children) or ; end
----------------------------< L O >--------------------------------------------------------------------------
----< L A O >----
local function lo (frame, args) if args.lo or args.lao then local ibox_args = return ibox_mln_blank (frame, ibox_args); endend
----------------------------< M N >--------------------------------------------------------------------------
----< M O N G O L I A N >----
local function mn (frame, args) if any_set then local ibox_args = return ibox_mln_mn (frame, ibox_args); endend
----------------------------< M N C >------------------------------------------------------------------------
----< M A N C H U >----
local function mnc (frame, args) if any_set then local ibox_args = return ibox_mln_mnc (frame, ibox_args); endend
----------------------------< M S >--------------------------------------------------------------------------
----< M A L A Y >----
local function ms (frame, args) if args.ms or args.msa then local ibox_args = return ibox_mln_blank (frame, ibox_args); endend
----------------------------< M Y >--------------------------------------------------------------------------
----< B U R M E S E >----
local function my (frame, args) if args.my then local ibox_args = return ibox_mln_my (frame, ibox_args); endend
----------------------------< N E >--------------------------------------------------------------------------
----< N E P A L I >----
local function ne (frame, args) if args.ne or args.nep then local ibox_args = return ibox_mln_blank (frame, ibox_args); endend
----------------------------< P I >--------------------------------------------------------------------------
----< P A L I >----
local function pi (frame, args) if args.pi or args.pli then local ibox_args = return ibox_mln_blank (frame, ibox_args); endend
----------------------------< P T >--------------------------------------------------------------------------
----< P O R T U G U E S E >----
local function pt (frame, args) if args.pt or args.por then local ibox_args = return ibox_mln_blank (frame, ibox_args); endend
----------------------------< P R A >------------------------------------------------------------------------
----< P R A K R I T >----
local function pra (frame, args) if args.pra then local ibox_args = return ibox_mln_blank (frame, ibox_args); endend
----------------------------< R U >--------------------------------------------------------------------------
----< R U S S I A N >----
local function ru (frame, args) if any_set then -- TODO: unify parameter names local ibox_args = return ibox_mln_ru (frame, ibox_args); endend
----------------------------< S A >--------------------------------------------------------------------------
----< S A N S K R I T >----
local function sa (frame, args) if args.sa or args.san then local ibox_args = return ibox_mln_blank (frame, ibox_args); endend
----------------------------< T A >--------------------------------------------------------------------------
----< T A M I L >----
local function ta (frame, args) if args.ta or args.tam then local ibox_args = return ibox_mln_blank (frame, ibox_args); endend
----------------------------< T E T >------------------------------------------------------------------------
----< T E T U M >----
local function tet (frame, args) if args.tet then local ibox_args = return ibox_mln_blank (frame, ibox_args); endend
----------------------------< T H >--------------------------------------------------------------------------
----< T H A I >----
local function th (frame, args) if args.th or args.tha then local ibox_args = return ibox_mln_th (frame, ibox_args); endend
----------------------------< T L >--------------------------------------------------------------------------
----< F I L I P I N O >----
local function tl (frame, args)-- if args.tl or args.tgl then if args.tgl then local ibox_args = return ibox_mln_blank (frame, ibox_args); endend
----------------------------< U G >--------------------------------------------------------------------------
----< U Y G H U R >----
local function ug (frame, args) if args.uig then local ibox_args = return ibox_mln_ug (frame, ibox_args); endend
----------------------------< V I >--------------------------------------------------------------------------
----< V I E T N A M E S E >----
local function vi (frame, args) if any_set then local ibox_args = return ibox_mln_vi (frame, ibox_args); endend
----------------------------< Z A >--------------------------------------------------------------------------
----< Z H U A N G >----
local function za (frame, args) if args.zha then local ibox_args = return ibox_mln_za (frame, ibox_args); endend
----------------------------< Z H >--------------------------------------------------------------------------
----------< C H I N E S E >----------
local function zh (frame, args) local children = ; if any_set then -- first infobox zh/zh local ibox_args = ibox_zhzh_enum_params_get (args, ); -- 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'
ibox_args['headercolor'] = args['child-hdr-color'] or args.headercolor;
table.insert (children, ibox_mln_zh (frame, ibox_args)); end end for i=2, 6 do if any_set then local ibox_args = ibox_zhzh_enum_params_get (args, i); -- 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 (frame, ibox_args)); end end end return table.concat (children) or ; -- big string of zh infoboxen or an empty string if nothing was done hereend
--name1= present withempty 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:, ? local infobox_args = ; -- table to hold arguments for ibox_mln frame:expandTemplate local children = ; -- table of returned infoboxen text
----------< H E A D E R I N F O B O X >----------
infobox_args['child'] = args.child; infobox_args['rowstyle1'] = 'display:none;'; if 'yes' ~= args.child then local hdr_args = table.insert (children, ibox_mln_header (frame, hdr_args)); end
----------< L A N G U A G E I N F O B O X E N >----------
local lang_iboxen =
local lang_ibox_order = ; if args['ibox-order'] then -- parameter value is comma-separated list of lang iboxen to render and their order local t = mw.text.split (args['ibox-order'], '%s*,%s*') -- 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 (lang_ibox_order, lang_iboxen[v]); -- 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 (frame, args) or ); -- add ibox string (or empty string when there is no ibox string) end
----------< B L A N K # I N F O B O X E N >----------
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 = table.insert (children, ibox_mln_blank (frame, ibox_args)); i = i + 1; -- bump the enumerator end
----------< F O O T E R I N F O B O X >----------
if 'yes' ~= args.child then table.insert (children, ibox_mln_footer (frame,)); end
----------< R E N D E R >----------
return table.concat (children); -- concatenate all of the children together into a ginormous stringend
--
return