Modul:etymology

Üdvözlöm, Ön a Modul:etymology szó jelentését keresi. A DICTIOUS-ban nem csak a Modul:etymology szó összes szótári jelentését megtalálod, hanem megismerheted az etimológiáját, a jellemzőit és azt is, hogyan kell a Modul:etymology szót egyes és többes számban mondani. Minden, amit a Modul:etymology szóról tudni kell, itt található. A Modul:etymology szó meghatározása segít abban, hogy pontosabban és helyesebben fogalmazz, amikor beszélsz vagy írsz. AModul:etymology és más szavak definíciójának ismerete gazdagítja a szókincsedet, és több és jobb nyelvi forráshoz juttat.

If in templates, invoke Module:etymology/templates instead.


local export = {}


local function ucfirst(str)
	return mw.getContentLanguage():ucfirst(str)
end


--[[	If language is an etymology language, iterates through parent languages
		until it finds a non-etymology language. ]]
function export.getNonEtymological(lang)
	while lang:getType() == "etymology language" do
		local parentCode = lang:getParentCode()
		local parent = require("Module:languages").getByCode(parentCode)
			or require("Module:etymology languages").getByCode(parentCode)
			or require("Module:families").getByCode(parentCode)
		
		lang = parent
--		mw.log(terminfo.lang:getCode() .. " " .. terminfo.lang:getType())
	end
	
	return lang
end


local function termError(terminfo)
	if terminfo.lang:getType() == "family" then
		if terminfo.term and terminfo.term ~= "-" then
			require("Module:debug").track("etymology/family/has-term")
		end
		
		terminfo.term = "-"
	end
	return terminfo
end


local function createLink(terminfo, templateName)
	local link = ""
	
	if terminfo.term == "-" then
		--[=[
		]
		]
		]
		]
		]=]
		require("Module:debug").track(templateName .. "/no-term")
	else
--		mw.log(terminfo.term)
		link = " " .. require("Module:links").full_link(terminfo, "term", true)
	end
	
	return link
end


function export.format_etyl(lang, source, sort_key, categories)
	local info = {}
	
	
	-- ]
	if sort_key then
		require("Module:debug").track("etymology/sortkey")
	end
	
	if not categories then
		categories = {}
	end
	
	if source:getCode() == "und" then
		info = {
			display = "undetermined",
			cat_name = "Más nyelvekből származó",
		}
	elseif source:getCode() == "mul-tax" then
		info = {
			display = "]",
			cat_name = "Tudományos nevekből származó",
		}
	else
		info.display = "]"
		
		if source:getType() == "family" then
			info.cat_name = source:getCategoryName()
		else
			info.cat_name = source:getCanonicalName()
		end
		info.cat_name = ucfirst(info.cat_name) .. " eredetű"
	end
	
	-- Add the categories, but only if there is a current language
	
	if lang then
		local m_utilities = require("Module:utilities")
		
		if lang:getCode() == source:getCode() then
			table.insert(categories, lang:getCanonicalName() .. " twice-borrowed terms")
		else
			table.insert(categories, info.cat_name .. " szavak")
		end
		
		categories = m_utilities.format_categories(categories, lang, sort_key)
	else
		categories = ""
	end
	
	return "<span class=\"etyl\">" .. info.display .. categories .. "</span>"
end


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


-- Internal implementation of {{derived|...}} template
function export.format_derived(lang, terminfo, sort_key, templateName)
	local source = terminfo.lang
	
	terminfo.lang = export.getNonEtymological(terminfo.lang)

	terminfo = termError(terminfo)
	
	local link = createLink(terminfo, templateName or "derived")
	
	return export.format_etyl(lang, source, sort_key) .. link
end


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

	terminfo = termError(terminfo)
	
	terminfo.lang = export.getNonEtymological(terminfo.lang)

	if not lang:hasAncestor(terminfo.lang) and mw.title.getCurrentTitle().nsText ~= "Sablon" then
		local function showLanguage(lang)
			return ("] (%s)")
				:format(lang:getCategoryName(), lang:getCanonicalName(), lang:getCode())
		end
		local postscript
		local ancestors = lang:getAncestors()
		local moduleLink = "[[Module:"
			.. require("Module:languages").getDataModuleName(lang:getCode())
			.. "]]"
		if not ancestors then
			postscript = showLanguage(lang) .. " has no ancestors."
		else
			local ancestorList = table.concat(
				require("Module:fun").map(
					showLanguage,
					ancestors),
				" and ")
			postscript = ("The ancestor%s of %s %s %s."):format(
				ancestors and "s" or "", lang:getCanonicalName(),
				ancestors and "are" or "is", ancestorList)
		end
		error(("%s is not set as an ancestor of %s in %s. %s")
			:format(showLanguage(terminfo.lang), showLanguage(lang), moduleLink, postscript))
	end
	
	local categories = {}
	
	local link = createLink(terminfo, "inherited")
	
	table.insert(categories, lang:getCode() .. ":" .. ucfirst(source:getCanonicalName()) .. " eredetű szavak")
	
	return export.format_etyl(lang, source, sort_key, categories) .. link
end


