Module:Infobox multi-lingual name: Difference between revisions

Created page with "--[[ TODO: all non-English text wrapped in {{lang}}? 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:Infob..."
 
No edit summary
 
Line 2: Line 2:
TODO:
TODO:
all non-English text wrapped in {{lang}}?
all non-English text wrapped in {{lang}}?
distingush various scripts?  Kanji is ja-Hani ...
distinguish various scripts?  Kanji is ja-Hani ...
every child infobox should support translit / transcription parameter(s)
every child infobox should support translit / transcription parameter(s)
every child infobox should have a literal meaning parameter
every child infobox should have a literal meaning parameter
Line 122: Line 122:


local function add_transcription (infobox_args, args, idx, show, i, lang)
local function add_transcription (infobox_args, args, idx, show, i, lang)
local special_xscriptions_t = {['bpmf'] = '-Bopo', ['usy'] = '-Cyrl', ['xej'] = '-Arab', ['zh-dungan'] = '-Cyrl'}; -- list of transcriptions not transliterations; TODO move to ~/data?
local special_ipa_t = {['bi'] = true, ['ci'] = true, ['ki'] = true, ['lhasa'] = true,  ['li'] = true,  ['mi'] = true, ['uipa'] = true,};
infobox_args['header' .. i] = show and data.xscript[idx].header; -- if headers are displayed
infobox_args['header' .. i] = show and data.xscript[idx].header; -- if headers are displayed
i = i + 1; -- bump the enumerator
i = i + 1; -- bump the enumerator
for _, v in ipairs (data.xscript[idx].t) do -- each label / data pair in the xscript subtable
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 ({lang, args[v[2]], italic = 'no'}), i); -- enumerator is bumped here
if special_xscriptions_t[v[2]] then -- special cases for bopomofo, Siril Yëziqi which are transcriptions, not Latn transliterations
i = add_label_data_pair (infobox_args, v[1], is_set (args[v[2]]) and lang_mod._lang ({lang .. special_xscriptions_t[v[2]], args[v[2]], italic = 'no'}), i); -- enumerator is bumped here
 
elseif special_ipa_t[v[2]] then
i = add_label_data_pair (infobox_args, v[1], args[v[2]], i); -- enumerator is bumped here
 
else
i = add_label_data_pair (infobox_args, v[1], is_set (args[v[2]]) and lang_mod._xlit ({lang, args[v[2]], italic = 'no'}), i); -- enumerator is bumped here
end
end
end
Line 229: Line 239:
end
end
infobox_args['bodyclass'] = 'collapsible collapsed';
infobox_args['bodyclass'] = 'mw-collapsible mw-collapsed';
infobox_args['bodystyle'] = 'display:inline-table; text-align: left;';
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['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'] = 'background-color: #dcffc9;'; -- 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;';
infobox_args['labelstyle'] = 'font-weight:normal;';


