Module:inherit: Difference between revisions

From Laenkea
Jump to navigation Jump to search
No edit summary
No edit summary
Line 9: Line 9:
[2] = {required = true},
[2] = {required = true},
[3] = {required = true},
[3] = {required = true},
[4] = {alias_for = "display"},
[4] = {alias_of = "display"},
["d"] = {alias_for = "display"},
["d"] = {alias_of = "display"},
["display"] = {},
["display"] = {},
[5] = {alias_for = "text"},
[5] = {alias_of = "text"},
["t"] = {alias_for = "text"},
["t"] = {alias_of = "text"},
["text"] = {},
["text"] = {},
["pos"] = {},
["pos"] = {},

Revision as of 22:37, 6 August 2023

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

local export = {}

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] = {required = true},
	[4] = {alias_of = "display"},
	["d"] = {alias_of = "display"},
	["display"] = {},
	[5] = {alias_of = "text"},
	["t"] = {alias_of = "text"},
	["text"] = {},
	["pos"] = {},
	["nocat"] = {type = "boolean"},
}

function export.show(frame)
	local args = m_parameters.process(frame:getParent().args, params)
	local language = m_languages.get_by_code(args[1])
	local origin = m_languages.get_by_code(args[2])
	local category = "[[Category:" .. language.name .. " terms inherited from " .. origin.name .. "]]"
	return m_links.full_link({
		language = origin,
		term = args[3],
		alt = args["display"],
		gloss = args["text"],
		pos = args["pos"],
	}, "term") .. (args["nocat"] and "" or category)
end

return export