For faster navigation, this Iframe is preloading the Wikiwand page for Module:Utilisateur:SyntaxTerror.

Module:Utilisateur:SyntaxTerror

 Documentation[voir] [modifier] [historique] [purger]

Utilisateur:SyntaxTerror/Brouillon/Module


local Langue = { }

-- Chargement du de la base de données des langues avec gestion d'erreur.
local dataLangue
local success, resultat = pcall (mw.loadData, 'Module:Langue/Data' )
if success then
    dataLangue = resultat
else
    -- Base de données à minima en cas de bug sur le Module:Langue/Data
    dataLangue = { en = { code = 'en', nom = anglais }, 
        de = { code = 'de', nom = 'allemand' }, 
        it = { code = 'it', nom = 'italien' }, 
        es = { code = 'es', nom = 'espagnol' }, }
    dataLangue.anglais = dataLangue.en
    dataLangue.allemand = dataLangue.de
    dataLangue.italien = dataLangue.it
    dataLangue.espagnol = dataLangue.es
end

-- traductionReference

function Langue.traductionReference(frame)
    local args = ( frame.getParent and frame:getParent().args ) or frame or { }
    local lang1 = args[1] or args["lang1"] or ''
    local art1 = args[2] or args["art1"] or ''
    local id1 = args[3] or args["id1"] or ''
    local lang2 = args[4] or args["lang2"] or ''
    local art2 = args[5] or args["art2"] or ''
    local id2 = args[6] or args["id2"] or ''
    
-- massages d'erreur en cas de paramètres manquants

    if lang1 == '' then
        return '<span style="color:red"> Erreur dans ((Traduction/Référence)) : langue non précisée. (1) </span>' -- [[Catégorie:Page avec code de langue invalide]]' 
    end
    if lang2 == '' and art2 ~= '' then
        return '<span style="color:red"> Erreur dans ((Traduction/Référence)) : langue non précisée. (2) </span>' -- [[Catégorie:Page avec code de langue invalide]]' 
    end

-- nettoyage et mise en minuscule de lang1 et lang2
    local lang1 = mw.ustring.lower( mw.text.trim( lang1 ) )
    local lang2 = mw.ustring.lower( mw.text.trim( lang2 ) )
    
-- mise de lang1 et lang 2 dans wiki1 et wiki2 dans la cas où ils ne correspondent pas au code de langue IETF correct
    local wiki1 = lang1
    local wiki2 = lang2
    
    local tabLangue1 = dataLangue[ lang1 ]
    local tabLangue2 = dataLangue[ lang2 ]
    local nom1 = ''
    local nom2 = ''
    
    if tabLangue1 then
        lang1= tabLangue1.nom
        code1 = tabLangue1.code
        if type( tabLangue1.page ) == 'string' then
            nom1 = tabLangue1.page .. '|' .. tabLangue1.nom
        else
            nom1 = tabLangue1.nom
        end
    else
        return '<span style="color:red;"> Erreur dans ((Traduction/Référence)) : langue non reconnue : (3)' .. lang1 .. ' </span>' -- [[Catégorie:Page avec code de langue invalide]]'
    end    
    
    if tabLangue2 and art2 then
        if type( tabLangue2.page ) == 'string' then
            nom2 = tabLangue2.page .. '|' .. tabLangue2.nom
        else
            nom2 = tabLangue2.nom
        end
--    else
--        return '<span style="color:red;"> Erreur dans ((Traduction/Référence)) : langue non reconnue : (4)' .. lang2 .. ' </span>[[Catégorie:Page avec code de langue invalide]]'
    end

-- texte pour la 1re langue

    local text1 = '* <span class="indicateur-langue">(<abbr class="abbr" title="Langue : '
    .. lang1 .. '">'
    .. code1 .. '</abbr>)</span> Cet article est partiellement ou en totalité issu de l’article de Wikipédia en [[' 
    .. nom1 .. ']] intitulé « <span class="plainlinks">[https://'
    .. wiki1 .. '.wikipedia.org/wiki/'
    .. mw.uri.encode( art1 , "WIKI" ) .. '?oldid='
    .. id1 .. ' '
    .. art1 .. ']</span> » (voir la <span class="plainlinks">[https://'
    .. wiki1 .. '.wikipedia.org/wiki/'
    .. mw.uri.encode( art1 , "WIKI" ) .. '?action=history liste des auteurs]</span>)'
    
-- texte pour la 2e langue
    
    local text2 = '\n* <span class="indicateur-langue">(<abbr class="abbr" title="Langue : '
    .. nom2 .. '">'
    .. lang2 .. '</abbr>)</span> Cet article est partiellement ou en totalité issu de l’article de Wikipédia en [[' 
    .. nom2 .. ']] intitulé « <span class="plainlinks">[https://'
    .. wiki2 .. '.wikipedia.org/wiki/'
    .. mw.uri.encode( art2 , "WIKI" ) .. '?oldid='
    .. id2 .. ' '
    .. art2 ..']</span> » (voir la <span class="plainlinks">[https://'
    .. wiki2 .. '.wikipedia.org/wiki/'
    .. mw.uri.encode( art2 , "WIKI" ) .. '?action=history liste des auteurs]</span>)'

    return text1 .. text2
end
    
return Langue

--[=[
    wikitext = 'lang1 = <span style="color:green;">' .. lang1 ..
    '</span>, art1 = <span style="color:green;">' .. art1 ..
    '</span>, id1 = <span style="color:green;">' .. id1 ..
    '</span>, lang2 = <span style="color:green;">' .. lang2 ..
    '</span>, art2 = <span style="color:green;">' .. art2 ..
    '</span>, id2 = <span style="color:green;">' .. id2 ..
    '</span>.'
]=]

--[=[

Utilisateur:SyntaxTerror/Brouillon/Module

]=]
{{bottomLinkPreText}} {{bottomLinkText}}
Module:Utilisateur:SyntaxTerror
Listen to this article

This browser is not supported by Wikiwand :(
Wikiwand requires a browser with modern capabilities in order to provide you with the best reading experience.
Please download and use one of the following browsers:

This article was just edited, click to reload
This article has been deleted on Wikipedia (Why?)

Back to homepage

Please click Add in the dialog above
Please click Allow in the top-left corner,
then click Install Now in the dialog
Please click Open in the download dialog,
then click Install
Please click the "Downloads" icon in the Safari toolbar, open the first download in the list,
then click Install
{{::$root.activation.text}}

Install Wikiwand

Install on Chrome Install on Firefox
Don't forget to rate us

Tell your friends about Wikiwand!

Gmail Facebook Twitter Link

Enjoying Wikiwand?

Tell your friends and spread the love:
Share on Gmail Share on Facebook Share on Twitter Share on Buffer

Our magic isn't perfect

You can help our automatic cover photo selection by reporting an unsuitable photo.

This photo is visually disturbing This photo is not a good choice

Thank you for helping!


Your input will affect cover photo selection, along with input from other users.

X

Get ready for Wikiwand 2.0 🎉! the new version arrives on September 1st! Don't want to wait?