local getArgs = require('Module:Arguments').getArgs
local p= {}

local function dump(t, ...)	-- funzione di base per inserire più elementi in una tabella
	local args = {...}
	for _, s in ipairs(args) do
		table.insert(t, s)
		end
	end

local nazioni= {
	["FRA"]= {
		"Flag of France.svg",
		"della ",
		"Francia"}}

local alias= {
	["Francia"]= "FRA"}

local sport= {
	["CA"]= "calcio"}

function p.visualizza ()	-- da completare
	local out= {"{| class=\"wikitable\" \n!codice !!bandiera !!genitivo\n"}
	for codice, i in pairs(nazioni) do
		-- codice è il codice di ciascuna nazione; i è la tabella di stringhe corrrispondenti alla nazione
		dump(out, "|-\n|", codice, "||[[file:", i[1], "|20px]] ", i[1], "||", i[2], i[3], "\n") end
	table.insert(out, "|}")
	return table.concat(out)
	end

function p.nazNB (frame)	-- completo, da aggiungere gestione errori
	local args= getArgs(frame)
	local nats= nazioni[args[2]] or nazioni[alias[args[2]]]
	local out= "[[nazionale"					-- si definisce la destinazione del link
	if nats["tipo"] then
		out= "[[selezione" end
	if args[4] then
		out= out.." "..args[4] end
	out= out.." di "..sport[args[1]]
	if args[3] == "M" then
		out= out.." maschile"
	elseif args[3] == "F" then
		out= out.." femminile" end
	if nats[4] then
		out= out.." "..nats[4]
	else
		out= out.." "..nats[2]..nats[3] end
	out= out.."|"..nats[3]						-- si definisce il testo del link
	if args[4] and not args[5] then
		out= out.." "..args[4] end
	out= out.."]]"
	return out
	end

--function p.bandiera (frame)
	
--function p.naz (frame)
	
return p