Módulo:Ficha de selecciones deportivas

Este módulo no tiene página de documentación[crear]
local p = {}
local ModuloFicha    = require('Módulo:Ficha')
local ModuloWikidata = require('Módulo:Wikidata')
local ModuloFormato  = require('Módulo:Formato texto')
local ModuloPaginas  = require('Módulo:Páginas')
local ModuloArgs     = require('Módulo:Argumentos')
local argumento      = ModuloArgs.obtenerValorDeArgumentos
local estilotit = 'background-color:#DCDCDC'
local estilosec = 'background-color:#DCDCDC; width: 315px'

local function safeText(text)
	return text or ''
end

local function helperEnlace(frame, pais, fem, categoria)
	local enlace = nil
	local plantilla = frame:getParent():getTitle()
	if plantilla:find('femenino') then
			fem = 'sí'
	end
	if safeText( pais ) == '' then
		return ''
	elseif plantilla:find('de fútbol') then
		enlace = 'Selección de fútbol de ' .. pais
		if fem == 'sí' or fem == 'si' or fem == 'fem' then
			enlace = enlace:gsub('Selección', 'Selección femenina')
		end
		if categoria ~= nil and categoria:find('sub') then
			enlace = enlace:gsub('fútbol', 'fútbol '.. categoria)
		end
	elseif plantilla:find('de baloncesto') then
		enlace = 'Selección de baloncesto de ' .. pais
		if fem == 'sí' or fem == 'si' or fem == 'fem' then
			enlace = enlace:gsub('Selección', 'Selección femenina')
		end
		if categoria ~= nil and categoria:find('sub') then
			enlace = enlace:gsub('baloncesto', 'baloncesto '.. categoria)
		end
	elseif plantilla:find('de rugby') then
		enlace = 'Selección de rugby de ' .. pais
		if fem == 'sí' or fem == 'si' or fem == 'fem' then
			enlace = enlace:gsub('Selección', 'Selección femenina')
		end
		if categoria ~= nil and categoria == '7'  then
			enlace = enlace:gsub('rugby', 'rugby 7')
		end
	elseif plantilla:find('de béisbol') then
		enlace = 'Selección de béisbol de ' .. pais
		if fem == 'sí' or fem == 'si' or fem == 'fem' then
			enlace = enlace:gsub('Selección', 'Selección femenina')
		end
	end
	if enlace then
		return '[[' .. enlace .. '|' .. pais .. ']]'
	else
		return '[[' .. pais .. ']]'
	end
end

local function helperBandera(frame, pais, param, fem, categoria, lado)
	if (pais == nil or pais == '') then
		pais = argumento{'país','Nombre'} or ''
	end
	if (pais ~= nil) and (pais ~= '') then
		local cadena = ''
		local bandera = ''
		bandera = bandera .. '{{Bandera|' .. pais
		if (param ~= nil) and (param ~= '') then
			bandera = bandera .. '|'..param
		end
		bandera = bandera .. '}} '
		if lado == 2 then
			cadena = cadena .. '{{Linkless exists|Plantilla:Geodatos ' .. pais ..'|' .. bandera .. '}}' .. ' '
		end
		local enlace = helperEnlace(frame, pais, fem, categoria)
		if enlace then
			cadena = cadena .. enlace
		end
		if lado == 1 then
			cadena = cadena .. ' ' .. '{{Linkless exists|Plantilla:Geodatos ' .. pais ..'|' .. bandera .. '}}'
		end
		return frame:preprocess(cadena)
	else
		return ''
	end
end

function obtenerXRI(frame, XRI)
	local plantilla = frame:getParent():getTitle()
	if	plantilla:find('de polo') or 
		plantilla:find('de voleibol') or
		plantilla:find('de tenis') then
		return nil
	end
	if (XRI == 'PRI' and argumento{'Peor resultado'} ~= nil) then
		return argumento{'Peor resultado'}
	elseif (XRI == 'MRI' and argumento{'Mejor resultado'} ~= nil) then
		return argumento{'Mejor resultado'}
	end
	local cuenta = 1
	local cadena = ''
	if	argumento{XRI} == nil and
		(	argumento{XRI..' país1'} == nil or
			argumento{XRI..' país1'} == ''	) and
		(	argumento{XRI..' país2'} == nil or
			argumento{XRI..' país2'} == ''	) then
		return 'Sin datos'
	end
	local seguir = true
	local evento = ''
	while (seguir == true) do
		i = cuenta
		if i == 1 then
			i = ''
		end
		if	(argumento{XRI..(cuenta + 1)} == nil) and
			(argumento{XRI..(cuenta + 1).. ' país1'} == nil) and
			(argumento{XRI..(cuenta + 1).. ' país2'} == nil) then
			seguir = false
		end
		if argumento{XRI..i} ~= nil then
			seguir = false
			return '[[' .. safeText(argumento{'país','Nombre'}) .. ']]' ..
				' ' .. safeText(argumento{XRI..i..' Marcador'}) ..
				' ' .. safeText(argumento{XRI..i}) ..
				'<br>' .. safeText(argumento{XRI..i..' Lugar'}) ..
				' — ' .. safeText(argumento{XRI..i..' Fecha'})
		end
		cadena = cadena ..
			( cadena == '' and '' or '<br>' ) ..
			helperBandera( frame, argumento{XRI..i..' país1'}, argumento{XRI..i..' bandera1'}, argumento{XRI..i..' fem1'}, argumento{XRI..i..' categoria1'}, 1 ) .. ' ' ..
			' '.. safeText( argumento{XRI..i..' marcador'} ) .. ' ' ..
			' ' .. helperBandera( frame, argumento{XRI..i..' país2'}, argumento{XRI..i..' bandera2'}, argumento{XRI..i..' fem2'}, argumento{XRI..i..' categoria2'}, 2 ) .. ' ' ..
			'<br><small>' .. safeText( argumento{XRI..i..' lugar'} ) ..
			' — ' .. safeText( argumento{XRI..i..' fecha'} ) .. '</small>' ..
			'<br><small>' .. safeText(argumento{XRI..i..' evento'}) .. '</small>'
		cuenta = cuenta + 1
	end
	return cadena
