Module:Payis

De Vouiquipèdia, l’enciclopèdia abada.

La documentation pour ce module peut être créée à Module:Payis/doc

local Payis = { }

-- Paramètros :
--    1 : code ISO-3166 de payis ;
--    tèxto ou ben 2 : tèxto dens cél payis ;
function Payis.country( frame )
	local args = ( frame.getParent and frame:getParent().args ) or frame or { }         -- prèparacion por apèl per modèlo ou ben tot drêt.
	local code = mw.ustring.lower( mw.text.trim( args[1] or '' ) )
	local texto = args.texto or ''
	if texto == '' then
		texto = args[2] or ''
	end
	return texto
end

-- Vêre Modèlo:Endicacion de payis
-- Paramètros :
--    1 : nom de payis ;
--    2 : code ISO-3166 ;
--    tèxto : tèxto dens cél payis ;
function Payis.endicacionDePayis( frame )
	local args = ( frame.getParent and frame:getParent().args ) or frame or { }
	local nomPayis = args[1] or ''
	local code = args.payis or mw.text.trim( args[2] or '' )
	local texto = args.texto
	local wikiText = ''
	-- Câs yô que lo premiér et/ou lo second paramètro est vouedo.
	--if code .. nomPayis == '' then
	--	return texto
	--elseif nomPayis == '' then
	--	nomPayis = dataPayis[ mw.ustring.lower( code ) ]
	--	nomPayis = (nomPayis and nomPayis.nom or '???')
	--elseif code == '' then
	--	code = dataPayis[ nomPayis ]
	--	code = ( code and code.code or '' )
	--	if code == '' then
	--		return texte
	--	end
	--end
	-- Maneyance du tèxto.
	if texto and texto ~= '' then
		texto = ' ' .. Payis.country{ code, texto = texto }
	else
		texto = ''
	end
	-- Compilacion de l’endiquior de payis et du tèxto.
	wikiText = '<span class="endiquior-payis">(<abbr class="abbr" title="Payis : '
		.. nomPayis .. '">'
		.. code .. '</abbr>)</span>'
		.. texto
	return wikiText
end

return Payis