Module:Test
Apparence
Seulement pour tester. Si un modèle utilise une fonction de ce module, il cassera un jour !
local p = {}
function p.yop() -- met un mot en lowercase
return mw.ustring.lower( "ÉLLOÈ" )
end
function p.poy() -- première lettre en majuscule
return mw.getContentLanguage():ucfirst( "ébloubi" )
end
local numeros = mw.loadData("Module:Data/NumérosPokémon")
function p.infosPokemon( poke, mode )
local forme, sexe, nom, lien, jeu, jeu_miniature
if ( string.match(poke, "forme%([^)]*%)") ) then
forme = " " .. string.sub(string.match(poke, "forme%([^)]*%)"), 7, -2)
poke = string.gsub( poke, "forme%([^)]*%)", "" )
else forme = "" end
if ( string.match(poke, "sexe%([^)]*%)") ) then
sexe = string.sub(string.match(poke, "sexe%([^)]*%)"), 6, -2)
if sexe == "f" then sexe = " ♀" else sexe = " ♂" end
poke = string.gsub( poke, "sexe%([^)]*%)", "" )
else sexe = "" end
if ( string.match(poke, "jeu%([^)]*%)") ) then
jeu = mw.getCurrentFrame():expandTemplate{ title = 'Sup', args = { string.sub(string.match(poke, "jeu%([^)]*%)"), 5, -2) } }
poke = string.gsub( poke, "jeu%([^)]*%)", "" )
else jeu = "" end
if ( string.match(poke, "jeu%-miniature%([^)]*%)") ) then
jeu_miniature = " " .. string.sub(string.match(poke, "jeu%-miniature%([^)]*%)"), 15, -2)
poke = string.gsub( poke, "jeu%-miniature%([^)]*%)", "" )
else jeu_miniature = "" end
if forme == " Alola" then
poke = mw.text.trim( poke )
nom = "Forme d'Alola"
lien = poke .. " d'Alola"
elseif forme == " Galar" then
poke = mw.text.trim( poke )
nom = "Forme de Galar"
lien = poke .. " de Galar"
elseif forme == " Gigamax" then
poke = mw.text.trim( poke )
nom = "Gigamax"
lien = poke .. " Gigamax"
else
if ( string.match(poke, "nom%([^)]*%)") ) then
nom = string.sub(string.match(poke, "nom%([^)]*%)"), 5, -2)
poke = string.gsub( poke, "nom%([^)]*%)", "" )
elseif forme ~= "" then nom = "Forme" .. forme
elseif sexe == " ♀" then nom = "Femelle"
elseif sexe == " ♂" then nom = "Mâle"
else nom = "" end
if ( string.match(poke, "lien%([^)]*%)") ) then
lien = string.sub(string.match(poke, "lien%([^)]*%)"), 6, -2)
poke = string.gsub( poke, "lien%([^)]*%)", "" )
else lien = mw.text.trim( poke ) end
end
poke = mw.text.trim( poke )
local num = numeros[poke]
if num == nil then num = "???" end
if mode == "miniature" then
if nom == "" then return "[[Fichier:Miniature " .. num .. forme .. sexe .. jeu_miniature .. ".png|link=" .. lien .. "|alt=" .. lien .. "|" .. lien .. "]]" .. jeu
else return "[[Fichier:Miniature " .. num .. forme .. sexe .. jeu_miniature .. ".png|link=" .. lien .. "|alt=" .. poke .. " (" .. nom .. ")|" .. poke .. " (" .. nom .. ")]]" .. jeu
end
else
if nom == "" then return "<span style='white-space: nowrap;' class='miniat-poke'>" .. num .. " [[Fichier:Miniature " .. num .. forme .. sexe .. jeu_miniature .. ".png|link=" .. lien .. "|alt=]] [[" .. lien .. "|" .. poke .. "]]" .. jeu .. "</span>"
else return "<span style='white-space: nowrap;' class='miniat-poke'>" .. num .. " [[Fichier:Miniature " .. num .. forme .. sexe .. jeu_miniature .. ".png|link=" .. lien .. "|alt=]] [[" .. lien .. "|" .. poke .. "]]" .. jeu .. "</span><br /><span style='font-style: italic; font-size: 90%;'>" .. nom .. "</span>"
end
end
end
function p.infosPokemon2(frame)
poke = frame.args[1]
mode = frame.args[2]
return p.infosPokemon(poke, mode)
end
function p.testregexp(frame)
a = frame.args[1]
b = a:gsub(".*{{Abréviation|(.*)}}.*", "%1")
return b
end
return p