Module:links/templates: Difference between revisions

No edit summary
m 1 revision imported
 
(5 intermediate revisions by 2 users not shown)
Line 6: Line 6:
local export = {}
local export = {}


local links_module = "Module:links"
local process_params = require("Module:parameters").process
local process_params = require("Module:parameters").process
local remove = table.remove
local remove = table.remove
Line 16: Line 17:
[[Module:scripts]]
[[Module:scripts]]
[[Module:parameters]]
[[Module:parameters]]
[[Module:debug]]
]=]
]=]


Line 34: Line 36:
[3] = true,
[3] = true,
[4] = true,
[4] = true,
["g"] = {list = true},
g = {list = true, type = "genders", flatten = true},
["gloss"] = alias_of_4,
gloss = alias_of_4,
["id"] = true,
id = true,
["lit"] = true,
lit = true,
["pos"] = true,
ng = true,
["sc"] = {type = "script"},
pos = true,
["t"] = alias_of_4,
sc = {type = "script"},
["tr"] = true,
t = alias_of_4,
["ts"] = true,
tr = true,
ts = true,
q = {type = "qualifier"},
qq = {type = "qualifier"},
l = {type = "labels"},
ll = {type = "labels"},
ref = {type = "references"},
["accel-form"] = true,
["accel-form"] = true,
["accel-translit"] = true,
["accel-translit"] = true,
Line 51: Line 59:
}
}
if iargs.compat then
if iargs.compat then
params["lang"] = {type = "language", default = "und"}
params.lang = {type = "language", default = "und"}
remove(params, 1)
remove(params, 1)
alias_of_4.alias_of = 3
alias_of_4.alias_of = 3
end
end
if iargs.langname then
if iargs.langname then
params["w"] = boolean
params.w = boolean
end
end
return process_params(frame:getParent().args, params), iargs
return process_params(frame:getParent().args, params), iargs
Line 63: Line 71:
-- Used in [[Template:l]] and [[Template:m]].
-- Used in [[Template:l]] and [[Template:m]].
function export.l_term_t(frame)
function export.l_term_t(frame)
local args, iargs = get_args(frame)
local args, iargs = get_args(frame)
local compat = iargs.compat
local compat = iargs.compat
local lang = args[compat and "lang" or 1]
local lang = args[compat and "lang" or 1]
-- Tracking for und.
if not compat and lang:getCode() == "und" then
require("Module:debug").track("link/und")
end
local term = args[(compat and 1 or 2)]
local term = args[(compat and 1 or 2)]
Line 85: Line 97:
end
end
-- Forward the information to full_link
-- Forward the information to full_link
return (langname and langname .. " " or "") .. require("Module:links").full_link(
return (langname and langname .. " " or "") .. require(links_module).full_link(
{
{
lang = lang,
lang = lang,
Line 93: Line 105:
alt = alt,
alt = alt,
gloss = args[4],
gloss = args[4],
id = args["id"],
id = args.id,
tr = args["tr"],
tr = args.tr,
ts = args["ts"],
ts = args.ts,
genders = args["g"],
genders = args.g,
pos = args["pos"],
pos = args.pos,
lit = args["lit"],
ng = args.ng,
lit = args.lit,
q = args.q,
qq = args.qq,
l = args.l,
ll = args.ll,
refs = args.ref,
show_qualifiers = true,
accel = args["accel-form"] and {
accel = args["accel-form"] and {
form = args["accel-form"],
form = args["accel-form"],
Line 110: Line 129:
iargs.face,
iargs.face,
not iargs.notself
not iargs.notself
)
end
-- Used in [[Template:link-annotations]].
function export.l_annotations_t(frame)
local args, iargs = get_args(frame)
-- Forward the information to format_link_annotations
return require(links_module).format_link_annotations(
{
lang = args[1],
tr = { args.tr },
ts = { args.ts },
genders = args.g,
pos = args.pos,
ng = args.ng,
lit = args.lit
},
iargs.face
)
)
end
end
Line 121: Line 159:
[2] = {allow_empty = true},
[2] = {allow_empty = true},
[3] = true,
[3] = true,
["id"] = true,
id = true,
["sc"] = {type = "script"},
sc = {type = "script"},
})
})
end
end
Line 129: Line 167:
local args = get_args(frame)
local args = get_args(frame)
local lang = args[1]
local lang = args[1]
local sc = args["sc"]
local sc = args.sc
local term = args[2]
local term = args[2]
term = term ~= "" and term or nil
term = term ~= "" and term or nil
return require("Module:links").language_link{
return require(links_module).language_link{
lang = lang,
lang = lang,
sc = sc,
sc = sc,
Line 154: Line 192:
local face = frame.args.face
local face = frame.args.face


local ret = require("Module:script utilities").tag_definition(require("Module:links").embedded_language_links{
local ret = require("Module:script utilities").tag_definition(require(links_module).embedded_language_links{
term = args[1],
term = args[1],
lang = require("Module:languages").getByCode("en"),
lang = require("Module:languages").getByCode("en"),
Line 184: Line 222:
[1] = {required = true},
[1] = {required = true},
[2] = true,
[2] = true,
["lang"] = {type = "language", default = "en"},
lang = {type = "language", default = "en"},
})
})
local term = args[1]
local term = args[1]
return require("Module:links").full_link{
return require(links_module).full_link{
lang = args.lang,
lang = args.lang,
term = term,
term = term,
Line 201: Line 239:
})
})
return require("Module:links").section_link(args[1])
return require(links_module).section_link(args[1])
end
end


return export
return export