Module:derive: Difference between revisions

From Laenkea
Jump to navigation Jump to search
(Created page with "local export = {} local get_by_code = require("Module:languages").get_by_code local make_link = require("Module:links").make_link function export.show(frame) local args = (frame:getParent() and frame:getParent().args) or frame.args local lang = get_by_code(args[1]) local origin = get_by_code(args[2]) local category = "" if not args["nocat"] then category = "Category:" .. lang.name .. " terms derived from " .. origin.name .. "" end return make_link{ ["link...")
 
No edit summary
Line 1: Line 1:
local export = {}
local export = {}
local get_by_code = require("Module:languages").get_by_code
 
local make_link = require("Module:links").make_link
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)
function export.show(frame)
local args = (frame:getParent() and frame:getParent().args) or frame.args
local args = m_parameters.process(frame:getParent().args, params)
local lang = get_by_code(args[1])
local language = m_languages.get_by_code(args[1])
local origin = get_by_code(args[2])
local origin = m_languages.get_by_code(args[2])
local category = ""
local category = "[[Category:" .. language.name .. " terms derived from " .. origin.name .. "]]"
if not args["nocat"] then
return m_links.full_link({
category = "[[Category:" .. lang.name .. " terms derived from " .. origin.name .. "]]"
language = origin,
end
term = args[3],
return make_link{
alt = args["display"],
["link_type"] = "mention",
gloss = args["text"],
["code"] = origin.code,
pos = args["pos"],
["word"] = args[3],
showlanguage = true,
["display"] = args[4] or args["d"] or args["display"],
}, "term") .. (args["nocat"] and "" or category)
["text"] = args[5] or args["t"] or args["text"],
["pos"] = args["pos"]
} .. category
end
end


return export
return export

Revision as of 22:42, 6 August 2023

Documentation for this module may be created at Module:derive/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 derived from " .. origin.name .. "]]"
	return m_links.full_link({
		language = origin,
		term = args[3],
		alt = args["display"],
		gloss = args["text"],
		pos = args["pos"],
		showlanguage = true,
	}, "term") .. (args["nocat"] and "" or category)
end

return export