Modification de Module:Référence
La modification peut être annulée. Veuillez vérifier les différences ci-dessous pour voir si c’est bien ce que vous voulez faire, puis publier ces changements pour finaliser l’annulation de cette modification.
Version actuelle | Votre texte | ||
Ligne 1 : | Ligne 1 : | ||
local p = {} | local p = {} | ||
-- | -------------------------------------- | ||
function | ----- Fonctions communes ----- | ||
if lang ~= | -------------------------------------- | ||
return | |||
function formatSentence(sentence, lang) | |||
if lang ~= 'fr' then | |||
return "''" .. sentence .. "''" | |||
else | else | ||
return sentence | return sentence | ||
Ligne 10 : | Ligne 13 : | ||
end | end | ||
function getArgs(frame) | |||
function | |||
local args = {} | local args = {} | ||
Ligne 24 : | Ligne 26 : | ||
end | end | ||
-- | -------------------------------------- | ||
-- | |||
local | function p._buildOneReference(args) | ||
if not | local ref = '' | ||
local type = args['type'] | |||
if not type then | |||
return 'Le paramètre type n\'est pas renseigné.' | |||
end | end | ||
local type = type:lower() | |||
local | |||
if | local name = args['nom'] | ||
if name then | |||
ref = '<ref name="' .. name .. '">' | |||
else | else | ||
ref = '<ref>' | |||
end | end | ||
local | local lang = args['langue'] or 'fr' | ||
if type == 'conversation' then | |||
local game = args['jeu'] | |||
if game then | |||
game = require( 'Module:Abréviation' ).name(game) | |||
if game == '' then | |||
game = 'jeu ?' | |||
else | |||
game = "''[[" .. game .. "]]''" | |||
end | |||
else | |||
game = 'jeu ?' | |||
end | end | ||
local character1 = args['personnage1'] or 'personnage1 ?' | |||
local character2 = args['personnage2'] or 'personnage2 ?' | |||
ref = ref .. 'Conversation entre ' .. character1 .. ' et ' .. character2 .. ' :' | |||
ref = ref .. '<br/>' | |||
if | for i = 1, 6 do | ||
break | local sentence = args['phrase' .. i] | ||
if sentence then | |||
ref = ref .. '— ' .. formatSentence(sentence, lang) .. '<br/>' | |||
else | |||
break | |||
end | |||
end | end | ||
if | ref = ref .. 'Extrait du fichier ' .. file .. ', ' .. game | ||
elseif type == 'document' then | |||
local quotation = args['citation'] | |||
if quotation then | |||
ref = ref .. '« ' .. formatSentence(quotation, lang) .. ' »<br/>' | |||
end | end | ||
local document = args['ouvrage'] or 'ouvrage ?' | |||
local author = args['auteur'] or 'auteur ?' | |||
local date = args['date'] or 'date ?' | |||
local publisher = args['éditeur'] or 'éditeur ?' | |||
local page = args['page'] or 'page ?' | |||
ref = ref .. author .. '. \'\'' .. document .. '\'\'. ' .. publisher .. ', ' .. date .. '. pp. ' .. page | |||
end | end | ||
ref = ref .. '</ref>' | |||
return ref | |||
return | |||
end | end | ||
function p. | function p.buildOneReference(frame) | ||
return p. | local args = getArgs(frame) | ||
return p._buildOneReference(args) | |||
end | end | ||
return p | return p |