Zum Inhalt springen

Modul:etymology language/templates

Vun Wiktionary
Dissen Vörlaag hef dokumentatsie neudig.
Maak de dokumentatsie veur dissen modul ovver t doel en gebroek op de dokumentatsieziede.

local export = {}

function export.exists(frame)
	local args = frame.args
	local etymlang = args[1] or error("Etymology language code has not been specified. Please pass parameter 1 to the module invocation.")
	
	etymlang = require("Modul:etymology language").getByCode(etymlang)
	
	if etymlang then
		return "1"
	else
		return ""
	end
end

function export.getByCode(frame)
	local args = frame.args
	local etymlang = args[1] or error("Etymology language code (parameter 1) has not been specified.")
	local itemname = args[2] or error("Function to call (parameter 2) has not been specified.")
	
	etymlang = require("Modul:etymology language").getByCode(etymlang) or error("The etymology language code '" .. etymlang .. "' is not valid.")
	
	-- The item that the caller wanted to look up
	if itemname == "getCanonicalName" then
		return etymlang:getCanonicalName()
	elseif itemname == "getAllNames" then
		local index = args[3]; if index == "" then index = nil end
		index = tonumber(index or error("Numeric index of the desired item in the list (parameter 3) has not been specified."))
		return etymlang:getAllNames()[index] or ""
	elseif itemname == "getParentCode" then
		return etymlang:getParentCode()
	elseif itemname == "getWikipediaArticle" then
		return etymlang:getWikipediaArticle()
	else
		error("Requested invalid item name \"" .. itemname .. "\".")
	end
end

function export.etyl(frame)
	local args = frame:getParent().args
	
	local source = args[1] or (mw.title.getCurrentTitle().nsText == "Template" and "und") or error("Parameter 1 (source language/family code) has not been specified.")
	local lang = args[2]; if lang == "" then lang = nil end
	local sort_key = args["sort"]; if sort_key == "" then sort_key = nil end
	
	-- "-" means no language. 
        if lang then
	    if lang == "-" then
		lang = nil
	   end
        else 
             error("De lang-parameter is neet op-egovven (parameter 2)")
	end

	if lang then
		lang = require("Modul:languages").getByCode(lang) or error("The language code \"" .. lang .. "\" is not valid.")
	end
	
	-- zugefügt und geändert, damit 30 Tochtersprachen kategoriesiert werden können
	
	local Ausgabe =""
	i = 2
	while i  <= 30 do
		local lang = args[i]; 

                if lang == "" then lang = nil end

	        if lang == "-" then
		     lang = nil
	        end

	 	if lang then
	 		lang = require("Modul:languages").getByCode(lang) or error("De spraokkode \"" .. lang .. "\" is neet geldig.")
	 		Ausgabe = Ausgabe .. require("Modul:etymology language").format(source, lang, sort_key, i)
	 	else
	 		break
	 	end
	 i = i + 1
	end
	return Ausgabe
end

return export