end
function obtenerMRI(frame)
	return obtenerXRI(frame, 'MRI')
end
function obtenerPRI(frame)
	return obtenerXRI(frame, 'PRI')
end

function obtenerXP(frame, MVPD)
	if argumento{MVPD} == nil or argumento{MVPD} == '' then
		return nil
	end
	return helperBandera( frame, argumento{'Nombre'}, nil, 1 ) ..
		" '''" .. safeText(argumento{MVPD..' Marcador'}) .. "''' " ..
		helperBandera( frame, argumento{MVPD}, nil, 2 ) ..
		'<br>' .. argumento{MVPD..' Lugar'} ..
		'<br>' .. argumento{MVPD..' Fecha'}
end
function obtenerMV(frame)
	return obtenerXP(frame, 'MV')
end
function obtenerPD(frame)
	return obtenerXP(frame, 'PD')
end

function obtenerXPI(frame, XPI)
	local cadena = nil
	local plantilla = frame:getParent():getTitle()
	if argumento{XPI} == nil and
	(	argumento{XPI..' país1'} == nil or
		argumento{XPI..' país1'} == ''	) and
	(	argumento{XPI..' país2'} == nil or
		argumento{XPI..' país2'} == ''	) then
		if	plantilla:find('de polo') or 
			plantilla:find('de tenis') then
			return nil
		else
			cadena = 'Sin datos'
		end
	else
		if argumento{XPI} ~= nil then
			return helperEnlace( frame, argumento{'país', 'Nombre'} ) .. 
				' ' .. safeText( argumento{XPI..' Marcador'} ) ..
				' ' .. helperEnlace( frame, argumento{XPI} ) ..
				'<br>' .. safeText( argumento{XPI..' Lugar'} ) ..
				' — ' .. safeText( argumento{XPI..' Fecha'} )
		end
		return helperBandera( frame, argumento{XPI..' país1'}, argumento{XPI..' bandera1'}, argumento{XPI..' fem1'}, argumento{XPI..' categoria1'}, 1 ) ..
			' ' .. safeText( argumento{XPI..' marcador'} ) ..
			' ' .. helperBandera( frame, argumento{XPI..' país2'}, argumento{XPI..' bandera2'}, argumento{XPI..' fem2'}, argumento{XPI..' categoria2'}, 2 ) ..
			'<br><small>' .. safeText( argumento{XPI..' lugar'} ) ..
			' — ' .. safeText( argumento{XPI..' fecha'} ) .. '</small>' ..
			'<br><small>' .. safeText( argumento{XPI..' evento'} ) .. '</small>'
	end
end
function obtenerPPI(frame)
	return obtenerXPI(frame, 'PPI')
end
function obtenerUPI(frame)
	return obtenerXPI(frame, 'UPI')
end

local function helperParticipaciones(first, second)
	if first == nil or first == '' then
		return nil
	else
		if second and second ~= '' then
			return safeText(first) ..
				'<small> (primera vez en ' .. safeText(second) .. ')</small>'
		else
			return safeText(first)
		end
	end
end

function obtenerparticipaciones(arg, frame)
	if arg == 'participación mundial' then
		return helperParticipaciones( argumento{'participación mundial','Participaciones','Participaciones Copa Mundial','Participación Campeonato Mundial'}, argumento{'primer mundial','Primer Mundial'} )
	elseif arg == 'liga mundial' then
		return helperParticipaciones( argumento{'Participación Liga Mundial'}, argumento{'Primera liga'} )
	elseif arg == 'Liga de Naciones' then
		return helperParticipaciones( argumento{'Participación Liga de Naciones'}, argumento{'Primera Liga de Naciones'} )
	elseif arg == 'participación regional' then
		return helperParticipaciones( argumento{'participación regional','Participaciones regional'}, argumento{'primer regional','Primer regional'} )
	elseif arg == 'participación regional2' then
		return helperParticipaciones( argumento{'participación regional2'}, argumento{'primer regional2'} )
	elseif arg == 'participación regional3' then
		return helperParticipaciones( argumento{'participación regional3'}, argumento{'primer regional3'} )
	elseif arg == 'participación regional4' then
		return helperParticipaciones( argumento{'participación regional4'}, argumento{'primer regional4'} )
	elseif arg == 'participación confederaciones' then
		return helperParticipaciones( argumento{'participación confederaciones'}, argumento{'primer confederaciones'} )
	elseif arg == 'participación olímpico' or arg == 'torneo olímpico' then
		return helperParticipaciones( argumento{'participación olímpico','Participación olímpica','participación olímpica'}, argumento{'primer olímpico','Primer Olímpico'} )
	end