Line 247: Line 257:
--[[--------------------------< I B O X _ B O I L E R P L A T E >----------------------------------------------
--[[--------------------------< I B O X _ B O I L E R P L A T E >----------------------------------------------


boilerplate style settings for the various child infoboxen (not for transcription infoboxen) beause they are
boilerplate style settings for the various child infoboxen (not for transcription infoboxen) because they are
mostly the same child-infobox to child-infobox
mostly the same child-infobox to child-infobox


TODO: |headercolor= is set to its default color in {{Infobox Chinese}}.  Better here than there isn't it?  less  
TODO: |headercolor= is set to its default color in {{Infobox Chinese}}.  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
maintenance 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
but leave the default here.  in the higher-level template(s) remove |headercolor= default values


Line 265: Line 275:
end
end
infobox_args['headerstyle'] = 'background-color: ' ..  h_color .. ';';
infobox_args['headerstyle'] = 'color: #202122;background-color: ' ..  h_color .. ';';
if is_set (args.fontstyle) then -- ???? |fontstyle= not a documented parameter; supported by {{Infobox Chinese/Korean}} and {{Infobox Chinese/Vietnamese}}
if is_set (args.fontstyle) then -- ???? |fontstyle= not a documented parameter; supported by {{Infobox Chinese/Korean}} and {{Infobox Chinese/Vietnamese}}
Line 303: Line 313:


if 'st' == args.order then
if 'st' == args.order then
i = add_label_data_pair (infobox_args, '[[Simplified Chinese characters|Simplified Chinese]]', is_set (args.s) and lang_mod._lang ({'zh-Hans', args.s, size = '1rem'}), i)
i = add_label_data_pair (infobox_args, '[[Simplified Chinese characters|Simplified&nbsp;Chinese]]', is_set (args.s) and lang_mod._lang ({'zh-Hans', args.s, size = '1rem'}), i)
i = add_label_data_pair (infobox_args, '[[Traditional Chinese characters|Traditional&nbsp;Chinese]]', is_set (args.t) and lang_mod._lang ({'zh-Hant', args.t, size = '1rem'}), i)
i = add_label_data_pair (infobox_args, '[[Traditional Chinese characters|Traditional&nbsp;Chinese]]', is_set (args.t) and lang_mod._lang ({'zh-Hant', args.t, size = '1rem'}), i)
else
else
i = add_label_data_pair (infobox_args, '[[Traditional Chinese characters|Traditional&nbsp;Chinese]]', is_set (args.t) and lang_mod._lang ({'zh-Hant', args.t, size = '1rem'}), i)
i = add_label_data_pair (infobox_args, '[[Traditional Chinese characters|Traditional&nbsp;Chinese]]', is_set (args.t) and lang_mod._lang ({'zh-Hant', args.t, size = '1rem'}), i)
i = add_label_data_pair (infobox_args, '[[Simplified Chinese characters|Simplified Chinese]]', is_set (args.s) and lang_mod._lang ({'zh-Hans', args.s, size = '1rem'}), i)
i = add_label_data_pair (infobox_args, '[[Simplified Chinese characters|Simplified&nbsp;Chinese]]', is_set (args.s) and lang_mod._lang ({'zh-Hans', args.s, size = '1rem'}), i)
end
end


Line 431: Line 441:
i = add_label_data_pair (infobox_args, label, data, i);
i = add_label_data_pair (infobox_args, label, data, i);
if is_set (args.lang_rom) and ietf_tag then
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 ({args.lang, args.lang_rom}), i);
i = add_label_data_pair (infobox_args, args.lang_std or 'Romanization', lang_mod._xlit ({args.lang, args.lang_rom}), i);
end
end
i = add_label_data_pair (infobox_args, 'IPA', args.lang_ipa, i);
i = add_label_data_pair (infobox_args, 'IPA', args.lang_ipa, i);
Line 640: Line 650:
end
end
else
else
i = add_label_data_pair (infobox_args, '[[Revised Romanization of Korean|Revised Romanization]]', is_set (args.rr) and lang_mod._transl ({'ko', 'rr', args.rr}) or nil, i)
i = add_label_data_pair (infobox_args, '[[Revised Romanization of Korean|Revised Romanization]]', is_set (args.rr) and lang_mod._xlit ({'ko', 'rr', args.rr}) or nil, i)
i = add_label_data_pair (infobox_args, '[[McCune–Reischauer]]', is_set (args.mr) and lang_mod._transl ({'ko', 'mr', args.mr}) or nil, i)
i = add_label_data_pair (infobox_args, '[[McCune–Reischauer]]', is_set (args.mr) and lang_mod._xlit ({'ko', 'mr', args.mr}) or nil, i)
i = add_label_data_pair (infobox_args, '[[Help:IPA/Korean|IPA]]', is_set (args.koreanipa) and args.koreanipa or nil, i)
i = add_label_data_pair (infobox_args, '[[Help:IPA/Korean|IPA]]', is_set (args.koreanipa) and args.koreanipa or nil, i)
end
end
Line 745: Line 755:
local i = 2;
local i = 2;


i = add_label_data_pair (infobox_args, '[[Burmese language|Burmese]]', is_set (args.my) and args.my or nil, i)
i = add_label_data_pair (infobox_args, '[[Burmese language|Burmese]]', is_set (args.my) and lang_mod._lang ({'my', args.my}) or nil, i)
i = add_label_data_pair (infobox_args, '[[Wikipedia:IPA_for_Burmese|IPA]]', is_set (args.bi) and args.bi or nil, i)
i = add_label_data_pair (infobox_args, '[[Wikipedia:IPA_for_Burmese|IPA]]', is_set (args.bi) and args.bi or nil, i)


Line 814: Line 824:


i = add_label_data_pair (infobox_args, '[[Thai language|Thai]]', (is_set (args.th) or is_set (args.tha)) and lang_mod._lang ({'th', args.th or args.tha}) or nil, i)
i = add_label_data_pair (infobox_args, '[[Thai language|Thai]]', (is_set (args.th) or is_set (args.tha)) and lang_mod._lang ({'th', args.th or args.tha}) or nil, i)
i = add_label_data_pair (infobox_args, '[[Royal Thai General System of Transcription|RTGS]]', is_set (args.rtgs) and lang_mod._transl ({'th', 'rtgs', args.rtgs}) or nil, i)
i = add_label_data_pair (infobox_args, '[[Royal Thai General System of Transcription|RTGS]]', is_set (args.rtgs) and lang_mod._xlit ({'th', 'rtgs', args.rtgs}) or nil, i)
i = add_label_data_pair (infobox_args, 'Romanization', is_set (args.rom) and lang_mod._transl ({'th', args.rom}) or nil, i)
i = add_label_data_pair (infobox_args, 'Romanization', is_set (args.rom) and lang_mod._xlit ({'th', args.rom}) or nil, i)
i = add_label_data_pair (infobox_args, '[[International Phonetic Alphabet|IPA]]', is_set (args.ipa) and args.ipa, i)
i = add_label_data_pair (infobox_args, '[[International Phonetic Alphabet|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)
i = add_label_data_pair (infobox_args, 'Literal meaning', is_set (args.lit) and args.lit, i)
Line 917: Line 927:
local i = 2;
local i = 2;


i = add_label_data_pair (infobox_args, '[[Zhuang language|Zhuang]]', is_set (args.zha) and ('<span style="font-family: Arial Unicode MS, sans-serif;">' .. args.zha .. '</span>') or nil, i)
i = add_label_data_pair (infobox_args, '[[Zhuang language|Zhuang]]', is_set (args.zha) and ('<span lang="za" style="font-family: Arial Unicode MS, sans-serif;">' .. args.zha .. '</span>') or nil, i)
i = add_label_data_pair (infobox_args, '[[Zhuang language|1957 orthography]]', is_set (args.zha57) and args.zha57 or nil, i)
i = add_label_data_pair (infobox_args, '[[Zhuang language|1957 orthography]]', is_set (args.zha57) and lang_mod._lang ({'za', args.zha57}) or nil, i)
i = add_label_data_pair (infobox_args, '[[Sawndip]]', is_set (args.sd) and args.sd or nil, i)
i = add_label_data_pair (infobox_args, '[[Sawndip]]', is_set (args.sd) and lang_mod._lang ({'za-Hani', args.sd}) or nil, i)


return frame:expandTemplate ({title='Infobox', args = infobox_args});
return frame:expandTemplate ({title='Infobox', args = infobox_args});
Line 954: Line 964:
end
end


-- infobox_args['subheaderstyle'] = 'font-size: 125%; background-color:' .. h_color .. ';';
-- 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['subheader'] = is_set (args.title) and args.title or mw.title.getCurrentTitle().text;
infobox_args['image'] = frame:callParserFunction ({name = '#invoke:InfoboxImage',
infobox_args['image'] = frame:callParserFunction ({name = '#invoke:InfoboxImage',
Line 984: Line 994:
infobox_args['caption2'] = is_set (args.piccap2) and args.piccap2 or nil;
infobox_args['caption2'] = is_set (args.piccap2) and args.piccap2 or nil;
infobox_args['headerstyle'] = 'background-color:' .. h_color;
infobox_args['headerstyle'] = 'color: #202122;background-color:' .. h_color;
infobox_args['headerstyle'] = 'width: 50%; white-space: nowrap';
infobox_args['headerstyle'] = 'width: 50%; white-space: nowrap';
-- always display the background of the image in light mode, see
-- [[Template_talk:Infobox_Chinese#Issue_in_dark_mode_or_inappropriate_use_of_infobox]]
-- 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 ({title='Infobox', args = infobox_args});
return frame:expandTemplate ({title='Infobox', args = infobox_args});