local export = {}
local function generate_lemmas(langs)
local output = '<table class="langtrack"><tr class="primary">'
for _, language in ipairs(langs) do
output = output .. "<th style=\"padding: 15px\">" .. mw.site.stats.pagesInCategory("Lema bahasa " .. language, "pages") .. "</th>"
end
output = output .. '</tr><tr class="secondary">'
for _, language in ipairs(langs) do
output = output .. "<th style=\"padding: 15px\">[[Khas:RecentChangesLinked/Kategori:Lema bahasa " .. language .. "|Lema bahasa " .. language .. "]]</th>"
end
output = output .. "</tr></table>"
return output
end
local function generate_nonlemmas(langs)
local output = '<table class="infobox langtrack"><tr class="primary">'
for _, language in ipairs(langs) do
output = output .. "<th style=\"padding: 15px\">" .. mw.site.stats.pagesInCategory("Bentuk bukan lema bahasa " .. language, "pages") .. "</th>"
end
output = output .. '</tr><tr class="secondary">'
for _, language in ipairs(langs) do
output = output .. "<th style=\"padding: 15px\">[[Khas:RecentChangesLinked/Kategori:Bentuk bukan lema bahasa " .. language .. "|Bentuk bukan lema bahasa " .. language .. "]]</th>"
end
output = output .. "</tr></table>"
return output
end
local function generate_both(langs)
local output = '<table class="infobox langtrack"><tr class="primary">'
for _, language in ipairs(langs) do
output = output .. "<th style=\"padding: 15px\">" .. mw.site.stats.pagesInCategory("Lema bahasa " .. language, "pages") .. "</th>"
end
output = output .. '</tr><tr class="secondary">'
for _, language in ipairs(langs) do
output = output .. "<th style=\"padding: 15px\">[[Khas:RecentChangesLinked/Kategori:Lema bahasa " .. language .. "|Lema bahasa " .. language .. "]]</th>"
end
output = output .. '</tr><tr class="primary">'
for _, language in ipairs(langs) do
output = output .. "<th style=\"padding: 15px\">" .. mw.site.stats.pagesInCategory("Bentuk bukan lema bahasa " .. language, "pages") .. "</th>"
end
output = output .. '</tr><tr class="secondary">'
for _, language in ipairs(langs) do
output = output .. "<th style=\"padding: 15px\">[[Khas:RecentChangesLinked/Kategori:Bentuk bukan lema bahasa " .. language .. "|Bentuk bukan lema bahasa " .. language .. "]]</th>"
end
output = output .. "</tr></table>"
return output
end
function export.show(frame)
local args = require("Module:parameters").process(
frame:getParent().args,
{
[1] = { list = true },
["type"] = { default = "lemma" },
})
local langs = {}
local languageData = mw.loadData("Module:languages/code to canonical name")
for _, language in ipairs(args[1]) do
language = languageData[language]
table.insert(langs, (language ~= "") and language or nil)
end
local output
if args.type == "lemma" then
output = generate_lemmas(langs)
elseif args.type == "nonlemma" then
output = generate_nonlemmas(langs)
elseif args.type == "both" then
output = generate_both(langs)
else
error("Invalid type.")
end
return output .. frame:extensionTag("templatestyles", nil, {src = "Template:language tracking/styles.css"})
end
return export