Module:links/templates

< Module:links
Revision as of 14:13, 6 August 2023 by Maria (talk | contribs) (Created page with "local exports = {} local m_links = require("Module:links") local m_languages = require("Module:languages") local m_parameters = require("Module:parameters") local params = { [1] = {required = true}, [2] = {required = true}, [3] = {alias_of = "alt"}, ["alt"] = {}, [4] = {alias_of = "text"}, ["t"] = {alias_of = "text"}, ["text"] = {}, } local function get_data(frame) local args = m_parameters.process(frame:getParent(), params) return { term = args[1], langu...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Documentation for this module may be created at Module:links/templates/documentation

local exports = {}

local m_links = require("Module:links")
local m_languages = require("Module:languages")
local m_parameters = require("Module:parameters")

local params = {
	[1] = {required = true},
	[2] = {required = true},
	[3] = {alias_of = "alt"},
	["alt"] = {},
	[4] = {alias_of = "text"},
	["t"] = {alias_of = "text"},
	["text"] = {},
}

local function get_data(frame)
	local args = m_parameters.process(frame:getParent(), params)
	return {
		term = args[1],
		language = m_languages.get_by_code(args[2]),
		alt = args["alt"],
		gloss = args["text"],
	}
end

function export.link(frame)
	return m_links.full_link(get_data(frame))
end

function export.mention(frame)
	return m_links.full_link(get_data(frame), "term")
end

function export.mention_with_language_name(frame)
	local data = get_data(frame)
	data["showlanguage"] = true
	return m_links.full_link(data, "term")
end

return exports