end

function obtenercamisetafutbol(frame)
	local color_cuerpo1 = argumento{'color_cuerpo1'} or 'FFFFFF'
	local color_izq1 = argumento{'color_izq1','izquierdo1'} or 'FFFFFF'
	local color_der1 = argumento{'color_der1','derecho1'} or ''
	local color_pantalon1 = argumento{'color_pantalón1','shorts1'} or 'FFFFFF'
	local color_medias1 = argumento{'color_medias1','medias1'} or 'FFFFFF'
	local trama_izq1 = argumento{'trama_izq1','patrón_izq1'} or ''
	local trama_cuerpo1 = argumento{'trama_cuerpo1','patrón_cuerpo1'} or ''
	local trama_der1 = argumento{'trama_der1','patrón_der1'} or ''
	local trama_pantalon1 = argumento{'trama_pantalón1','patrón_pant1'} or ''
	local trama_medias1 = argumento{'trama_medias1','patrón_med1'} or ''
	local tipo_izq1 = argumento{'tipo_izq1'} or 'png' 
	local tipo_der1 = argumento{'tipo_der1'} or 'png'
	local tipo_pantalon1 = argumento{'tipo_pantalón1'} or 'png'
	local tipo_cuerpo1 = argumento{'tipo_cuerpo1'} or 'png'
	local tipo_medias1 = argumento{'tipo_medias1'} or 'png'
	local cadenaaux = '{{Uniforme' ..
		'|color brazo izquierdo = ' .. color_izq1 ..
		'|color cuerpo          = ' .. color_cuerpo1 ..
		'|color brazo derecho   = ' .. color_der1 ..
		'|color pantalón        = ' .. color_pantalon1 ..
		'|color medias          = ' .. color_medias1 ..
		'|trama brazo izquierdo = ' .. trama_izq1 ..
		'|trama cuerpo          = ' .. trama_cuerpo1 ..
		'|trama brazo derecho   = ' .. trama_der1 ..
		'|trama pantalón        = ' .. trama_pantalon1 ..
		'|trama medias          = ' .. trama_medias1 ..
		'|tipo_izq              = ' .. tipo_izq1 ..
		'|tipo_cuerpo           = ' .. tipo_cuerpo1 ..
		'|tipo_der              = ' .. tipo_der1 ..
		'|tipo_pan              = ' .. tipo_pantalon1 ..
		'|tipo_med              = ' .. tipo_medias1 ..
		'|título                = Primera' ..
		'}}'
	local color_cuerpo2 = argumento{'color_cuerpo2'} or 'FFFFFF'
	local color_izq2 = argumento{'color_izq2','izquierdo2'} or 'FFFFFF'
	local color_der2 = argumento{'color_der2','derecho2'} or 'FFFFFF'
	local color_pantalon2 = argumento{'color_pantalón2','shorts2'} or 'FFFFFF'
	local color_medias2 = argumento{'color_medias2','medias2'} or 'FFFFFF'
	local trama_izq2 = argumento{'trama_izq2','patrón_izq2'} or ''
	local trama_cuerpo2 = argumento{'trama_cuerpo2','patrón_cuerpo2'} or ''
	local trama_der2 = argumento{'trama_der2','patrón_der2'} or ''
	local trama_pantalon2 = argumento{'trama_pantalón2','patrón_pant2'} or ''
	local trama_medias2 = argumento{'trama_medias2','patrón_med2'} or ''
	local tipo_izq2 = argumento{'tipo_izq2'} or 'png'
	local tipo_der2 = argumento{'tipo_der2'} or 'png'
	local tipo_pantalon2 = argumento{'tipo_pantalón2'} or 'png'
	local tipo_medias2 = argumento{'tipo_medias2'} or 'png'
	local tipo_cuerpo2 = argumento{'tipo_cuerpo2'} or 'png'
	local cadenaaux1 = '{{Uniforme' ..
		'|color brazo izquierdo = ' .. color_izq2 ..
		'|color cuerpo          = ' .. color_cuerpo2 ..
		'|color brazo derecho   = ' .. color_der2 ..
		'|color pantalón        = ' .. color_pantalon2 ..
		'|color medias          = ' .. color_medias2 ..
		'|trama brazo izquierdo = ' .. trama_izq2 ..
		'|trama cuerpo          = ' .. trama_cuerpo2 ..
		'|trama brazo derecho   = ' .. trama_der2 ..
		'|trama pantalón        = ' .. trama_pantalon2 ..
		'|trama medias          = ' .. trama_medias2 ..
		'|tipo_izq              = ' .. tipo_izq2 ..
		'|tipo_cuerpo           = ' .. tipo_cuerpo2 ..
		'|tipo_der              = ' .. tipo_der2 ..
		'|tipo_pan              = ' .. tipo_pantalon2 ..
		'|tipo_med              = ' .. tipo_medias2 ..
		'|título                = Segunda' ..
		'}}'
	local color_cuerpo3 = argumento{'color_cuerpo3'} or 'FFFFFF'
	local color_izq3 = argumento{'color_izq3'}
	local color_der3 = argumento{'color_der3'}
	local color_pantalon3 = argumento{'color_pantalón3'} or 'FFFFFF'
	local color_medias3 = argumento{'color_medias3'} or ''
	local trama_izq3 = argumento{'trama_izq3'} or ''
	local trama_cuerpo3 = argumento{'trama_cuerpo3'} or ''
	local trama_der3 = argumento{'trama_der3'} or ''
	local trama_pantalon3 = argumento{'tipo_pantalón3'} or ''
	local trama_medias3 = argumento{'trama_medias3'} or ''
	local tipo_izq3 = argumento{'tipo_izq3'} or 'png'
	local tipo_der3 = argumento{'tipo_der3'} or 'png'
	local tipo_pantalon3 = argumento{'trama_pantalón3'} or ''
	local tipo_medias3 = argumento{'tipo_medias3'} or 'png'
	local tipo_cuerpo3 = argumento{'tipo_cuerpo3'} or 'png'
	local tipo_local = argumento{'tipo_local'} or 'png'
	if (color_izq3 == nil) and (color_der3 == nil) then -- No hay una tercera camiseta ..
		local cadenaret = '<table class="toccolours" style="padding:0; margin:0; background-color:#fff; width:100%; text-align:center">'..
			'<tr style="vertical-align: top;">' ..
			'<td style="width: 50%;">' ..
			frame:preprocess(cadenaaux) ..
			'</td>' ..
			'<td style="width: 50%;">' ..
			frame:preprocess(cadenaaux1) ..
			'</td>' ..
			'</tr>' ..
			'</table>'
		return cadenaret
	else
		cadenaaux2 = '{{Uniforme' ..
			'|color brazo izquierdo = ' .. safeText(color_izq3) ..
			'|color cuerpo          = ' .. color_cuerpo3 ..
			'|color brazo derecho   = ' .. safeText(color_der3) ..
			'|color pantalón        = ' .. color_pantalon3 ..
			'|color medias          = ' .. color_medias3 ..
			'|trama brazo izquierdo = ' .. trama_izq3 ..
			'|trama cuerpo          = ' .. trama_cuerpo3 ..
			'|trama brazo derecho   = ' .. trama_der3 ..
			'|trama pantalón        = ' .. trama_pantalon3 ..
			'|trama medias          = ' .. trama_medias3 ..
			'|tipo_izq              = ' .. tipo_izq3 ..
			'|tipo_cuerpo           = ' .. tipo_cuerpo3 ..
			'|tipo_der              = ' .. tipo_der3 ..
			'|tipo_pan              = ' .. tipo_pantalon3 ..
			'|tipo_med              = ' .. tipo_medias3 ..
			'|título                = Tercera' ..
			'}}'
			local cadenaret = '<table class="toccolours" style="padding:0; margin:0; background-color:#fff; width:100%; text-align:center">'..
			'<tr style="vertical-align: top;">' ..
			'<td style="width: 50%;">' ..
			frame:preprocess(cadenaaux) ..
			'</td>' ..
			'<td style="width: 50%;">' ..
			frame:preprocess(cadenaaux1) ..
			'</td>' ..
			'<td style="width: 50%;">' ..
			frame:preprocess(cadenaaux2) ..
			'</td>' ..
			'</tr>' ..
			'</table>'
		return cadenaret
	end
