Documentation for this module may be created at Module:taxonomy/doc

local export = {}

local lang_en = require("Module:languages").getByCode("bcl")
local lang_mul = require("Module:languages").getByCode("mul")


function export.taxon(frame)
	local params = {
		[1] = {required = true, default = "{{{1}}}"},
		[2] = {required = true, default = "{{{2}}}"},
		[3] = {required = true, default = "{{{3}}}"},
		[4] = {},
		
		["i"] = {type = "boolean"},
		["nodot"] = {type = "boolean"},
	}
	
	local args = require("Module:parameters").process(frame:getParent().args, params)
	
	local ret = {}
	local categories = {"mul:Taxonomic names (" .. args[1] .. ")"}
	
	table.insert(ret, "Sarong taksomiko ")
	table.insert(ret, require("Module:links").language_link{lang = lang_en, term = args[1]})
	table.insert(ret, " na nasa ")
	table.insert(ret, require("Module:links").language_link{lang = lang_en, term = args[2]})
	table.insert(ret, " ")
	
	local parent = require("Module:links").language_link{lang = lang_mul, term = args[3]}
	
	if args[2] == "heno" or args[2] == "espesye" or args["i"] then
		parent = "''" .. parent .. "''"
	end
	
	table.insert(ret, parent)
	
	-- Track missing taxonomic name
	parent = mw.title.new(args[3])
	
	if not (parent and parent.exists) then
		table.insert(categories, "Entries using missing taxonomic name (" .. args[2] .. ")")
	end
	
	-- Vernacular name
	if args[4] then
		table.insert(ret, " – ")
	    table.insert(ret, args[4])
	else
		table.insert(categories, "Taxonomic names needing vernacular names")
	end
	
	if not args["nodot"] then
		table.insert(ret, ".")
	end
	
	return table.concat(ret) .. require("Module:utilities").format_categories(categories, lang_mul)
end


return export