2,788
edits
No edit summary |
No edit summary |
||
Line 1: | Line 1: | ||
local export = {} | local export = {} | ||
function export.make_link(args) | |||
if link_type ~= "mention" and link_type ~= "list" then | if (not args["link_type"]) or (args["link_type"] ~= "mention" and args["link_type"] ~= "list") then | ||
error("Link type must be specified") | error("Link type must be specified") | ||
end | end | ||
if not args["code"] then | |||
local word = | error("Language code must be specified") | ||
local display = | end | ||
local text = | local word = args["word"] | ||
local display = args["display"] | |||
local text = frame.args["text"] | |||
local pos = frame.args["pos"] | local pos = frame.args["pos"] | ||
local language = require("Module:languages").get_by_code( | local language = require("Module:languages").get_by_code(args["code"]) | ||
local link = "" | local link = "" | ||
if link_type == "mention" then | if link_type == "mention" then | ||
Line 35: | Line 37: | ||
end | end | ||
return link | return link | ||
end | |||
function export.make_list_link(args) | |||
args["link_type"] = "list" | |||
return export.make_link(args) | |||
end | |||
function export.make_mention_link(args) | |||
args["link_type"] = "mention" | |||
return export.make_link(args, "mention") | |||
end | |||
local function make_from_frame(frame, link_type) | |||
local args = (frame:getParent() and frame:getParent().args) or frame.args | |||
return export.make_link{ | |||
["code"] = args[1], | |||
["word"] = args[2], | |||
["display"] = args[3] or args["d"] or args["display"], | |||
["text"] = args[4] or args["t"] or args["text"], | |||
["pos"] = args["pos"] | |||
} | |||
end | end | ||
function export.list(frame) | function export.list(frame) | ||
return make_from_frame(frame, "list") | |||
return | |||
end | end | ||
function export.mention(frame) | function export.mention(frame) | ||
return make_from_frame(frame, "mention") | |||
return | |||
end | end | ||
return export | return export |