end

function obtenercamisetabaloncesto(frame)
	local colorcuerpo = argumento{'color_cuerpo1'} or 'ffffff'
	local colorpantalon = argumento{'color_pantalón1'} or 'ffffff'
	local tramacuerpo = argumento{'trama_cuerpo1'} or ''
	local tramapantalon = argumento{'trama_pantalón1'} or ''
	local cadenaaux = '{{Uniforme de baloncesto' ..
		'|color_cuerpo = ' .. colorcuerpo ..
		'|color_pantalón = ' .. colorpantalon ..
		'|trama_cuerpo = ' .. tramapantalon ..
		'|título = Local' ..
		'}}'
	local colorcuerpo2 = argumento{'color_cuerpo2'} or 'ffffff'
	local colorpantalon2 = argumento{'color_pantalón2'} or 'ffffff'
	local tramacuerpo2 = argumento{'trama_cuerpo2'} or ''
	local tramapantalon2 = argumento{'trama_pantalón2'} or ''
	local cadenaaux1 = '{{Uniforme de baloncesto' ..
		'|color_cuerpo = ' .. colorcuerpo2 ..
		'|color_pantalón = ' .. colorpantalon2 ..
		'|trama_cuerpo = ' .. tramapantalon2 ..
		'|título = Visitante' ..
		'}}'
	local cadenaret = '<table class="toccolours" style="padding:0; margin:0; background-color:#fff; width:100%; text-align:center">'..
		'<tr style="vertical-align: top;">' ..
		'<td style="width: 50%;">' ..
		frame:preprocess(cadenaaux) ..
		'</td>' ..
		'<td style="width: 50%;">' ..
		frame:preprocess(cadenaaux1) ..
		'</td>' ..
		'</tr>' ..
		'</table>'
	return cadenaret
