Module:Pays

Une page de Wikipédia, l'encyclopédie libre.

 Documentation[créer] [purger]
local Pays = { }

-- Paramètres :
--    1 : code ISO-3166 de pays ;
--    texte ou 2 : texte dans ce pays ;
function Pays.country( frame )
	local args = ( frame.getParent and frame:getParent().args ) or frame or { }         -- préparation pour appel par modèle ou direct.
	local code = mw.ustring.lower( mw.text.trim( args[1] or '' ) )
	local texte = args.texte or ''
	if texte == '' then
		texte = args[2] or ''
	end
	return texte
end

-- Voir Modèle:Indication de pays
-- Paramètres :
--    1 : nom de pays ;
--    2 : code ISO-3166 ;
--    texte : texte dans ce pays ;
function Pays.indicationDePays( frame )
	local args = ( frame.getParent and frame:getParent().args ) or frame or { }
	local nomPays = args[1] or ''
	local code = args.pays or mw.text.trim( args[2] or '' )
	local texte = args.texte
	local wikiText = ''
	-- Cas où le premier et/ou le deuxième paramètre est vide.
	--if code .. nomPays == '' then
	--	return texte
	--elseif nomPays == '' then
	--	nomPays = dataPays[ mw.ustring.lower( code ) ]
	--	nomPays = (nomPays and nomPays.nom or '???')
	--elseif code == '' then
	--	code = dataPays[ nomPays ]
	--	code = ( code and code.code or '' )
	--	if code == '' then
	--		return texte
	--	end
	--end
	-- Gestion du texte.
	if texte and texte ~= '' then
		texte = ' ' .. Pays.country{ code, texte = texte }
	else
		texte = ''
	end
	-- Compilation de l'indicateur de pays et du texte.
	wikiText = '<span class="indicateur-pays">(<abbr class="abbr" title="Pays : '
		.. nomPays .. '">'
		.. code .. '</abbr>)</span>'
		.. texte
	return wikiText
end

return Pays