Module:etymology languages/templates
Appearance
- De neikommende dokumintaasje stiet op Module:etymology languages/templates/dokumintaasje. [bewurkje]
Oernommen fan en:Module:etymology languages/templates.
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("Module:etymology languages").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("Module:etymology languages").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.getByCanonicalName(frame)
local args = frame.args
local etymlang = args[1] or error("Etymology language name (parameter 1) has not been specified.")
etymlang = require("Module:etymology languages").getByCanonicalName(etymlang)
if etymlang then
return etymlang:getCode()
else
return ""
end
end
return export