A modult a Modul:wikipedia/doc lapon tudod dokumentálni
local export = {}
local function process_links(linkdata, prefix, name, wmlang, sc)
prefix = prefix .. ":" .. (wmlang:getCode() == "hu" and "" or wmlang:getCode() .. ":")
local links = {}
local iplinks = {}
local m_links = require("Module:links")
local lang = wmlang:getWiktionaryLanguage()
local ipalt = name .. " " .. (wmlang:getCode() == "hu" and "" or "<sup>" .. wmlang:getCode() .. "</sup>")
for i, link in ipairs(linkdata) do
link.lang = lang
link.sc = sc
link.term = prefix .. link.term
link.tr = "-"
-- used by ], not on huwiktionary
-- table.insert(iplinks, "<span class=\"interProject\">]</span>")
table.insert(links, m_links.full_link(link, "bold"))
end
return links, iplinks
end
function export.wikipedia_box(frame)
local params = {
= {},
= {},
= {},
= {alias_of = "cat"},
= {},
= {alias_of = "dab"},
= {type = "boolean"},
= {default = "hu"},
= {},
= {},
= {},
= {},
= {},
= {},
}
local args = require("Module:parameters").process(frame:getParent().args, params)
local wmlang = require("Module:wikimedia languages").getByCodeWithFallback(args) or error("A(z) „" .. args .. "” Wikimédia-nyelvkód érvénytelen.")
local sc = args and (require("Module:scripts").getByCode(args) or error("A(z) „" .. args .. "” ábécékód érvénytelen.")) or nil
local linkdata = {}
if args then
table.insert(linkdata, {term = "Category:" .. args, alt = args or args})
elseif args then
table.insert(linkdata, {term = "Portal:" .. args, alt = args or args})
else
table.insert(linkdata, {term = args or args or mw.title.getCurrentTitle().text, alt = args or args or args or mw.title.getCurrentTitle().text})
end
if args or args then
if args then
table.insert(linkdata, {term = "Category:" .. args, alt = args or args})
else
table.insert(linkdata, {term = args, alt = args or args})
end
end
local links, iplinks = process_links(linkdata, "w", "Wikipédia", wmlang, sc)
local langname
if wmlang:getCode() == "hu" then
langname = "A " -- Wikipédia
elseif wmlang:getCode() == "en" then
langname = "Az angol"
else
langname = "A " .. wmlang:getCanonicalName()
end
if frame.args then
langname = langname:gsub('^A', 'a')
return
"<div class=\"sister-wikipedia sister-project noprint floatright\" style=\"border: solid #aaa 1px; font-size: 90%; background: #f9f9f9; width: 250px; padding: 4px; text-align: left;\">" ..
"<div style=\"float: left;\">]</div>" ..
"<div style=\"margin-left: 15px;\">" ..
" " ..
mw.text.listToText(links) .. " " ..
langname ..
" Wikipédián" ..
"</div>" ..
"</div>"
else
local linktype
if args then
linktype = "van ilyen témájú kategóriája"
elseif args or args then
linktype = "vannak ilyen témájú szócikkei"
elseif args then
linktype = "vannak ilyen témájú kategóriái"
elseif args then
linktype = "van ilyen témájú portálja"
else
linktype = "van ilyen témájú szócikke"
end
return
"<div class=\"sister-wikipedia sister-project noprint floatright\" style=\"border: 1px solid #aaa; font-size: 90%; background: #f9f9f9; width: 250px; padding: 4px; text-align: left;\">" ..
"<div style=\"float: left;\">]</div>" ..
"<div style=\"margin-left: 60px;\">" .. langname .. " ] " .. linktype .. ":" ..
"<div style=\"margin-left: 10px;\">" .. mw.text.listToText( links ) .. "</div>" ..
"</div>" ..
table.concat(iplinks) .. ((args == mw.title.getCurrentTitle().text and not (args or args)) and "]" or "") ..
"</div>"
end
end
function export.projectlink(frame)
local params = {
= {},
= {},
= {},
= {type = "boolean"},
= {default = "hu"},
= {},
= {},
}
local args = require("Module:parameters").process(frame:getParent().args, params)
local wmlang = require("Module:wikimedia languages").getByCodeWithFallback(args) or error("A(z) „" .. args .. "” Wikimédia-nyelvkód érvénytelen.")
local sc = args and (require("Module:scripts").getByCode(args) or error("A(z) „" .. args .. "” ábécékód érvénytelen.")) or nil
local linkdata = {term = args or args or mw.title.getCurrentTitle().text, alt = args or args or args or mw.title.getCurrentTitle().text}
if args then
linkdata.alt = "''" .. linkdata.alt .. "''"
end
local links, iplinks = process_links({linkdata}, frame.args, frame.args, wmlang, sc)
local langname
if wmlang:getCode() == "hu" then
langname = "magyar"
elseif wmlang:getCode() == "en" then
langname = "angol"
else
langname = wmlang:getCanonicalName()
end
return
" .. "|15px|link=" .. linkdata.term .. "]] " ..
mw.text.listToText( links ) .. " - Wikipédia (" .. langname .. ")" .. (args and "" or "") ..
table.concat(iplinks)
end
return export