Module:links: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
No edit summary |
||
Line 1: | Line 1: | ||
local export = {} | local export = {} | ||
function export. | function export.language_link(data) | ||
if | if not data.term then | ||
error(" | error("language link data must contain term") | ||
end | end | ||
local link = "[[" .. data.term | |||
if data.language then | |||
link = link .. "#" .. data.language.code | |||
end | end | ||
return link .. "|" .. data.alt or data.term .. "]]" | |||
end | end | ||
function export. | function export.link_extras(data) | ||
if not (data.pos or data.gloss) then return nil end | |||
return | local out = {} | ||
if data.gloss then table.insert(out, '“' .. data.gloss .. '”') end | |||
if data.pos then table.insert(out, data.pos) end | |||
return table.concat(out) | |||
end | end | ||
function export. | function export.full_link(data, face) | ||
local link = export.language_link(data) | |||
if face and face ~= "" then | |||
end | link = require("Module:formatting").wrap_face(link, data.language, face) | ||
end | |||
local | local extras = export.link_extras(data) | ||
if extras then | |||
extras = " (" .. extras .. ")" | |||
end | |||
local prefix | |||
if data.language and data.showlanguage then | |||
prefix = "[[" .. language.link .. "|" .. language.name .. "]] " | |||
end | |||
return (prefix or "") .. link .. (extras or "") | |||
end | |||
return | |||
end | end | ||
return export | return export |
Revision as of 13:59, 6 August 2023
Documentation for this module may be created at Module:links/documentation
local export = {}
function export.language_link(data)
if not data.term then
error("language link data must contain term")
end
local link = "[[" .. data.term
if data.language then
link = link .. "#" .. data.language.code
end
return link .. "|" .. data.alt or data.term .. "]]"
end
function export.link_extras(data)
if not (data.pos or data.gloss) then return nil end
local out = {}
if data.gloss then table.insert(out, '“' .. data.gloss .. '”') end
if data.pos then table.insert(out, data.pos) end
return table.concat(out)
end
function export.full_link(data, face)
local link = export.language_link(data)
if face and face ~= "" then
link = require("Module:formatting").wrap_face(link, data.language, face)
end
local extras = export.link_extras(data)
if extras then
extras = " (" .. extras .. ")"
end
local prefix
if data.language and data.showlanguage then
prefix = "[[" .. language.link .. "|" .. language.name .. "]] "
end
return (prefix or "") .. link .. (extras or "")
end
return export