Module:Language template transcluder
Jump to navigation
Jump to search
local p = {}
function p.passParams(frame)
local args = frame:getParent().args -- Get parameters from template "lt"
local params = {}
local t = args["t"] -- Get the value of "t"
if not t or t == "" then
return "Error: Missing template name"
end
-- Get FULLPAGENAME and extract the translation projects name (second) part
local title = mw.title.getCurrentTitle().fullText
local parts = mw.text.split(title, "/", true) -- Split the title by "/"
if #parts < 2 then
return "Error: The page is not in any translation projects"
end
local secondPart = parts[2] -- Get the second part
-- Construct the correct template name
local templateName = "Template:" .. secondPart .. "/" .. t
-- Filter parameters, excluding "t"
for key, value in pairs(args) do
if value ~= "" and key ~= "t" then
params[key] = value
end
end
-- Expand and return the actual template content
return frame:expandTemplate{ title = templateName, args = params }
end
return p