end

function obtenercabecera(frame, tipo)
	local deporte = nil
	local plantilla = frame:getParent():getTitle()
	if plantilla:find('Plantilla:Ficha de selección de fútbol 2') then
		deporte = 'fútbol' -- mismo tipo que nombre
	elseif plantilla:find('Plantilla:Selección nacional de fútbol playa') then
		if tipo == 'tipo' then
			deporte = 'fútbol' -- no existe tipo 'fútbol-playa'
		else
			deporte = 'fútbol playa'
		end
	elseif plantilla:find('Plantilla:Selección nacional de fútbol sala') then
		if tipo == 'tipo' then
			deporte = 'fútbol' -- no existe tipo 'fútbol-sala'
		else
			deporte = 'fútbol sala'
		end
	elseif plantilla:find('Plantilla:Ficha de selección de baloncesto') then
		deporte = 'baloncesto' -- mismo tipo que nombre
	elseif plantilla:find('Plantilla:Ficha de selección de béisbol') then
		deporte = 'béisbol' -- mismo tipo que nombre
	elseif plantilla:find('Plantilla:Ficha de selección de balonmano') then
		deporte = 'balonmano' -- mismo tipo que nombre
	elseif plantilla:find('Plantilla:Ficha de selección de polo') then
		deporte = 'polo' -- no existe tipo 'polo'
	elseif plantilla:find('Plantilla:Ficha de selección de voleibol femenino') then
		if tipo == 'tipo' then
			deporte = 'voleibol' -- no existe tipo 'voleibol-femenino'
			fem = 'sí'
		else
			deporte = 'voleibol femenino'
			fem = 'sí'
		end
	elseif plantilla:find('Plantilla:Ficha de selección de voleibol') then
		deporte = 'voleibol' -- mismo tipo que nombre
	elseif plantilla:find('Plantilla:Ficha de selección de rugby') then
		if argumento{'especial'} == 7 and tipo ~= 'tipo' then
			deporte = 'rugby 7' -- no existe tipo 'rugby-7'
		else
			deporte = 'rugby' -- mismo tipo que nombre
		end
	elseif plantilla:find('Plantilla:Ficha de equipo de tenis') then
		deporte = 'tenis' -- mismo tipo que nombre
		estilotit = 'background-color:#cccc88'
		estilosec = 'background-color:#cccc88'
	elseif plantilla:find('Plantilla:Ficha de selección de hockey sobre césped') or
		plantilla:find('Plantilla:Ficha de selección de hockey sobre patines') then
		if tipo == 'tipo' then
			deporte = 'hockey' -- no existe tipo 'hockey-césped'
		else
			deporte = 'hockey sobre césped'
		end
	elseif plantilla:find('Plantilla:Ficha de selección de hockey sobre hielo') then
		if tipo == 'tipo' then
			deporte = 'hockey'
		else
			deporte = 'hockey sobre hielo'
		end
	end
	return deporte
end

function obtenercamiseta(frame)
	local plantilla = frame:getParent():getTitle()
	if	plantilla:find('Plantilla:Ficha de selección de fútbol') or 
		plantilla:find('Plantilla:Ficha de selección de balonmano') or 
		plantilla:find('Plantilla:Selección nacional de fútbol sala') or
		plantilla:find('Plantilla:Ficha de selección de rugby') or
		plantilla:find('Plantilla:Ficha de selección de hockey')
	then
		return obtenercamisetafutbol(frame)
	elseif plantilla:find('Plantilla:Ficha de selección de baloncesto') then
		return obtenercamisetabaloncesto(frame)
	end
end

