Modul:härledning

Definition från Wiktionary, den fria ordlistan.
Hoppa till navigering Hoppa till sök

Dokumentationen för denna modul kan skapas på Modul:härledning/dok /test


Modul:härledning/dok

local export = {}
local lang = require("Modul:lang")

function export.getWikitext(frame)
	local args                  = frame:getParent().args
	local prefixed_templatename = frame:getParent():getTitle()
	local templatename          = mw.ustring.gsub(prefixed_templatename, "^[^:]+:", "")
	local is_min_template       = mw.ustring.sub(templatename, -1, -1) == "-"
	local using_old_template    = not (lang.hasLanguage(args[1] or "b") and lang.hasLanguage(args[2] or "b"))

	if (using_old_template and not args[2]) or (not using_old_template and not args[3]) then
		return "[[Kategori:Wiktionary:härledning/Saknar parametrar]]"
	end

	local opening = is_min_template and "" or (args["genitivform"] and "Från " or "Av ")
	
	if args["inled"] then
		if args["inled"] == "-" then
			opening = ""
		elseif args["inled"] == "" then
			opening = args["genitivform"] and "Från " or "Av "
		else 
			opening = args["inled"] .. " "
		end
	end

	local period = is_min_template and "" or "."

	if args["punkt"] then
		if args["punkt"] == "-" then
			period = ""
		elseif args["punkt"] == "" then
			period = "."
		end
	end

	local ucfirst_entry_language = using_old_template and lang.getLanguageUCFirst(args["språk"] or "sv") or lang.getLanguageUCFirst(args[1])
	local lc_language            = using_old_template and lang.getLanguage(args[1]) or lang.getLanguage(args[2])
	local lang_word              = args["genitivform"] or lc_language
	
	if using_old_template and args[1] == "grc" or not using_old_template and args[2] == "grc" then
		lang_word = "grekiska"
	elseif using_old_template and args[1] == "gd" or not using_old_template and args[2] == "grc" then
		lang_word = "gäliska"
	elseif using_old_template and args[1] == "el" or not using_old_template and args[2] == "grc" then
		lang_word = "nygrekiska"
	elseif using_old_template and args[1] == "la" or not using_old_template and args[2] == "grc" then
		lang_word = "latinska"
	end
	
	local ucfirst_language       = lang.getLanguageUCFirst(using_old_template and args[1] or args[2])
	local derivative             = using_old_template and args[2] or args[3] or ""
	local literal_meaning        = using_old_template and args[3] or args[4]
	local translitteration       = args["tr"] 
	local tr_and_lit_text        = ""
	if literal_meaning and translitteration then
		tr_and_lit_text = " ''(" .. translitteration .. ", ''”" .. literal_meaning .. "”)"
	elseif literal_meaning then
		tr_and_lit_text = " (”" .. literal_meaning .. "”)"
	elseif translitteration then
		tr_and_lit_text = " ''(" .. translitteration .. ")''"
	end
		
	local italics                = args["kursiv"] == "-" and "" or "''"
	local derivative_text        = italics .. "[[" .. derivative .. "#" .. ucfirst_language .. "|" .. derivative .. "]]" .. italics --use link instead
	
	local str                    = ""

	str = str .. opening .. lang_word .. " " .. derivative_text .. tr_and_lit_text .. period
	
	if args["kat"] ~= "-" then
		str = str .. "[[Kategori:" .. ucfirst_entry_language .. "/Härledningar från ".. lc_language .."]]"
	end
	
	if using_old_template then
		str = str .. "[[Kategori:Wiktionary:härledning/Använder gammal mall]]"
	end

	if args["språk"] then
		str = str .. "[[Kategori:Wiktionary:härledning/Använder ogiltiga parametrar]]"	
	end
	
	return str
end

return export