Module:User:Isomorphyc/etymology-draft

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


local export = {}

function export.format_etyl(lang, source, sort_key)
	local info
	
	if source:getCode() == "und" then
		info = {
			display = "undetermined",
			cat_name = "other languages"}
	elseif source:getType() == "etymology language" then
		info = {
			display = "]",
			cat_name = source:getCanonicalName()}
	elseif source:getType() == "family" then
		info = {
			display = "]",
			cat_name = source:getCategoryName()}
	else
		info = {
			display = "]",
			cat_name = source:getCanonicalName()}
	end
	
	-- Add the categories, but only if there is a current language
	local categories = ""
	
	if lang then
		local m_utilities = require("Module:utilities")
		
		categories = {}
		
		if lang:getCode() == source:getCode() or (source:getType() == "etymology language" and lang:getCode() == source:getParentCode()) then
			categories = m_utilities.format_categories({lang:getCanonicalName() .. " twice-borrowed terms"}, lang, sort_key)
		else
			categories = m_utilities.format_categories({lang:getCanonicalName() .. " terms derived from " .. info.cat_name}, lang, sort_key)
		end
	end
	
	return "<span class=\"etyl\">" .. info.display .. categories .. "</span>"
end

-- Internal implementation of {{cognate|...}} and {{cog|...}} templates
function export.format_cognate(terminfo, sort_key)
	return export.format_derived(nil, terminfo, sort_key)
end

function remove_links(text)
	if type(text) == "table" then text = text.args end; if not text then text = "" end
	text = text:gsub("%]-|?]-%]%]", "")
	text = text:gsub("%]-|", "")
	text = text:gsub("%[%[", "")
	text = text:gsub("%]%]", "")
	return text
end


function preprocess_pr(terminfo)
	terminfo.pr = terminfo.lang:transliterate1(remove_links(terminfo.term), terminfo.sc, false)
end

-- Internal implementation of {{derived|...}} and {{der|...}} templates
function export.format_derived(lang, terminfo, sort_key)
	preprocess_pr(terminfo)
	local source = terminfo.lang

	if not (terminfo.lang:getType() == "regular" or terminfo.lang:getType() == "reconstructed" or terminfo.lang:getType() == "etymology language") then
		if terminfo.term then
			error("A term was provided but the given code \"" .. terminfo.lang:getCode() .. "\" is not a language, and therefore cannot have terms or dictionary entries.")
		else
			terminfo.term = "-"
		end
	end
	
	if terminfo.lang:getType() == "etymology language" then
		local parent = require("Module:User:Isomorphyc/languages-draft").getByCode(terminfo.lang:getParentCode()) or
		require("Module:families").getByCode(terminfo.lang:getParentCode())

		if not (parent:getType() == "regular" or parent:getType() == "reconstructed" or parent:getType() == "etymology language") then
			if terminfo.term then
				error("A term was provided but the given code \"" .. terminfo.lang:getCode() .. "\" is not a language, and therefore cannot have terms or dictionary entries.")
			else
				terminfo.term = "-"
			end
		end

		terminfo.lang = parent
	end
	
	local link = ""
	
	if terminfo.term ~= "-" then
		link = " " .. require("Module:User:Isomorphyc/links-draft").full_link(terminfo, "term", true)
	end
	
	return export.format_etyl(lang, source, sort_key) .. link
end

