Module:rootsee

Hello, you have come here looking for the meaning of the word Module:rootsee. In DICTIOUS you will not only get to know all the dictionary meanings for the word Module:rootsee, but we will also tell you about its etymology, its characteristics and you will know how to say Module:rootsee in singular and plural. Everything you need to know about the word Module:rootsee you have here. The definition of the word Module:rootsee will help you to be more precise and correct when speaking or writing your texts. Knowing the definition ofModule:rootsee, as well as those of other words, enriches your vocabulary and provides you with more and better linguistic resources.


local export = {}

local m_languages = require("Module:languages")
local scripts_module = "Module:scripts"

local rsplit = mw.text.split


local function categorize(lang, source, root, id)
	local categories = {}

	local root_suffix = " root " .. root .. (id and " (" .. id .. ")" or "")
	if source then
		root_suffix = "the " .. source:getCanonicalName() .. root_suffix
	else
		root_suffix = "the" .. root_suffix
	end

	if not lang then
		return "Terms derived from " .. root_suffix
	elseif source then
		return lang:getCanonicalName() .. " terms derived from " .. root_suffix
	else
		return lang:getCanonicalName() .. " terms belonging to " .. root_suffix
	end
end


function export.rootsee(frame)
	local params = {
		 = {template_default = "en"},
		 = {template_default = "ine"},
		 = {template_default = "gʷem"},
		 = {},
		 = {}, -- one of "categories", "pages", "all" or "parents"; defaults to "all"; see ].
		 = {}, -- for testing and documentation pages
	}

	local args = require("Module:parameters").process(frame:getParent().args, params)
	local title

	if args.pagename then -- for testing, doc pages, etc.
		title = mw.title.new(args.pagename)
		if not title then
			error(("Bad value for pagename=: '%s'"):format(args.pagename))
		end
	else
		title = mw.title.getCurrentTitle()
	end

	local function convert_plus(val)
		if val == "+" then
			return nil
		else
			return val
		end
	end

	local lang = convert_plus(args)
	if lang then
		lang = m_languages.getByCode(lang, 1)
	end

	local source = convert_plus(args)
	local orig_source = source
	if source then
		source = m_languages.getByCode(source, 2, nil, "allow family")
		if source:hasType("family") then
			source = source:getProtoLanguage()
			if not source then
				error(("Family '%s' has no proto-language"):format(args))
			end
		end
	elseif lang then
		source = lang
	elseif title:inNamespace("Reconstruction") or title:inNamespace("Appendix") then
		local langname = title.text:match("^(.-)/")
		if not langname then
			error(("Unable to infer source from pagename '%s' as it isn't doesn't have a current language in it (no slash)")
				:format(title.fullText))
		end
		source = m_languages.getByCanonicalName(langname)
		if not source then
			error(("Unable to infer source from pagename '%s' as current language '%s' isn't recognized as a language name")
				:format(title.fullText, langname))
		end
	else
		error(("Unable to infer source from pagename '%s' as it isn't a Reconstruction or Appendix page"):format(
			title.fullText))
	end

	local root = convert_plus(args)
	if not root then
		root = title.subpageText
		-- If none of dest lang, source lang and root were given, we're being asked to display a category of the form
		-- ] where `root` comes from the current page. If this
		-- page is a Reconstruction page, make the root reconstructed even if the source language isn't
		-- reconstruction-only. This is definitely an edge case but is parallel to the derivsee() code in
		-- ].
		if not lang and not orig_source and title:inNamespace("Reconstruction") and not root:find("^%*") then
			root = "*" .. root
		end
	end

	if not root:find(" ") and not root:find("%-") then
		local is_latin = root:find("^$")
		if not is_latin then
			local sc = require(scripts_module).findBestScriptWithoutLang(root)
			if sc and sc:getCode():find("Lat") then -- Latn, Latf, Latg, pjt-Latn
				is_latin = true
			end
		end
		if is_latin then
			if source:getCode() == "nv" then
				root = "-" .. root
			else
				root = root .. "-"
			end
		end
	end
	if source:hasType("reconstructed") and not root:find("^%*") then
		root = "*" .. root
	end

	if source and lang and source:getCode() == lang:getCode() then
		source = nil
	end

	return frame:callParserFunction{
		name = "#categorytree",
		args = {
			categorize(lang, source, root, args.id),
			depth = 0,
			class = '"derivedterms"',
			mode = args.mode or "all",
			hideprefix = "always",
			showcount = "on",
		}
	}
end

return export