Module:Carta

local p = {}

function p.carta(frame) for name, value in pairs(frame.args) do       if name ~= '' then local nombre = '' local n = p.normalize(value) local RdDatos = {} local RdLetter = '' local Letter = p.selectLetter(string.sub(n, 0, 1)) if RdLetter ~= Letter then RdLetter = Letter RdDatos = require('Module:RdDatos' .. RdLetter) end if RdDatos[n] ~= nil then local rddatos = RdDatos[n] nombre = rddatos[1] end return nombre end end end

function p.selectLetter(letter) local char_n = string.byte(letter) if char_n > 64 and char_n < 91 then return letter else return '7' end end

function p.normalize (cardname) cardname = string.lower(cardname) cardname = string.gsub(cardname, 'Á', 'a') cardname = string.gsub(cardname, 'Ä', 'a') cardname = string.gsub(cardname, 'Â', 'a') cardname = string.gsub(cardname, 'É', 'e') cardname = string.gsub(cardname, 'Ë', 'e') cardname = string.gsub(cardname, 'Í', 'i') cardname = string.gsub(cardname, 'Ï', 'i') cardname = string.gsub(cardname, 'Ó', 'o') cardname = string.gsub(cardname, 'Ö', 'o') cardname = string.gsub(cardname, 'Ú', 'u') cardname = string.gsub(cardname, 'Ü', 'u') cardname = string.gsub(cardname, 'á', 'a') cardname = string.gsub(cardname, 'ä', 'a') cardname = string.gsub(cardname, 'â', 'a') cardname = string.gsub(cardname, 'é', 'e') cardname = string.gsub(cardname, 'ë', 'e') cardname = string.gsub(cardname, 'í', 'i') cardname = string.gsub(cardname, 'ï', 'i') cardname = string.gsub(cardname, 'ó', 'o') cardname = string.gsub(cardname, 'ö', 'o') cardname = string.gsub(cardname, 'ú', 'u') cardname = string.gsub(cardname, 'ü', 'u') cardname = string.upper(cardname) cardname = string.gsub(cardname, ' ', '') cardname = string.gsub(cardname, '"', )   cardname = string.gsub(cardname, "'", )    cardname = string.gsub(cardname, ',', )    cardname = string.gsub(cardname, '%.', )    cardname = string.gsub(cardname, '%-', )    cardname = string.gsub(cardname, '¡', )    cardname = string.gsub(cardname, '!', )    cardname = string.gsub(cardname, '¿', )    cardname = string.gsub(cardname, '%?', )    cardname = string.gsub(cardname, ':', )    cardname = string.gsub(cardname, 'º', )    cardname = string.gsub(cardname, '/', )    cardname = string.gsub(cardname, '#', )    cardname = string.gsub(cardname, '&', 'Y')    cardname = string.gsub(cardname, '“', )    cardname = string.gsub(cardname, '”', )    cardname = string.gsub(cardname, '’', )    cardname = string.gsub(cardname, '%–', )    cardname = string.gsub(cardname, 'ñ', 'Ñ')    cardname = string.gsub(cardname, '·', ) cardname = string.gsub(cardname, '☆', '') cardname = string.gsub(cardname, 'ß', 'B') return cardname end

function p.convnombreimagen(filename) filename = string.lower(filename) filename = string.gsub(filename, 'Á', 'á') filename = string.gsub(filename, 'Ä', 'ä') filename = string.gsub(filename, 'Â', 'â') filename = string.gsub(filename, 'É', 'é') filename = string.gsub(filename, 'Ë', 'ë') filename = string.gsub(filename, 'Í', 'í') filename = string.gsub(filename, 'Ï', 'ï') filename = string.gsub(filename, 'Ó', 'ó') filename = string.gsub(filename, 'Ö', 'ö') filename = string.gsub(filename, 'Ú', 'ú') filename = string.gsub(filename, 'Ü', 'ü') filename = string.gsub(filename, '/', '-') filename = string.gsub(filename, '&#39;', '') filename = string.gsub(filename, '\, ) filename = string.gsub(filename, '"', )   filename = string.gsub(filename, '&quot;', )    filename = string.gsub(filename, '&#34;', )    filename = string.gsub(filename, '?', )    filename = string.gsub(filename, '&#3f;', '')    return filename end

return p