function p.Ficha(frame)
	ModuloArgs.obtenerTablaDeArgumentos(frame)
	local nombre = argumento{'nombre','Nombre'} or ModuloPaginas.nombrePagina({desambiguar='sí'})
	local cabecera = obtenercabecera(frame, 'nombre')
	local plantilla = frame:getParent():getTitle()
		if plantilla:find('femenino' or 'femenina') then
			fem = 'sí'
	end
	if nombre:find('Copa Davis') == nil and nombre:find('Fed Cup') == nil then
		if nombre:find('Selección') == nil then -- Si el wikipedista no edita la variable "nombre" escribiendo 'Selección de...', entonces:
			if cabecera then
				if (argumento{'especial'} == 'sub-23' or argumento{'especial'} == 'sub-22'
				or argumento{'especial'} == 'sub-21' or argumento{'especial'} == 'sub-20'
				or argumento{'especial'} == 'sub-19' or argumento{'especial'} == 'sub-18'
				or argumento{'especial'} == 'sub-17' or argumento{'especial'} == 'sub-16'
				or argumento{'especial'} == 'sub-15' or argumento{'especial'} == 'sub-14') then
					nombre = 'Selección de '.. cabecera .. ' '.. argumento{'especial'} .. ' de ' .. nombre
				else
					nombre = 'Selección de '.. cabecera .. ' de ' .. nombre
				end
				if argumento{'fem'} == 'sí' or argumento{'fem'} == 'si' or argumento{'fem'} == 'fem' then
					nombre = nombre:gsub('Selección','Selección femenina')
				end
				if nombre:find('rugby') and argumento('especial') == '7' then
					 nombre = nombre:gsub('rugby','rugby 7')
			    end
			end
		end
	end
	local goleadorgoles = ''
	if argumento{'mayor goleador goles'} ~= nil and argumento{'mayor goleador goles'} ~= '' then
		goleadorgoles = safeText( argumento('mayor goleador') )..' ('..argumento{'mayor goleador goles'}..')'
	else
		goleadorgoles = safeText( argumento{'mayor goleador'} )
	end
	local mayorparticipacion = ''
	if argumento{'mayor partidos'} ~= nil and argumento{'mayor partidos'} ~= '' then
		mayorparticipacion = safeText( argumento('más participaciones') )..' ('..argumento('mayor partidos')..')'
	else
		mayorparticipacion = safeText( argumento{'más participaciones'} )
	end
	local pais = argumento{'país','Nombre'}
	local bandera = ''
	if pais ~= nil then
		if argumento{'Bandera'}~= nil then
			bandera = frame:preprocess('[[Archivo:'..argumento{'Bandera'}..'|200px]]')
		else
			bandera = frame:preprocess('{{Bandera|'..pais..'|tamaño=200px}}')
		end
	end
	if plantilla:find('hockey sobre patines') then
		bandera = frame:preprocess('{{Bandera|'..argumento{'Nombre'}..'|tamaño=200px}}')
	end
	local titulodt = 'Seleccionador'
	local dtband1 = ''
	local dtband2 = ''
	if argumento{'país-dt'} ~= nil then
		dtband1 = frame:preprocess('{{Bandera| '..argumento{'país-dt'}..'|tamaño=20px}}&nbsp;')
	end
	if argumento{'país2-dt'} ~= nil then
		dtband2 = frame:preprocess('{{Bandera| '..argumento('país2-dt')..'|tamaño=20px}}&nbsp;')
	end
	local dt = ''
	if argumento{'director técnico','Entrenador'} == nil then
		dt = 'No tiene'
	else
		if (argumento{'año-dt'} == '') or (argumento{'año-dt'} == nil) then
			dt = dtband1..dtband2..argumento{'director técnico','Entrenador'}
		else
			dt = dtband1..dtband2..argumento{'director técnico','Entrenador'} ..' <small>(desde '..safeText(argumento{'año-dt'})..')</small>'
		end
	end
	local rankingFIBA = nil
	local rankingFIVB = nil
	local obtenercod = nil
	local titulocapitan = 'Capitán'
	local titulocod = nil
	if plantilla:find('Plantilla:Ficha de selección de fútbol') then
		titulocod = '[[Anexo:Códigos de la FIFA|<span style="color:#000000;">Código FIFA</span>]]'
		obtenercod = argumento{'cod'}
		titulocapitan = '[[Capitán (fútbol)|<span style="color:#000000;">Capitán</span>]]'
		if argumento{'fem'} == "sí" then
			titulocapitan = titulocapitan:gsub("Capitán","Capitana")
		end
	elseif plantilla:find('Plantilla:Ficha de selección de baloncesto') then
		obtenercod = argumento{'cod'}
		femeninoFIBA = argumento{'femenino'} or ''
		if obtenercod then
			rankingFIBA = frame:preprocess('{{Selección de baloncesto/clasificación|'..obtenercod..'|'..femeninoFIBA..'}}')
				.. ' ' .. frame:preprocess('{{Selección de baloncesto/clasificación|fecha|'..femeninoFIBA..'}}')
		end
		titulodt = 'Seleccionador'
		obtenercod = nil
	elseif plantilla:find('Plantilla:Ficha de selección de voleibol') then
		femeninoFIVB = fem or ''
		if pais then
			rankingFIVB = frame:preprocess('{{Selección de voleibol/clasificación|'..pais..'|'..femeninoFIVB..'}}')
				.. ' ' .. frame:preprocess('{{Selección de voleibol/clasificación|fecha|'..femeninoFIVB..'}}')
		end
	elseif plantilla:find('hockey sobre patines') then
		titulocod = 'Código FIRS'
		obtenercod = argumento{'cod'}
	elseif plantilla:find('hockey sobre hielo') then
		titulocod = 'Código IIHS'
		obtenercod = argumento{'cod'}
	end
	local titulomundial
	local categoria = argumento{'especial'}
	local lang = mw.language.getContentLanguage()
	if cabecera then
		titulomundial = '[[Copa Mundial de '.. lang:ucfirst(cabecera) ..']]'
	end
	if plantilla:find('Plantilla:Ficha de selección de balonmano') then
		if argumento{'fem'} == 'sí' or argumento{'fem'} == 'si' or argumento{'fem'} == 'fem' or fem == 'sí' then
			titulomundial = '[[Campeonato Mundial de Balonmano Femenino|Campeonato Mundial]]'
		else
			titulomundial = '[[Campeonato Mundial de Balonmano Masculino|Campeonato Mundial]]'
		end
	elseif plantilla:find('Plantilla:Ficha de selección de voleibol') then
		if argumento{'fem'} == 'sí' or fem == 'sí' then
			if categoria then
				if categoria:find('sub') then
					titulomundial = '[[Campeonato Mundial de Voleibol Femenino '.. lang:ucfirst(categoria).. '|Campeonato Mundial]]'
				else
					titulomundial = '[[Campeonato Mundial de Voleibol Femenino|Campeonato Mundial]]'
				end
			else
				titulomundial = '[[Campeonato Mundial de Voleibol Femenino|Campeonato Mundial]]'
			end
		else
			if categoria then
				if categoria:find('sub') then
					titulomundial = '[[Campeonato Mundial de Voleibol Masculino '.. lang:ucfirst(categoria).. '|Campeonato Mundial]]'
				else
					titulomundial = '[[Campeonato Mundial de Voleibol Masculino|Campeonato Mundial]]'
				end
			else
				titulomundial = '[[Campeonato Mundial de Voleibol Masculino|Campeonato Mundial]]'
			end
		end
	elseif plantilla:find('Plantilla:Ficha de selección de fútbol') or plantilla:find('Plantilla:Ficha de selección de fútbol 2') then
		if argumento{'fem'} == 'sí' then
			if categoria then
				if categoria:find('sub') then
					titulomundial = '[[Copa Mundial Femenina de Fútbol '.. lang:ucfirst(categoria).. '|Copa Mundial]]'
				else
					titulomundial = '[[Copa Mundial Femenina de Fútbol|Copa Mundial]]'
				end
			else
				titulomundial = '[[Copa Mundial Femenina de Fútbol|Copa Mundial]]'
			end
		else
			if categoria then
				if categoria:find('sub') then
					titulomundial = '[[Copa Mundial de Fútbol '.. lang:ucfirst(categoria).. '|Copa Mundial]]'
				else
					titulomundial = '[[Copa Mundial de Fútbol|<span style="color:#000000;">Mundial</span>]]'
				end
			else
				titulomundial = '[[Copa Mundial de Fútbol|<span style="color:#000000;">Mundial</span>]]'
			end
		end
	elseif plantilla:find('Plantilla:Selección nacional de fútbol sala') then
		if argumento{'fem'} == 'sí' then
			titulomundial = '[[Campeonato Mundial Femenino de fútbol sala de la FIFA|Campeonato Mundial]]'
		else
			titulomundial = '[[Copa Mundial masculina de fútbol sala de la FIFA|Copa Mundial]]'
		end
	end
	local juegosolimpicos
	if cabecera then
		juegosolimpicos = 'Torneos Olímpicos'
	end
	if	plantilla:find('Plantilla:Ficha de selección de fútbol') then
		juegosolimpicos = '[[Fútbol en los Juegos Olímpicos|<span style="color:#000000;">Juegos Olímpicos</span>]]'
	end
	if	plantilla:find('Plantilla:Ficha de selección de voleibol') then
		juegosolimpicos = '[[Voleibol en los Juegos Olímpicos|<span style="color:#000000;">Juegos Olímpicos</span>]]'
	end
	PPI = obtenerPPI(frame)
	UPI = obtenerUPI(frame)
	MRI = obtenerMRI(frame)
	PRI = obtenerPRI(frame)
	MV = obtenerMV(frame)
	PD = obtenerPD(frame)
	if MV ~= nil then
		MRI = nil
		PRI = nil
	end
	if pais ~= nil then
		if pais:find('Copa Davis') then 
			pais = ''
		end
	end
	equipaciones = 'Equipaciones'
	if	plantilla:find('Plantilla:Ficha de selección de fútbol') then
		equipaciones = '[[Equipamiento de los futbolistas|<span style="color:#000000;">Equipaciones</span>]]'
	end
	local Ficha = {
		tipocabecera = obtenercabecera(frame, 'tipo'),
		['titulo'] = nombre,
		estilotitulo = estilotit,
		estiloseccion = estilosec,
		{'',bandera},
		{tipo = 'sección',
			['titulo'] ='Datos generales',
			{'País', pais },
			{titulocod, obtenercod},
			{'Federación', argumento{'asociación'}},
			{'Confederación',argumento{'confederación'}},
			{'Federación', argumento{'Federación'}},
			{'Seudónimo(s)',argumento{'seudónimo'}},
			{titulodt, dt},
			{titulocapitan,argumento{'capitán','Capitán'}},
			{'Más goles',goleadorgoles},
			{'Más partidos', mayorparticipacion},
			{'[[Clasificación mundial de la FIFA|<span style="color:#000000; white-space:nowrap;">Clasificación FIFA</span>]]',argumento{'Ranking FIFA'}},
			{'[[Ranking Mundial FIBA|Ranking FIBA]]', rankingFIBA},
			{'Ranking FIVB', rankingFIVB},
			{'[[Anexo:Códigos de la Federación Internacional de Tenis|Código ITF]]',argumento{'Código ITF'}},
			{'Primera participación', argumento{'Primera participación'}},
			{'Ediciones disputadas', argumento{'Ediciones disputadas'}},
			{'Participaciones Grupo Mundial', argumento{'Participaciones Grupo Mundial'}},
			{'Títulos ganados', argumento{'Títulos'}},
			{'Finales jugadas', argumento{'Finalista'}},
			{'Mejor puesto', argumento{'Mejor puesto'}},
			{'Colores',argumento{'Colores'}},
			{'Estadio(s)',argumento{'estadio'}},
		},
			{tipo = 'sección',
			['título'] = equipaciones,
			{'',obtenercamiseta(frame)}
		},
		{tipo = 'sección',
			['título'] = 'Primer partido',
			{'',PPI}
		},
		{tipo='sección',
			['título'] = 'Último partido',
			{'',UPI}
		},
		{tipo='sección',
			['título'] = 'Mejor(es) resultado(s)',
			{'',MRI}
		},
		{tipo='sección',
			['título'] = 'Mejor resultado',
			{'',MV}
		},
		{tipo = 'sección',
			['título'] = 'Peor(es) resultado(s)',
			{'',PRI}
		},
		{tipo = 'sección',
			['título'] = 'Peor resultado',
			{'',PD}
		},
		{tipo = 'sección',
			['título'] = titulomundial,
			{'Participaciones', obtenerparticipaciones('participación mundial', frame)},
			{'Medallas',argumento{'Medallas Mundial'}},
			{'Mejor resultado', argumento{'mejor mundial','Mejor resultado Copa Mundial','Mejor resultado mundial'},},
		},
		{tipo = 'sección',
			['título']	= '[[Liga Mundial de Voleibol|Liga Mundial]]',
			{'Participaciones', obtenerparticipaciones('liga mundial')},
			{'Mejor resultado', argumento{'Mejor resultado liga'}},
		},
		{tipo = 'sección',
			['título'] = safeText( argumento{'copa regional','Copa regional nombre'}),
			{'Participaciones', obtenerparticipaciones('participación regional', frame)},
			{'Medallas',argumento{'Medallas regional'}},
			{'Mejor resultado', argumento{'mejor regional','Mejor resultado regional'},},
		},
		{tipo = 'sección',
			['título'] = safeText( argumento{'copa regional2'}),
			{'Participaciones', obtenerparticipaciones('participación regional2', frame)},
			{'Medallas',argumento{'Medallas regional2'}},
			{'Mejor resultado', argumento{'mejor regional2'},},
		},
		{tipo = 'sección',
			['título'] = safeText( argumento{'copa regional3'}),
			{'Participaciones', obtenerparticipaciones('participación regional3', frame)},
			{'Medallas',argumento{'Medallas regional3'}},
			{'Mejor resultado', argumento{'mejor regional3'}},
		},
		{tipo = 'sección',
			['título'] = safeText( argumento{'copa regional4'}),
			{'Participaciones', obtenerparticipaciones('participación regional4', frame)},
			{'Medallas',argumento{'Medallas regional4'}},
			{'Mejor resultado', argumento{'mejor regional4'},},
		},
		{tipo = 'sección',
			['título'] = '[[Copa FIFA Confederaciones|<span style="color:#000000;">Confederaciones</span>]]',
			{'Participaciones', obtenerparticipaciones('participación confederaciones', frame)},
			{'Mejor resultado', argumento{'mejor confederaciones'}},
		},
		{tipo= 'sección',
			['título'] = juegosolimpicos,
			{'Participaciones', obtenerparticipaciones('torneo olímpico', frame)},
			{'Mejor resultado', argumento{'mejor olímpico','Mejor resultado olímpico'},},
			{'Medallas', argumento{'Medallas olímpico'},}
		},
		{tipo = 'sección',
			['título'] = '[[Grand Prix de Voleibol]]',
			{'Participaciones', argumento{'Participación Grand Prix'}},
			{'Mejor resultado', argumento{'Mejor resultado Grand Prix'}},
		},
		{tipo = 'sección',
			['título'] = '[[Liga de Naciones de Voleibol Femenino|Liga de Naciones]]',
			{'Participaciones', obtenerparticipaciones('Liga de Naciones', frame)},
			{'Mejor resultado', argumento{'Mejor resultado Liga de Naciones', 'Mejor resultado LNV'}},
		},
		{tipo = 'sección',
			['título'] = 'Estadística de jugador',
			{'Mas triunfos totales', argumento{'Jugador más ganador'}},
			{'Mas triunfos en individuales', argumento{'Individuales más ganador'}},
			{'Más triunfos en dobles', argumento{'Dobles más ganador'}},
			{'Mejor equipo de dobles', argumento{'Mejor equipo de dobles'}},
			{'Más eliminatorias jugadas', argumento{'Más series disputadas'}},
			{'Más años jugados', argumento{'Más ediciones disputadas'}},
		},
	}
	return ModuloFicha.infobox(Ficha)
end
return p