Module:topics: Difference between revisions
Jump to navigation
Jump to search
(Created page with "local export = {} local m_languages = require("Module:languages") function export.show(frame) local args = frame:getParent().args local language = m_languages.get_by_code(args[1]) local cats = "" local i = 2 while args[i] do cats = cats .. "[[Category:" .. language.code .. ":" .. args[i] .. "]]" i = i + 1 end if cats == "" then error("at least 1 topic must be supplied to {{topic}}") end return cats end return export") |
TheNightAvl (talk | contribs) No edit summary |
||
(One intermediate revision by the same user not shown) | |||
Line 8: | Line 8: | ||
local i = 2 | local i = 2 | ||
while args[i] do | while args[i] do | ||
cats = cats .. "[[Category:" .. language.code .. ":" .. | local capped = mw.ustring.upper(mw.ustring.sub(args[i],1,1)) .. mw.ustring.sub(args[i],2) or "" | ||
cats = cats .. "[[Category:" .. language.code .. ":" .. capped .. "]]" | |||
i = i + 1 | i = i + 1 | ||
end | end | ||
if cats == "" then | if cats == "" then | ||
error("at least 1 topic must be supplied to {{topic}}") | error("at least 1 topic must be supplied to {{topic}}") | ||
end | |||
if args["text"] then | |||
cats = args["text"] .. cats | |||
end | end | ||
return cats | return cats |
Latest revision as of 21:59, 12 July 2024
Documentation for this module may be created at Module:topics/documentation
local export = {}
local m_languages = require("Module:languages")
function export.show(frame)
local args = frame:getParent().args
local language = m_languages.get_by_code(args[1])
local cats = ""
local i = 2
while args[i] do
local capped = mw.ustring.upper(mw.ustring.sub(args[i],1,1)) .. mw.ustring.sub(args[i],2) or ""
cats = cats .. "[[Category:" .. language.code .. ":" .. capped .. "]]"
i = i + 1
end
if cats == "" then
error("at least 1 topic must be supplied to {{topic}}")
end
if args["text"] then
cats = args["text"] .. cats
end
return cats
end
return export