Jump to content

Module:Wikitiki89/testmod

Unchecked
From Wikipedia

Documentation for this module may be created at Module:Wikitiki89/testmod/doc

local z = {}

function z.languageifyLinks(frame)
    local pframe = frame:getParent()
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    
    local text = args[1] or ""
    local langname = args[2] or "English"
    
    -- handle unpiped wikilinks:
    text = text:gsub("%[%[([^%[%]|{}#]+)%]%]", "[[%1#" .. langname .. "|%1]]")
    -- handled piped wikilinks:
    text = text:gsub("%[%[([^%[%]|{}#]+)|([^%[%]|{}]+)%]%]", "[[%1#" .. langname .. "|%2]]")
    
    return text
end
 
return z