12,564
edits
TheNightAvl (talk | contribs) No edit summary |
TheNightAvl (talk | contribs) No edit summary |
||
| Line 11: | Line 11: | ||
function build_grid(data) | function build_grid(data) | ||
local grid = "" | local grid = "" | ||
local term_count = #data.terms | |||
local function build(new) | local function build(new) | ||
grid = grid .. new | grid = grid .. new | ||
end | end | ||
if term_count > 10 then mw.addWarning("<div class=\"noprint maintenance-box maintenance-box-red\" style=\"background:#FFE7DD; width:90%; margin: 0.75em auto; border:1px dashed #884444; padding: 0.25em;\"><table><tr><td rowspan=\"2\">[[File:Nuvola_apps_important_yellow.svg|48px]]</td><th style=\"text-align: left;\">There are more than ten terms in the gloss grid!</th></tr><tr><td>You may want to consider splitting it up into multiple lines.</td></tr></table></div>") end | if term_count > 10 then mw.addWarning("<div class=\"noprint maintenance-box maintenance-box-red\" style=\"background:#FFE7DD; width:90%; margin: 0.75em auto; border:1px dashed #884444; padding: 0.25em;\"><table><tr><td rowspan=\"2\">[[File:Nuvola_apps_important_yellow.svg|48px]]</td><th style=\"text-align: left;\">There are more than ten terms in the gloss grid!</th></tr><tr><td>You may want to consider splitting it up into multiple lines.</td></tr></table></div>") end | ||
| Line 31: | Line 29: | ||
-- build split IPA row | -- build split IPA row | ||
if data.IPAs | if data.IPAs then | ||
build("<tr>") | build("<tr>") | ||
for i = 1, term_count do | for i = 1, term_count do | ||
| Line 54: | Line 52: | ||
-- build gloss row | -- build gloss row | ||
if data.glosses | if data.glosses then | ||
build("<tr>") | build("<tr>") | ||
for i = 1, term_count do | for i = 1, term_count do | ||
| Line 67: | Line 65: | ||
-- build split translation row | -- build split translation row | ||
if data.translations | if data.translations then | ||
build("<tr>") | build("<tr>") | ||
for i = 1, term_count do | for i = 1, term_count do | ||
| Line 104: | Line 102: | ||
local terms, glosses, translations, IPAs = {}, {}, {}, {} | local terms, glosses, translations, IPAs = {}, {}, {}, {} | ||
local g_count, t_count, p_count = 0, 0, 0 | |||
local nolinks = args["nolinks"] or args["nolink"] or false | local nolinks = args["nolinks"] or args["nolink"] or false | ||
| Line 114: | Line 113: | ||
translations[i-1] = term_args["t"] | translations[i-1] = term_args["t"] | ||
term_args["t"] = nil | term_args["t"] = nil | ||
t_count = t_count + 1 | |||
end | end | ||
if term_args["gl"] or term_args["g"] then | if term_args["gl"] or term_args["g"] then | ||
glosses[i-1] = term_args["gl"] or term_args["g"] | glosses[i-1] = term_args["gl"] or term_args["g"] | ||
term_args["gl"], term_args["g"] = nil, nil | term_args["gl"], term_args["g"] = nil, nil | ||
g_count = g_count + 1 | |||
end | end | ||
if term_args["pr"] or term_args["p"] or term_args["ipa"] then | if term_args["pr"] or term_args["p"] or term_args["ipa"] then | ||
IPAs[i-1] = term_args["pr"] or term_args["p"] or term_args["ipa"] | IPAs[i-1] = term_args["pr"] or term_args["p"] or term_args["ipa"] | ||
term_args["pr"], term_args["p"], term_args["ipa"] = nil, nil, nil | term_args["pr"], term_args["p"], term_args["ipa"] = nil, nil, nil | ||
p_count = p_count + 1 | |||
end | end | ||
| Line 157: | Line 159: | ||
end | end | ||
local send_build = { | |||
terms = terms, | terms = terms, | ||
s_IPA = args["pr"] or args["p"] or args["ipa"], | s_IPA = args["pr"] or args["p"] or args["ipa"], | ||
s_translation = args["t"], | s_translation = args["t"], | ||
| Line 167: | Line 166: | ||
phonemic = (args["phnm"] ~= nil) | phonemic = (args["phnm"] ~= nil) | ||
} | } | ||
if p_count > 0 then send_build["IPAs"] = IPAs end | |||
if g_count > 0 then send_build["glosses"] = glosses end | |||
if t_count > 0 then send_build["translations"] = translations end | |||
return build_grid(send_build) | |||
end | end | ||