-- Internal implementation of {{borrowed|...}} template
function export.format_borrowed(lang, terminfo, sort_key, nocap, notext, borrowing_type)
	local source = terminfo.lang
	
	terminfo.lang = export.getNonEtymological(terminfo.lang)
	
	terminfo = termError(terminfo)
	
	local text = ""
	local categories = {}

	if lang:getCode() == source:getCode() then
		table.insert(categories, lang:getCanonicalName() .. " twice-borrowed terms")
	elseif source:getType() == "family" then
		table.insert(categories, lang:getCode() .. ":" .. ucfirst(source:getCategoryName()) .. " eredetű szavak")
	else
		table.insert(categories, lang:getCode() .. ":" .. ucfirst(source:getCanonicalName()) .. " eredetű szavak")
	end

	if not notext then
		if borrowing_type == "learned" then
			text = "] from "
		elseif borrowing_type == "semi-learned" then
			text = "] from "
		elseif borrowing_type == "orthographic" then
			text = "] ] from "
		elseif borrowing_type == "unadapted" then
			text = "] from "
		else
			text = "] from "
		end
	end

	if borrowing_type == "learned" then
		table.insert(categories, lang:getCanonicalName() .. " learned borrowings")
	elseif borrowing_type == "semi-learned" then
		table.insert(categories, lang:getCanonicalName() .. " semi-learned borrowings")
	elseif borrowing_type == "orthographic" then
		table.insert(categories, lang:getCanonicalName() .. " orthographic borrowings")
	elseif borrowing_type == "unadapted" then
		if source:getType() == "family" then
			table.insert(categories, lang:getCanonicalName() .. " unadapted borrowings from " .. source:getCategoryName())
		else
			table.insert(categories, lang:getCanonicalName() .. " unadapted borrowings from " .. source:getCanonicalName())
		end
	end
	
	local link = createLink(terminfo, "borrowed")
	
	return text .. export.format_etyl(lang, source, sort_key, categories) .. link
end


-- Internal implementation of {{calque|...}} template
function export.calque(lang, terminfo, sort_key, nocap, notext)
	local result = ""
	
	if not notext then
		result = result .. "] of "
	end
	
	local source = terminfo.lang
	
	terminfo.lang = export.getNonEtymological(terminfo.lang)

	terminfo = termError(terminfo)

	local categories = {}

	if source:getType() == "family" then
		table.insert(categories, lang:getCanonicalName() .. " terms calqued from " .. source:getCategoryName())
	else
		table.insert(categories, lang:getCanonicalName() .. " terms calqued from " .. source:getCanonicalName())
	end
	
	local link = createLink(terminfo, "calque")
	
	result = result .. " " ..  export.format_etyl(lang, source, sort_key, categories) .. link
	
	return result
end


-- Internal implementation of {{partial calque|...}} template
function export.partial_calque(lang, terminfo, sort_key, nocap, notext)
	local result = ""
	
	if not notext then
		result = result .. "] of "
	end
	
	local source = terminfo.lang
	
	terminfo.lang = export.getNonEtymological(terminfo.lang)

	terminfo = termError(terminfo)

	local categories = {}

	if source:getType() == "family" then
		table.insert(categories, lang:getCanonicalName() .. " terms partially calqued from " .. source:getCategoryName())
	else
		table.insert(categories, lang:getCanonicalName() .. " terms partially calqued from " .. source:getCanonicalName())
	end
	
	local link = createLink(terminfo, "partial_calque")
	
	result = result .. " " ..  export.format_etyl(lang, source, sort_key, categories) .. link
	
	return result
end


-- Internal implementation of {{semantic loan|...}} template
function export.format_semantic_loan(lang, terminfo, sort_key, nocap, notext)
	if nocap then
		require("Module:debug").track("semantic_loan/nocap")
	end
	
	local source = terminfo.lang
	
	terminfo.lang = export.getNonEtymological(terminfo.lang)

	terminfo = termError(terminfo)

	local text = ""
	local categories = {}

	if source:getType() == "family" then
		table.insert(categories, lang:getCanonicalName() .. " semantic loans from " .. source:getCategoryName())
	else
		table.insert(categories, lang:getCanonicalName() .. " semantic loans from " .. source:getCanonicalName())
	end
	
	if not notext then
		text = "] from "
	end
	
	local link = createLink(terminfo, "semantic_loan")
	
	return text .. export.format_etyl(lang, source, sort_key, categories) .. link
end

-- Internal implementation of {{phono-semantic matching|...}} template
function export.psm(lang, terminfo, sort_key, nocap, notext)
	if nocap then
		require("Module:debug").track("psm/nocap")
	end
	
	local source = terminfo.lang
	
	terminfo.lang = export.getNonEtymological(terminfo.lang)

	terminfo = termError(terminfo)

	local text = ""
	local categories = {}

	if source:getType() == "family" then
		table.insert(categories, lang:getCanonicalName() .. " phono-semantic matchings ")
	else
		table.insert(categories, lang:getCanonicalName() .. " phono-semantic matchings ")
	end
	
	if not notext then
		text = "] of "
	end
	
	local link = createLink(terminfo, "psm")
	
	return text .. export.format_etyl(lang, source, sort_key, categories) .. link
end

return export