local export = {}
local m_languages = require("Module:languages")
function export.show(frame)
local list_with_holes = { list = true, allow_holes = true }
local params = {
= {type = "number"},
= {type = "boolean", default = false},
= {type = "number"}
}
local frame_args = require("Module:parameters").process(frame.args, params)
params = {
= { required = true, default = "en" },
= { required = true, list = true, allow_holes = true },
= {},
= list_with_holes,
= list_with_holes,
= list_with_holes,
= list_with_holes,
= list_with_holes,
= list_with_holes,
= { alias_of = "t" },
= list_with_holes,
= list_with_holes,
= {},
= {type = "number"},
= {type = "boolean", default = false},
= {type = "number"}
}
local args = require("Module:parameters").process(frame:getParent().args, params)
local terms
if args.maxindex > 0 then
terms = args
else
terms = {"beer and skittles", "beer belly", "beer-bust", "beer can", "beered-up", "beer garden", "beer goggles", "beer gut", "beer hall", "beerily", "beerish", "beerless", "beer mat", "beer muscles", "beer o'clock", "beer parlour", "beerstone", "beery", "bock beer", "champagne taste on a beer budget", "craft beer", "cry in one's beer", "ginger beer", "keg beer", "ice beer", "near beer", "root beer", "small beer", "spruce beer"}
terms.maxindex = #terms
end
local sc = args
local columns = frame_args or args
local inline = frame_args or args
local limit = frame_args or args
local lang = args
lang = m_languages.getByCode(lang) or m_languages.err(lang, "lang")
if sc then
sc = require("Module:scripts").getByCode(sc) or error("The script code \"" .. sc .. "\" is not valid.")
end
local links = {}
local maxindex = {}
if limit then
maxindex = limit
else
maxindex = math.max(terms.maxindex, args.tr.maxindex, args.ts.maxindex)
end
local link_data = {}
for i = 1, maxindex do
link_data = {
lang = lang,
sc = sc,
term = terms,
accel = args.accel,
alt = args.alt,
g = args.g,
id = args.id,
lit = args.lit,
pos = args.pos,
gloss = args.t,
tr = args.tr,
ts = args.ts,
}
end
-- Assume no non-BMP characters for now.
local compare = require "Module:collation".make_compare_func(lang)
table.sort(link_data,
function (a, b)
if a.term and b.term then
return compare(a.term, b.term)
else
return a.term ~= nil
end
end)
local links = {}
local full_link = require "Module:links".full_link
for i = 1, maxindex do
links = full_link(link_data)
end
local class = {}
if inline then
columns = false
table.insert(class, "horizontal")
end
if columns == 2 then
table.insert(class, "column-count-2")
elseif columns == 3 then
table.insert(class, "column-count-3")
end
local links = table.concat(links, "</li>\n<li>")
local class = table.concat(class, " ")
return "<ul class=\"links-list " .. class .. "\">\n<li>" .. links .. "</li>\n</ul>"
end
return export