Aller au contenu

Module:Cycling race

Cette page fait l’objet d’une mesure de semi-protection étendue.
Une page de Wikipédia, l'encyclopédie libre.
Ceci est une version archivée de cette page, en date du 10 décembre 2015 à 19:13 et modifiée en dernier par Jérémy-Günther-Heinz Jähnick (discuter | contributions) (Test de d:Module:Cycling race, développé par Molarus ( https://www.wikidata.org/w/index.php?title=Module:Cycling_race&action=history )). Elle peut contenir des erreurs, des inexactitudes ou des contenus vandalisés non présents dans la version actuelle.
(diff) ← Version précédente | Voir la version actuelle (diff) | Version suivante → (diff)

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

Utilisation

Le module Cycling race est un programme codé en Lua. Il n'accepte que les données de Wikidata. Il est une simple copie de sa version sur Wikidata Module:Cycling race. Toute amélioration du module doit donc se faire sur Wikidata et le code doit être recopié sur toutes les versions linguistiques de Wikipédia qui l'utilisent.

Fonctions

Toutes les fonctions peuvent être appelée par les modèles en anglais, "{{Cycling race/" +Fonction dans le code+"}}". Pour rendre l'utilisation plus facile d'accès, les noms des modèles ont été traduits en français.

Nom complet Fonction dans le code Modèle (FR) Description Exemple
Fonctions pour une course cycliste
Infobox raceinfobox {{Course cycliste/courseinfobox}} Affiche l'infobox de la course {{Cycling race/raceinfobox|Q1578389}}
ou
{{Course cycliste/courseinfobox|Q1578389}}
Liste des vainqueurs listofwinners {{Course cycliste/listedesvainqueurs}} Affiche le palmarès d'une course {{Cycling race/listofwinners|Q15043657}}
ou
{{Course cycliste/listedesvainqueurs|Q15043657}}
Liste des vainqueurs (pour les championnats) listofwinnersChamp {{Course cycliste/listedesvainqueurschamp}} Affiche le palmarès d'un championnat (sans les drapeaux) {{Course cycliste/listedesvainqueurschamp|Q15043657}}
Liste des vainqueurs à partir d'une année donnée (pour les championnats) listofwinnersChampsecondpart {{Course cycliste/listedesvainqueurschampdeuxiemepartie}} Affiche le palmarès d'un championnat à partir d'une année donnée (sans les drapeaux), évite de surcharger le serveur {{Course cycliste/listedesvainqueurschampdeuxiemepartie|Q30577837|2018}}
Liste des vainqueurs du classement par points listofpointswinners {{Course cycliste/listedesvainqueurspoints}} Affiche le palmarès d'une course {{Course cycliste/listedesvainqueurspoints|Q15043657}}
Liste des vainqueurs du classement de la montagne listofmountainwinners {{Course cycliste/listedesvainqueursmontagne}} Affiche le palmarès d'une course {{Course cycliste/listedesvainqueursmontagne|Q15043657}}
Liste des vainqueurs du classement du meilleur jeune listofyoungwinners {{Course cycliste/listedesvainqueursjeune}} Affiche le palmarès d'une course {{Course cycliste/listedesvainqueursjeune|Q15043657}}
Fonctions pour une équipe cycliste
Infobox teaminfobox {{Course cycliste/equipeinfobox}} Affiche l'infobox d'une équipe {{Course cycliste/equipeinfobox|Q1757136}}
Infobox teamseasoninfobox {{Course cycliste/saisonequipeinfobox}} Affiche l'infobox d'une saison d'une équipe {{Course cycliste/saisonequipeinfobox|Q104525546}}
Effectif teamroster {{Course cycliste/effectif}} Affiche l'effectif d'une équipe pour une saison donnéee {{Course cycliste/effectif|Q21968189}}
Effectif actuel lastteamroster {{Course cycliste/derniereffectif}} Affiche l'effectif d'une équipe pour la saison actuelle {{Course cycliste/effectifactuel|Q2651858}}
Victoires victories {{Course cycliste/victoires}} Affiche les victoires d'une équipe {{Course cycliste/victoires|Q27891882}}
Classement UCI UCIclassification {{Course cycliste/classementUCI}} Affiche le classement UCI des différents coureurs de l'équipe {{Course cycliste/classementUCI|Q27891882}}
Classement des coureurs dans une compétition teamriderCompetitionranking {{Course cycliste/classementcoureurscompetition}} Affiche le classement des coureurs dans une compétition donnée {{Course cycliste/classementcoureurscompetition|Q104525546|WWT}}
Classement équipe teamranking {{Course cycliste/classementequipe}} Affiche un tableau avec les classements d'une équipe dans une compétition {{Course cycliste/classementequipe|Q2651858|women}}
Fonctions pour les éditions d'une course cycliste
Infobox infobox {{Course cycliste/infobox}} Affiche l'infobox pour une course cycliste (une édition) {{Course cycliste/infobox|Q28859163}}
Liste des étapes listofstages {{Course cycliste/listedesetapes}} Affiche un tableau listant les étapes {{Course cycliste/listedesetapes|Q18589873}}
Evolution des classements listofstagesclassification {{Course cycliste/evolutiondesclassements}} Affiche un tableau listant les leaders des classements {{Course cycliste/evolutiondesclassements|Q18589873}}
Liste des équipes listofteams {{Course cycliste/listedesequipes}} Liste les équipes participant à une course {{Course cycliste/listedesequipes|Q20872500}}
Liste des partants startlist {{Course cycliste/listedespartants}} Liste des partants à une course {{Course cycliste/listedespartants|Q20872500}}
Liste des partants tableau startlisttable {{Course cycliste/listedespartantstableau}} Liste des partants à une course sous forme de liste {{Course cycliste/listedespartantstableau|Q20872500}}
Classement général generalclassification {{Course cycliste/classementgeneral}} Affiche le classement général de la course ou étape {{Course cycliste/classementgeneral|Q21934629}}
Classement général par points generalclassificationpoint {{Course cycliste/classementgeneralpoint}} Affiche le classement général par points de la course ou étape {{Course cycliste/classementgeneralpoint|Q21934629}}
Classement étape stageclassification {{Course cycliste/classementetape}} Affiche le classement de l'étape {{Course cycliste/classementetape|Q21934629}}
Classement clm par équipes teamtimetrialclassification {{Course cycliste/classementclmparequipes}} Affiche le classement d'une étape en clm par équipes (attention, il existe aussi la fonction pour l'affichage du classement général d'un clm par équipes) {{Course cycliste/classementclmparequipes|Q26209129}}
Classement par points pointsclassification {{Course cycliste/classementparpoints}} Affiche le classement par points, de la course ou de l'étape {{Course cycliste/classementparpoints|Q20882755}}
Classement par équipes au temps teamsclassificationbytime {{Course cycliste/classementparequipesautemps}} Affiche le classement par équipes au temps {{Course cycliste/classementparequipesautemps|Q20882755}}
Classement par équipes aux points teamsclassificationbypoints {{Course cycliste/classementparequipesauxpoints}} Affiche le classement par équipes aux points {{Course cycliste/classementparequipesauxpoints|Q20882755}}
Classement de la montagne mountainsclassification {{Course cycliste/classementdelamontagne}} Affiche le classement de la montagne {{Course cycliste/classementdelamontagne|Q20882755}}
Classement des sprints sprintsclassification {{Course cycliste/classementdessprints}} Affiche le classement des sprints {{Course cycliste/classementdessprints|Q20882755}}
Classement du meilleur jeune bestyoungclassification {{Course cycliste/classementdumeilleurjeune}} Affiche le classement du meilleur jeune (au temps) {{Course cycliste/classementdumeilleurjeune|Q20882755}}
Classement du meilleur jeune par points bestyoungclassificationbypoints {{Course cycliste/classementdumeilleurjeuneparpoints}} Affiche le classement du meilleur jeune par points {{Course cycliste/classementdumeilleurjeuneparpoints|Q20882755}}
Classement du combiné combinationclassification {{Course cycliste/classementducombine}} Affiche le classement du combiné {{Course cycliste/classementducombine|Q20882755}}
Classement de la combativité combativeclassification {{Course cycliste/classementdelacombativite}} Affiche le classement de la combativité {{Course cycliste/classementdelacombativite|Q20882755}}
Classement par points personnalisé custompointsclassification {{Course cycliste/classementparpointsperso}} Affiche un classement par points, de la course ou de l'étape {{Course cycliste/classementparpointsperso|Q42158490|propriété=P3494|titre=Classement cyclamen}}
Classement au temps personnalisé customtimeclassification {{Course cycliste/classementautempsperso}} Affiche un classement au temps, de la course ou de l'étape {{Course cycliste/classementparpointsperso|Q42158490|propriété=P4323|titre=Classement du meilleur amateur}}
Fonctions pour les calendriers
Calendrier calendar {{Course cycliste/calendrier}} Affiche le calendrier et les vainqueurs d'une compétition {{Course cycliste/calendrier|women|2018}}
Calendrier personalisé calendarcustom {{Course cycliste/calendrierperso}} Affiche le calendrier et les vainqueurs d'une compétition, affichage personnalisé {{Course cycliste/calendrierperso|Q47034891|podium=1|classe=1}}
Championnats nationaux nationalchampionships {{Course cycliste/championnatsnationaux}} Affiche la liste des championnats nationaux (féminins) pour une année donnée {{Course cycliste/championnatsnationaux|2018}}
Infobox pour les championnats champinfobox {{Course cycliste/championnatinfobox}} Affiche l'infobox d'un championnats {{Course cycliste/championnatinfobox|Q60967591}}
Infobox pour les compétitions, calendriers ou les challenges seasoninfobox {{Course cycliste/competitioninfobox}} Affiche l'infobox d'une compétition {{Course cycliste/competitioninfobox|Q2395083}}
Fonctions pour les étapes d'une course cycliste
Infobox étape stageinfobox {{Course cycliste/infoboxetape}} Affiche l'infobox d'étape cycliste {{Course cycliste/infoboxetape|Q265672}}
Fonctions pour les coureurs
Infobox riderinfobox {{Course cycliste/coureurinfobox}} Affiche l'infobox d'un coureur {{Course cycliste/coureurinfobox}|Q40853827}}
Classement coureur riderranking {{Course cycliste/classementcoureur}} Affiche un tableau avec les classements UCI du coureur {{Course cycliste/classementcoureur}|Q40853827}}
local p = {}
  function headoftable(x)
	local l10nDef = { }
	l10nDef["//fr.wikipedia.org"] = {"Étape", "Date", "Villes étapes", "Distance (km)", "Vainqueur d'étape", "Leader du classement général"}
	l10nDef["//en.wikipedia.org"] = {"Stage", "Date", "Course", "Distance (km)", "Stage winner", "Overall leader"}
	l10nDef["//de.wikipedia.org"] = {"Etappe", "Datum", "Etappenorte", "Länge (km)", "Etappensieger", "Gesamtführender"}
	l10nDef["//als.wikipedia.org"] = l10nDef["//de.wikipedia.org" ]
	l10nDef["//www.wikidata.org"] = {"Étape", "Date", "Villes étapes", "Distance (km)", "Vainqueur d'étape", "Leader du classement général"}

	local l10n = l10nDef[mw.site.server]
	if not l10n then
    	l10n = l10nDef["//fr.wikipedia.org"]   -- default
	end
  return l10n[x]
  end 

  function wikilinks(x, a, b) -- x= 10a: a = 10, b = a. x = 5: a = 5, b = "" 
 	local translDef = { ["//www.wikidata.org"] = "étape", 
		                ["//fr.wikipedia.org"] = "étape", 
		                ["//en.wikipedia.org"] = "Stage",
		                ["//de.wikipedia.org"] = "Etappe" }		                

    local word = translDef[mw.site.server]
    local word1, word2
	if not word then
    	word2 = translDef["//fr.wikipedia.org"]   -- default
	end

  -- fr: {{1re}} étape, {{2e}} étape
  if mw.site.server == "//www.wikidata.org" or mw.site.server == "//fr.wikipedia.org" then 
  	 if b == "" then -- series_ordinal without character		
	   if a == "1" then word1 = "{{1re}} "..word else word1 = "{{"..a.."e}} "..word end -- table text = {{1re}} étape, {{2ae}} étape,
	   if a == "1" then word2 = "#1re "..word else word2 = "#"..a.."e "..word end --text of section header = #1re étape, #2e étape
   	   return word1, word2
   	 end
     if b ~= "" then -- series_ordinal with character: instead of eg "1a re" it is "1re a"	
 	   if a == "1" then word1 = "{{1re"..b.."}} "..word else word1 = "{{"..a.."e"..b.."}} "..word end -- table text = {{1re}} étape, {{2ae}} étape,
	   if a == "1" then word2 = "#1re"..b.." "..word else word2 = "#"..a.."e"..b.." "..word end --text of section header = #1re étape, #2e étape
   	   return word1, word2	
     end  	
  end
  -- default
  word1 = x                  -- table text = 1, 2a, 3
  word2 = "#"..word.." ".. x -- text of section header = #Etappe 2a, #Stage 4
 	
  --return table text, text of section header
  return word1, word2 
  end
  
  function p.listofstages(frame)
 	local i, v, uu
 	local etape = {}
 	local entity = {}
 	local series_ordinal, point_of_time, length = {}, {}, {}
    local labels1, labels2, labels3, labels4 = {}, {}, {}, {}
    local y, m, d = {}, {}, {}
    local flag1, flag2 = {}, {}
    local number0, number1, number2 = {}, {}, {}
    local stage = {}
    local level = 1  
   
 	entity0 = mw.wikibase.getEntityObject( frame.args[1] ) -- Q18589873 (Quatre jours de Dunkerque 2015)

    -- begin level 1
    local table_first, table_proto, table_last
    table_first = "<table cellpadding='4' cellspacing='0' style='border:1px solid rgb(200,200,200); color:black;"
    table_first = table_first .. "margin:0 0 0.5em 0; background-color:rgb(255, 255, 255); padding:5px; clear:left; "
    table_first = table_first .. "text-align:left; vertical-align:top; font-size:85%; line-height:1.6em;'>" 

    table_proto = {"<tr style='background:#FFDF80; text-align:center;'><th>", headoftable(1), "</th><th>", 
    		      headoftable(2), "</th><th>", headoftable(3), "</th><th>", headoftable(4), "</th><th>", 
    		      headoftable(5), "</th><th>", headoftable(6), "</th></tr>"}
    table_last = "</table>"
    -- missing is that the names in table_proto are taken from WD if possible
    -- end level 1
    
    local pp = entity0:getProperties()
    -- look in all values of array `pp' and if there is one P527 then increase to level = 2
    for i,v in ipairs(pp) do if v == 'P527' then level = 2 end end 
 	
 	-- only for level: 2
 	-- read series_ordinal and the Qnumber and sort them after series_ordinal, eg: 1 2a 2b 3 4 5
 	local num = 1
 	local parts = {}
 	while level == 2 and entity0.claims["P527"][num]  do
 		etape[num] = 'Q'..entity0.claims["P527"][num].mainsnak.datavalue.value['numeric-id']	
        entity[num] = mw.wikibase.getEntityObject( etape[num] ) 
        if pcall(function ()
           if unexpected_condition then error() end
           series_ordinal[num] = entity[num].claims["P1545"][1].mainsnak.datavalue.value
           end        	
        ) then else series_ordinal[num] = " " end
 	    table.insert(parts, num, {nr = series_ordinal[num], Qnum = etape[num]})	
 	    num = num + 1 
    end 
    -- sort parts after nr = series_ordinal[num], not Qnum
 	table.sort(parts, function(a, b) 
 		local num1 = string.sub(a.nr, string.find(a.nr, "%d+"))
 		local num2 = string.sub(b.nr, string.find(b.nr, "%d+"))	
 		local char1, char2	
 		if 	string.find(a.nr, "%a") then char1 = string.sub(a.nr, string.find(a.nr, "%a")) else char1 = "" end
 		if 	string.find(b.nr, "%a") then char2 = string.sub(b.nr, string.find(b.nr, "%a")) else char2 = "" end	

 	 	local comp
 	 	if char1 == "" and char2 == "" then comp =  tonumber(num1) < tonumber(num2) end
 	 	if char1 ~= "" and char2 == "" then comp =  tonumber(num1) < tonumber(num2) end
 	 	if char1 == "" and char2 ~= "" then comp =  tonumber(num1) < tonumber(num2) end
 	 	if char1 ~= "" and char2 ~= "" then comp =  char1 < char2 end
        return comp end)
 		--return a.nr < b.nr end) 
 	
 	num = 1
    while level == 2 and entity0.claims["P527"][num]  do -- begin while loop 1; P527 (has part) 
      -- collect data from Wikidata in tables 
      entity[num] = mw.wikibase.getEntityObject( parts[num].Qnum )
      number0[num] = " [[File:Wikidata-logo S.svg|12px|link=d:" .. parts[num].Qnum .. "]]" 
      if pcall(function ()
         if unexpected_condition then error() end
         series_ordinal[num] = entity[num].claims["P1545"][1].mainsnak.datavalue.value
         end        	
      ) then else series_ordinal[num] = " " end

      if pcall(function()
         if unexpected_condition then error() end    	
         point_of_time[num] = entity[num].claims["P585"][1].mainsnak.datavalue.value.time 
         end       	
      ) then else point_of_time[num] = " " end

      if pcall(function()
         if unexpected_condition then error() end    	
         labels1[num] = mw.wikibase.label( 'Q'..entity[num].claims["P1427"][1].mainsnak.datavalue.value['numeric-id'] )
         labels1[num] = "[[" .. labels1[num] .. "]]"
         end      	
      ) then else labels1[num] = "n.v." end
      
      if pcall(function()
         if unexpected_condition then error() end    	
         labels2[num] = mw.wikibase.label( 'Q'..entity[num].claims["P1444"][1].mainsnak.datavalue.value['numeric-id'] )
         labels2[num] = "[[" .. labels2[num] .. "]]"
         end      	
      ) then else labels2[num] = "n.v." end

      if pcall(function() -- string.sub cuts of the first character, a plus sign, from the entity-part
         if unexpected_condition then error() end    	
         length[num] = string.sub( entity[num].claims["P2043"][1].mainsnak.datavalue.value.amount, 2, -1)
         end        	
      ) then else length[num] = " " end     

      -- find the vainqueur d'étape, Q20882747
      i = 1
      labels3[num] = "" -- "unknown3"
      number1[num] = ""
      flag1[num] = ""
      if pcall(function()
      	 if unexpected_condition then error() end   
         local t = entity[num].claims["P1346"][i] -- error or no error?
         end
      ) then -- t: no error
         while entity[num].claims["P1346"][i] do 
            if pcall(function()
               if unexpected_condition then error() end        	
         	   local t = entity[num].claims["P1346"][i].qualifiers.P642[1].datavalue.value['numeric-id']
               end
             ) then -- t: no error
             if entity[num].claims["P1346"][i].qualifiers.P642[1].datavalue.value['numeric-id'] == 20882747 then 
       	        number1[num] = 'Q'..entity[num].claims["P1346"][i].mainsnak.datavalue.value['numeric-id']            	
                if pcall(function()
                   if unexpected_condition then error() end    	
                   flag1[num] = flag ('Q'..mw.wikibase.getEntity( number1[num] ).claims["P27"][1].mainsnak.datavalue.value['numeric-id'], point_of_time[num] )
                   end        	
                ) then else -- winning racing team (time trial) has no P27 but P17
                   flag1[num] = flag ('Q'..mw.wikibase.getEntity( number1[num] ).claims["P17"][1].mainsnak.datavalue.value['numeric-id'], point_of_time[num] )
                end 
                labels3[num] = " [[" .. mw.wikibase.label(number1[num]) .. "]]"
      	        number1[num] = " [[File:Wikidata-logo S.svg|12px|link=d:" .. number1[num] .. "]]"            	
    	     else 
             end -- end if             
             else -- t: error, 
          	    number1[num] = 'Q'..entity[num].claims["P1346"][i].mainsnak.datavalue.value['numeric-id']  
         	    labels3[num] = " [[" .. mw.wikibase.label(number1[num]) .. "]]"
                if pcall(function()
                   if unexpected_condition then error() end    	
                   flag1[num] = flag ('Q'..mw.wikibase.getEntity( number1[num] ).claims["P27"][1].mainsnak.datavalue.value['numeric-id'], point_of_time[num] )
                   end        	
                ) then else -- winning racing team (time trial) has no P27 but P17
                   flag1[num] = flag ('Q'..mw.wikibase.getEntity( number1[num] ).claims["P17"][1].mainsnak.datavalue.value['numeric-id'], point_of_time[num] )
                end  
         	    number1[num] = " [[File:Wikidata-logo S.svg|12px|link=d:" .. number1[num] .. "]]" 
         	end  -- end pcall  
            i = i + 1
         end -- end while loop   
      else  -- t: error
      	 number1[num] = ""
         labels3[num] = "" -- "unknown3"
         flag1[num] = ""
      end -- end pcall      

     -- find the leader du classement général à l'issue de l'étape, Q20882763 
      i = 1
      labels4[num] = ""   --"unknown4" 
      number2[num] = ""
      flag2[num] = ""
      if pcall(function()
      	 if unexpected_condition then error() end   
         local t = entity[num].claims["P1346"][i] -- error or no error?
         end
      ) then -- t: no error
         while entity[num].claims["P1346"][i] do 
            if pcall(function()
               if unexpected_condition then error() end        	
         	   local t = entity[num].claims["P1346"][i].qualifiers.P642[1].datavalue.value['numeric-id']
               end
             ) then -- t: no error
             if entity[num].claims["P1346"][i].qualifiers.P642[1].datavalue.value['numeric-id'] == 20882763 or entity[num].claims["P1346"][i].qualifiers.P642[1].datavalue.value['numeric-id'] == 20882667 then 
      	        number2[num] = 'Q'..entity[num].claims["P1346"][i].mainsnak.datavalue.value['numeric-id']            	
                if pcall(function()
                   if unexpected_condition then error() end    	
                   flag2[num] = flag ('Q'..mw.wikibase.getEntity( number2[num] ).claims["P27"][1].mainsnak.datavalue.value['numeric-id'], point_of_time[num] )
                   end        	
                ) then else -- winning racing team (time trial) has no P27 but P17
                   flag2[num] = flag ('Q'..mw.wikibase.getEntity( number2[num] ).claims["P17"][1].mainsnak.datavalue.value['numeric-id'], point_of_time[num] )
                end 
                labels4[num] = " [[" .. mw.wikibase.label(number2[num]) .. "]]"
      	        number2[num] = " [[File:Wikidata-logo S.svg|12px|link=d:" .. number2[num] .. "]]"            	
    	     else 
             end -- end if             
             else -- t: error, 
         	    number2[num] = 'Q'..entity[num].claims["P1346"][i].mainsnak.datavalue.value['numeric-id']  
         	    labels4[num] = " [[" .. mw.wikibase.label(number2[num]) .. "]]"
                if pcall(function()
                   if unexpected_condition then error() end    	
                   flag2[num] = flag ('Q'..mw.wikibase.getEntity( number2[num] ).claims["P27"][1].mainsnak.datavalue.value['numeric-id'], point_of_time[num] )
                   end        	
                ) then else -- winning racing team (time trial) has no P27 but P17
                   flag2[num] = flag ('Q'..mw.wikibase.getEntity( number2[num] ).claims["P17"][1].mainsnak.datavalue.value['numeric-id'], point_of_time[num] )
                end  
         	    number2[num] = " [[File:Wikidata-logo S.svg|12px|link=d:" .. number2[num] .. "]]" 
         	end  -- end pcall  
            i = i + 1
         end -- end while loop   
      else  -- t: error
      	 number2[num] = ""
         labels4[num] = "" --"unknown4"
         flag2[num] = ""
      end -- end pcall      

      if pcall(function()
         if unexpected_condition then error() end
         -- find the type of stages
         i = 1
         stage[num] = ""
         uu = entity[num].claims["P31"][i].mainsnak.datavalue.value['numeric-id']
         while entity[num].claims["P31"][i] do        
           if uu == 20646667 then stage[num] = typeofstage('plain stage') end
           if uu == 20646670 then stage[num] = typeofstage('hilly stage') end
           if uu == 20680270 then stage[num] = typeofstage('intermediate stage') end
           if uu == 20646668 then stage[num] = typeofstage('mountain stage') end
           if uu == 485321 then stage[num] = typeofstage('time trial stage') end
           if uu == 2266066 then stage[num] = typeofstage('time trial stage') end
           if uu == 2348250 then stage[num] = typeofstage('time trial stage') end
           if uu == 20679712 then stage[num] = typeofstage('uphill time trial stage') end
         i = i + 1	
         end 
         end      	
      ) then else stage[num] = " " end     

     _, _, y[num], m[num], d[num] = string.find(point_of_time[num], "(%d+)-(%d+)-(%d+)") -- d = day, m = month

    num = num + 1 
    end -- end while loop 1

    -- table corrections
    local a = {}
    a[1] = "<sup>re</sup> étape"
    for i=2, num-1 do a[i] = "<sup>e</sup> étape" end

    -- build table for output
    local table_center = ""
    for var=1, num-1 do
    	local a, b 
    	a, _ = string.gsub(series_ordinal[var], "%a", "") -- 20, not 20a
   		if string.find(series_ordinal[var], "%a") then b = string.sub(series_ordinal[var], string.find(series_ordinal[var], "%a")) 
 		else b = "" end
     	local ee, er = wikilinks(series_ordinal[var], a, b)

        table_center = table_center.."<tr><td>".."[["..er.."|"..ee.."]]"..number0[var].."</td><td>"..d[var].."."..m[var].."</td><td>"..labels1[var].." – "..labels2[var]..stage[var].."</td>" 
        table_center = table_center.."<td style='text-align:center'>"..length[var].." </td><td>"..flag1[var]..labels3[var]..number1[var].."</td>"
        table_center = table_center.."<td>"..flag2[var]..labels4[var]..number2[var].."</td></tr>"
    end
    if level == 1 then return table_first .. table.concat(table_proto) .. table_last end

    return table_first .. table.concat(table_proto) .. table_center .. table_last 
end

 function typeofstage(x)
 	local y = ""
 	if x == 'plain stage' then y = "[[File:Plainstage.svg|border|right|20px]]" end
 	if x == 'hilly stage' then y = "[[File:Hillystage.svg|border|right|20px]]" end
  	if x == 'intermediate stage' then y = "[[File:Mediummountainstage.svg|right|border|20px]]" end	
  	if x == 'mountain stage' then y = "[[File:Mountainstage.svg|border|right|20px]]" end	
  	if x == 'time trial stage' then y = "[[File:Time Trial.svg|right|20px]]" end
  	if x == 'uphill time trial stage' then y = "[[File:Mountainstage.svg|border|right|20px]]" end
   	if x == 'rest day' then y = "[[File:Stage rest day.svg|border|right|20px]]" end 
 return y
 end

 function flag (x, date)
 	_, _, yr, m, d = string.find(date, "(%d+)-(%d+)-(%d+)") -- yr = year, m = month, d = day 
 	-- yr="1970" for test 
    local year = tonumber(yr)
 	local y = ""
 	-- testing if x is the value of p27 (pays de nationalité/country of citizenship) of a person
	if x == 'Q16' then y = "[[File:Flag of Canada (Pantone).svg|border|20px]]" return y end  -- Q16 = Canada
	if x == 'Q17' then y = "[[File:Flag of Japan.svg|border|20px]]" return y end  -- Q17 = Japon
	if x == 'Q20' then y = "[[File:Flag of Norway.svg|border|20px]]" return y end  -- Q20 = Norvège
	if x == 'Q27' then y = "[[File:Flag of Ireland.svg|border|20px]]" return y end  -- Q27 = Irlande
	if x == 'Q28' then y = "[[File:Flag of Hungary.svg|border|20px]]" return y end  -- Q28 = Hongrie
 	if x == 'Q29' then if year >= 1977 and year <= 1981 then return "[[File:Flag of Spain (1977 - 1981).svg|border|left|20px]]" end y =  "[[File:Flag of Spain.svg|border|left|20px]]" return y end -- Q29 = Espagne		
	if x == 'Q30' then y = "[[File:Flag of the United States (Pantone).svg|border|20px]]" return y end  -- Q30 = États-Unis
	if x == 'Q31' then y = "[[File:Flag of Belgium (civil).svg|border|20px]]" return y end  -- Q31 = Belgique
	if x == 'Q32' then y = "[[File:Flag of Luxembourg.svg|border|20px]]" return y end  -- Q32 = Luxembourg
	if x == 'Q33' then y = "[[File:Flag of Finland.svg|border|20px]]" return y end  -- Q33 = Finlande
	if x == 'Q34' then y = "[[File:Flag of Sweden.svg|border|20px]]" return y end  -- Q34 = Suède
	if x == 'Q35' then y = "[[File:Flag of Denmark.svg|border|20px]]" return y end  -- Q35 = Danemark
	if x == 'Q36' then y = "[[File:Flag of Poland.svg|border|20px]]" return y end  -- Q36 = Pologne
	if x == 'Q37' then y = "[[File:Flag of Lithuania.svg|border|20px]]" return y end  -- Q37 = Lituanie
	if x == 'Q38' then y = "[[File:Flag of Italy.svg|border|20px]]" return y end  -- Q38 = Italie
	if x == 'Q39' then y = "[[File:Flag of Switzerland (Pantone).svg|border|15px]]" return y end  -- Q39 = Suisse
	if x == 'Q40' then y = "[[File:Flag of Austria.svg|border|20px]]" return y end  -- Q40 = Autriche
	if x == 'Q41' then y = "[[File:Flag of Greece.svg|border|20px]]" return y end  -- Q41 = Grèce
	if x == 'Q43' then y = "[[File:Flag of Turkey.svg|border|20px]]" return y end  -- Q43 = Turquie
	if x == 'Q45' then y = "[[File:Flag of Portugal.svg|border|20px]]" return y end  -- Q45 = Portugal
	if x == 'Q55' then y = "[[File:Flag of the Netherlands.svg|border|20px]]" return y end  -- Q55 = Pays-Bas
	if x == 'Q77' then y = "[[File:Flag of Uruguay.svg|border|20px]]" return y end  -- Q77 = Uruguay
	if x == 'Q79' then y = "[[File:Flag of Egypt.svg|border|20px]]" return y end  -- Q79 = Égypte
	if x == 'Q96' then y = "[[File:Flag of Mexico.svg|border|20px]]" return y end  -- Q96 = Mexique
	if x == 'Q114' then y = "[[File:Flag of Kenya.svg|border|20px]]" return y end  -- Q114 = Kenya
	if x == 'Q115' then y = "[[File:Flag of Ethiopia.svg|border|20px]]" return y end  -- Q115 = Éthiopie
	if x == 'Q117' then y = "[[File:Flag of Ghana.svg|border|20px]]" return y end  -- Q117 = Ghana
	if x == 'Q142' then y = "[[File:Flag of France.svg|border|20px]]" return y end  -- Q142 = France
	if x == 'Q145' then y = "[[File:Flag of the United Kingdom.svg|border|20px]]" return y end  -- Q145 = Royaume-uni
	if x == 'Q148' then y = "[[File:Flag of the People's Republic of China.svg|border|20px]]" return y end  -- Q148 = Chine
	if x == 'Q155' then y = "[[File:Flag of Brazil.svg|border|20px]]" return y end  -- Q155 = Brésil
	if x == 'Q159' then y = "[[File:Flag of Russia.svg|border|20px]]" return y end  -- Q159 = Russie
	if x == 'Q176' then y = "[[File:Flag of Quebec.svg|border|20px]]" return y end  -- Q176 = Québec
	if x == 'Q183' then y = "[[File:Flag of Germany.svg|border|20px]]" return y end  -- Q183 = Allemagne
	if x == 'Q184' then y = "[[File:Flag of Belarus.svg|border|20px]]" return y end  -- Q184 = Biélorussie
	if x == 'Q189' then y = "[[File:Flag of Iceland.svg|border|20px]]" return y end  -- Q189 = Islande
	if x == 'Q191' then y = "[[File:Flag of Estonia.svg|border|20px]]" return y end  -- Q191 = Estonie
	if x == 'Q211' then y = "[[File:Flag of Latvia.svg|border|20px]]" return y end  -- Q211 = Lettonie
	if x == 'Q212' then y = "[[File:Flag of Ukraine.svg|border|20px]]" return y end  -- Q212 = Ukraine
	if x == 'Q213' then y = "[[File:Flag of the Czech Republic.svg|border|20px]]" return y end  -- Q213 = République tchèque
	if x == 'Q214' then y = "[[File:Flag of Slovakia.svg|border|20px]]" return y end  -- Q214 = Slovaquie
	if x == 'Q215' then y = "[[File:Flag of Slovenia.svg|border|20px]]" return y end  -- Q215 = Slovénie
	if x == 'Q217' then y = "[[File:Flag of Moldova.svg|border|20px]]" return y end  -- Q217 = Moldavie
	if x == 'Q218' then y = "[[File:Flag of Romania.svg|border|20px]]" return y end  -- Q218 = Roumanie
	if x == 'Q219' then y = "[[File:Flag of Bulgaria.svg|border|20px]]" return y end  -- Q219 = Bulgarie
	if x == 'Q221' then y = "[[File:Flag of Macedonia.svg|border|20px]]" return y end  -- Q221 = Macédoine
	if x == 'Q222' then y = "[[File:Flag of Albania.svg|border|20px]]" return y end  -- Q222 = Albanie
	if x == 'Q224' then y = "[[File:Flag of Croatia.svg|border|20px]]" return y end  -- Q224 = Croatie
	if x == 'Q225' then y = "[[File:Flag of Bosnia and Herzegovina.svg|border|20px]]" return y end  -- Q225 = Bosnie-Herzégovine
	if x == 'Q227' then y = "[[File:Flag of Azerbaijan.svg|border|20px]]" return y end  -- Q227 = Azerbaïdjan
	if x == 'Q228' then y = "[[File:Flag of Andorra.svg|border|20px]]" return y end  -- Q228 = Andorre
	if x == 'Q229' then y = "[[File:Flag of Cyprus (1960-2006).svg|border|20px]]" return y end  -- Q229 = Chypre
	if x == 'Q230' then y = "[[File:Flag of Georgia.svg|border|20px]]" return y end  -- Q230 = Géorgie
	if x == 'Q232' then y = "[[File:Flag of Kazakhstan.svg|border|20px]]" return y end  -- Q232 = Kazakhstan
	if x == 'Q233' then y = "[[File:Flag of Malta.svg|border|20px]]" return y end  -- Q233 = Malte
	if x == 'Q235' then y = "[[File:Flag of Monaco.svg|border|20px]]" return y end  -- Q235 = Monaco
	if x == 'Q236' then y = "[[File:Flag of Montenegro.svg|border|20px]]" return y end  -- Q236 = Monténégro
	if x == 'Q237' then y = "[[File:Flag of the Vatican City.svg|border|15px]]" return y end  -- Q237 = Vatican
	if x == 'Q238' then y = "[[File:Flag of San Marino.svg|border|20px]]" return y end  -- Q238 = Saint-Marin
	if x == 'Q241' then y = "[[File:Flag of Cuba.svg|border|20px]]" return y end  -- Q241 = Cuba
	if x == 'Q242' then y = "[[File:Flag of Belize.svg|border|20px]]" return y end  -- Q242 = Belize
	if x == 'Q244' then y = "[[File:Flag of Barbados.svg|border|20px]]" return y end  -- Q244 = Barbade
	if x == 'Q252' then y = "[[File:Flag of Indonesia.svg|border|20px]]" return y end  -- Q252 = Indonésie
	if x == 'Q258' then y = "[[File:Flag of South Africa.svg|border|20px]]" return y end  -- Q258 = Afrique du Sud
	if x == 'Q262' then y = "[[File:Flag of Algeria.svg|border|20px]]" return y end  -- Q262 = Algérie
	if x == 'Q265' then y = "[[File:Flag of Uzbekistan.svg|border|20px]]" return y end  -- Q265 = Ouzbékistan
	if x == 'Q298' then y = "[[File:Flag of Chile.svg|border|20px]]" return y end  -- Q298 = Chili
	if x == 'Q334' then y = "[[File:Flag of Singapore.svg|border|20px]]" return y end  -- Q334 = Singapour
	if x == 'Q347' then y = "[[File:Flag of Liechtenstein.svg|border|20px]]" return y end  -- Q347 = Liechtenstein
	if x == 'Q398' then y = "[[File:Flag of Bahrain.svg|border|20px]]" return y end  -- Q398 = Bahreïn
	if x == 'Q399' then y = "[[File:Flag of Armenia.svg|border|20px]]" return y end  -- Q399 = Arménie
	if x == 'Q403' then y = "[[File:Flag of Serbia.svg|border|20px]]" return y end  -- Q403 = Serbie
	if x == 'Q408' then y = "[[File:Flag of Australia (converted).svg|border|20px]]" return y end  -- Q408 = Australie
	if x == 'Q414' then y = "[[File:Flag of Argentina.svg|border|20px]]" return y end  -- Q414 = Argentine
	if x == 'Q419' then y = "[[File:Flag of Peru.svg|border|20px]]" return y end  -- Q419 = Pérou
	if x == 'Q423' then y = "[[File:Flag of North Korea.svg|border|20px]]" return y end  -- Q423 = Corée du Nord
	if x == 'Q424' then y = "[[File:Flag of Cambodia.svg|border|20px]]" return y end  -- Q424 = Cambodge
	if x == 'Q574' then y = "[[File:Flag of East Timor.svg|border|20px]]" return y end  -- Q574 = Timor oriental
	if x == 'Q657' then y = "[[File:Flag of Chad.svg|border|20px]]" return y end  -- Q657 = Tchad
	if x == 'Q664' then y = "[[File:Flag of New Zealand.svg|border|20px]]" return y end  -- Q664 = Nouvelle-Zélande
	if x == 'Q668' then y = "[[File:Flag of India.svg|border|20px]]" return y end  -- Q668 = Inde
	if x == 'Q672' then y = "[[File:Flag of Tuvalu.svg|border|20px]]" return y end  -- Q672 = Tuvalu
	if x == 'Q678' then y = "[[File:Flag of Tonga.svg|border|20px]]" return y end  -- Q678 = Tonga
	if x == 'Q683' then y = "[[File:Flag of Samoa.svg|border|20px]]" return y end  -- Q683 = Samoa
	if x == 'Q685' then y = "[[File:Flag of the Solomon Islands.svg|border|20px]]" return y end  -- Q685 = Salomon
	if x == 'Q686' then y = "[[File:Flag of Vanuatu.svg|border|20px]]" return y end  -- Q686 = Vanuatu
	if x == 'Q691' then y = "[[File:Flag of Papua New Guinea.svg|border|20px]]" return y end  -- Q691 = Papouasie-Nouvelle-Guinée
	if x == 'Q695' then y = "[[File:Flag of Palau.svg|border|20px]]" return y end  -- Q695 = Palaos
	if x == 'Q697' then y = "[[File:Flag of Nauru.svg|border|20px]]" return y end  -- Q697 = Nauru
	if x == 'Q702' then y = "[[File:Flag of the Federated States of Micronesia.svg|border|20px]]" return y end  -- Q702 = Micronésie
	if x == 'Q709' then y = "[[File:Flag of the Marshall Islands.svg|border|20px]]" return y end  -- Q709 = Îles Marshall
	if x == 'Q710' then y = "[[File:Flag of Kiribati.svg|border|20px]]" return y end  -- Q710 = Kiribati
	if x == 'Q711' then y = "[[File:Flag of Mongolia.svg|border|20px]]" return y end  -- Q711 = Mongolie
	if x == 'Q712' then y = "[[File:Flag of Fiji.svg|border|20px]]" return y end  -- Q712 = Fidji
	if x == 'Q717' then y = "[[File:Flag of Venezuela.svg|border|20px]]" return y end  -- Q717 = Venezuela
	if x == 'Q730' then y = "[[File:Flag of Suriname.svg|border|20px]]" return y end  -- Q730 = Suriname
	if x == 'Q733' then y = "[[File:Flag of Paraguay.svg|border|20px]]" return y end  -- Q733 = Paraguay
	if x == 'Q734' then y = "[[File:Flag of Guyana.svg|border|20px]]" return y end  -- Q734 = Guyana
	if x == 'Q736' then y = "[[File:Flag of Ecuador.svg|border|20px]]" return y end  -- Q736 = Équateur
	if x == 'Q739' then y = "[[File:Flag of Colombia.svg|border|20px]]" return y end  -- Q739 = Colombie
	if x == 'Q750' then y = "[[File:Flag of Bolivia (state).svg|border|20px]]" return y end  -- Q750 = Bolivie
	if x == 'Q754' then y = "[[File:Flag of Trinidad and Tobago.svg|border|20px]]" return y end  -- Q754 = Trinité-et-Tobago
	if x == 'Q757' then y = "[[File:Flag of Saint Vincent and the Grenadines.svg|border|20px]]" return y end  -- Q757 = Saint-Vincent-et-les-Grenadines
	if x == 'Q760' then y = "[[File:Flag of Saint Lucia.svg|border|20px]]" return y end  -- Q760 = Sainte-Lucie
	if x == 'Q763' then y = "[[File:Flag of Saint Kitts and Nevis.svg|border|20px]]" return y end  -- Q763 = Saint-Christophe-et-Niévès
	if x == 'Q766' then y = "[[File:Flag of Jamaica.svg|border|20px]]" return y end  -- Q766 = Jamaïque
	if x == 'Q769' then y = "[[File:Flag of Grenada.svg|border|20px]]" return y end  -- Q769 = Grenade
	if x == 'Q774' then y = "[[File:Flag of Guatemala.svg|border|20px]]" return y end  -- Q774 = Guatemala
	if x == 'Q778' then y = "[[File:Flag of the Bahamas.svg|border|20px]]" return y end  -- Q778 = Bahamas
	if x == 'Q781' then y = "[[File:Flag of Antigua and Barbuda.svg|border|20px]]" return y end  -- Q781 = Antigua-et-Barbuda
	if x == 'Q783' then y = "[[File:Flag of Honduras.svg|border|20px]]" return y end  -- Q783 = Honduras
	if x == 'Q784' then y = "[[File:Flag of Dominica.svg|border|20px]]" return y end  -- Q784 = Dominique
	if x == 'Q786' then y = "[[File:Flag of the Dominican Republic.svg|border|20px]]" return y end  -- Q786 = République dominicaine
	if x == 'Q790' then y = "[[File:Flag of Haiti.svg|border|20px]]" return y end  -- Q790 = Haïti
	if x == 'Q792' then y = "[[File:Flag of El Salvador.svg|border|20px]]" return y end  -- Q792 = Salvador
	if x == 'Q794' then y = "[[File:Flag of Iran.svg|border|20px]]" return y end  -- Q794 = Iran
	if x == 'Q796' then y = "[[File:Flag of Iraq.svg|border|20px]]" return y end  -- Q796 = Irak
	if x == 'Q800' then y = "[[File:Flag of Costa Rica.svg|border|20px]]" return y end  -- Q800 = Costa Rica
	if x == 'Q801' then y = "[[File:Flag of Israel.svg|border|20px]]" return y end  -- Q801 = Israël
	if x == 'Q804' then y = "[[File:Flag of Panama.svg|border|20px]]" return y end  -- Q804 = Panama
	if x == 'Q805' then y = "[[File:Flag of Yemen.svg|border|20px]]" return y end  -- Q805 = Yémen
	if x == 'Q810' then y = "[[File:Flag of Jordan.svg|border|20px]]" return y end  -- Q810 = Jordanie
	if x == 'Q811' then y = "[[File:Flag of Nicaragua.svg|border|20px]]" return y end  -- Q811 = Nicaragua
	if x == 'Q813' then y = "[[File:Flag of Kyrgyzstan.svg|border|20px]]" return y end  -- Q813 = Kirghizistan
	if x == 'Q817' then y = "[[File:Flag of Kuwait.svg|border|20px]]" return y end  -- Q817 = Koweït
	if x == 'Q819' then y = "[[File:Flag of Laos.svg|border|20px]]" return y end  -- Q819 = Laos
	if x == 'Q822' then y = "[[File:Flag of Lebanon.svg|border|20px]]" return y end  -- Q822 = Liban
	if x == 'Q826' then y = "[[File:Flag of Maldives.svg|border|20px]]" return y end  -- Q826 = Maldives
	if x == 'Q833' then y = "[[File:Flag of Malaysia.svg|border|20px]]" return y end  -- Q833 = Malaisie
	if x == 'Q836' then y = "[[File:Flag of Myanmar.svg|border|20px]]" return y end  -- Q836 = Birmanie
	if x == 'Q837' then y = "[[File:Flag of Nepal.svg|border|15px]]" return y end  -- Q837 = Népal
	if x == 'Q842' then y = "[[File:Flag of Oman.svg|border|20px]]" return y end  -- Q842 = Oman
	if x == 'Q843' then y = "[[File:Flag of Pakistan.svg|border|20px]]" return y end  -- Q843 = Pakistan
	if x == 'Q846' then y = "[[File:Flag of Qatar.svg|border|20px]]" return y end  -- Q846 = Qatar
	if x == 'Q851' then y = "[[File:Flag of Saudi Arabia.svg|border|20px]]" return y end  -- Q851 = Arabie saoudite
	if x == 'Q854' then y = "[[File:Flag of Sri Lanka.svg|border|20px]]" return y end  -- Q854 = Sri Lanka
	if x == 'Q858' then y = "[[File:Flag of Syria.svg|border|20px]]" return y end  -- Q858 = Syrie
	if x == 'Q863' then y = "[[File:Flag of Tajikistan.svg|border|20px]]" return y end  -- Q863 = Tadjikistan
	if x == 'Q865' then y = "[[File:Flag of the Republic of China.svg|border|20px]]" return y end  -- Q865 = Taïwan
	if x == 'Q869' then y = "[[File:Flag of Thailand.svg|border|20px]]" return y end  -- Q869 = Thaïlande
	if x == 'Q874' then y = "[[File:Flag of Turkmenistan.svg|border|20px]]" return y end  -- Q874 = Turkménistan
	if x == 'Q878' then y = "[[File:Flag of the United Arab Emirates.svg|border|20px]]" return y end  -- Q875 = Émirats arabes unis
	if x == 'Q881' then y = "[[File:Flag of Vietnam.svg|border|20px]]" return y end  -- Q881 = Viêt Nam
	if x == 'Q884' then y = "[[File:Flag of South Korea.svg|border|20px]]" return y end  -- Q884 = Corée du Sud
	if x == 'Q889' then y = "[[File:Flag of Afghanistan.svg|border|20px]]" return y end  -- Q889 = Afghanistan
	if x == 'Q902' then y = "[[File:Flag of Bangladesh.svg|border|20px]]" return y end  -- Q902 = Bangladesh
	if x == 'Q912' then y = "[[File:Flag of Mali.svg|border|20px]]" return y end  -- Q912 = Mali
	if x == 'Q916' then y = "[[File:Flag of Angola.svg|border|20px]]" return y end  -- Q916 = Angola
	if x == 'Q917' then y = "[[File:Flag of Bhutan.svg|border|20px]]" return y end  -- Q917 = Bhoutan
	if x == 'Q921' then y = "[[File:Flag of Brunei.svg|border|20px]]" return y end  -- Q921 = Brunei
	if x == 'Q924' then y = "[[File:Flag of Tanzania.svg|border|20px]]" return y end  -- Q924 = Tanzanie
	if x == 'Q928' then y = "[[File:Flag of the Philippines.svg|border|20px]]" return y end  -- Q928 = Philippines
	if x == 'Q929' then y = "[[File:Flag of the Central African Republic.svg|border|20px]]" return y end  -- Q929 = République centrafricaine
	if x == 'Q945' then y = "[[File:Flag of Togo.svg|border|20px]]" return y end  -- Q945 = Togo
	if x == 'Q948' then y = "[[File:Flag of Tunisia.svg|border|20px]]" return y end  -- Q948 = Tunisie
	if x == 'Q953' then y = "[[File:Flag of Zambia.svg|border|20px]]" return y end  -- Q953 = Zambie
	if x == 'Q954' then y = "[[File:Flag of Zimbabwe.svg|border|20px]]" return y end  -- Q954 = Zimbabwe
	if x == 'Q958' then y = "[[File:Flag of South Sudan.svg|border|20px]]" return y end  -- Q958 = Soudan du Sud
	if x == 'Q962' then y = "[[File:Flag of Benin.svg|border|20px]]" return y end  -- Q962 = Bénin
	if x == 'Q963' then y = "[[File:Flag of Botswana.svg|border|20px]]" return y end  -- Q963 = Botswana
	if x == 'Q965' then y = "[[File:Flag of Burkina Faso.svg|border|20px]]" return y end  -- Q965 = Burkina faso
	if x == 'Q967' then y = "[[File:Flag of Burundi.svg|border|20px]]" return y end  -- Q967 = Burundi
	if x == 'Q970' then y = "[[File:Flag of the Comoros.svg|border|20px]]" return y end  -- Q970 = Comores
	if x == 'Q971' then y = "[[File:Flag of the Republic of the Congo.svg|border|20px]]" return y end  -- Q971 = République du Congo
	if x == 'Q974' then y = "[[File:Flag of the Democratic Republic of the Congo.svg|border|20px]]" return y end  -- Q974 = République démocratique du Congo
	if x == 'Q977' then y = "[[File:Flag of Djibouti.svg|border|20px]]" return y end  -- Q977 = Djibouti
	if x == 'Q983' then y = "[[File:Flag of Equatorial Guinea.svg|border|20px]]" return y end  -- Q983 = Guinée équatoriale
	if x == 'Q986' then y = "[[File:Flag of Eritrea.svg|border|20px]]" return y end  -- Q986 = Érythrée
	if x == 'Q1000' then y = "[[File:Flag of Gabon.svg|border|20px]]" return y end  -- Q1000 = Gabon
	if x == 'Q1005' then y = "[[File:Flag of The Gambia.svg|border|20px]]" return y end  -- Q1005 = Gambie
	if x == 'Q1006' then y = "[[File:Flag of Guinea.svg|border|20px]]" return y end  -- Q1006 = Guinée
	if x == 'Q1007' then y = "[[File:Flag of Guinea-Bissau.svg|border|20px]]" return y end  -- Q1007 = Guinée-Bissau
	if x == 'Q1008' then y = "[[File:Flag of Côte d'Ivoire.svg|border|20px]]" return y end  -- Q1008 = Côte d'Ivoire
	if x == 'Q1009' then y = "[[File:Flag of Cameroon.svg|border|20px]]" return y end  -- Q1009 = Cameroun
	if x == 'Q1011' then y = "[[File:Flag of Cape Verde.svg|border|20px]]" return y end  -- Q1011 = Cap-Vert
	if x == 'Q1013' then y = "[[File:Flag of Lesotho.svg|border|20px]]" return y end  -- Q1013 = Lesotho
	if x == 'Q1014' then y = "[[File:Flag of Liberia.svg|border|20px]]" return y end  -- Q1014 = Liberia
	if x == 'Q1016' then y = "[[File:Flag of Libya (1951).svg|border|20px]]" return y end  -- Q1016 = Libye
	if x == 'Q1019' then y = "[[File:Flag of Madagascar.svg|border|20px]]" return y end  -- Q1019 = Madagascar
	if x == 'Q1020' then y = "[[File:Flag of Malawi.svg|border|20px]]" return y end  -- Q1020 = Malawi
	if x == 'Q1025' then y = "[[File:Flag of Mauritania.svg|border|20px]]" return y end  -- Q1025 = Mauritanie
	if x == 'Q1027' then y = "[[File:Flag of Mauritius.svg|border|20px]]" return y end  -- Q1027 = Maurice
	if x == 'Q1028' then y = "[[File:Flag of Morocco.svg|border|20px]]" return y end  -- Q1028 = Maroc
	if x == 'Q1029' then y = "[[File:Flag of Mozambique.svg|border|20px]]" return y end  -- Q1029 = Mozambique
	if x == 'Q1030' then y = "[[File:Flag of Namibia.svg|border|20px]]" return y end  -- Q1030 = Namibie
	if x == 'Q1032' then y = "[[File:Flag of Niger.svg|border|20px]]" return y end  -- Q1032 = Niger
	if x == 'Q1033' then y = "[[File:Flag of Nigeria.svg|border|20px]]" return y end  -- Q1033 = Nigeria
	if x == 'Q1036' then y = "[[File:Flag of Uganda.svg|border|20px]]" return y end  -- Q1036 = Ouganda
	if x == 'Q1037' then y = "[[File:Flag of Rwanda.svg|border|20px]]" return y end  -- Q1037 = Rwanda
	if x == 'Q1039' then y = "[[File:Flag of Sao Tome and Principe.svg|border|20px]]" return y end  -- Q1039 = Sao Tomé-et-Principe
	if x == 'Q1041' then y = "[[File:Flag of Senegal.svg|border|20px]]" return y end  -- Q1041 = Sénégal
	if x == 'Q1042' then y = "[[File:Flag of Seychelles.svg|border|20px]]" return y end  -- Q1042 = Seychelles
	if x == 'Q1044' then y = "[[File:Flag of Sierra Leone.svg|border|20px]]" return y end  -- Q1044 = Sierra Leone
	if x == 'Q1045' then y = "[[File:Flag of Somalia.svg|border|20px]]" return y end  -- Q1045 = Somalie
	if x == 'Q1049' then y = "[[File:Flag of Sudan.svg|border|20px]]" return y end  -- Q1049 = Soudan
	if x == 'Q1050' then y = "[[File:Flag of Swaziland.svg|border|20px]]" return y end  -- Q1050 = Swaziland
	if x == 'Q1246' then y = "[[File:Flag of Kosovo.svg|border|20px]]" return y end  -- Q1246 = Kosovo
	if x == 'Q15180' then y = "[[File:Flag of the Soviet Union.svg|border|20px]]" return y end  -- Q15180 = Union des républiques socialistes soviétiques
	if x == 'Q16957' then y = "[[File:Flag of East Germany.svg|border|20px]]" return y end  -- Q16957 = République démocratique allemande
	if x == 'Q26988' then y = "[[File:Flag of the Cook Islands.svg|border|20px]]" return y end  -- Q26988 = Îles cook
	if x == 'Q28513' then y = "[[File:Flag of Austria-Hungary (1869-1918).svg|border|20px]]" return y end  -- Q28513 = Autriche-Hongrie
	if x == 'Q33946' then y = "[[File:Flag of the Czech Republic.svg|border|20px]]" return y end  -- Q33946 = Tchécoslovaquie
	if x == 'Q34020' then y = "[[File:Flag of Niue.svg|border|20px]]" return y end  -- Q34020 = Niue
	if x == 'Q34266' then y = "[[File:Flag of Russia.svg|border|20px]]" return y end  -- Q34266 = Empire russe
	if x == 'Q36704' then y = "[[File:Flag of SFR Yugoslavia.svg|border|20px]]" return y end  -- Q36704 = Yougoslavie
 return y

end  	
return p