Module:root

From Laenkea
Revision as of 08:55, 6 August 2023 by Maria (talk | contribs) (Created page with "local export = {} local m_languages = require("Module:languages") function export.make_categories(language, source, roots) local categories = {} local root_prefix = (source.proto and "*") or "" for _, root in ipairs(roots) do if language.code == source.code then table.insert(categories, "Category:" .. language.name .. " terms belonging to the root " .. root_prefix .. root .. "") else table.insert(categories, "[[Category:" .. language.name .. " terms der...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

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

local export = {}
local m_languages = require("Module:languages")

function export.make_categories(language, source, roots)
	local categories = {}
	local root_prefix = (source.proto and "*") or ""
	for _, root in ipairs(roots) do
		if language.code == source.code then
			table.insert(categories, "[[Category:" .. language.name .. " terms belonging to the root " .. root_prefix .. root .. "]]")
		else
			table.insert(categories, "[[Category:" .. language.name .. " terms derived from the " .. source.name .. " root " .. root_prefix .. root .. "]]")
		end
	end
	return table.concat(categories)
end

function export.show(frame)
	local params = {
		[1] = {required = true},
		[2] = {required = true},
		[3] = {required = true, list = true},
	}
	local args = require("Module:parameters").process(frame:getParent().args, params)
	local language = m_languages.get_by_code(args[1])
	local source = m_languages.get_by_code(args[2])
	return export.make_categories(language, source, args[3])
end

return export