-- Internal implementation of {{inherited|...}} and {{inh|...}} templates
function export.format_inherited(lang, terminfo, sort_key)
	preprocess_pr(terminfo)
	local source = terminfo.lang

	if not (terminfo.lang:getType() == "regular" or terminfo.lang:getType() == "reconstructed" or terminfo.lang:getType() == "etymology language") then
		if terminfo.term then
			error("A term was provided but the given code \"" .. terminfo.lang:getCode() .. "\" is not a language, and therefore cannot have terms or dictionary entries.")
		else
			terminfo.term = "-"
		end
	end
	
	if terminfo.lang:getType() == "etymology language" then
		local parent = require("Module:User:Isomorphyc/languages-draft").getByCode(terminfo.lang:getParentCode()) or
		require("Module:families").getByCode(terminfo.lang:getParentCode())

		if not (parent:getType() == "regular" or parent:getType() == "reconstructed" or parent:getType() == "etymology language") then
			if terminfo.term then
				error("A term was provided but the given code \"" .. terminfo.lang:getCode() .. "\" is not a language, and therefore cannot have terms or dictionary entries.")
			else
				terminfo.term = "-"
			end
		end
		
		terminfo.lang = parent
	end

	if not lang:hasAncestor(terminfo.lang) and mw.title.getCurrentTitle().nsText ~= "Template" then
		error(terminfo.lang:getCanonicalName() .. " is not an ancestor of " .. lang:getCanonicalName() .. ".")
	end
	
	local link = ""
	
	if terminfo.term ~= "-" then
		link = " " .. require("Module:User:Isomorphyc/links-draft").full_link(terminfo, "term", true)
	end
	
	local categories = require("Module:utilities").format_categories({lang:getCanonicalName() .. " terms derived from " .. source:getCanonicalName()}, lang, sort_key)
	categories = categories .. require("Module:utilities").format_categories({lang:getCanonicalName() .. " terms inherited from " .. source:getCanonicalName()}, lang, sort_key)
	
	return export.format_etyl(nil, source, sort_key) .. link .. categories
end

-- Internal implementation of {{borrowed|...}} and {{bor|...}} templates
function export.format_borrowed(lang, terminfo, sort_key, nocap, notext, learned)
	if nocap then
		require("Module:debug").track("bor/nocap")
	end
	
	preprocess_pr(terminfo)
	local source = terminfo.lang

	if not (terminfo.lang:getType() == "regular" or terminfo.lang:getType() == "reconstructed" or terminfo.lang:getType() == "etymology language") then
		if terminfo.term then
			error("A term was provided but the given code \"" .. terminfo.lang:getCode() .. "\" is not a language, and therefore cannot have terms or dictionary entries.")
		else
			terminfo.term = "-"
		end
	end
	
	if terminfo.lang:getType() == "etymology language" then
		local parent = require("Module:User:Isomorphyc/languages-draft").getByCode(terminfo.lang:getParentCode()) or
		require("Module:families").getByCode(terminfo.lang:getParentCode())

		if not (parent:getType() == "regular" or parent:getType() == "reconstructed" or parent:getType() == "etymology language") then
			if terminfo.term then
				error("A term was provided but the given code \"" .. terminfo.lang:getCode() .. "\" is not a language, and therefore cannot have terms or dictionary entries.")
			else
				terminfo.term = "-"
			end
		end
		
		terminfo.lang = parent
	end

	local text = ""
	local categories = {}

	if lang:getCode() == terminfo.lang:getCode() then
		table.insert(categories, lang:getCanonicalName() .. " twice-borrowed terms")
	elseif source:getType() == "family" then
		table.insert(categories, lang:getCanonicalName() .. " terms derived from " .. source:getCategoryName())
		table.insert(categories, lang:getCanonicalName() .. " terms borrowed from " .. source:getCategoryName())
	else
		table.insert(categories, lang:getCanonicalName() .. " terms derived from " .. source:getCanonicalName())
		table.insert(categories, lang:getCanonicalName() .. " terms borrowed from " .. source:getCanonicalName())
	end
	
	if learned then
		text = "] from "
		table.insert(categories, lang:getCanonicalName() .. " learnedly borrowed terms")
	else
		text = "] from "
	end
	
	local link = ""
	
	if terminfo.term ~= "-" then
		link = " " .. require("Module:User:Isomorphyc/links-draft").full_link(terminfo, "term", true)
	end
	
	categories = require("Module:utilities").format_categories(categories, lang, sort_key)
	
	return (notext and "" or text) .. export.format_etyl(nil, source, sort_key) .. link .. categories
end

-- Internal implementation of {{calque|...}} template
function export.calque(lang, terminfo, parts, sort_key, nocap, notext)
	preprocess_pr(terminfo)
	local result = ""
	
	if parts and #parts ~= 0 then
		result = result .. require("Module:compound").show_compound(lang, nil, parts)
		result = result .. ", ] of"
		result = result .. "] "
	elseif not notext then
		result = result .. "] of "
	end
	
	local categories = require("Module:utilities").format_categories({lang:getCanonicalName() .. " calques"}, lang, sort_key)
	
	result = result .. " " .. export.format_borrowed(lang, terminfo, sort_key, false, true, false) .. categories
	
	return result
end

return export