Modul:Cycling race: Forskelle mellem versioner

Content deleted Content added
m fjerner skjul/vis
opdatering fra Wikidata
Linje 4:
wiki = "fr"
end
--import translation
local l10n = mw.loadData("Module:Cycling race/l10n")
 
--import data
local data = mw.loadData("Module:Cycling race/data")
 
local contentLanguage = mw.getContentLanguage()
Line 12 ⟶ 17:
-- == Structure of the code ==
-- I) Constant
-- II) Basic functionsTranslation
-- III) Basic functions
-- IV) Functions less basic called from other functions
-----A) Time functions
-----B) Link functions
Line 19 ⟶ 25:
-----D) Jersey, flag functions
-----E) Other (winner)
-- IV) Translation
-- V) Main functions
----- A) Function race reference
Line 29 ⟶ 34:
----- F) Classifications
----- G) Infobox
----- H) TeamRace rosterinfobox
----- I) Team roster
----- J) Function list of winners (palmarès)
----- JK) List of stages
----- KL) List of stages classification
----- IM) Start list
----- JN) Rider ranking
----- O) Rider infobox
 
--Tip: search "--==" to navigate between the sections
 
--== I) Classes declared as global ==
-- Class of a cycling race. Class is: 1.UWT, 2.UWT, 1.HC, ... add new classes, no problem
local class = { "Q22231106", "Q22231107", "Q22231108", "Q22231109", "Q22231110", "Q22231111", "Q22231112",
"Q22231113", "Q22231114", "Q22231115", "Q22231116", "Q22231117", "Q22231118", "Q22231119", "Q23015458",
"Q23005601", "Q23005603", "Q74275170", "Q74275176" }
local classes = {
Q22231106 = true, Q22231107 = true, Q22231108 = true, Q22231109 = true, Q22231110 = true, Q22231111 = true,
Q22231112 = true, Q22231113 = true, Q22231114 = true, Q22231115 = true, Q22231116 = true, Q22231117 = true,
Q22231118 = true, Q22231119 = true, Q23015458 = true, Q23005601 = true, Q23005603 = true, Q74275170 = true,
Q74275176 = true
}
 
--Data that requires # functions and cannot be called with mw.loadData
local class_2x = {"Q22231107", "Q23005603", "Q22231115", "Q22231109", "Q22231112", "Q22231113", "Q22231117", "Q74275176"} --multi stage races
local class = {
local class_without2x = { "Q22231106", "Q22231108", "Q22231110", "Q22231111", "Q22231114", "Q22231116",
"Q60669124", -- Am (Q60669124)
"Q22231118", "Q22231119", "Q23015458", "Q23005601", "Q74275170" }
local class_champ = { "Q22231118", "Q22231119", "Q23015458"}-- CC (Q22231118)
"Q23015458", -- CDM (Q23015458)
"Q22231119", -- CN (Q22231119)
"Q60181400", -- NE (Q60181400)
"Q23005601", -- 1.WWT (Q23005601)
"Q23005603", -- 2.WWT (Q23005603)
"Q22231106", -- 1.UWT (Q22231106)
"Q22231107", -- 2.UWT (Q22231107)
"Q74275170", -- 1.Pro (Q74275170)
"Q74275176", -- 2.Pro (Q74275176)
"Q101069484", -- 1.PT (Q101069484)
"Q101052547", -- 2.PT (Q101052547)
"Q22231108", -- 1.HC (Q22231108)
"Q22231109", -- 2.HC (Q22231109)
"Q22231110", -- 1.1 (Q22231110)
"Q22231111", -- 1.2 (Q22231111)
"Q30336909", -- 1.3 (Q30336909)
"Q30339152", -- 1.4 (Q30339152)
"Q98686837", -- 1.5 (Q98686837)
"Q60669131", -- 1.7.1 (Q60669131)
"Q22231112", -- 2.1 (Q22231112)
"Q22231113", -- 2.2 (Q22231113)
"Q101052391", -- 2.3 (Q101052391)
"Q101052353", -- 2.4 (Q101052353)
"Q29866603", -- 2.5 (Q29866603)
"Q101049923", -- 2.6 (Q101049923)
"Q22231116", -- 1.2U (Q22231116)
"Q22231117", -- 2.2U (Q22231117)
"Q22231114", -- 1.Ncup (Q22231114)
"Q22231115" -- 2.Ncup (Q22231115)
}
 
local class_without2x = {
"Q23005601", -- 1.WWT (Q23005601)
"Q22231106", -- 1.UWT (Q22231106)
"Q74275170", -- 1.Pro (Q74275170)
"Q101069484", -- 1.PT (Q101069484)
"Q22231108", -- 1.HC (Q22231108)
"Q22231110", -- 1.1 (Q22231110)
"Q22231111", -- 1.2 (Q22231111)
"Q30336909", -- 1.3 (Q30336909)
"Q30339152", -- 1.4 (Q30339152)
"Q98686837", -- 1.5 (Q98686837)
"Q60669131", -- 1.7.1 (Q60669131)
"Q22231116", -- 1.2U (Q22231116)
"Q22231114" -- 1.Ncup (Q22231114)
}
 
local class_champ = { "Q22231118", "Q22231119", "Q23015458"}
local stages = {'Q18131152', 'Q20646667', 'Q20646670', 'Q20680270', 'Q20646668', 'Q20679712', 'Q2348250', 'Q2266066', 'Q485321'}
local UCI_Circuits = {
'Q1194340', -- Europa
'Q1063423', -- Asia
'Q1063430', -- America
'Q268357', -- Africa
'Q1039648', -- Oceania
'Q1329578', -- ProTour
'Q12270097', -- World Calendar
'Q635366', -- World Tour
'Q21075974', -- Wonen World Tour
'Q1693153', -- Women's Road World Rankings
"Q71580493"-- ProSeries
}
local class_2x = {
"Q23005603", -- 2.WWT (Q23005603)
"Q22231107", -- 2.UWT (Q22231107)
"Q74275176", -- 2.Pro (Q74275176)
"Q101052547", -- 2.PT (Q101052547)
"Q22231109", -- 2.HC (Q22231109)
"Q22231112", -- 2.1 (Q22231112)
"Q22231113", -- 2.2 (Q22231113)
"Q101052391", -- 2.3 (Q101052391)
"Q101052353", -- 2.4 (Q101052353)
"Q29866603", -- 2.5 (Q29866603)
"Q101049923", -- 2.6 (Q101049923)
"Q22231117", -- 2.2U (Q22231117)
"Q22231115" -- 2.Ncup (Q22231115)
}
 
--dictionnaries
local class_sort={["Q22231106"]='01', ["Q22231107"]='01', ["Q23005601"]='01', ["Q23005603"]='01', ["Q22231115"]='01', -- 1.UWT, 2.UWT, 1.WWT, 2.WWT, 2.Ncup
local classes=data.classes
["Q22231114"]='02', ["Q22231109"]='03', ["Q22231108"]='04', ["Q22231112"]='05', ["Q22231110"]='06', -- 1.Ncup, 2.HC, 1.HC, 2.1, 1.1
local class_sort=data.class_sort
["Q22231113"]='07', ["Q22231117"]='07', ["Q22231111"]='08', ["Q22231116"]='08', ["Q22231119"]='09', --2.2, 2.2U, 1.2, 1.2U, CN
local bg_color_table = data.bg_color_table
["Q22231118"]='13', ["Q23015458"]='15', ["Q74275176"]='03', ["Q74275170"]='04' }
local stages = {'Q18131152', 'Q20646667', 'Q20646670', 'Q20680270', 'Q20646668', 'Q20679712', 'Q2348250', 'Q2266066', 'Q485321'}
-- UCI Europe Tour,..., UCI ProTour, UCI World Calendar, UCI WorldTour, UCI Women’s WorldTour, UCI Women's Road World Rankings
local UCI_Circuits = {'Q1194340', 'Q1063423', 'Q1063430', 'Q268357', 'Q1039648', 'Q1329578', 'Q12270097', 'Q635366', 'Q21075974', 'Q1693153', "Q71580493"}
 
local available, translations = pcall(require, "Module:Cycling race/lang")
Line 75 ⟶ 148:
end
 
local standardtablecss=data.standardtablecss_part1..textalign..data.standardtablecss_part2
local standardtablecss="border:1px solid rgb(200,200,200); color:black; margin:0 0 0.5em 0;"..
"background-color:rgb(255, 255, 255); padding:5px; clear:left; text-align:" ..
textalign .. "; font-size:85%; line-height:1.6em;"
 
local no_country_calendar={'ru'}
Line 83 ⟶ 154:
local no_country_classification={'es','da','no','ru'}
local no_roll_startlist={'fr','da','no','ar'}
local display_language_in_riderinfobox={'ru'}
local display_flag_in_riderinfobox={'ru'}
local display_birthnameastitle_in_riderinfobox={'ru'}
local display_noweight_in_riderinfobox={'fr','pl'}
 
local bg_color_table silver_theme_countries= {'da'}
["Q24257871"] ="#FFFF99" , -- Jersey yellow.svg (General)
["Q24257763"] ="#FFC0CB" , -- Jersey pink.svg (General)
["Q24257872"] ="#FF8666" , -- Jersey red.svg (General)
["Q24687408"] ="#99CBFF" , -- Jersey blue.svg (General)
["Q24258056"] ="#FFD030" , -- Jersey orange.svg (General)
["Q26696171"] ="#FFFFFF" , -- Jersey white.svg (General)
["Q24258125"] ="#BFFF80" , -- Jersey green 2.svg (General)
["Q24257991"] ="#FFD030" , -- Jersey gold.svg (General)
["Q24645208"] ="#90EE90" , -- Jersey green.svg (General)
["Q26945271"] ="#90EE90" , -- MaillotVolta.png (General)
["Q26945272"] ="#BF80FF" , -- Jersey violet.svg (General)
["Q29982321"] ="#FFFF99" , -- Jersey combined.svg (General)
["Q29594434"] ="#87CEEB" , -- Jersey green lines volta.svg (General)
["Q30132459"] ="#FFFF99" , -- Jersey yellow-bluebar.svg (General)
["Q85230888"] ="#FFD030" , -- Jersey orange.svg (General Tour Colombia)
["Q24645209"] ="#90EE90" , -- Jersey green.svg (Points)
["Q25831179"] ="#FFFFFF" , -- Jersey white.svg (Points)
["Q26919974"] ="#FF8666" , -- Jersey red.svg (Points)
["Q24687409"] ="#99CBFF" , -- Jersey blue.svg (Points)
["Q25265938"] ="#BF80FF" , -- Jersey violet.svg (Points)
["Q641083"] ="#BF80FF" , -- Jersey violet.svg (Points), Giro
["Q27114205"] ="#C0C0C0" , -- Jersey black.svg (Points)
["Q28546656"] ="#FFFF99" , -- Jersey yellow.svg (Points)
["Q28820618"] ="#87CEEB" , -- MaillotCyan.PNG (Points)
["Q29982764"] ="#FFD030" , -- Jersey orange.svg (Points)
["Q43276992"] ="#FFC0CB" , -- Jersey pink.svg (Points)
["Q47945989"] ="#6495ED" , -- Jersey dark blue.svg (Points)
["Q56449834"] ="#E0FFFF" , -- Jersey blue dotted.png (Points)
["Q56449834"] ="#DDDDDD" , -- Jersey silver.svg (Points)
["Q65557843"] ="#FF8666" , -- Jersey red-blackdots.svg (Points)
["Q62471242"] ="#99CBFF" , -- Jersey blue lines volta.svg (Points)
["Q65665708"] ="#FFC0CB" , -- Jersey polkadot.svg (Points)
["Q25265958"] ="#FFC0CB" , -- Jersey polkadot.svg (Mountain)
["Q25265959"] ="#E0FFFF" , -- Jersey blue dotted.png (Mountain)
["Q25265960"] ="#FFC0CB" , -- Jersey climbing Dauphine.png (Mountain)
["Q27670178"] ="#FF8666" , -- Jersey red.svg (Mountain)
["Q27670182"] ="#90EE90" , -- Jersey green.svg (Mountain)
["Q27670174"] ="#FFD030" , -- Jersey orange.svg (Mountain)
["Q24790519"] ="#C0C0C0" , -- Jersey grey.svg (Mountain)
["Q27670105"] ="#C0C0C0" , -- Jersey blackdots.png (Mountain)
["Q28604413"] ="#99CBFF" , -- Jersey blue.svg (Mountain)
["Q25266023"] ="#F5DEB3" , -- Jersey brown.svg (Mountain)
["Q27670126"] ="#FF8666" , -- Jersey granate.svg (Mountain)
["Q25831602"] ="#FF69B4" , -- Jersey rosa.svg (Mountain)
["Q29168665"] ="#FFC0CB" , -- Jersey pink.svg (Mountain)
["Q29823248"] ="#FFFFFF" , -- Jersey white.svg (Mountain)
["Q28820591"] ="#F5DEB3" , -- Jersey red green.svg (Mountain)
["Q36859499"] ="#CCFFCC" , -- Jersey greendots.svg (Mountain)
["Q33060977"] ="#C0C0C0" , -- Jersey black.svg (Mountain)
["Q47537141"] ="#87CEEB" , -- MaillotCyan.PNG (Mountain)
["Q50822370"] ="#FFC0CB" , -- Jersey red lines volta.svg (Mountain)
["Q56246573"] ="#C0C0C0" , -- Jersey black white dotted.svg (Mountain)
["Q85231689"] ="#99CBFF" , -- Jersey blue.svg (Mountain)
["Q26858731"] ="#FFFFFF" , -- Jersey white.svg (Combinated)
["Q28823004"] ="#FFFF99" , -- Jersey combined.svg (Combinated)
["Q28604421"] ="#FFD030" , -- Jersey orange.svg (Combinated)
["Q43098388"] ="#99CBFF" , -- Jersey blue.svg (Combinated)
["Q24790627"] ="#FF8666" , -- Jersey red.svg (Sprints)
["Q25831754"] ="#99CBFF" , -- Jersey blue.svg (Sprints)
["Q26806427"] ="#90EE90" , -- Jersey green.svg (Sprints)
["Q27478100"] ="#C0C0C0" , -- Jersey black.svg (Sprints)
["Q28060932"] ="#BF80FF" , -- Jersey violet.svg (Sprints)
["Q28483869"] ="#FFFF99" , -- Jersey yellow.svg (Sprints)
["Q33134180"] ="#FF69B4" , -- Jersey rosa.svg (Sprints)
["Q42532690"] ="#E0FFFF" , -- Jersey light blue.svg (Sprints)
["Q43278032"] ="#FFC0CB" , -- Jersey polkadot.svg (Sprints)
["Q47513277"] ="#FFFFFF" , -- Jersey white.svg (Sprints)
["Q64814800"] ="#C0C0C0" , -- Jersey grey.svg (Sprints)
["Q65614883"] ="#FFFFFF" , -- Jersey white-black strip.png (Sprints)
["Q50822390"] ="#FFD030" , -- Jersey orange lines volta.svg (Sprints)
["Q62471233"] ="#FFD030" , -- Jersey orange lines volta.svg (Best young)
["Q24645383"] ="#FFFFFF" , -- Jersey white.svg (Best young)
["Q26919967"] ="#90EE90" , -- Jersey green.svg (Best young)
["Q26209148"] ="#99CBFF" , -- Jersey blue.svg (Best young)
["Q26696523"] ="#FFD030" , -- Jersey orange.svg (Best young)
["Q29229790"] ="#BF80FF" , -- Jersey violet.svg (Best young)
["Q29982765"] ="#FFC0CB" , -- Jersey pink.svg (Best young)
["Q33134078"] ="#FF8666" , -- Jersey red.svg (Best young)
["Q38929482"] ="#FFFF99" , -- Jersey yellow.svg (Best young)
["Q33026698"] ="#FF8666" , -- Jersey red.svg (Best young)
["Q56002706"] ="#87CEEB" , -- MaillotCyan.PNG (Best young)
["Q50822410"] ="#99CBFF" , -- Jersey blue lines volta.svg (Best young)
["Q85231184"] ="#FFFFFF" , -- Jersey white.svg (Best young)
["Q26953919"] ="#8FBC8F" , -- Jersey dark green.svg (Combativity)
["Q29957114"] ="#87CEEB" , -- MaillotCyan.PNG (Combativity)
["Q25265995"] ="#F5DEB3" , -- Jersey red green.svg (Combativity)
["Q29594765"] ="#C0C0C0" , -- Jersey black.svg (Combativity)
["Q30035039"] ="#FFD030" , -- Jersey orange.svg (Combativity)
["Q30035038"] ="#90EE90" , -- Jersey green.svg (Combativity)
["Q48691401"] ="#F2BC38" , -- Jersey Goldenrod.svg (Combativity)
["Q61710200"] ="#FF8666" , -- Jersey Red.svg (Combativity)
["Q31474628"] ="#99CBFF" , -- Jersey blue.svg (Nationality)
["Q27117411"] ="#FF8666" , -- Jersey red.svg (Best suisse)
["Q65935870"] ="#FFFFFF" , -- Jersey white.svg (Best suisse)
}
 
local backgroundColor="#FFDF80"
--== II) basic functions
local backgroundColorLight="#FFF7DF"
for _, value in pairs(silver_theme_countries) do -- get data if country should be printed in this wiki
if value == wiki then
backgroundColor="#EAECF0"
backgroundColorLight="#EFEFEF"
end
end
 
--== II) Translation ==
local function translate(func_name_short, index, title)
if index == nil then index=1 end -- for prologue
if index==1000 then --code for some custom function
return title
else
if func_name_short then
local func_name=func_name_short.."_translate"
if l10n[func_name][index] then
return l10n[func_name][index]
end
else
return "error: no func_name found"
end
end
end
 
function plural(num)
local plural=false --latin language
local gen_singular=false --for slavic language
local gen_plural=false --for slavic language
if num then
if num > 1 then
plural=true
if num < 5 then -- 2, 3 and 4
gen_singular = true
elseif num > 20 then
local modulo = math.fmod( num, 10)
--modulo==1 --> nothing, it is singular
if modulo>1 and modulo<5 then
gen_singular = true
elseif modulo>4 then
gen_plural=true
end
else
gen_plural=true
end
end
end
return plural, gen_singular, gen_plural
end
 
function black_list( Label)
local black_list=l10n.black_list
--[[ List of Wikipedia articles with the same lemma as the non existing rider article. Those lemmas are printed
as text "black" in the tables, not "blue" or "red". This way there will be no false wikilinks at the WhatLinksHere entry.
List should be updated maybe once a year. ]]
return black_list[Label]
end
 
local function stageLink(x, a, b) -- x= 10a: a = 10, b = a. x = 5: a = 5, b = ""
local l10nDef = {["fr"]="étape", ["en"]="stage", ["ar"]="مرحلة", ["br"]="Tennad", ["ca"]="etapa", ["cs"]="etapa", ["de"]="Etappe", ["da"]="etape", ["eo"]="Etapo",
["es"]="etapa", ["eu"]="Etapa", ["fi"]="Etappi", ["fo"]="teinur", ["hu"]="szakasz", ["it"]="Tappa", ["ja"]="ステージ", ["la"]="Statio", ["lb"]="Etapp",
["lv"]="Posms", ["mk"]="Етапа", ["nl"]="Etappe", ["no"]="etappe", ["pl"]="Etap", ["pt"]="Etapa", ["ro"]="Etapa", ["ru"]="Этап", ["sk"]="Etapa",
["sv"]="Etapp", ["ast"]="etapa" }
 
local word1, word2
word2=l10nDef[wiki]
if word2 == nil then word2=l10nDef["en"] end -- if no translation, show en translation
local word = word2
 
if wiki=="ar" then return word2 .. " " .. ( a or "" ) , "#" .. word2 .. " " .. ( a or "" ) end
 
-- fr: {{1re}} étape, {{2e}} étape
if wiki=="fr" then
if b == "" then -- series_ordinal without character
if a == "1" then word1 = "1<sup>re</sup> "..word else word1 = a.."<sup>e</sup> "..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 = "1<sup>re</sup> "..b.." "..word else word1 = a.."<sup>e</sup> "..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
if wiki=="hu" then
if b == "" then return a..". "..word, "#"..a..". "..word
else return a..b.." "..word, "#"..a..b.." "..word end
end
if wiki=="de" or wiki=="da" or wiki=="fo" or wiki=="lb" or wiki=="no" then return a..". "..b.." "..word, "#"..a..". "..b.." "..word end
if wiki=="ca" then return a.."a "..b.." "..word, "#"..a..". "..b.." "..word end
if wiki=="es" then return a..".ª "..word.." "..b, "#"..a..".ª "..word.." "..b end
if wiki=="ast" then
if b == "" then -- series_ordinal without character
if a == "1" or a == "3" then word1 = a.."ᵉʳ "..word else word1 = a.."ª "..word end -- table text = 1ᵉʳ etapa, 2ª etapa, 3ᵉʳ etapa,
if a == "1" or a == "3" then word2 = "#"..a.."ᵉʳ "..word else word2 = "#"..a.."ª "..word end --text of section header = #1ᵉʳ etapa, #2ª etapa, #3ᵉʳ etapa
return word1, word2
end
if b ~= "" then -- series_ordinal with character: instead of eg "1a re" it is "1re a"
if a == "1" or a == "3" then word1 = a.."ᵉʳ "..b.." "..word else word1 = a.."ª "..b.." "..word end -- table text = {{1ᵉʳ}} etapa, {{2ª}} etapa,
if a == "1" or a == "3" then word2 = "#"..a.."ᵉʳ "..b.." "..word else word2 = "#"..a.."ª"..b.." "..word end --text of section header = #1ᵉʳ etapa, #2ª etapa
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 word1, word2
end
 
local function typeofstage(x, typ, noborder)
-- plain, hilly, inter, ... must be "" or "any text"
-- l10nDef[""] = {plain = "", hilly="", inter='', mount='', time_prologue='', time_team='', time_indiv='', uphill='', rest=''}
local l10nDef = {
["ar"] = {plain = "مرحلة مستوية", hilly="مرحلة التلال", inter='مرحلة متوسطة', mount='مرحلة جبلية', time_prologue='مرحلة سباق ضد الساعة', time_team='مرحلة سباق الفرق ضد الساعة', time_indiv='مرحلة سباق فردي ضد الساعة', uphill='مرحلة تسلق الجبل ضد الساعة', rest='يوم راحة'},
["ast"] = {plain = "etapa llana", hilly="etapa escarpada", inter='etapa de mediu monte', mount='etapa de monte', time_prologue='prólogu', time_team='contrarreló per equipos', time_indiv='contrarreló individual', uphill='cronoescalada', rest='xornada de descansu'},
["fr"] = {plain = "étape de plaine", hilly="étape vallonnée", inter='étape de moyenne montagne', mount='étape de montagne', time_prologue='prologue', time_team='contre-la-montre par équipes', time_indiv='contre-la-montre individuel', uphill='contre-la-montre en côte', rest='étape de repos'},
["en"] = {plain = "plain stage", hilly="hilly stage", inter='intermediate stage', mount='mountain stage', time_prologue='time trial stage', time_team='team time trial stage', time_indiv='individual time trial stage', uphill='uphill time trial stage', rest='rest day'},
["br"] = {plain = "tennad plaen", hilly="tennad digompez", inter='tennad damveneziek', mount='tennad meneziek', time_prologue='prolog', time_team='ABEU a-skipailhoù', time_indiv='ABEU', uphill='', rest='devezh diskuizh'},
["ca"] = {plain = "etapa plana", hilly="etapa accidentada", inter='etapa de mitja muntanya', mount='etapa de muntanya', time_prologue='pròleg', time_team='contrarellotge per equips', time_indiv='contrarellotge individual', uphill='', rest='etapa de descans'},
["cs"] = {plain = "rovinatá etapa", hilly="", inter='kopcovitá etapa', mount='horská etapa', time_prologue='prolog', time_team='týmová časovka', time_indiv='individuální časovka', uphill='', rest=''},
["da"] = {plain = "flad etape", hilly="kuperet etape", inter='middel bjergetape', mount='bjergetape', time_prologue='prolog', time_team='holdtidskørsel', time_indiv='enkeltstart', uphill='bjergenkeltstart', rest='hviledag'},
["de"] = {plain = "Flachetappe", hilly="Hügelige Etappe", inter='Mittelschwere Etappe', mount='Hochgebirgsetappe', time_prologue='Prolog', time_team='Teamzeitfahren', time_indiv='Einzelzeitfahren', uphill='Bergzeitfahren', rest='Ruhetag'},
["eo"] = {plain = "ebena etapo", hilly="malebena etapo", inter='mezgranda montaro etapo', mount='montara etapo', time_prologue='prologo', time_team='teama kontraux-la-kronometro', time_indiv='individua kontraux-la-kronometro', uphill='malebena kontraux-la-kronometro', rest='ripoza etapo'},
["es"] = {plain = "etapa llana", hilly="etapa escarpada", inter='etapa de media montaña', mount='etapa de montaña', time_prologue='prólogo', time_team='contrarreloj por equipos', time_indiv='contrarreloj individual', uphill='cronoescalada', rest='jornada de descanso'},
["eu"] = {plain = "etapa laua", hilly="etapa gorabeheratsua", inter='bitarteko etapa', mount='mendiko etapa', time_prologue='aitzinetapa', time_team='taldekako erlojupekoa', time_indiv='banakako erlojupekoa', uphill='erlojupeko igoera', rest='atseden eguna'},
["fi"] = {plain = "Tasamaaetappi", hilly="Mäkietappi", inter='Keskivaikea vuorietappi', mount='Vuorietappi', time_prologue='', time_team='Joukkueaika-ajo', time_indiv='Henkilökohtainen aika-ajo', uphill='mäkiaika-ajo', rest='välipäivä'},
["fo"] = {plain = "Slætt", hilly="Slætt við brúgvasteinum", inter='Óslætt', mount='Fjallateinur', time_prologue='Forteinur', time_team='Liðsúkkling', time_indiv='Einkultstartur', uphill='', rest='Hvílidagur'},
["hu"] = {plain = "sík szakasz", hilly="dombos szakasz", inter='közepes hegyi szakasz', mount='hegyi szakasz', time_prologue='prolog', time_team='csapat időfutam', time_indiv='egyéni időfutam', uphill='hegyi időfutam', rest=''},
["ja"] = {plain = "平坦ステージ", hilly="丘陵ステージ", inter='中間ステージ', mount='山岳ステージ', time_prologue='タイムトライアルステージ', time_team='チームタイムトライアルステージ', time_indiv='個人タイムトライアルステージ', uphill='アップヒルタイムトライアルステージ', rest='休養日'},
["lb"] = {plain = "Flaach Etapp", hilly="Hiwweleg Etapp", inter='Mëttelschwéier Etapp', mount='Biergetapp', time_prologue='Prolog', time_team='Contre-la-montre (Ekipp)', time_indiv='Contre-la-montre (Eenzel)', uphill='Biergcourse', rest='Roudag'},
["lv"] = {plain = "līdzenuma posms", hilly="paugurains posms", inter='vidēju kalnu posms', mount='kalnu posms', time_prologue='individuālais brauciens', time_team='komandu brauciens', time_indiv='individuālais brauciens', uphill='individuālais brauciens kalnā', rest='atpūtas diena'},
["mk"] = {plain = "рамна етапа", hilly="ридеста етапа", inter='среднопланинска етапа', mount='планинска етапа', time_prologue='пролог', time_team='екипен хронометар', time_indiv='индивидуален хронометар', uphill='', rest='ден за одмор'},
["nl"] = {plain = "vlakke rit", hilly="heuvelrit", inter='heuvelrit', mount='bergrit', time_prologue='proloog', time_team='ploegentijdrit', time_indiv='individuele tijdrit', uphill='klimtijdrit', rest='rustdag'},
["no"] = {plain = "flat etappe", hilly="kupert etappe", inter='middels klatreetappe', mount='klatreetappe', time_prologue='prolog', time_team='lagtempo', time_indiv='temporitt', uphill='klatretempoetappe', rest='hviledag'},
["pl"] = {plain = "płaski", hilly="pagórkowaty", inter='górzysty', mount='górski', time_prologue='prolog', time_team='jazda drużynowa na czas', time_indiv='jazda indywidualna na czas', uphill='jazda indywidualna na czas pod górę', rest='dzień przerwy'},
["pt"] = {plain = "etapa plana", hilly="etapa escarpada", inter='média montanha', mount='alta montanha', time_prologue='prólogo', time_team='contrarrelógio por equipes', time_indiv='contrarrelógio individual', uphill='cronoescalada', rest='jornada de descanso'},
["ro"] = {plain = "etapă de plat", hilly="etapă valonată", inter='etapă intermediară', mount='etapă de munte', time_prologue='prolog', time_team='contratimp pe echipe', time_indiv='contratimp individual', uphill='', rest='zi de repaus'},
["ru"] = {plain = "равнинный", hilly="холмистый", inter='среднегорный', mount='горный', time_prologue='пролог', time_team='командная разделка', time_indiv='индивидуальная разделка', uphill='горная разделка', rest='день отдыха'},
["sv"] = {plain = "Flack etapp", hilly="", inter='Kuperat', mount='Bergsetapp', time_prologue='Prolog', time_team='Lagtempoetapp', time_indiv='Tempoetapp', uphill='', rest='Vilodag'},
}
local l10n = l10nDef[wiki]
if not l10n then l10n = l10nDef["en"] end -- default
 
local border
if noborder then border="" else border="|border|right" end
if x=='plain stage' then return "[[File:Plainstage.svg"..border.."|20px|"..l10n.plain.."]]" end
if x=='hilly stage' then return "[[File:Hillystage.svg"..border.."|20px|"..l10n.hilly.."]]" end
if x=='intermediate stage' then return "[[File:Mediummountainstage.svg"..border.."|20px|"..l10n.inter.."]]" end
if x=='mountain stage' then return "[[File:Mountainstage.svg"..border.."|20px|"..l10n.mount.."]]" end
if x=='uphill time trial stage' then return "[[File:Mountain Time Trial Stage.svg"..border.."|20px|"..l10n.uphill.."]]" end
if x=='rest day' then return "[[File:Stage rest day.svg"..border.."|20px|"..l10n.rest.."]]" end
if x=='time trial stage' then
if noborder then border="" else border="|right" end
if typ==2348250 then return "[[File:Team Time Trial Stage.svg"..border.."|20px|"..l10n.time_team.."]]" end
if typ==2266066 then return "[[File:Time Trial.svg"..border.."|20px|"..l10n.time_indiv.."]]" end
if typ==485321 then return "[[File:Time Trial.svg"..border.."|20px|"..l10n.time_prologue.."]]" end
end
end
 
local function typeofstagelogo(stageID, noborder)
local sType
p = mw.wikibase.getBestStatements(stageID, 'P31') -- P31 is 'instance of'
for _,t in pairs(p) do
if t.mainsnak.snaktype == 'value' then
local iOf = t.mainsnak.datavalue.value['numeric-id']
if iOf == 20646667 then sType = typeofstage('plain stage', nil, noborder) break end
if iOf == 20646670 then sType = typeofstage('hilly stage', nil,moborder) break end
if iOf == 20680270 then sType = typeofstage('intermediate stage', nil,noborder) break end
if iOf == 20646668 then sType = typeofstage('mountain stage',nil, noborder) break end
if iOf == 485321 then sType = typeofstage('time trial stage', 485321, noborder) break end -- prologue
if iOf == 2266066 then sType = typeofstage('time trial stage', 2266066, noborder) break end -- individual time trial
if iOf == 2348250 then sType = typeofstage('time trial stage', 2348250, noborder) break end -- team time trial
if iOf == 20679712 then sType = typeofstage('uphill time trial stage', nil, noborder) break end
end
end
return sType or ''
end
 
--== III) basic functions
--[[ Get any value for a property which is not deprecated ]]
local function firstValue(QID, PID, field)
if QID then
local ss = wikibase.getAllStatements(QID, PID)
for _, s in pairs(ss) do
if s.rank ~= 'deprecated' and s.mainsnak.snaktype == 'value' then
return field and s.mainsnak.datavalue.value[field] or s.mainsnak.datavalue.value
end
end
else
return nil
end
end
Line 194 ⟶ 360:
--[[ Go from season of a team to the team ]]
local function getParentID(teamID)
return firstValue(teamID, 'P361P5138', 'id') -- P361 is 'part of'
or firstValue(teamID, 'P5138P361', 'id') -- P5138 is 'season of club or team'
end
 
Line 260 ⟶ 426:
end
 
--== IIIIV) Functions less basic called from other functions ==
--=== A) Time functions ===
--[[ Get a Wikidata statement for an entity and property valid at the given timevalue ]]
local function checktime(s,q, time)
local start, startPrecision, END, endPrecision
if not q then
return s
end
if q.P580 and q.P580[1] and q.P580[1].snaktype == 'value' then -- P580 is start time
start = q.P580[1].datavalue.value.time
Line 287 ⟶ 456:
END = string.sub(END, 1, 9) .. '32' -- Set day to 32
end
if END >= time then
return s
end
Line 295 ⟶ 464:
 
local function getStatementForTime(ID, property, time)
local temp
for _, s in statements(ID, property) do
temp =checktime(s, s.qualifiers, time)
local start, startPrecision, END, endPrecision
if temp then return temp end
local q = s.qualifiers
if q then
if q.P580 and q.P580[1] and q.P580[1].snaktype == 'value' then -- P580 is start time
start = q.P580[1].datavalue.value.time
startPrecision = q.P580[1].datavalue.value.precision
if startPrecision == 9 then -- precision is years
start = string.sub(start, 1, 5) -- Cut of everything after year
elseif startPrecision == 10 then -- precision is months
start = string.sub(start, 1, 8) -- Cut of everything after month
end
end
if q.P582 and q.P582[1] and q.P582[1].snaktype == 'value' then -- P582 is end time
END = q.P582[1].datavalue.value.time
endPrecision = q.P582[1].datavalue.value.precision
end
end
if not start or start <= time then
if not END then
return s
end
if endPrecision == 9 then -- precision 9 is 'years'
END = string.sub(END, 1, 6) .. '13' -- Set month to 13
elseif endPrecision == 10 then -- precision 10 is 'months'
END = string.sub(END, 1, 9) .. '32' -- Set day to 32
end
if END > time then
return s
end
end
end
return nil
end
 
--[[ Get start time of race as a timevalue ('+2016-01-01T00:00:00Z') or nil ]]
local function gettimeOfRace getTimeOfRace(raceID)
local timeOfRace
local p580 = mw.wikibase.getBestStatements(raceID, "P580") -- P580 is start time
Line 353 ⟶ 496:
 
local function getStartEndTime(sTime, eTime, mode)
-- Note: Add the formats4formats to "formats" and use func_datefuncDate
local lang = contentLanguage
local starttime, endtime
Line 406 ⟶ 549:
else starttime = lang:formatDate( "j", sTime )
end
elseif wiki == "de" or wiki == "da" or wiki == "fo" or wiki == "lb" or wiki == "no" then
if y ~= y2 then starttime = lang:formatDate( "j. F Y", sTime )
elseif m ~= m2 then starttime = lang:formatDate( "j. F", sTime )
Line 474 ⟶ 617:
end
elseif wiki == "cs" then endtime = lang:formatDate( "j. xg Y", eTime )
elseif wiki == "de" or wiki == "da" or wiki == "fi" or wiki == "fo" or wiki == "lb" or wiki == "no" then
if mode=='long' or y ~= y2 then
endtime = lang:formatDate( "j. F Y", eTime )
Line 509 ⟶ 652:
end
 
local formats = {data.formats
[''] = { long = 'j F Y', small = 'j M', onlyday = 'j' },
ar = { long = 'j F Y', small = 'j F', onlyday = 'j' },
br = { long = 'j "a viz" F Y', small = 'j "a viz" M', onlyday = 'j' },
ca = { long = 'j "de" F "de" Y', small = 'j "de" M', onlyday = 'j' },
cs = { long = 'j. xg Y', small = 'j. M', onlyday = 'j' },
da = { long = 'j. F Y', small = 'j. M', onlyday = 'j.' }, -- copy of de
de = { long = 'j. F Y', small = 'j. M', onlyday = 'j.' },
eo = { long = 'j"-a de" F Y', small = 'j"-a de" M', onlyday = 'j' },
en = { long = 'F d, Y', small = 'M d', onlyday = 'd' },
es = { long = 'j "de" F "de" Y', small = 'j "de" M', onlyday = 'j' }, -- copy of ca
eu = { long = 'Y".eko" F"k" j', small = 'M"k" j', onlyday = 'j' },
fi = { long = 'j. F"ta" Y', small = 'j. M', onlyday = 'j.' },
fo = { long = 'j. F Y', small = 'j. M', onlyday = 'j.' }, -- copy of de
he = { long = 'j xg Y', small = 'j F', onlyday = 'j' },
hu = { long = 'Y. F j.', small = 'M. j.', onlyday = 'j.' },
ja = { long = 'Y年m月d日', small = 'm月d日', onlyday = 'd日' },
lv = { long = 'Y. "gada" j. F', small = 'j. M', onlyday = 'j.' },
ru = { long = 'j xg Y', small = 'j M', onlyday = 'j' },
no = { long = 'j. F Y', small = 'j. M', onlyday = 'j.' }, -- copy of de
}
 
local function func_datefuncDate(date, mode)
-- local date = '+2016-05-20'
-- local mode = 'small'
local format = formats[wiki] or formats['']
local lang = contentLanguage
 
--handle problems with lack of precision
local lang = contentLanguage
local daycorrect=true
local monthcorrect=true
 
if string.sub(date,710,811)=='00' then --manage the 30 Novemberdaycorrect=false issueend
if string.sub(date,7,8)=='00' then monthcorrect=false end
 
if mode == 'longY' then
return langstring.sub(date,2,5) --only year, note: contentLanguage:formatDate( "Y", date ) returns the wrong year
else
return '-'
end
else
return contentLanguage:formatDate(format[mode], date)
end
 
if daycorrect and monthcorrect then
return contentLanguage:formatDate(format[mode], date)
else
if daycorrect or (monthcorrect==false and daycorrect==false) then --no month
if mode=='long' then
return string.sub(date,2,5) --only year, note: contentLanguage:formatDate("Y", date) returns the wrong year
else --otherwise we don't know
return '-'
end
else --month correct, but day incorrect
if mode=='onlyday' then
return '-'
else
local newdate=string.sub(date,1,9).."01"..string.sub(date,12)
return string.sub(contentLanguage:formatDate(format[mode], newdate), 3) --cut the day
end
end
end
end
 
Line 583 ⟶ 724:
--return officialName, isLocal
local slavicWikis = {mk = true, ru = true}
local wikiisslavicwikiIsSlavic = slavicWikis[wiki]
 
local p1448 = getStatementForTime(teamID, 'P1448', timeOfRace) -- P1448 is official name
Line 606 ⟶ 747:
if name then return name, true end
end
lang=p1448.mainsnak.datavalue.value.language
if not wikiisslavic then
if not wikiIsSlavic and slavicWikis[lang]==nil then
return p1448.mainsnak.datavalue.value.text, false --then prefer label
end
Line 627 ⟶ 769:
end
 
-- RiderID --> RiderLink
local function getRiderLink(riderID, startOfSeason) --startOfSeason optional
--Priority order
Line 636 ⟶ 779:
local slavicWikis = {mk = true, ru = true}
local sitelink = wikibase.getSitelink(riderID)
local officialname,officialnametemp, language, name
local wikiisslavicwikiIsSlavic = slavicWikis[wiki]
local correctlanguage=true
local listOfProperty={'P1813','P1448'}
Line 645 ⟶ 788:
if not officialname then
language = p1813.mainsnak.datavalue.value.language
officialnametemp = p1813.mainsnak.datavalue.value.text
local languageisslavic = slavicWikis[language]
if wikiIsSlavic then
if (languageisslavic==true and wikiisslavic==true) or (languageisslavic==nil and wikiisslavic==nil) then
if wiki==language then
officialnametemp = p1813.mainsnak.datavalue.value.text
name=officialnametemp --only exact language
if startOfSeason~= nil then
end
local q = p1813.qualifiers
if q thenelse
if wiki==language then --exact language --> ok
local temp = checktime(officialnametemp,q,startOfSeason)
if temp then officialname name= officialnametemp end--if the time is correct than it is finished
elseif slavicWikis[language]==nil then
else
--normally all "latin" languages use the same name, except for cyrillic translation
officialname = officialnametemp
local russianLabel= wikibase.getLabelByLang(riderID, "ru")
if russianLabel then
local russianEnd=string.sub(russianLabel, -3)
if russianEnd~="вна" and russianEnd~="вич" then --otherwise rejected
name=officialnametemp
end
else -- no russian label, it is most probably not a cyrillic translation
name=officialnametemp --any language latin
end
end
end
if startOfSeason~= nil then
local q = p1813.qualifiers
if q then
local temp = checktime(name,q,startOfSeason)
if temp then officialname = name end--if the time is correct than it is finished
else
officialname = name
end
end
Line 698 ⟶ 858:
end
 
if black_list(wiki, label) then
link = label
else
Line 768 ⟶ 928:
Q20738667 = true, Q28492441 = true, Q20639848 = true, Q20639847 = true, Q20652655 = true,
Q20653563 = true, Q20653564 = true, Q20653566 = true, Q2466826 = true, Q26849121 = true,
Q78464255 = true, Q80425135=true, Q54660600=true, Q54555994=true, Q99658502=true,
Q20653570=true
}
for _, p31 in statements(teamID, 'P31') do
if checktime(p31, p31.qualifiers, timeOfRace) then
local natureID = p31.mainsnak.datavalue.value.id
local natureID = p31.mainsnak.datavalue.value.id
if teamCats[natureID] then
catID =if teamCats[natureID] then
catID = natureID
break
break
end
end
end
 
if not catID then
parentID = getParentID(teamID)
Line 787 ⟶ 951:
-- Find country if needed
local countryID
if country or catID == 'Q23726798' or catID == 'Q20738667' or catID == 'Q54555994' then
countryID = firstValue(teamID, 'P1532', 'id') -- P17 is country for sport
if countryID == nil then
Line 793 ⟶ 957:
end
end
if countryID and (catID == 'Q23726798' or catID == 'Q20738667') then
or catID == 'Q54660600' or catID == 'Q54555994' or catID == 'Q99658502') then
-- It is a national cycling team
name = getCountryName(countryID)
Line 805 ⟶ 970:
end
name = name .. s
elseif catID == 'Q54555994' then -- national cycling team U19
end
local s
if wiki == 'fr' then s = ' juniors'
elseif wiki == 'mk' then s = ' под 19 години'
elseif wiki == 'ar' then s = ' تحت 19'
elseif wiki == 'es' then s = ' sub-19'
else s = ' U19'
end
name = name .. s
elseif catID == 'Q99658502' then -- national cycling team "B"
local s
if wiki == 'fr' then s = ' "B"'
elseif wiki == 'mk' then s = ' "B"'
elseif wiki == 'ar' then s = ' "B"'
elseif wiki == 'es' then s = ' "B"'
else s = ' "B"'
end
name = name .. s
end
sitelink = getRawTeamLink(teamID)
else
Line 877 ⟶ 1.060:
return contentLanguage:formatDate("F Y", string.sub(date, 2, 8))
elseif precision >= 11 then -- Precision is day (or less)
return func_datefuncDate(date, 'long')
end
end
Line 946 ⟶ 1.129:
end
 
local function black_listgetImageOrMap(wikiQID, LabelPID)
local p18 = wikibase.getBestStatements(QID, PID) -- P18 is 'image'
--[[ List of Wikipedia articles with the same lemma as the non existing rider article. Those lemmas are printed
as text "black" in the tables, not "blue" or "red". This way there will be no false wikilinks at the WhatLinksHere entry.
List should be updated maybe once a year. ]]
local black_list
if wiki == 'de' then black_list = {
["Ryan Anderson"]=true, ["Chris Butler"]=true, ["Josef Černý"]=true, ["Brad Evans"]=true, ["Robert Fontaine"]=true,
["Carlos Giménez"]=true, ["George Harper"]=true, ["Mathias Jørgensen"]=true, ["Luis Lemus"]=true, ["David Lozano"]=true, ["Jan Maas"]=true,
["James McLaughlin"]=true, ["Nikolaj Michajlow"]=true, ["Antonio Molina"]=true, ["Ben O'Connor"]=true, ["Andrea Peron"]=true, ["Cristian Rodríguez"]=true,
["Nick Schultz"]=true, ["Adam Stachowiak"]=true, ["Michel Vermote"]=true, ["Johannes Weber"]=true, ["Martin Weiss"]=true, ["Christopher Williams"]=true,
["Samuel Williams"]=true, ["Peter Williams"]=true, ['Stephen Williams']=true, ["Michael Woods"]=true, ["Michael Wright"] = true, ["Edoardo Zardini"]=true,
["Georg Zimmermann"]=true,
}
elseif wiki == 'fr' then black_list = {
['Pierre Barbier']=true, ['Jessica Cutler']=true, ['Fernanda da Silva']=true, ['Guillaume Delvaux']=true, ['Willy De Waele']=true,
['Jules Dubois']=true, ['Jean Dupont']=true, ['Robert Fontaine']=true, ['René Fournier']=true, ['Pierre Gauthier']=true, ['Marc Goossens']=true,
['Claude Guyot']=true, ['Amy Hill']=true, ['Liang Hongyu']=true, ['Marcus Johansson']=true, ['Mathias Jørgensen']=true, ['José Mendoza']=true,
['Daniel Müller']=true, ['Henri Parmentier']=true, ['Jean Raynal']=true, ['Pascal Robert']=true, ['Jean-Yves Roy']=true, ['Michael Shermer']=true,
['Juris Silovs']=true, ['Jacques Simon']=true, ['Guy Thomas']=true, ['Ryan Thomas']=true, ['Hans Vonk']=true, ['Jan Wijnants']=true,
}
else
black_list = {}
end
return black_list[Label]
end
 
local function getImage(QID)
local p18 = wikibase.getBestStatements(QID, 'P18') -- P18 is 'image'
local first
for _, image in pairs(p18) do
Line 991 ⟶ 1.148:
end
return first
end
 
local function getLogo(QID)
return getImageOrMap(QID, 'P154')
end
 
local function getImage(QID)
return getImageOrMap(QID, 'P18')
end
 
local function getMap(QID)
return getImageOrMap(QID, 'P242')
end
 
local function getSectionalView(QID)
return getImageOrMap(QID, 'P2713')
end
 
Line 996 ⟶ 1.169:
local function raceLink(QID)
local sitelink = wikibase.getSitelink(QID)
local instanceOf = firstValue(QID, 'P31P3450', 'id') -- P31 is 'instance of'
if instanceOf == nil then
instanceOf = firstValue(QID, 'P31', 'id') -- P31 is 'instance of'
end
if instanceOf == 'Q1137352' then -- Q1137352 is 'French Road Cycling Cup'
local label2 = wikibase.getLabel(instanceOf)
Line 1.011 ⟶ 1.187:
end
 
local function getPlaceLink(placeID,timeOfRace)
local sitelink = wikibase.getSitelink(placeID)
local name = ''
 
if available_list then
name = translations.list(placeID)
end
if not name then
local temp=getOfficialName(placeID, timeOfRace)
if temp then name=temp.."Oui" end
end
if sitelink then
-- Delete " (...)" form e.g. "Unley (South Australia)"
if name ~='' then
return '[[' .. sitelink .. '|' .. string.gsub(sitelink, ' %b()', '') .. ']]'
return '[[' .. sitelink .. '|' .. name .. ']]'
else
return '[[' .. sitelink .. '|' .. string.gsub(sitelink, ' %b()', '') .. ']]'
end
end
local label = wikibase.getLabel(placeID) or ''
Line 1.023 ⟶ 1.212:
end
return contentLanguage:ucfirst(label)
end
 
-- ClassID --> ClassLink
local function classLink(class)
-- some WPs use a unique article for this case
local link = wikibase.getSitelink('Q22348500') -- Q22348500 is 'cycling race class'
local function classLinkFn(class)
local link
if wiki~="fr" then --not used
link= wikibase.getSitelink('Q22348500') -- Q22348500 is 'cycling race class'
end
local label = getLabelFallback(class, {wikilang, 'en', 'fr', 'de'})
if label and link then
Line 1.048 ⟶ 1.242:
local name = content.name
local nameNoShy = string.gsub(name, '&#173;', '') -- filter soft hyphen out
local nameNoShyLow, name_pluralNoShyLow
if nameNoShy then
nameNoShyLow = mw.ustring.lower(nameNoShy)
end
local name_plural = content.name_plural
local name_pluralNoShy = name_plural and string.gsub(name_plural, '&#173;', '') -- filter soft hyphen out
if name_pluralNoShy then
name_pluralNoShyLow = mw.ustring.lower(name_pluralNoShy)
end
if args[nameNoShy] and args[nameNoShy] ~= '' then
if content.special then
Line 1.059 ⟶ 1.261:
else
content.content = mw.text.trim(args[nameNoShy])
end
elseif nameNoShyLow and args[nameNoShyLow] and args[nameNoShyLow] ~= '' then
if content.special then
local newname, value = string.match(args[nameNoShyLow], '([^:]+):(.*)')
if value and mw.text.trim(value) ~= '' then
content.name = mw.text.trim(newname)
content.content = mw.text.trim(value)
end
else
content.content = mw.text.trim(args[nameNoShyLow])
end
elseif args[name_pluralNoShy] and args[name_pluralNoShy] ~= '' then
content.name = content.name_plural
content.content = mw.text.trim(args[name_pluralNoShy])
elseif name_pluralNoShyLow and args[name_pluralNoShyLow] and args[name_pluralNoShyLow] ~= '' then
content.name = content.name_plural
content.content = mw.text.trim(args[name_pluralNoShyLow])
end
end
end
 
local function checkDis(q)
dis="road"
if q and q.P642 and q.P642[1] and q.P642[1].snaktype == 'value' then
if q.P642[1].datavalue.value.id == 'Q520611' or q.P642[1].datavalue.value.id =='Q1031445' then
onlyRoad=false
dis="mountainBike"
elseif q.P642[1].datavalue.value.id == 'Q335638' then
onlyRoad=false
dis="cycloCross"
elseif q.P642[1].datavalue.value.id == 'Q221635' then
onlyRoad=false
dis="track"
end
end
return dis
end
 
-- Rider --> Team link
local function getTeam(riderID, timeOfRace, q)
-- q: qualifiers of statement in race entity where the rider is the value
Line 1.074 ⟶ 1.307:
link = getTeamLinkCat(teamID, timeOfRace)
else
localfor p54_, =s getStatementForTimein statements(riderID, 'P54', timeOfRace) do
if p54not link then --like a break
p54 =checktime(s, s.qualifiers, timeOfRace)
teamID = p54.mainsnak.datavalue.value.id
if p54 then
link = getTeamLinkCat(teamID, timeOfRace)
dis=checkDis(p54.qualifiers)
if dis=='road' then --by default
teamID = p54.mainsnak.datavalue.value.id
link = getTeamLinkCat(teamID, timeOfRace)
end
end
end
end
end
return link, teamID
end
 
--RiderID --> UCI code
local function getTeamCode(riderID, timeOfRace, q)
-- q: qualifiers of statement in race entity where the rider is the value
Line 1.097 ⟶ 1.338:
end
return code
end
 
local function seasonToTeamID(teamID)
if teamID then
local parentID=getParentID(teamID)
if parentID then--season was used
return parentID
else
return teamID
end
else
return nil
end
end
 
Line 1.118 ⟶ 1.372:
 
--=== C) Function for the output ===
local function getcoutrybool getCountryBool(no_country_list)
local country = true
for _, value in pairs(no_country_list) do -- get data if country should be printed in this wiki
Line 1.130 ⟶ 1.384:
if wiki == "ar" and s.item == "" or not s.item then return "" end
if s.error_message == 1 then
error_message = func_error_message(wiki, 1)
error_message = mw.ustring.gsub(error_message, "<1>", s.property)
error_message = mw.ustring.gsub(error_message, "<2>", mw.wikibase.label( s.item ))
Line 1.144 ⟶ 1.398:
:css('padding', '3px')
local title = translate(s.header_function (wiki, s.header_1, s.title)
if s.header_1 == 19 and wiki == "ar" then title = title .. " " .. s.year end
local caption = table:tag('tr'):tag('th'):attr('colspan', tostring(#s.header_2 + 1))
:cssText('padding:2px; text-align:center; background-color:#EAECF0; line-height: 1.8em;')
:css('background-color',backgroundColor)
caption:tag('span'):cssText('float:left; margin: 0 5px'):wikitext('[[File:Wikidata-logo S.svg|12px|link=d:'.. s.item.. '#'.. s.property..']] '.. error_message)
caption:wikitext(title)
 
local country=getcoutrybool getCountryBool(s.no_country)
 
local header = table:tag('tr')
Line 1.159 ⟶ 1.415:
header:tag('th')
:cssText('text-align:center;padding:2px 20px 2px 2px;white-space:nowrap')
:wikitext(translate(s.header_function (wiki, k))
end
end
Line 1.165 ⟶ 1.421:
local column = header:tag('th')
:cssText('text-align:center;padding:2px 20px 2px 2px;white-space:nowrap')
:wikitext(translate(s.header_function (wiki, k))
if s.data_sort_type[i] == 'unsortable' then
column:addClass('unsortable')
Line 1.179 ⟶ 1.435:
if wiki == "ar" and s.item == "" or not s.item then return "" end
if s.error_message == 1 then
error_message = func_error_message(wiki, 1)
error_message = mw.ustring.gsub(error_message, "<1>", s.property)
error_message = mw.ustring.gsub(error_message, "<2>", mw.wikibase.label( s.item ))
Line 1.191 ⟶ 1.447:
end
 
local cssTable= "border: 1px solid rgb(200,200,200); margin: 0 0 0.5em 0;"..
"background-color: rgb(255, 255, 255); padding: 5px0px; float: left;"..
"clear: left; ; text-align: left; vertical-align: top; font-size: 85%; line-height: 1.8em;"
local wdLink = '[[File:Wikidata-logo S.svg|12px|link=d:'.. s.item.. '#'.. s.property..']] '.. error_message
Line 1.200 ⟶ 1.456:
:cssText('center = margin: 0 0.5em 0;clear:both; border: 1px solid rgb(200,200,200);' ..
'cellpadding="4" cellspacing="0" style="width:100%; background-color: rgb(255, 255, 255);padding: 5px;'..
'margin-bottom:1em; background-color:#EAECF0'..backgroundColor..';')
:attr('title','['..startlist_translatetranslate("startlist",14)..']/['..startlist_translatetranslate("startlist",15)..']')
local tDiv= rollTable1:tag('div'):addClass("NavHead")
:cssText('text-align:'.. textalign .." =;height:1.8em;background-color:#EAECF0; color:black;font-weight:bold;")
:css('background-color',backgroundColor)
tDiv:tag('span')
local tSpan=tDiv:tag('span'):cssText('float:' .. floattable):wikitext(wdLink)
tSpan:wikitext(title)
tDiv:wikitext(startlist_translatetranslate("startlist",1))
tDiv = rollTable1:tag('div'):addClass("NavContent"):cssText("margin:0; background:white; display:block; text-align:left;")
Line 1.224 ⟶ 1.481:
local tTable =tCell:tag('table')
:attr('cellpadding','40')
:cssText(cssTable)
tCell = tTable:tag('tr'):tag('th')
:cssTextcss("background-color:#EAECF0;",backgroundColor)
:attr('colspan','3'):attr('align','center')
tCell:tag('span'):cssText('float:left'):wikitext(wdLink)
tCell:wikitext(startlist_translatetranslate("startlist",1))
local tRow=tCell:tag('tr')
 
Line 1.333 ⟶ 1.592:
Q419 = {'PER', {'Flag of Peru.svg', '+1950'},
{'Flag of Peru (1825-1950).svg', '+1825-02-25', '+1950'}},
Q424 = {'CAM', {'Flag of Cambodia.svg', '+1993-06-30'},
{'Flag of Cambodia.svg', '+1948-10-20', '+1970-10-09'}},
Q664 = {'NZL', {'Flag of New Zealand.svg'}},
Q711 = {'MGL', {'Flag of Mongolia.svg'}},
Line 1.457 ⟶ 1.718:
end
 
-- countryID --> shape ([[France|FRA]])
local function ucicodeCountry(countryID)
local function uciCodeCountry(countryID)
local ucicode, countryName
local uciCode, countryName
local blacklist={Q736=true}
if countryID then
--get UCI code
if flags[countryID] then
ucicodeuciCode=flags[countryID][1]
end
--get link, assumed for a country the label is equal to the link, where not correct in the blacklist
Line 1.475 ⟶ 1.737:
countryName = mw.wikibase.getSitelink(countryID)
end
if ucicodeuciCode and countryName then
return ' <small>([['..countryName..'|'..ucicodeuciCode..']])</small> '
else
return ''
Line 1.485 ⟶ 1.747:
end
 
local function jersey_infobox(wiki, winner_classification, item, timeOfRace)
local jersey, jersey_name = '', ''
local jerseyWPID = ''
Line 1.539 ⟶ 1.801:
{'Q33937', 'jeune', '+2019', '+2500', 'Q24645383', 'Q60233927'}, -- Jersey white.svg
 
{'Q2091354', 'leader', '+2011', '+2500', 'Q24257871', 'Q30020298'}, -- Tour of Norway, Jersey yellow.svg
{'Q2091354', 'sprints', '+2011', '+2011', 'Q26806427', 'Q30020298'}, -- Jersey green.svg
{'Q2091354', 'points', '+2012', '+2017', 'Q24645209', 'Q30020298'}, -- Jersey green.svg
{'Q2091354', 'points', '+2018', '+2018', 'Q28820618', 'Q30020298'}, -- MaillotCyan.PNG
{'Q2091354', 'points', '+2019', '+2500', 'Q47945989', 'Q30020298'}, -- Jersey dark blue.svg
{'Q2091354', 'montagne', '+2011', '+2015', 'Q25265958', 'Q30020298'}, -- Jersey polkadot.svg
{'Q2091354', 'montagne', '+2016', '+2017', 'Q27670174', 'Q30020298'}, -- Jersey orange.svg
{'Q2091354', 'montagne', '+2018', '+2500', 'Q25265958', 'Q30020298'}, -- Jersey polkadot.svg
{'Q2091354', 'jeune', '+2011', '+2500', 'Q24645383', 'Q30020298'}, -- Jersey white.svg
{'Q2091354', 'winner_fighting', '+2017', '+2017', 'Q29957114', 'Q30020298'}, -- MaillotCyan.PNG
{'Q128713', 'leader', '+2013', '+2017', 'Q24257871', 'Q30020299'}, -- Tour des Fjords, Jersey yellow.svg
{'Q128713', 'leader', '+2018', '+2018', 'Q29594434', 'Q30020299'}, -- MaillotCyan.PNG
{'Q128713', 'points', '+2013', '+2014', 'Q24645209', 'Q30020299'}, -- Jersey green.svg
{'Q128713', 'points', '+2015', '+2017', 'Q24687409', 'Q30020299'}, -- Jersey blue.svg
{'Q128713', 'points', '+2018', '+2018', 'Q25265938', 'Q30020299'}, -- Jersey violet.svg
{'Q128713', 'montagne', '+2013', '+2018', 'Q25265958', 'Q30020299'}, -- Jersey polkadot.svg
{'Q128713', 'jeune', '+2013', '+2018', 'Q24645383', 'Q30020299'}, -- Jersey white.svg
{'Q128713', 'winner_fighting', '+2015', '+2015', 'Q30035038', 'Q30020299'}, -- Jersey green.svg
{'Q128713', 'winner_fighting', '+2016', '+2017', 'Q30035039', 'Q30020299'}, -- Jersey orange.svg
{'Q128961', 'leader', '+2013', '+2500', 'Q24687408', 'Q30020300'}, -- Arctic Race of Norway, Jersey blue.svg
{'Q128961', 'points', '+2013', '+2500', 'Q24645209', 'Q30020300'}, -- Jersey green.svg
{'Q128961', 'montagne', '+2013', '+2014', 'Q27670178', 'Q30020300'}, -- Jersey red.svg
{'Q128961', 'montagne', '+2015', '+2500', 'Q27670174', 'Q30020300'}, -- Jersey orange.svg
{'Q128961', 'jeune', '+2013', '+2500', 'Q24645383', 'Q30020300'}, -- Jersey white.svg
{'Q128961', 'winner_fighting', '+2014', '+2500', 'Q27644113', 'Q30020300'}, -- Jersey red number.svg
{'Q17619325', 'leader', '+2014', '+2014', 'Q24257871', 'Q30020302'}, -- Ladies Tour of Norway, Jersey yellow.svg
{'Q17619325', 'leader', '+2015', '+2016', 'Q26945272', 'Q30020302'}, -- Jersey violet.svg
{'Q17619325', 'leader', '+2017', '+2500', 'Q24257871', 'Q30020302'}, -- Jersey yellow.svg
{'Q17619325', 'points', '+2014', '+2500', 'Q24645209', 'Q30020302'}, -- Jersey green.svg
{'Q17619325', 'montagne', '+2014', '+2500', 'Q25265958', 'Q30020302'}, -- Jersey polkadot.svg
{'Q17619325', 'jeune', '+2014', '+2500', 'Q24645383', 'Q30020302'}, -- Jersey white.svg
{'Q17619325', 'winner_fighting', '+2016', '+2500', 'Q30035039', 'Q30020302'}, -- Jersey orange.svg
}
--timeOfRace = '+1968-07-01T00:00:00Z'
Line 1.684 ⟶ 1.946:
 
local function subwinner(riderId, timeOfRace, q)
local outputtableoutTable={}
local riderTeam, riderLink, countryID
 
Line 1.709 ⟶ 1.971:
end
 
local function winner(raceID, winners, timeOfRace, country, WDlink_on, team, ref, winnersId)
local p1346 = wikibase.getAllStatements(raceID, 'P1346') -- P1346 is 'winner'
for _, winner in pairs(p1346) do
Line 1.791 ⟶ 2.053:
if disqualified==true then
riderLink='<s>'..riderLink..'</s>'
end
if winnersId and winnersId[wOf] then
if disqualified or ((not wID) and wCriterion) then
winnersId[wOf]= 'Q666' --to identify disqualification
else
winnersId[wOf]= wID --identify cancelled
end
end
if winners[wOf] == '' then
Line 1.804 ⟶ 2.073:
end
 
local function sortandconcatsortAndConcat(t_Body, resulttableresultTable)
table.sort(t_Body, function(a, b) return a[1] < b[1] end)
for _, m in ipairs(t_Body) do resulttableresultTable:node(m[2]) end
return resulttableresultTable
end
 
Line 1.813 ⟶ 2.082:
local function fn_date(entityID, functionName) --to move as a general function
local tempdate, timeOfRace, sortkey, sortkeyDate
local outputtableoutTable={}
local sTime = firstValue(entityID, 'P580', 'time') -- P580 is 'start time'
local eTime = firstValue(entityID, 'P582', 'time') -- P582 is 'end time'
Line 1.830 ⟶ 2.099:
local pTime = firstValue(entityID, 'P585', 'time') -- P585 is 'point in time'
if pTime then
tempdate = func_datefuncDate(pTime, 'small')
timeOfRace = pTime
sortkeyDate = pTime
end
end
local _, _, y, m, d = string.find(sortkeyDate or "", "(%d+)-(%d+)-(%d+)")
if y~= nil and m~= nil and d~=nil then
sortkey = y..m..d
Line 1.849 ⟶ 2.118:
:wikitext(tempdate)
outputtableoutTable[1]=timeOfRace
outputtableoutTable[2]=tostring(tCell)
outputtableoutTable[3]=sortkey
return outputtableoutTable
end
 
Line 1.859 ⟶ 2.128:
-- parentID taken from fn_race, optional
--outputtableoutTable[1] is the cell
--outputtableoutTable[2] is the name of the country
--outputtableoutTable[3] is the flag
local country, countryname, outputtableoutTable= {}, {}, {}
local countryID, parentID, raceSitelink
Line 1.888 ⟶ 2.157:
country[#country + 1]=flag(countryID, timeOfRace).." "..countryname[#countryname]
end
outputtableoutTable[3]=flag(countryID, timeOfRace)
end
end
Line 1.895 ⟶ 2.164:
end
 
if countryID == nil then outputtableoutTable[3]="no flag" end
if countryname[1] then tCell:attr('data-sort-value',countryname[1]) end
if countrybool==false then
tCell:wikitext(country[1].." "..(raceSitelink or ''))
outputtableoutTable[2]=''
else
if countryname[1] then
outputtableoutTable[2]=countryname[1]
if country[1] then tCell:wikitext(country[1]) end
else
outputtableoutTable[2]=''
end
end
outputtableoutTable[1]=tCell
return outputtableoutTable
end
 
local function commastagecommaStage(stageID,racelabelraceLabel) --how to write "stage, "
local outputtableoutTable={'',''}
local stagenumberstageNumber=''
local substagesubStage = ''
local stagenumberonlystageNumberonly, stageletterstageLetter
outputtable[1]=''
outputtable[2]=''
 
local temp=firstValue(stageID, 'P1545')
if temp then stagenumberstageNumber = temp end
 
if stagenumberstageNumber=='0' then --prologue
stageNumber= translate("victories",9)
stagenumber= victories_translate(wiki,9)
else
if stagenumberstageNumber==nil then
stageNumber= translate("victories",8)
stagenumber= victories_translate(wiki,8)
else
--look for substagesubStage
local i,j = string.find(stagenumberstageNumber, "%a+") --if letter in the stage number
if i ~= nil then --we have to do something
local k,l = string.find(stagenumberstageNumber, "%d+") --select the number in the stage number
stagenumberonlystageNumberonly = string.sub(stagenumberstageNumber, k, l)--cut the string in 2
stageletterstageLetter = string.sub(stagenumberstageNumber, i, j)
stageNumber=stageNumberonly
stagenumber=stagenumberonly
if stageletterstageLetter ~= nil then substagesubStage=stageletterstageLetter end
end
if wiki == 'ar' then
stagenumberstageNumber= victories_translatetranslate(wiki"victories",8)..' '..number('f', stagenumbertonumber(stageNumber), wiki)
else
stagenumberstageNumber= number('f', stagenumbertonumber(stageNumber), wiki)..substagesubStage..' '..victories_translatetranslate(wiki"victories",8)
end
end
Line 1.972 ⟶ 2.239:
 
for _, v in ipairs(correpondance) do
if string.find(racelabelraceLabel, v.name) then
comma = v.article
break
Line 1.979 ⟶ 2.246:
end
 
if wiki == 'fr' or wiki == "lb" or wiki=="ca" or wiki=="es" or wiki=="ast" then
outputtableoutTable[1]=stagenumberstageNumber..comma
else
elseif wiki=="de" or wiki=="da" or wiki=="fo" or wiki=="no" or wiki=="ru" or wiki=="ar" or wiki=="lv" then
--if wiki=="de" or wiki=="da" or wiki=="fo" or wiki == "lb" or wiki=="no" or wiki=="ru" or wiki=="ar" or wiki=="lv" or wiki=="pl" then
outputtable[2]=comma..stagenumber
outTable[2]=comma..stageNumber
end
return outputtableoutTable
end
 
local function getMainRaceLink(entityID,entity_type,stageID, functionName,timeOfRace) --the link to the edition but with a general name
local instanceOf, instanceOfTemp, label, Sitelink, isclass, prefix, postfix
Sitelink=wikibase.getSitelink(entityID)
prefix=''; postfix='' --general classification
listOfProperty={'P2561','P1448'}
 
--system with P3450 and P2094
for _, p31 in statements(entityID, 'P31') do
instanceOf=firstValue(entityID, 'P3450', 'id')
instanceOf = p31.mainsnak.datavalue.value.id
if instanceOf==nil then
isclass=false
for _, p31 in statements(entityID, 'P31') do
for _,thisClass in ipairs(class) do--we don't want the class, but the main race
instanceOfTemp = p31.mainsnak.datavalue.value.id
if instanceOf == thisClass then isclass=true end
isclass=false
for _,thisClass in ipairs(class) do--we don't want the class, but the main race
if instanceOfTemp == thisClass then isclass=true end
end
if isclass==false then
instanceOf=instanceOfTemp
end
end
end
if isclass==false then
for _, prop in ipairs(listOfProperty) do
--get information from the parent
for _, p2561 in statements(instanceOf, prop) do --name for championship
if label==nilinstanceOf then
--look for
local lang_WD = p2561.mainsnak.datavalue.value.language
for _, prop in ipairs(listOfProperty) do
if wiki == lang_WD then
for _, p2561 in statements(instanceOf, prop) do --name for championship
local nametemp = p2561.mainsnak.datavalue.value.text
if timeOfRace~label== nil then
local qlang_WD = p2561.qualifiersmainsnak.datavalue.value.language
if qwiki == lang_WD then
local tempnametemp = checktime(nametemp,q,timeOfRace)p2561.mainsnak.datavalue.value.text
if timeOfRace~= nil then
if temp then label = nametemp end--if the time is correct than it is finished
elselocal q = p2561.qualifiers
labelif =q nametempthen
local temp = checktime(nametemp,q,timeOfRace)
end
if temp then label = nametemp end--if the time is correct than it is finished
else
label = nametemp
end
end
Line 2.020 ⟶ 2.298:
end
end
end
 
if label==nil then
label=wikibase.label(instanceOf)
if not label then
label = getLabelFallback(entityID, {'en', 'fr', 'de'}) or ''
end
end
if Sitelink==nil then --only if no link to the race direct
Sitelink=wikibase.getSitelink(instanceOf)
end
if Sitelink==nil and entity_type=='champ' then --only for champ
local temp=firstValue(instanceOf, 'P361','id')
if temp then Sitelink= wikibase.getSitelink(temp) end
end
end
if Sitelink==nil then --only if no link to the race direct
Sitelink=wikibase.getSitelink(instanceOf)
end
if Sitelink==nil and entity_type=='champ' then --only for champ
local temp=firstValue(instanceOf, 'P361','id')
if temp then Sitelink= wikibase.getSitelink(temp) end
end
end
Line 2.047 ⟶ 2.325:
if entity_type=='2' then
if functionName~=nil then --calendar=nil
if wiki == 'fr' then prefix= victories_translatetranslate(wiki"victories",1)..', ' --general classification
elseif wiki == 'ar' then postfix ='، '..victories_translatetranslate(wiki"victories",1)
else postfix = ', '..victories_translatetranslate(wiki"victories",1)
end
end
elseif entity_type=='stage' then
--how to write "stage, " is concentrated in one function
local commatablecommaTable=commastagecommaStage(stageID, label)
prefix= commatablecommaTable[1]
postfix=commatablecommaTable[2]
end
 
Line 2.066 ⟶ 2.344:
end
 
local function fn_getClassInfo(entityID,instanceOf, displayed_class) --get the class of the race
--with only P31, it is necessary to check if the entityID is a class, with P2094, it is not necessary
local display=false
local outputtableoutTable={}
local entity_type, class_textclassText, sortkey_class, classID
 
if displayed_class==nil then
display=true
else
for _, thisClass in ipairs(displayed_class) do
if entityIDinstanceOf ==thisClass then
display=true break
end
end
end
Line 2.081 ⟶ 2.363:
listOfClassesName = {'champ', '2','1'}
classID=firstValue(entityID, 'P2094', 'id')
for ii, thisClassesList in ipairs(listOfClassesList) do
if entity_typeclassID==nil then
classIDs={instanceOf}
for _, thisClass in ipairs(thisClassesList) do
else
if entityID == thisClass then
classIDs={classID, instanceOf} --try the first and then the second
entity_type = listOfClassesName[ii]
end
class_text = mw.wikibase.label(thisClass)
sortkey_class = class_sort[thisClass]
for _, class_id in ipairs(classIDs) do
for ii, thisClassesList in ipairs(listOfClassesList) do
if entity_type==nil then --break
for _, thisClass in ipairs(thisClassesList) do
if class_id == thisClass then
entity_type = listOfClassesName[ii]
classText = mw.wikibase.label(thisClass)
sortkey_class = class_sort[thisClass]
end
end
end
end
end
 
if entity_type==nil then entity_type = 'nada' end--to allow display of race without class...
 
if display~=false then
outputtableoutTable[1]=entity_type
outputtableoutTable[2]=class_textclassText
outputtableoutTable[3]=sortkey_class
outputtableoutTable[4]=entityIDinstanceOf --save the class
end
return outputtableoutTable
end
 
--look for the circuitID to create a link as [[World Tour|1.UWT]]
--a bit redundant with classLink which needs less computation
--for infobox classLink gives enough info
local function classToCircuit(classID, entityID, classText, child, q)
local displayedCircuitID, circuitID, classLink, circuitLink, circuitLinkFull
if classID then
if classID=='Q23005601' or classID=='Q23005603' then --1WWT 2WWT clear
displayedCircuitID = 'Q21075974'
elseif classID=='Q22231106' or classID=='Q22231107' then --1UWT 2UWT clear
displayedCircuitID = 'Q635366'
else --we have to look in the item
if child then --for instance Flèche wallonne 2020
for _, p361 in statements(entityID, 'P361') do
circuitID = p361.mainsnak.datavalue.value.id
for _, p31 in statements(circuitID, 'P31') do --is it a UCI circuit?
parentCircuitID = p31.mainsnak.datavalue.value.id
for i=1,#UCI_Circuits do
if parentCircuitID == UCI_Circuits[i] then --Yes it is
displayedCircuitID=circuitID
break
end
end
end
end
else --for instance Flèche wallonne
if q then
if q.P642 and q.P642[1].snaktype == 'value' and q.P642[1].datavalue.value.id then
displayedCircuitID = q.P642[1].datavalue.value.id
end
end
end
end
if wikibase.getSitelink('Q22348500') and wiki~="fr" then --for the WP that use this element
classLink = classLinkFn(classID)
end
end
if displayedCircuitID~=nil then
circuitLink = wikibase.getSitelink(displayedCircuitID) --we display the circuit of the year
circuitLinkFull=WPlinkpure(displayedCircuitID)
if circuitLink ~= nil and not classLink then --do not erase Q22348500
if classText ~= nil then
classLink = '[['..circuitLink..'|'..classText..']]'
else
classLink = '[['..circuitLink .. ']]'
end
end
elseif not classLink and classText~=nil then
classLink=classText
end
return classLink, circuitLinkFull
end
 
local function getStartEndfromQuali(q) --return sTime and eTime as date
local sTime, eTime
if q then
if q.P580 and q.P580[1] and q.P580[1].snaktype == 'value' then -- P580 is start time
sTime = q.P580[1].datavalue.value.time
end
if q.P582 and q.P582[1] and q.P582[1].snaktype == 'value' then -- P582 is end time
eTime = q.P582[1].datavalue.value.time
end
end
return sTime, eTime
end
 
local function getPeriod(q, brackets)
local sTime, startTime, eTime, endTime
 
sTime, eTime = getStartEndfromQuali(q)
if sTime then startTime= funcDate(sTime,'Y') end
if eTime then endTime =funcDate(eTime,'Y') end
 
local period
if sTime and eTime then
period=startTime .. '-'..endTime
elseif sTime then
period=startTime .. '-'
elseif eTime then
period='-'..endTime
else
period=""
end
if brackets and period~="" then
period="("..period..")"
end
return period, sTime
end
 
local function getClass(entityID)
local classLink, circuitLink, SiteLink
local classTable={}
 
for ii, p279 in statements(entityID, 'P279') do
if p279 and p279.mainsnak.snaktype == 'value' then
temp = p279.mainsnak.datavalue.value.id
classID=nil
for jj=1,#class do -- #class = number of elements in class
if temp == class[jj] then
classID=temp
classText = wikibase.label(temp)
break
end
end
if classID then
classLink, circuitLink=classToCircuit(classID, entityID, classText, false,p279.qualifiers)
if classLink then
local period, sTime=getPeriod(p279.qualifiers, true)
local classStr = classLink .. " <small>"..period.."</small>"
table.insert(classTable, {sTime, classStr, circuitLink})
end
end
end
end
table.sort(classTable, function(a, b) return a[1] < b[1] end)
for _, class in pairs(classTable) do
if not str then str='' else str=str..'<br>' end
str=str..class[2]
circuitLink=class[3]
end
 
return str, circuitLink, #classTable
end
 
Line 2.106 ⟶ 2.526:
--first function read from victory main
--outputtableoutTable[1] is the cell with the race, or sitelink if country is false
--outputtableoutTable[2] is the cell with the class
local Sitelink,instanceOf,instanceOfTemp,circuitID,parentCircuitID, displayedCircuitID, Circuitlink
local ClasslinkclassLink, entity_type, classID, class_textclassText
local inputtable, outputtableoutTable={}, {}
local display=true -- should be true to work, bypassed
local sortkey_class = ''
Line 2.123 ⟶ 2.543:
local parentID = getParentID(entityID)
entityID = parentID
outputtableoutTable[3] = parentID --as we read it here, no need to read it afterwards
display = true
for _, p31bis in statements(parentID, 'P31') do
local instanceOfbis = p31bis.mainsnak.datavalue.value.id
inputtable=fn_getClassInfo(parentID, instanceOfbis,displayed_class)
if inputtable[1]~=nil and inputtable[1]~='nada' then
class_textclassText =inputtable[2]
sortkey_class=inputtable[3]
classID=inputtable[4]
Line 2.136 ⟶ 2.556:
end
end
 
if entity_type==nil then --bypass if stage
inputtable=fn_getClassInfo(entityID,instanceOf,displayed_class) --if a P2094 is present, the instanceOf does not matter
if inputtable[1]==nil then
elseif inputtable[1]=='nada' then --no display="inputtable[1]==nil" inputtable[1]=='nada'--> display but empty
Line 2.144 ⟶ 2.565:
display=true
entity_type=inputtable[1]
class_textclassText =inputtable[2]
sortkey_class=inputtable[3]
classID=inputtable[4]
Line 2.151 ⟶ 2.572:
end
--Now we have the class and know the type of race it is
--Get the circuit, if we display it only
if class_text ~=nil then Classlink = class_text else Classlink ='' sortkey_class='' end
 
if display then
if entity_type == 'stage' then
Line 2.162 ⟶ 2.580:
if country~=false then
local tCell=mw.html.create('td'):cssText("text-align:".. textalign ..";padding:0 2.3em"):wikitext(Sitelink)
outputtableoutTable[1]=tostring(tCell)
else
outputtableoutTable[1]=Sitelink --already opened
end
if displayclass == true then
classLink, _ =classToCircuit(classID, entityID, classText, true, nil)
if classID=='Q23005601' or classID=='Q23005603' then --1WWT 2WWT clear
if not classLink then classLink="" end
displayedCircuitID = 'Q21075974'
elseif classID=='Q22231106' or classID=='Q22231107' then --1UWT 2UWT clear
displayedCircuitID = 'Q635366'
else --we have to look in the item
for _, p361 in statements(entityID, 'P361') do
circuitID = p361.mainsnak.datavalue.value.id
for _, p31 in statements(circuitID, 'P31') do --is it a UCI circuit?
parentCircuitID = p31.mainsnak.datavalue.value.id
for i=1,#UCI_Circuits do
if parentCircuitID == UCI_Circuits[i] then --Yes it is
displayedCircuitID=circuitID
break
end
end
end
end
end
if displayedCircuitID~=nil then
Circuitlink = wikibase.getSitelink(displayedCircuitID) --we display the circuit of the year
if Circuitlink ~= nil then
if class_text ~= nil then
Classlink = '[['..Circuitlink..'|'..class_text..']]'
else
Classlink = '[['..Circuitlink .. ']]'
end
end
end
-- class
local tCell=mw.html.create('td')
:attr('data-sort-value',sortkey_class)
:cssText("text-align:center;padding:0 0.5em")
:wikitext(ClasslinkclassLink)
outputtableoutTable[2]=tCell
end
end
 
return outputtable
return outTable
end
 
Line 2.245 ⟶ 2.639:
return tCell:wikitext(tempwinner), thereisawinner
end
end
 
local function compareDate(tdate) --test future
if tdate then
local today=os.date("*t")
local _, _, y, m, d = string.find(tdate, "(%d+)%p(%d+)%p(%d+)")
local tYear=tonumber(y)
local tMonth=tonumber(m)
local tDay=tonumber(d)
if tYear>today['year'] then
return true
elseif tYear<today['year'] then
return false --the last race is the future
else
if tMonth>today['month'] then
return true
elseif tMonth<today['month'] then
return false
else
if tDay>today['day'] then
return true
elseif tDay<today['day'] then
return false
else
return false --arbitrary
end
end
end
else
return false --arbitrary
end
end
 
local function calculateAge(birthDate, endDate) --test future
local eYear, eMonth, eDay
if birthDate then
if not endDate then
local today=os.date("*t")
eYear=today['year']
eMonth=today['month']
eDay=today['day']
else
local _, _, y, m, d = string.find(endDate, "(%d+)%p(%d+)%p(%d+)")
eYear=tonumber(y)
eMonth=tonumber(m)
eDay=tonumber(d)
end
 
local _, _, y, m, d = string.find(birthDate, "(%d+)%p(%d+)%p(%d+)")
local tYear=tonumber(y)
local tMonth=tonumber(m)
local tDay=tonumber(d)
local alreadyThisYear
 
if eMonth>tMonth then
alreadyThisYear=true
elseif eMonth<tMonth then
alreadyThisYear=false
else
if eDay>tDay then
alreadyThisYear=true
elseif eDay<tDay then
alreadyThisYear=false
else
alreadyThisYear=true
end
end
if alreadyThisYear then
return eYear-tYear, tYear, eYear+1
else
return eYear-tYear-1, tYear, eYear+1
end
else
return 0, tYear, eYear+1
end
end
 
local function evaluateWinnerMax(t)
local winners = t.vainqueur
local result
local most_wins = 0
local most_wins_ID = {}
for winnerID, winner in pairs(winners) do
if winner.count > most_wins then
most_wins = winner.count
most_wins_ID = { winnerID }
elseif winner.count == most_wins then
most_wins_ID[#most_wins_ID + 1] = winnerID
end
end
 
if most_wins > 1 then
for _, id in pairs(most_wins_ID) do
if not result then
result=winners[id].link
else
result=result.."<br>"..winners[id].link
end
end
local _, gen_singular, gen_plural=plural(most_wins)
if gen_singular then --slavic plural, 1 victory is not displayed
word_victory=translate("raceinfobox",29)
elseif gen_plural then
word_victory=translate("raceinfobox",30)
else
word_victory=translate("raceinfobox",32) --singular
end
result=result.."<br>("..tostring(most_wins).." "..word_victory..")"
end
t.maxWinner=result
end
 
local function listOfWinners(itemID,t)
local winners = { Q20882667 = '',}-- Q20882667 is 'overall winner general classification'
local winnersId={ Q20882667 = '',}--to detect disqualification
local WDlink_on, sitelink
 
-- WDlink_on is used to decide if a Wikidata flag will be shown
if wiki == "mk" or wiki == "ja" or wiki == "ru" then WDlink_on = true else WDlink_on = false end
 
-- Get the date to sort the editions
for _, p527 in statements(itemID, 'P527') do --_, p527
local raceDate, year, raceID, entity_race, a, b
raceId = 'Q'..p527.mainsnak.datavalue.value['numeric-id'] -- Qnumbers of the parts of a tour
raceDate=getTimeOfRace(raceId)
table.insert(t.race, { raceId=raceId, raceDate=raceDate, future=compareDate(raceDate)} ) --check if future
table.sort(t.race, function(a,b) return a['raceDate'] < b['raceDate'] end) -- t.race is sorted after year
end
--look for the next race
local lastRunEdition, lastEditionDate, nextEdition
for num, race in ipairs(t.race) do
if race['future'] then
nextEdition=num
break
end
end
--Get the winners
local numberOfEditions=0
local lastWinner, winnerId
 
for num=1,#t.race do
winners.Q20882667=''
winnersId.Q20882667=''
winner(t.race[num]['raceId'], winners, t.race[num]['raceDate'], false, WDlink_on, nil, nil, winnersId )
if t.race[num]['future']==false then --in the past
if winnersId.Q20882667~="Q30108381" then --cancelled
numberOfEditions=numberOfEditions+1
lastRunEdition=num
lastEditionDate=t.race[num]['raceDate']
lastWinner=winners.Q20882667
end
end
winnerId=winnersId.Q20882667
if winnerId~=nil and winnerId~='' and winnerId~='Q666' then --code for disqualification
if not t.vainqueur[winnerId] then
t.vainqueur[winnerId]={}
t.vainqueur[winnerId].link=winners.Q20882667
t.vainqueur[winnerId].count=0
end
t.vainqueur[winnerId].count=t.vainqueur[winnerId].count+1
end
end
 
local monthId=firstValue(itemID, 'P2922','id')
if monthId then
t.lastEditionMonth=getLabelFallback(monthId, {wikilang, 'en', 'fr', 'de'}) or ''
else
t.lastEditionMonth=contentLanguage:formatDate("M", lastEditionDate)
end
 
t.lastEditionYear=contentLanguage:formatDate("Y", lastEditionDate)
t.numberOfEditions=numberOfEditions
evaluateWinnerMax(t)
 
if lastRunEdition then
t.lastWinner=lastWinner or '' --t.vainqueur[lastRunEdition]['link']
sitelink = wikibase.getSitelink(t.race[lastRunEdition]['raceId'])
if sitelink ~= nil then
t.lastLink = "[[" .. sitelink .. "]]"
else
t.lastLink = nil
end
end
if nextEdition then
sitelink = wikibase.getSitelink(t.race[nextEdition]['raceId'])
if sitelink ~= nil then
t.nextLink = "[[" .. sitelink .. "]]"
else
t.nextLink = nil
end
end
end
 
function getPeriodicity(itemID, t)
local p = wikibase.getBestStatements(itemID, 'P2257')
if p[1] and p[1].mainsnak.snaktype == 'value' then
local period=p[1].mainsnak.datavalue.value.amount
local periodunit=p[1].mainsnak.datavalue.value.unit
if tonumber(period)==1 and periodunit == 'http://www.wikidata.org/entity/Q577' then
return translate("raceinfobox",1).." ("..t.lastEditionMonth ..")"
elseif tonumber(period)==1 and periodunit == 'http://www.wikidata.org/entity/Q5151' then
return translate("raceinfobox",2)
else
return nil
end
else
return nil
end
end
 
local function getType(itemID)
local result, typeID
typeID =firstValue(itemID, 'P31', 'id')
if typeID ~= nil then
if typeID=="Q2912397" and wiki=="fr" then
result="[[Cyclisme_sur_route#Épreuve_d'un_jour|Course d'un jour]]"
else
result=WPlinkpure(typeID)
end
end --else result=nil
return result
end
 
local function getFormerNames(itemID, PID)
local listOfNames={}
 
local slavicWikis = {mk = true, ru = true}
local officialname,officialnametemp, language
local wikiIsSlavic = slavicWikis[wiki]
local correctlanguage=true
local listOfProperty={PID}
 
for _, prop in ipairs(listOfProperty) do
for _, p1813 in statements(itemID, prop) do
officialname=nil
language = p1813.mainsnak.datavalue.value.language
officialnametemp = p1813.mainsnak.datavalue.value.text
if wikiIsSlavic then
if wiki==language then
officialname=officialnametemp --only exact language
end
else
if slavicWikis[language]==nil then
officialname=officialnametemp --any language latin
end
end
 
local period, sTime=getPeriod( p1813.qualifiers)
if officialname then
table.insert(listOfNames,{sTime, period, officialname, language})
end
end
end
table.sort(listOfNames, function(a, b) return a[1] < b[1] end)
return listOfNames
end
 
local function officialSite(itemID)
local p856 = wikibase.getBestStatements(itemID, 'P856')
if p856[1] and p856[1].mainsnak.snaktype == 'value' then
local url = p856[1].mainsnak.datavalue.value
return '['..url.." "..translate("raceinfobox",3)..']'
end
return nil
end
 
Line 2.255 ⟶ 2.920:
else km = 'km' end
return km
end
 
local function getm(wiki)
local m
if wiki == "ar" then m = 'م'
elseif wiki == "mk" then m = 'м'
elseif wiki == "ru" then m = 'м'
elseif wiki == "ja" then m = ''
else m = 'm' end
return m
end
 
local function getKg(wiki)
local kg
if wiki == "ar" then kg = 'كجم'
elseif wiki == "mk" then kg = 'kg'
elseif wiki == "ru" then kg = 'kg'
elseif wiki == "ja" then kg = ''
else kg = 'kg' end
return kg
end
 
Line 2.267 ⟶ 2.952:
end
return nil
end
 
local function checkm(p)
local m, unit
if p[1] and p[1].mainsnak.snaktype == 'value' then
m = tonumber(p[1].mainsnak.datavalue.value.amount)
unit = p[1].mainsnak.datavalue.value.unit
if unit == 'http://www.wikidata.org/entity/Q11573' then
return m
elseif unit=='http://www.wikidata.org/entity/Q174728' then --cm
return m*0.01
end
end
return nil
end
 
local function checkkg(p)
local kg, unit
if p[1] and p[1].mainsnak.snaktype == 'value' then
kg = tonumber(p[1].mainsnak.datavalue.value.amount)
unit = p[1].mainsnak.datavalue.value.unit
if unit == 'http://www.wikidata.org/entity/Q11570' then
return kg
end
end
return nil
end
 
local function getHeight(entityID)
local m
local text
local lang = contentLanguage
 
local p = mw.wikibase.getBestStatements(entityID, 'P2048')
m= checkm(p)
if m then
text = lang:formatNum(m)
if wiki == 'fo' then
text = string.gsub(text, "%.", ",")
end
text = text .. ' ' .. getm(wiki)
end
return text
end
 
local function getWeight(entityID)
local kg
local text
local lang = contentLanguage
local p = mw.wikibase.getBestStatements(entityID, 'P2067')
kg = checkkg(p)
 
if kg then
text = lang:formatNum(kg)
if wiki == 'fo' then
text = string.gsub(text, "%.", ",")
end
text = text .. ' ' .. getKg(wiki)
end
return text
end
 
Line 2.374 ⟶ 3.120:
end
 
local function getgendercodegetGenderCode(riderID, default)
local gender
local p21 = mw.wikibase.getBestStatements(riderID, 'P21') -- P21 is gender
Line 2.425 ⟶ 3.171:
end
 
local function calculate_timecalculateTime(t)
local time = tonumber(t)
local h, m, s = 0, 0, 0
Line 2.436 ⟶ 3.182:
end
 
if h>0 then str = str..mw.ustring.format ('%i'..unittranslate("unit",2), h) end
if m>=0 and h>0 then str = str.. mw.ustring.format('%02i'..unittranslate("unit",3), m) end
if m>0 and h==0 then str = str.. mw.ustring.format('%i'..unittranslate("unit",3), m) end
if s>=0 and (h>0 or m>0) then str = str.. mw.ustring.format('%02i'..unittranslate("unit",4), s) end
if s>=0 and h==0 and m==0 then str = str.. mw.ustring.format('%i'..unittranslate("unit",4), s) end
return str --time..': '..h..' '..m..' '..s
end
 
function func_error_message(wiki,x)
local l10nDef = {
["en"] = {'Property <1> is missing in item "<2>" (<3>)'},
Line 2.465 ⟶ 3.211:
end
return l10n
end
 
--== IV) Translation ==
function startlist_translate(x)
local l10nDef = {
["ar"] = {"المشاركين","م","عداء","مرتبة","مدير الرياضة:","لم يكمل السباق","HD","لم يبدأ","تم إقصائه","طريق","فردي ضد الساعة","و","بدون فريق","عرض","إخفاء"},
["ast"] = {"Llista de participantes", "Númberu", "Ciclista","Posición","Direutor deportivu:","AB","FLT","NTS","DES","ruta","CRI","y", "ensin equipo","amosar","anubrir"},
["br"] = {"Roll ar berzidi", "Niv.", "Reder","Pos","Rener sport :","AB","HD","NP","DQ","hent","chrono","ha", "hep skipailh","diskouez","kuzhat"},
["ca"] = {"Llista de participants", "#", "Rider","Rank","Directeur sportif:","DNF","HD","NP","DQ","road","ITT","and", "no team","show","hide"},
["da"] = {"Startliste", "Nr.", "Rytter","Placering","Sportsdirektør:","DNF","HD","DNS","DQ","landevej","enkeltstart","og", "intet hold","vis","skjul"},
["de"] = {"Startliste", "Nr.", "Fahrer","Platz","Sportlicher Leiter:","DNF","HD","NP","DQ","Straße","Zeitfahrt","und", "no team","Öffnen","Schließen"},
["en"] = {"Startlist", "#", "Rider","Rank","Directeur sportif :","DNF","OTL","DNS","DSQ","road","ITT","and", "no team","show","hide"},
["es"] = {"Lista de participantes", "Dorsal", "Ciclista","Posición","Director deportivo:","AB","FLT","NTS","DES","ruta","CRI","y", "sin equipo","show","hide"},
["fr"] = {"Liste des participants", "Num", "Coureur","Pos","Directeur sportif :","AB","HD","NP","DQ","route","chrono","et", "sans équipe","afficher","masquer"},
["lv"] = {"Starta saraksts", "#", "Braucējs","Rangs","Sporta direktors:","DNF","HD","NP","DQ","šoseja","ITT","un", "nav komandas","show","hide"},
["mk"] = {"Почетен состав", "Бр.", "Возач","Место","Спортски директор:","НЗ","HD","NP","DQ","друмска","ITT","и", "нема екипа","show","hide"},
["nl"] = {"Deelnemerslijst", "Nummer", "Wielrenner","Ranglijst", "Ploegleider :","AB","HD","NP","DQ","weg","chrono","en", "zonder ploeg","show","hide"},
["pt"] = {"Lista de Participantes", "Dorsal", "Ciclista","Posição","Director desportivo:","DNF","HD","NP","DQ","estrada","CRI","e", "sem equipe","show","hide"},
["ru"] = {"Составы команд", "№", "Гонщик","Место","Спортивный директор:","DNF","OTL","DNS","DSQ","RR","ITT","и", "без команды","показать","скрыть"},
["no"] = {"Startliste", "Nr.", "Rytter","Plassering","Sportsdirektør:","DNF","OTL","DNS","DSQ","landevei","tempo","og", "ingen lag","vis","skjul"},
}
local l10n = l10nDef[wiki]
if not l10n then l10n = l10nDef["en"] end -- default
return l10n[x]
end
 
function startlisttable_translate(wiki,x)
local l10nDef ={
["ar"] = {"المشاركين", "#", "الدراج","الفريق","المرتبة"},
["ca"] = {"Llista de participants", "#", "Rider",'Equip',"Rank"},
["da"] = {"Startliste", "Nr.", "Rytter","Holdnavn","Placering"},
["de"] = {"Startliste", "Nr.", "Fahrer","Team","Platz"},
["en"] = {"Startlist", "#", "Rider","Team","Rank"},
["es"] = {"Lista de participantes", "Dorsal", "Ciclista","Equipo","Posición"},
["fr"] = {"Liste des participants", "Num", "Coureur","Équipe","Pos"},
["lv"] = {"Starta saraksts", "#", "Braucējs","Komandas nosaukums","Rangs"},
["mk"] = {"Почетен состав", "Бр.", "Возач","Име на екипата", "Место"},
["nl"] = {"Deelnemerslijst", "Nummer", "Wielrenner","Ploegnaam","Ranglijst"},
["pt"] = {"Lista de Participantes", "Dorsal", "Ciclista","Equipe","Posição"},
["ru"] = {"Составы команд", "№", "Гонщик","Команда","Место"},
["no"] = {"Startliste", "Nr.", "Rytter","Lagnavn","Plassering"},
}
local l10n = l10nDef[wiki]
if not l10n then l10n = l10nDef["en"] end -- default
return l10n[x]
end
 
local function race_reference_translate(wiki, x)
local l10nDef = {
["ar"] = {"مصدر: ", "مصادر: "},
["ast"] = {"Fonte: ","Fontes: "},
["br"] = {"Dave : ", "Daveoù : "},
["da"] = {"Kilde: ","Kilder: "},
["de"] = {"Quelle: ","Quellen: "},
["en"] = {"Source: ", "Sources: "},
["es"] = {"Fuente: ","Fuentes: "},
["fr"] = {"Source : ", "Sources : "},
["he"] = {"מקור : ", "מקורות : "},
["hu"] = {"Forrás: ", "Források: "},
["lv"] = {"Avots: ", "Avoti: "},
["mk"] = {"Извор: ", "Извори: "},
["no"] = {"Kilde: ","Kilder: "},
["pt"] = {"Fonte: ","Fontes: "},
["ru"] = {"Источник: ", "Источники: "},
}
local l10n = l10nDef[wiki] or l10nDef["en"] -- default
return l10n[x]
end
 
local function calendar_translate(wiki, x, title)
local l10nDef = {
["ar"] = { "تقويم الاتحاد الدولي للدراجات", "التاريخ", "#", "السباق", "البلد", "الصنف", "الفائز", "الثاني", "الثالث", "متصدر الترتيب العام", "طواف العالم للدراجات للنساء", "", "طواف العالم للدراجات" , "طواف أوروبا للدراجات" , "طواف آسيا للدراجات" , "طواف أمريكا للدراجات" , "طواف أفريقيا للدراجات" , "طواف أوقيانوسيا للدراجات", "بطولات وطنية", "سباق الطريق", "سباق فردي ضد الساعة" },
["ast"] = {"Calendariu UCI", "Data", "#","Carrera", "País", "Clas", "Ganador","Segundu", "Terceru", "Líder","UCI WorldTour Femenín","","UCI WorldTour","UCI Europe Tour","UCI Asia Tour","UCI America Tour","UCI Africa Tour","UCI Oceania Tour","Campeonatu nacional","Carrera de ruta","Contrarreló individual"},
["br"] = {"Deiziadur UCI", "Deiziad", "niv.","Redadeg", "Bro", "Klas", "Gounezer", "Eil", "Trede", "E penn ar renkamant hollek","UCI Women's World Tour","","UCI World Tour","UCI Europe Tour","UCI Asia Tour","UCI America Tour","UCI Africa Tour","UCI Oceania Tour","Kampionadoù broadel","Redadeg a-renk","A-benn d'an eur hiniennel"},
["fr"] = {"Calendrier UCI", "Date", "n°","Course", "Pays", "Classe", "Vainqueur", "Deuxième", "Troisième", "Leader du classement général","UCI Women's World Tour","","UCI World Tour","UCI Europe Tour","UCI Asia Tour","UCI America Tour","UCI Africa Tour","UCI Oceania Tour","Championnats nationaux","Course en ligne","Contre-la-montre"},
["en"] = {"UCI Calendar", "Date", "#","Race", "Country", "Class", "Winner", "Second", "Third", "Overall leader","UCI Women's World Tour","","UCI World Tour","UCI Europe Tour","UCI Asia Tour","UCI America Tour","UCI Africa Tour","UCI Oceania Tour","National championship","Road race","Individual time trial"},
["de"] = {"UCI Kalender", "Datum", "Nr.","Rennen", "Staat", "Klasse", "Sieger", "Zweiter", "Dritter", "Gesamt&shy;führender","UCI Women's World Tour","","UCI World Tour","UCI Europe Tour","UCI Asia Tour","UCI America Tour","UCI Africa Tour","UCI Oceania Tour","Nationale Straßen-Radsportmeister","Straßenrennen","Einzelzeitfahren"},
["da"] = {"","Dato", "#","Løb", "Land", "Klasse", "Vinder","Toer", "Treer", "Førende rytter","UCI Women's World Tour","","UCI World Tour","UCI Europe Tour","UCI Asia Tour","UCI America Tour","UCI Africa Tour","UCI Oceania Tour","Nationalt mesterskab","Landevej","Enkeltstart"},
["es"] = {"Calendario UCI", "Fecha", "#","Carrera", "País", "Clase", "Ganador","Segundo", "Tercero", "Líder","UCI Women's World Tour","","UCI World Tour","UCI Europe Tour","UCI Asia Tour","UCI America Tour","UCI Africa Tour","UCI Oceania Tour","Campeonato nacional","Carrera de ruta","Contrarreloj individual"},
["he"] = {"UCI Calendar", "תאריך", "#","מרוץ", "מדינה", "Class", "מנצח", "שני", "שלישי", "Overall leader","UCI Women's World Tour","","UCI World Tour","UCI Europe Tour","UCI Asia Tour","UCI America Tour","UCI Africa Tour","UCI Oceania Tour","אלוף לאומי","Road race","Individual time trial"},
["ja"] = {"", "開催日", "#","レース", "国", "国", "勝者","準優勝", "3位", "全体リーダー","UCI Women's World Tour","","UCI World Tour","UCI Europe Tour","UCI Asia Tour","UCI America Tour","UCI Africa Tour","UCI Oceania Tour","National championship","Road race","Individual time trial"},
["lv"] = {"", "Datums", "#","Sacensības", "Valsts", "Kategorija", "Uzvarētājs","Otrais", "Trešais", "Kopvērtējuma līderis","UCI Women's World Tour","","UCI World Tour","UCI Europe Tour","UCI Asia Tour","UCI America Tour","UCI Africa Tour","UCI Oceania Tour","National championship","Road race","Individual time trial"},
["mk"] = {"", "Датум","#", "Трка", "Земја", "Класа", "Победник", "Второпласиран", "Третопласиран", "Cевкупен лидер","UCI Women's World Tour","","UCI World Tour","UCI Europe Tour","UCI Asia Tour","UCI America Tour","UCI Africa Tour","UCI Oceania Tour","National championship","Road race","Individual time trial"},
["no"] = {"", "Dato", "#","Ritt", "Land", "Klasse", "Vinner", "Andreplass", "Tredjeplass", "Sammenlagt&shy;leder","UCI Women's World Tour","","UCI World Tour","UCI Europe Tour","UCI Asia Tour","UCI America Tour","UCI Africa Tour","UCI Oceania Tour","Nasjonalt mesterskap","Landevei","Tempo"},
["pt"] = {"Calendário UCI", "Data", "#", "Corrida", "País", "Clase", "Vencedor", "Segundo", "Terceiro", "Líder", "UCI Women's World Tour", "", "UCI World Tour", "UCI Europe Tour", "UCI Asia Tour", "UCI America Tour", "UCI Africa Tour", "UCI Oceania Tour", "Campeonato nacional", "Corrida de estrada", "Contrarrelógio individual"},
["ru"] = {"", "Дата", "№","Гонка", "Страна", "Класс", "Победитель","Второй", "Третий", "Лидер генеральной классификации","UCI Women's World Tour","","UCI World Tour","UCI Europe Tour","UCI Asia Tour","UCI America Tour","UCI Africa Tour","UCI Oceania Tour","National championship","Road race","Individual time trial"},
}
local l10n = l10nDef[wiki]
if not l10n then l10n = l10nDef["en"] end -- default
if x==1000 then --code
return title
else
return l10n[x]
end
end
 
function victories_translate(wiki, x)
local l10nDef = {
["ar"] = {"التصنيف العام", "سجل الفوز", "التاريخ", "السباق", "البلد", "الصنف", "الفائز","مرحلة","المقدمة"},
["fr"] = {"Classement général", "Victoires", "Date", "Course", "Pays", "Classe", "Vainqueur","étape","Prologue"},
["en"] = {"General classification", "Victories", "Date", "Race", "Country", "Class", "Winner","stage","Prologue"},
["de"] = {"Gesamtwertung", "Siege", "Datum", "Rennen", "Staat", "Klasse", "Sieger","Etappe","Prolog"},
["da"] = {"Samlede stilling", "Sejre", "Dato", "Løb", "Land", "Klasse", "Vinder","etape","Prolog"},
["es"] = {"Clasificación general", "Victorias", "Fecha", "Carrera", "País", "Clase", "Ganador","etapa","Prólogo"},
["ja"] = {"General classification", "Victories", "開催日", "レース", "国", "国", "勝者","ステージ","プロローグ"},
["lv"] = {"Kopvērtējums", "Uzvaras", "Datums", "Sacensības", "Valsts", "Kategorija", "Uzvarētājs","posms","prologs"},
["mk"] = {"General classification", "Victories", "Датум", "Трка", "Земја", "Класа", "Победник","Етапа","Пролог"},
["no"] = {"Sammenlagt", "Seire", "Dato", "Ritt", "Land", "Klasse", "Vinner","etappe","Prolog"},
["ru"] = {"генеральная классификация", "Победы", "Дата", "Гонка", "Страна", "Класс", "Победитель","этап","пролог"},
["ast"] = {"Clasificación xeneral", "Victories", "Data", "Carrera", "País", "Clas", "Ganador","etapa","Prólogu"},
["br"]={"Renkamant hollek", "Trec'hioù", "Deiziad", "Redadeg", "Bro", "Klas", "Gounezer","tennad","Prolog"},
["ca"]={"Classifiació general", "Victòries", "Data", "Cursa", "País", "Classe", "Vencedor","etapa","Pròleg"},
["cs"]={"General classification", "Victories", "Date", "Race", "Country", "Class", "Winner","etapa","Prolog"},
["eo"]={"General classification", "Victories", "Date", "Race", "Country", "Class", "Winner","Etapo","Prologo"},
["eu"]={"General classification", "Victories", "Date", "Race", "Country", "Class", "Winner","Etapa","Aitzinetapa"},
["fi"]={"General classification", "Victories", "Date", "Race", "Country", "Class", "Winner","Etappi","Prologi"},
["fo"]={"General classification", "Victories", "Date", "Race", "Country", "Class", "Winner","teinur","Forteinur"},
["he"] = {"סיווג כללי", "נצחונות", "תאריך", "מרוץ", "מדינה", "מחלקה", "מנצח","שלב","פרולוג"},
["la"]={"General classification", "Victories", "Date", "Race", "Country", "Class", "Winner","Statio","Incipit prologus"},
["it"]={"General classification", "Victories", "Date", "Race", "Country", "Class", "Winner","Tappa","Prologo"},
["hu"]={"General classification", "Victories", "Date", "Race", "Country", "Class", "Winner","Szakasz","Prolog"},
["lb"]={"General classification", "Victories", "Date", "Race", "Country", "Class", "Winner","etapp","Prolog"},
["nl"]={"Algemeen klassement", "Overwinningen", "Datum", "Race", "Land", "Klassement", "Winnaar","Etappe","Proloog"},
["pl"]={"General classification", "Victories", "Date", "Race", "Country", "Class", "Winner","Etap","Prologu"},
["pt"]={"Classificação geral", "Victórias", "Data", "Corrida", "País", "Classe", "Vencedor", "Etapa", "Prólogo"},
["ro"]={"General classification", "Victories", "Date", "Race", "Country", "Class", "Winner","Etapa","Prolog"},
["sk"]={"General classification", "Victories", "Date", "Race", "Country", "Class", "Winner","Etapa","Prológ"},
["sv"]={"General classification", "Victories", "Date", "Race", "Country", "Class", "Winner","Etapp","Prolog"},
}
local l10n = l10nDef[wiki]
if not l10n then l10n = l10nDef["en"] end -- default
return l10n[x]
end
 
local function listofstagesclassification_translate(x)
local l10nDef = {
["ar"]={"لا أحد","النهائي"},
["fr"]={"non attribué","Classements finals"},
["en"]={"not attributed","Final"},
["da"]={"ikke uddelt","Samlet"},
["es"]={"no otorgado","Clasificaciones finales"},
["no"]={"ikke utdelt","Sammenlagt"},
["ru"]={"не определялся","Итог"},
}
local l10n = l10nDef[wiki]
if not l10n then l10n = l10nDef["en"] end -- default
return l10n[x]
end
 
local function stageinfobox_translate(x)
--[[ This function permits to translate fields of the infobox for stages. Take the line below, give a Wikipedia
(ex : mk), and translate all fields. By default, English values are taken.]]
local l10nDef = {
["fr"] = {"Généralités", "Course", "Type", "Date", "Dates", "Distance", "Pays", "Pays",
"Lieu de départ", "Lieu d'arrivée", "Partants",
"Arrivants", "Vitesse moyenne", "Coût", "Résultats de l’étape", "Vainqueur", "Deuxième", "Troisième", "Combatif",
"Classement général à l’issue de l’étape", "Leader", "Deuxième", "Troisième",
"Classements annexes à l’issue de l’étape", "Points", "Montagne", "Sprints", "Jeune", "Super- combatif",
"Combiné", "Étapes volantes", "Régularité",
"Équipe", "Équipe aux points",
"Image", "Légende", "Carte", "Vue en coupe", "Documentation", "Cima Coppi", "Cima Pantani", "Azzurri d'Italia", "Fuga", "Dénivelé"},
["ar"] = {"تفاصيل السباق", "سباق", "نوع", "تاريخ", "تاريخ", "مسافة", "بلد", "بلدان", "نقطة البداية", "نقطة النهاية", "الدراجين في البداية",
"الدراجين في النهاية", "متوسط السرعة", "الكلفة", "نتائج المرحلة", "الفائز", "الثاني", "الثالث", "متمرس",
"التصنيف العام بعد المرحلة", "القائد", "الثاني", "الثالث",
"التصنيفات الثانوية بعد المرحلة", "النقاط", "الجبل", "سباقات السرعة", "شاب", "تصنيف القتال", "ممتزجة", "سباقات سرعة متوسطة", "الانتظام",
"فريق", "فريق حسب النقاط", "صورة", "أسطورة", "بطاقة", "عرض الاقسام", "توثيق",
"سيما كوبي", "سيما بانتاني", "أزوري دي إيطاليا", "Breakaway", "الارتفاع"},
["en"] = {"Race details", "Race", "Type", "Date", "Dates", "Distance", "Country", "Countries",
"Journey origin", "Lieu d'arrivée", "Starting riders",
"Arriving riders", "Average speed", "Cost", "Stage results", "Winner", "Second", "Third", "Combative",
"General classification after stage", "Leader", "Second", "Third",
"Secondary classifications after stage", "Points", "Mountain", "Sprints", "Young", "Combativity",
"Combinated", "Intermediate sprints", "Regularity",
"Team", "Team by points",
"Image", "Legend", "Card", "Sectional view", "Documentation", "Cima Coppi", "Cima Pantani",
"Azzurri d'Italia", "Breakaway", "Elevation"},
["ja"] = {"レース詳細", "レース", "種類", "日付", "日付", "距離", "国", "国", "スタート", "ゴール", "スタート選手",
"ゴール選手", "平均速度", "Cost", "ステージ結果", "優勝", "2位", "3位", "Combative",
"ステージ後クラス", "1位", "2位", "3位",
"ステージ後副次的クラス", "ポイント賞", "山岳賞", "スプリント賞", "新人賞", "敢闘賞", "コンビネーション賞", "Metas volantes", "Regularity",
"チーム", "ポイント順位",
"画像", "凡例", "カード", "断面図", "ドキュメンテーション", "Cima Coppi", "Cima Pantani", "Azzurri d'Italia", "Breakaway", "Elevation"},
["ca"] = {"Detalls de la cursa", "Cursa", "Tipus", "Data", "Dates", "Distància", "País", "Països", "Origen de la cursa", "Lloc d’arribada", "Corredors sortits",
"Corredors arribats", "Velocitat mitjana", "Durada", "Resultats de l'etapa", "Guanyador", "Segon", "Tercer", "Combatiu",
"Classificació general després de l'etapa", "Líder", "Segon", "Tercer",
"Classificacions secundàries després de l'etapa ", "Punts", "Muntanya", "Esprints ", "Jove", "Combativitat", "Combinada", "Metes volants", "Regularitat",
"Equip", "Equip per punts",
"Imatge", "Llegenda", "Card", "Sectional view", "Documentació", "Cima Coppi", "Cima Pantani", "Azzurri d'Itàlia", "Fuga", "Elevation"},
["da"] = {"Etapedetaljer", "Rute", "Type", "Dato", "Datoer", "Distance", "Land", "Lande", "Startby", "Målby", "Startende ryttere",
"Fuldførende ryttere", "Gennemsnitlig fart", "Omkostninger", "Etaperesultat", "Vinder", "Toer", "Treer", "Mest angrebsivrige",
"Samlede stilling efter etapen", "Førende rytter", "Toer", "Treer",
"Klassementerne efter etapen", "Point", "Bjerg", "Sprint", "Ungdom", "Mest angrebsivrige", "Kombination", "Indlagt spurt", "Regularitet",
"Hold", "Hold efter point",
"Billede", "Billedtekst", "Kort", "Profil", "Dokumentation", "Cima Coppi", "Cima Pantani", "Azzurri d'Italia", "Udbrud", "Elevation"},
["es"] = {"Detalles de la carrera", "Carrera", "Tipo", "Fecha", "Fechas", "Distancia", "País", "Países", "Lugar de inicio", "Lugar de llegada", "Ciclistas participantes",
"Ciclistas finalizados", "Velocidad media", "Duración", "Resultados de la etapa", "Ganador", "Segundo", "Tercero", "Combativo",
"Clasificación general después de la etapa", "Líder", "Segundo", "Tercero",
"Clasificaciones secundarias después de la etapa", "Puntos", "Montaña", "Esprint", "Joven", "Combatividad", "Combinada", "Metas volantes", "Regularidad",
"Equipo", "Equipo por puntos",
"Imagen", "Leyenda", "Card", "Sectional view", "Documentation", "Cima Coppi", "Cima Pantani", "Azzurri d'Italia", "Fuga", "Elevation"},
["fo"] = {"Smálutir um kapping", "Kapping", "Slag", "Dagur", "Dagar", "Fjarstøða", "Land", "Lond", "Byrjunarbýur", "Málbýur", "Byrjandi súkklarar",
"Fullførandi súkklarar", "Miðalferð", "Kostnaður", "Teinaúrslit", "Vinnari", "Annað pláss", "Triðja pláss", "Álopsheiður",
"Høvuðskappingin eftir teinin", "Førandi súkklari", "Tveyari", "Tríari",
"Aðrar kappingar eftir teinin", "Stig", "Fjøll", "Spurtar", "Ungdóms", "Álopsheiður", "Kombinatiónsheiður", "Metas volantes", "Regularitetur",
"Lið", "Lið eftir stigum",
"Mynd", "Myndatekstur", "Kort", "Brotpartur", "Skjalfesting", "Cima Coppi", "Cima Pantani", "Azzurri d'Italia", "Breakaway", "Elevation"},
["he"] = {"פרטי מרוץ", "מרוץ", "סוג", "תאריך", "תאריכים", "מרחק", "מדינה", "מדינות",
"התחלת המסלול", "Lieu d'arrivée", "רוכבים מתחילים",
"רוכבים מסיימים", "מהירות ממוצעת", "Cost", "Stage results", "מנצח", "מקום שני", "מקום שלישי", "Combative",
"General classification after stage", "מוביל", "שני", "שלישי",
"Secondary classifications after stage", "נקודות", "הר", "Sprints", "Young", "Combativity",
"Combinated", "Intermediate sprints", "Regularity",
"קבוצה", "קבוצה על פי ניקוד",
"תמונה", "כיתוב", "Card", "Sectional view", "Documentation", "Cima Coppi", "Cima Pantani",
"Azzurri d'Italia", "Breakaway", "Elevation"},
["lb"] = {"Allgemenges", "Course", "Typ", "Datum", "Datumer", "Distanz", "Land", "Land", "Depart", "Arrivée", "Um Start",
"Ukomm", "Vitess-moyenne", "Käschten", "Résultater vun der Etapp", "Gewënner", "Zweeten", "Drëtten", "Combativ",
"Generalklassement no der Etapp", "Éischten", "Zweeten", "Drëtten",
"Aner Klassementer no der Etapp", "Punkten", "Bierg", "Sprint", "Bescht Jonken", "Super- combativ", "Combiné", "Fligend Etappen", "Regelméissegkeet",
"Equipe", "Equipe no Punkten",
"Fichier", "Legend", "Kaart", "Profil", "Dokumentatioun", "Cima Coppi", "Cima Pantani", "Azzurri d'Italia", "Breakaway", "Elevation"},
["no"] = {"Etappedetaljer", "Etappe", "Type", "Dato", "Datoer", "Distanse", "Land", "Land", "Startsted", "Målsted", "Startende ryttere",
"Fullførende ryttere", "Snittfart", "Omkostninger", "Etapperesultat", "Vinner", "Andre", "Tredje", "Offensiv",
"Sammenlagtstilling etter etappen", "Sammenlagtleder", "Andre", "Tredje",
"Klassifisering etter etappen", "Poeng", "Klatring", "Spurt", "Ungdom", "Offensiv", "Kombinasjon", "Innlagte spurter", "Regularitet",
"Lag", "Lag (poeng)",
"Bilde", "Bildetekst", "Kart", "Profil", "Dokumentasjon", "Cima Coppi", "Cima Pantani", "Azzurri d'Italia", "Brudd", "Elevation"},
["pt"] = {"Detalhes da corrida", "Corrida", "Tipo", "Data", "Datas", "Distância", "País", "Países", "Origem da viagem", "Local de chegada", "Partida dos ciclistas",
"Chegada dos ciclistas", "Velocidade média", "Custo", "Resultados da etapa", "Vencedor", "Segundo", "Terceiro", "Combativo",
"Classificação geral após a etapa", "Líder", "Segundo", "Terceiro",
"Classificação secundária após a etapa", "Pontos", "Montanha", "Corridas de velocidade", "Jovem", "Combatividade", "Combinados", "Metas volantes", "Regularidade",
"Equipe", "Equipe por pontos",
"Imagem", "Legenda", "Ficha", "Vista secional", "Documentação", "Cima Coppi", "Cima Pantani", "Azzurri d'Italia", "Fuga", "Elevation"},
["nl"] = {"Race details", "Wedstrijd", "Soort", "Datum", "Datums", "Afstand", "Land", "Landen", "Start van de etappe", "Aankomstplaats", "Coureurs aan de start",
"Coureurs bij de finish", "Gemiddelde snelheid", "Kosten", "Etappeuitslag", "Winnaar", "Tweede", "Derde", "Combative",
"Algemeen klassement na de etappe", "Leider", "Tweede", "Derde",
"Bijkomende uitslagen na de wedstrijd", "Punten", "Berg", "Sprints", "Jongeren", "Combativity", "Combinatie", "Metas volantes", "Regularity",
"Team", "Team per punten",
"Afbeelding", "Legenda", "Kaart", "Dwarsdoorsnede", "Documentatie", "Cima Coppi", "Cima Pantani", "Azzurri d'Italia", "Demarrage", "Elevation"},
["ru"] = {"Детали гонки", "Гонка", "Тип", "Дата", "Даты", "Дистанция", "Страна", "Страны", "Место старта", "Место финиша", "Стартовало гонщиков",
"Финишировало гонщиков", "Средняя скорость", "Затраты", "Результаты этапа", "Победитель", "Второй", "Третий", "Боец",
"Генеральная классификация после этапа", "Лидер", "Второй", "Третий",
"Классификации после этапа", "Очки", "Горная", "Спринтерская", "Молодёжная", "Бойцовская", "Комбинированная", "Промежуточные финиши", "Регулярность",
"Командная по времени", "Командная по очкам",
"Изображение", "Описание", "Карта", "Сектора", "Документация", "Cima Coppi", "Cima Pantani", "Azzurri d'Italia", "Breakaway", "Elevation"},
["ast"] = {"Detalles de la carrera", "Carrera", "Tipu", "Data", "Dates", "Distancia", "País", "Países", "Llugar d'entamu",
"Llugar de llegada", "Ciclistes participantes", "Ciclistes acabaos", "Velocidá media", "Duración", "Resultaos de la etapa",
"Ganador", "Segundu", "Terceru", "Combativu", "Clasificación xeneral depués de la etapa", "Líder", "Segundu", "Terceru",
"Clasificaciones secundaries depués de la etapa", "Puntos", "Monte", "Esprint", "Mozu", "Combatividá", "Combinada", "Metes volantes",
"Regularidá", "Equipu", "Equipu per puntos", "Imaxe", "Lleenda", "Card", "Sectional view", "Documentación", "Cume Coppi",
"Cume Pantani", "Azzurri d'Italia", "Fuga", "Elevation"},
["br"] = {"Hollegezhioù", "Redadeg", "Doare", "Deiziad", "Deiziadoù", "Hed", "Bro", "Broioù",
"Lec'h loc'hañ", "Lec'h degouezhout", "Loc'herien",
"Erruerien", "Tizh keitat", "Koust", "Disoc'hoù an tennad", "Gounezer", "Eil", "Trede", "Stourmer",
"Classement général à l’issue de l’étape", "Levier", "Eil", "Trede",
"Classements annexes à l’issue de l’étape", "Poentoù", "Menez", "Sprintoù", "Yaouank", "Stourmer meur",
"Liesrenkadur", "Sprintoù etre", "Régularité",
"Skipailh", "Skipailh a-boentoù",
"Skeudenn", "Alc'hwez", "Kartenn", "Gwell e skejad", "Teuliadur", "Cima Coppi", "Cima Pantani", "Azzurri d'Italia", "Fuga", "Elevation"},
}
local l10n = l10nDef[wiki]
if not l10n then l10n = l10nDef["en"] end -- default
return l10n[x]
end
 
local function getSquadTableColumn(x)
local l10nDef = { -- note (in the table), note (below the table)
["ar"] = {"المتسابق", "تاريخ الولادة", "الفريق السابق", "ملاحظة", "ملاحظة", "البلد", "قائمة الفريق"},
["fr"] = {"Cycliste", "Date de naissance", "Équipe précédente", "note", "note", "Pays", "Effectif"},
["en"] = {"Rider", "Date of birth", "Previous team", "note", "note", "Country", "Team roster"},
["br"] = {"Reder", "Deiziad genel", "Skipailh a-raok", "notenn", "notenn", "Bro", "Koskor"},
["ca"] = {"Ciclista", "Data de naixement", "Equip previ", "Nota", "Nota", "País", "Team roster"},
["cs"] = {"Cyklista", "Datum narození", "Předchozí tým", "note", "note", "Stát", "Týmová soupiska"},
["da"] = {"Rytter", "Fødselsdag", "Seneste hold", "note", "note", "Land", "Trup"},
["de"] = {"Name", "Geburtsdatum", "Vorheriges Team", "Anm.", "Anmerkung", "Land", "Team roster"},
["eo"] = {"Antaŭnomo Nomo", "Naskiĝtago", "Previous team", "note", "note", "Lando", "Team roster"},
["es"] = {"Corredor", "Fecha de nacimiento", "Equipo previo", "Nota", "Nota", "País", "Integrantes del equipo"},
["eu"] = {"Izena", "Jaiotze-data", "Aurreko taldea", "Oharra", "Oharra", "Herrialdea", "Team roster"},
["fi"] = {"Ajaja", "Syntymäaika", "Edellinen joukkue", "huomio", "huomio", "Maa", "Team roster"},
["fo"] = {"Súkklari", "Føðingardagur", "Undanfarna lið", "note", "note", "Land", "Team roster"},
["he"] = {"רוכב", "תאריך לידה", "קבוצה קודמת", "הערה", "הערה", "מדינה", "סגל הקבוצה"},
["hu"] = {"Név", "Születésnap", "Előző csapat", "jegyzet", "jegyzet", "Ország", "Team roster"},
["it"] = {"Ciclista", "Data di nascita", "Previous team", "Nota", "Nota", "Paese", "Team roster"},
["ja"] = {"選手名", "生年月日", "前所属", "脚注", "脚注", "国", "Team roster"},
["lb"] = {"Coureur", "Gebuertsdatum", "Equipe virdrun", "Nott", "Nott", "Staat", "Team roster"},
["lv"] = {"Braucējs", "Dzimšanas datums", "Iepriekšējā komanda", "piezīme", "piezīme", "Valsts", "Komandas sastāvs"},
["mk"] = {"Велосипедист", "Датум на раѓање", "Претходна екипа", "Фуснота", "Фуснота", "Држава", "Состав на екипата"},
["nl"] = {"Naam", "Geboortedatum", "Vorige ploeg", "noot", "noot", "Nationaliteit", "Renners"},
["no"] = {"Rytter", "Fødselsdato", "Tidligere lag", "note", "note", "Land", "Ryttere"},
["pl"] = {"Imię i nazwisko", "Data urodzenia", "Poprzednia grupa", "Przypis", "Przypis", "Państwo", "Team roster"},
["pt"] = {"Ciclista", "Data de nascimento", "Equipe anterior", "Nota", "Nota", "Pais", "Integrantes da equipe"},
["ro"] = {"Ciclist", "Data nașterii", "Previous team", "note", "note", "Țară", "Team roster"},
["ru"] = {"Гонщик", "Дата рождения", "Предыдущая команда", "Примечание", "Примечание", "Страна", "Состав"},
["sv"] = {"Namn", "Födelsedatum", "Previous team", "not", "not", "Land", "Team roster"},
["zh"] = {"車手", "出生日期", "Previous team", "脚注", "脚注", "国家", "Team roster"},
["ast"] = {"Corredor", "Data de nacencia", "Equipu previu", "Nota", "Nota", "País", "Integrantes del equipu"},
}
local l10n = l10nDef[wiki]
if not l10n then l10n = l10nDef["en"] end -- default
return l10n[x]
end
 
local function infobox_translate(x)
-- This function permits to translate fields of the infobox, take the line below, give a Wikipedia (ex : mk), and translate all fields. By default, English values are taken.
-- l10nDef["//??.wikipedia.org"] = {"RACE DETAILS", "COURSE", "COMPETITION", "COMPETITIONS", "STAGES", "DATE", "DATES", "DISTANCE", "COUNTRY", "COUNTRIES",
-- "JOURNEY ORIGIN", "JOURNEY DESTINATION", "TEAMS", "STARTING RIDERS", "ARRIVING RIDERS", "AVERAGE SPEED", "COST", "PALMARES", "WINNER", "SECOND", "THIRD",
-- "POINTS", "MOUNTAINS", "SPRINTS", "YOUTH", "COMBATIVITY", "COMBINATION", "TEAM", "Picture", "Caption", "Map", "Special 1", "Special 2", "Documentation",
-- "METAS VOLANTES", "REGULARIDAD", "TEAM POINTS"}
local l10nDef = {
["ar"] = {"تفاصيل السباق", "سلسلة", "منافسة", "مسابقات", "مراحل", "التاريخ", "التواريخ", "المسافات", "البلد", "البلدان",
"نقطة البداية", "نقطة النهاية", "الفرق", "عدد المتسابقين في البداية", "عدد المتسابقين في النهاية", "متوسط السرعة", "الكلفة", "المنصة", "الفائز", "الثاني",
"الثالث", "حسب النقاط", "تسلق الجبل", "سباقات السرعة", "أفضل شاب", "تصنيف القتال", "مجموعة", "الفريق", "صورة", "تعليق", "خريطة", "مميز 1", "مميز 2", "توثيق", "سباقات السرعة", "انتظام", "نقاط الفريق", "فوجا بيناريلو", "أزوري دي إيطاليا","صاعد", "هواة","الجنسية"
,"الارتفاع"
},
["fr"] = {"Généralités", "Course", "Compétition", "Compétitions", "Étapes", "Date", "Dates", "Distance", "Pays", "Pays",
"Lieu de départ", "Lieu d'arrivée", "Équipes", "Partants", "Arrivants", "Vitesse moyenne", "Coût", "Résultats", "Vainqueur", "Deuxième", "Troisième",
"Classement par points", "Meilleur grimpeur", "Meilleur sprinteur", "Meilleur jeune", "Super-combatif", "Meilleur au combiné", "Meilleure équipe",
"Image", "Légende", "Carte", "Special 1", "Special 2", "Documentation", "Étapes volantes", "Régularité", "Meilleure équipe aux points",
"Fuga", "Azzurri d'Italia", "Néophyte", "Amateur","Nationalité","Dénivelé"},
["en"] = {"Race details", "Course", "Competition", "Competitions", "Stages", "Date", "Dates", "Distance", "Country", "Countries",
"Journey origin", "Journey destination", "Teams", "Starting riders", "Arriving riders", "Average speed", "Cost", "Palmares", "Winner", "Second",
"Third", "Points", "Mountains", "Sprints", "Youth", "Combativity", "Combination", "Team", "Picture", "Caption", "Map", "Special 1", "Special 2",
"Documentation", "Intermediate sprints", "Regularidad", "Team points", "Breakaway", "Azzurri d'Italia", "Rookie","Amateur","Nationality","Elevation"},
["ja"] = {"レース詳細", "コース", "競技", "競技", "ステージ", "日付", "日付", "距離", "距離", "国",
"スタート", "ゴール", "チーム", "参加人数", "完走人数", "平均速度", "Cost", "結果", "優勝", "準優勝",
"3位", "ポイント賞", "山岳賞", "スプリント賞", "新人賞", "敢闘賞", "チーム総合時間賞", "チーム", "画像", "キャプション", "地図", "Special 1", "Special 2",
"ドキュメンテーション", "Metas volantes", "Regularidad", "チームポイント", "Breakaway", "Azzurri d'Italia", "Rookie","Amateur","Nationality","Elevation"},
["br"] = {"Hollegezhioù", "Redadeg", "Kevezadeg", "Kevezadegoù", "Tennadoù", "Deiziad", "Deiziadoù", "Hed", "Bro", "Broioù",
"Lec'h loc'hañ", "Lec'h degouezhout", "Skipailhoù", "Loc'herien", "Erruerien", "Tizh keitat", "Koust", "Disoc'hoù", "Gounezer", "Eil", "Trede",
"Renkadur a-boentoù", "Kraper gwellañ", "Sprinter gwellañ", "Yaouank gwellañ", "Stourmer meur", "Gwellañ el liesrenkadur", "Skipailh gwellañ",
"Skeudenn", "Alc'hwez", "Kartenn", "Dibar 1", "Dibar 2", "Teuliadur", "Metas volantes", "Regularidad", "Skipailh a-boentoù", "Achapadenn", "Azzurri d'Italia", "Rookie","Amateur","Nationality",
"Elevation"
},
["ca"] = {"Detalls de la cursa", "Cursa", "Competició", "Competicions", "Etapes", "Data", "Dates", "Distància", "País", "Països",
"Sortida", "Arribada", "Equips", "Inscrits", "Finalitzen", "Velocitat mitjana", "Cost", "Palmarès", "Vencedor", "Segon", "Tercer", "Punts", "Muntanya",
"Esprints", "Joves", "Combativitat", "Combinada", "Equip", "Picture", "Caption", "Map", "Special 1", "Special 2", "Documentació", "Metes volants",
"Regularitat", "Team points", "Fuga", "Azzurri d'Itàlia", "Rookie","Amateur","Nationality","Elevation"},
["cs"] = {"Přehled", "Závod", "Soutěž", "Soutěže", "Počet etap", "Datum", "Datum", "Celková délka", "Země", "Země", "Start", "Cíl",
"Týmy", "Běžci", "Příjezdy", "Rychlostní průměr", "Náklady", "Konečné pořadí", "Celkový vítěz", "2. místo", "3. místo", "Vítěz bodovací soutěže",
"Nejlepší vrchař", "Nejlepší sprinter", "Nejlepší mladý jezdec", "Nejaktivnější jezdec", "Nejlepší kombinovaná", "Nejlepší družstvo", "Picture",
"Caption", "Map", "Special 1", "Special 2", "Dokumentace", "Metas volantes", "Regularidad", "Team points", "Breakaway", "Azzurri d'Italia", "Rookie","Amatour","Broadelezh",
"Elevation"
},
["da"] = {"Løbsdetaljer", "Rute", "Konkurrence", "Konkurrencer", "Etaper", "Dato", "Datoer", "Distance", "Land", "Lande",
"Startby", "Målby", "Hold", "Startende ryttere", "Fuldførende ryttere", "Gennemsnitlig fart", "Pris", "Resultater", "Vinder", "Toer", "Treer",
"Pointtrøje", "Bjergtrøje", "Sprinttrøje", "Ungdomstrøje", "Mest angrebsivrige", "Kombinationstrøje", "Holdkonkurrence", "Billede", "Billedtekst",
"Kort", "Special 1", "Special 2", "Dokumentation", "Indlagt spurt", "Regularitet", "Holdkonkurrence efter point", "Udbrud", "Azzurri d'Italia", "Rookie","Amatør","Nationalitet",
"Elevation"
},
["de"] = {"Allgemeines", "Ausgabe", "Rennserie", " Wettbewerb", "Etappen", "Datum", "Datum", "Gesamtlänge", "Austragungsland",
"Austragungsländer", "Start", "Ziel", "Teams", "Fahrer am Start", "Fahrer im Ziel", "Durchschnitts&#173;geschwindigkeit", "Kosten", "Ergebnis",
"Sieger", "Zweiter", "Dritter", "Punktewertung", "Bergwertung", "Sprintwertung", "Nachwuchswertung", "Kämpferischster Fahrer", "Kombinationswertung",
"Teamwertung", "Bild", "Beschriftung", "Karte", "Special 1", "Special 2", "Dokumentation", "Metas volantes", "Regularidad", "Teamwertung (Punkte)",
"Breakaway", "Azzurri d'Italia", "Rookie","Amateur","Nationality","Elevation"},
["eo"] = {"Gxeneralajxo", "Bicikla konkurso", "Konkuro", "Konkuroj", "Etapoj", "Dato", "Datoj", "Longo", "Lando", "Landoj",
"Komencloko", "Alvenloko", "Teamoj", "Startantoj", "Alvenantoj", "Averagxa rapido", "Kosto", "Rezultoj", "Venkinto", "Dua pozicio", "Tria pozicio",
"Klasifiko laux poentoj", "Plej bona grimpanto", "Plej bona sprinto", "Plej bona juno", "Superbatalema", "Plej bona por kombino", "Plej bona teamo",
"Picture", "Caption", "Map", "Special 1", "Special 2", "Dokumentado", "Metas volantes", "Regularidad", "Team points", "Breakaway", "Azzurri d'Italia",
"Rookie", "Amateur","Nationality","Elevation"},
["es"] = {"Detalles", "Carrera", "Competición", "Competiciones", "Etapas", "Fecha", "Fechas", "Distancia total", "País", "Países",
"Lugar de inicio", "Lugar de llegada", "Equipos", "Ciclistas participantes", "Ciclistas finalizados", "Velocidad media", "Costo", "Clasificación final",
"Ganador", "Segundo", "Tercero", "Puntos", "Montaña", "Metas volantes", "Jóvenes", "Combatividad", "Combinada", "Equipo", "Imagen", "Leyenda", "Mapa",
"Especial 1", "Especial 2", "Documentación", "Metas volantes", "Regularidad", "Team points", "Fuga", "Azzurri d'Italia", "Novatos","Amateur","Nationality",
"Elevation"
},
["eu"] = {"Lasterketaren xehetasunak", "Ibilbidea", "Lehiaketa", "Lehiaketak", "Etapak", "Data", "Datak", "Distantzia",
"Herrialdea", "Herrialdeak", "Jardunaldiko abiapuntua", "Jardunaldiko helmuga", "Taldeak", "Abiatutako txirrindulariak", "Iritsitako txirrindulariak",
"Batez besteko abiadura", "Kostua", "Azken sailkapena", "Irabazlea", "Bigarrena", "Hirugarrena", "Puntuak", "Mendiak", "Esprintak", "Gazteak",
"Saiatuena", "Konbinatua", "Taldeak", "Picture", "Caption", "Map", "Special 1", "Special 2", "Dokumentazioa", "Metas volantes", "Regularidad",
"Team points", "Breakaway", "Azzurri d'Italia", "Rookie", "Amateur","Nationality","Elevation"},
["fi"] = {"Kilpailun tiedot", "Nimi", "Kilpailu", "Kilpailut", "Etapit", "Päivä", "Päivät", "Matka", "Maa", "Maat",
"Lähtöpaikka", "Saapumispaikka", "Joukkueet", "Osallistuneet pyöräilijät", "Maaliin saapuneet pyöräilijät", "Keskinopeus", "Kustannukset", "Lopputilanne",
"Voittaja", "Toinen", "Kolmas", "Pistekilpailu", "Mäkikirikilpailu", "Sprintit", "Nuoret", "Yritteliäin", "Yhdistelmä", "Joukkue", "Kuva", "Kuvateksti",
"Kartta", "Special 1", "Special 2", "Ohjesivu", "Metas volantes", "Regularidad", "Team points", "Breakaway", "Azzurri d'Italia", "Rookie", "Amateur","Nationality",
"Elevation"
},
["fo"] = {"Smálutir", "Leið", "Kapping", "Kappingar", "Teinar", "Dagfesting", "Dagfestingar", "Strekki", "Land", "Lond", "Byrjunarbýur",
"Málbýur", "Lið", "Byrjandi súkklarar", "Fullførandi súkklarar", "Miðalferð", "Kostnaður", "Palmares", "Vinnari", "Nr. 2", "Nr. 3", "Stig", "Fjøll",
"Spurtar", "Ungdómur", "Mest álopssinnaður", "Kombinatión", "Lið", "Picture", "Caption", "Map", "Special 1", "Special 2", "Dokumentation", "Metas volantes",
"Regularidad", "Team points", "Breakaway", "Azzurri d'Italia", "Rookie", "Amateur","Nationality","Elevation"},
["he"] = {"פרטי מרוץ", "Course", "תחרות", "תחרויות", "Stages", "תאריך", "תאריכים", "מרחק", "מדינה", "מדינות",
"התחלת מסלול", "סוף מסלול", "קבוצות", "Starting riders", "Arriving riders", "Average speed", "Cost", "Palmares", "מנצח", "שני",
"שלישי", "ניקוד", "הרים", "ספרינטים", "Youth", "Combativity", "Combination", "קבוצה", "תמונה", "Caption", "Map", "Special 1", "Special 2",
"תיעוד", "Intermediate sprints", "Regularidad", "Team points", "Breakaway", "Azzurri d'Italia", "Rookie", "Amateur","Nationality","Elevation"},
["hu"] = {"Verseny adatai", "Verseny", "Sorozat", "Sorozatok", "Szakaszok", "Dátum", "Dátum", "Versenytáv", "Ország", "Országok",
"Verseny rajtja", "Verseny célja", "Csapatok", "Induló versenyzők", "Beérkező versenyzők", "Átlagsebesség", "Költség", "Rangsor", "Győztes", "Második",
"Harmadik", "Pontverseny", "Hegyi pontverseny", "Sprint", "Fiatalok versenye", "Legaktívabb versenyző", "Combination", "Csapatverseny", "Kép", "Képaláírás", "Térkép", "Special 1", "Special 2",
"Dokumentáció", "Intermediate sprints", "Regularidad", "Team points", "Breakaway", "Azzurri d'Italia", "Rookie","Amateur","Nationality","Elevation"},
["lb"] = {"Detailer", "Course", "Kompetitioun", "Kompetitiounen", "Etappen", "Datum", "Datumer", "Distanz", "Land", "Länner",
"Depart", "Arrivée", "Equippen", "Um Depart", "Ukomm", "Vitess-Moyenne", "Käschten", "Palmarès", "Gewënner", "Zweeten", "Drëtten", "Beschte Sprinter",
"Biergpräis", "Sprinter", "Beschte Jonken", "Kombativitéit", "Kombinatioun", "Equipe", "Picture", "Caption", "Map", "Special 1", "Special 2",
"Dokumentatioun", "Étapes volantes", "Regularidad", "Team points", "Breakaway", "Azzurri d'Italia", "Rookie", "Amateur","Nationality","Elevation"},
["lv"] = {"Sacensību informācija", "Sacensības", "Kategorija", "Sacensības", "Posmi", "Datums", "Datumi", "Distance", "Valsts",
"Valstis", "Starts", "Finišs", "Komandas", "Braucēji startā", "Braucēji finišā", "Vidējais ātrums", "Izmaksas", "Rezultāti", "Uzvarētājs", "Otrais",
"Trešais", "Punkti", "Kalnu karalis", "Sprints", "Jaunais braucējs", "Cīnītājs", "Kombinācija", "Komanda", "Atēls", "Paraksts", "Karte", "Papildinformācija 1",
"Papildinformācija 2", "Dokumentācija", "Metas volantes", "Regularidad", "Team points", "Breakaway", "Azzurri d'Italia", "Rookie", "Amateur","Nationality","Elevation"},
["mk"] = {"Детали за трката", "Издание", "Натпреварување", "Натпреварувања", "Етапи", "Датум", "Датуми", "Растојание",
"Држава", "Држави", "Поаѓалиште", "Одредиште", "Екипи", "Возачи на почеток", "Возачи на крај", "Просечна брзина", "Трошоци", "Добитници на наградите",
"Победник", "Второпласиран", "Третопласиран", "Бодовен", "Планински", "Спринтерски", "Младински", "Борбеност", "Комбиниран", "Екипен", "слика", "опис",
"местоположбена карта", "Special 1", "Special 2", "Документација", "Metas volantes", "Regularidad", "Team points", "Breakaway", "Azzurri d'Italia",
"Rookie", "Amateur","Nationality","Elevation"},
["nl"] = {"Wedstrijddetails", "Koers", "Wedstrijd", "Wedstrijden", "Etappes", "Datum", "Datums", "Afstand", "Land", "Landen",
"Startplaats", "Finishplaats", "Teams", "Aantal coureurs aan de start", "Aantal coureurs bij de aankomst", "Gemiddelde snelheid", "Kosten", "Palmares",
"Winnaar", "Tweede", "Derde", "Punten", "Bergen", "Sprints", "Jeugd", "Aanvalslust", "Combinatie", "Team", "Afbeelding", "Bijschrift", "Kaart", "Special 1",
"Special 2", "Documentatie", "Metas volantes", "Regularidad", "Teampunten", "Demarrage", "Azzurri d'Italia", "Rookie", "Amateur",
"Nationality","Elevation"},
["no"] = {"Detaljer", "Ritt", "Konkurranse", "Konkurranser", "Etapper", "Dato", "Datoer", "Distanse", "Land", "Land", "Startsted",
"Målsted", "Lag", "Startende ryttere", "Fullførende ryttere", "Gjennomsnittsfart", "Kostnad", "Resultater", "Vinner", "2. plass", "3. plass", "Poeng",
"Klatring", "Spurt", "Ungdom", "Mest offensive", "Kombinasjon", "Lagkonkurranse", "Bilde", "Bildetekst", "Kart", "Spesial 1", "Spesial 2", "Dokumentasjon",
"Innlagte spurter", "Regularitet", "Lagkonkurranse (poeng)", "Brudd", "Azzurri d'Italia", "Nykommer", "Amatør","Nasjonalitet","Elevation"},
["pl"] = {"Wyrażenia ogólne", "Wyścig", "Konkurencja", "Konkursy", "Etapów", "Data", "Daty", "Dystans", "Państwo", "Państwy",
"Odejście", "Przyjazd", "Zespoły", "Zgłoszenia", "Ukończyło wyścig", "Średnia prędkość", "Koszt", "Podium", "Pierwsze miejsce", "Drugie miejsce",
"Trzecie miejsce", "Punktowa", "Górska", "Sprinterska", "Młodzieżowa", "Najaktywniejszych", "Kombinowana", "Drużynowa", "Picture", "Caption", "Map",
"Special 1", "Special 2", "Dokumentacja", "Metas volantes", "Regularidad", "Team points", "Breakaway", "Azzurri d'Italia", "Rookie", "Amateur",
"Nationality","Elevation"},
["pt"] = {"Detalhes", "Corrida", "Válida para", "Válida para", "Etapas", "Data", "Data", "Distância", "País", "Países",
"Partida", "Chegada", "Nº de equipes", "Ciclistas que iniciaram", "Ciclistas que finalizaram", "Velocidade média", "Custo", "Classificação final",
"Vencedor", "Segundo", "Terceiro", "Prêmio por pontos", "Prêmio de montanha", "Sprints", "Juventude", "Disputa", "Combinação", "Equipes", "Imagem",
"Legenda", "Mapa", "Special 1", "Special 2", "Documentação", "Metas volantes", "Regularidad", "Team points", "Breakaway", "Azzurri d'Italia", "Rookie",
"Amateur","Nationality","Elevation"},
["ro"] = {"Detalii cursă", "Cursă", "Competiție", "Competiții", "Etape", "Dată", "Date", "Distanță", "Țară", "Țări", "Start",
"Sosire", "Echipe", "Cicliști la start", "Cicliști la sosire", "Viteză medie", "Cost", "Palmares", "Câștigător", "Al doilea", "Al treilea", "Clasament pe puncte",
"Cel mai bun cățărător", "Cel mai bun sprinter", "Cel mai bun tânăr", "Combativitate", "Combinat", "Echipă", "Picture", "Caption", "Map", "Special 1",
"Special 2", "Documentație", "Metas volantes", "Regularidad", "Team points", "Breakaway", "Azzurri d'Italia", "Rookie", "Amateur","Nationality","Elevation"},
["ru"] = {"Детали гонки", "Маршрут", "Соревнование", "Соревнования", "Этапы", "Дата", "Даты", "Дистанция", "Страна", "Страны",
"Место старта", "Место финиша", "Команды", "Стартовало гонщиков", "Финишировало гонщиков", "Средняя скорость", "Призовые", "Призёры", "Победитель",
"Второй", "Третий", "Очковая", "Горная", "Спринтерская", "Молодёжная", "Бойцовская", "Комбинированная", "Командная по времени", "Вид", "Описание", "Карта", "Сектор 1",
"Сектор 2", "Документация", "Промежуточные финиши", "Регулярность", "Командная по очкам", "Breakaway", "Azzurri d'Italia", "Rookie", "Amateur","Nationality","Elevation"},
["sv"] = {"Race details", "Course", "Competition", "Competitions", "Stages", "Date", "Dates", "Distance", "Country", "Countries",
"Journey origin", "Journey destination", "Teams", "Starting riders", "Arriving riders", "Average speed", "Cost", "Palmares", "Winner", "Second",
"Third", "Points", "Mountains", "Sprints", "Youth", "Combativity", "Combination", "Team", "Picture", "Caption", "Map", "Special 1", "Special 2",
"Documentation", "Metas volantes", "Regularidad", "Team points", "Breakaway", "Azzurri d'Italia", "Rookie", "Amateur","Nationality","Elevation"},
["ast"] = {"Detalles", "Carrera", "Competición", "Competiciones", "Etapes", "Data", "Dates", "Distancia total", "País", "Países",
"Llugar d'entamu", "Llugar de llegada", "Equipos", "Ciclistes participantes", "Ciclistes acabaos", "Velocidá media", "Costu", "Clasificación final", "Ganador", "Segundu",
"Terceru", "Puntos", "Monte", "Metes volantes", "Mozos", "Combatividá", "Combinada", "Equipu", "Imaxe", "Lleenda", "Mapa", "Especial 1", "Especial 2",
"Documentación", "Metes volantes", "Regularidá", "Team points", "Fuga", "Azzurri d'Italia", "Rookie", "Amateur","Nationality","Elevation"}
}
local l10n = l10nDef[wiki]
if not l10n then l10n = l10nDef["en"] end -- default
return l10n[x]
end
 
function unit(x)
local l10nDef = {
["ar"] = {"", " س ", " دقيقة ", " ث", ' كم/س', " نقطة", " نقطة"},
["fr"] = {"en", " h ", " min ", " s", ' km/h', " pt", " pts"},
["br"] = {"", "e ", "' ", '"', ' km/h', " pt", " ptoù"},
["da"] = {"", "t ", "' ", '"', ' km/t', " point", " point"},
["de"] = {"", " h ", " min ", " s", ' km/h', " P.", " P."},
["en"] = {"", "h ", "' ", '"', ' km/h', " pt", " pts"},
["es"] = {"", " h ", " min ", " s", ' km/h', " pt&nbsp;&nbsp;", " pts"},
["eu"] = {"", " h ", " min ", " s", ' km/h', " pt", " pt"},
["fo"] = {"", "t ", "' ", '"', ' km/t', " pt", " pts"},
["fi"] = {"", ".", ".", "", ' km/h', " pt", " pts"},
["he"] = {"", "h ", "' ", '"', ' קמ"ש', " נק\'", " נקודות"},
["hu"] = {"", " óra ", ":", "", ' km/h', " pt", " pts"},
["it"] = {"", "h", "'", '"', ' km/h', " pt", " pts"},
["ja"] = {"", "時間", "分", '秒', 'km/h', "ポイント", "ポイント"},
["lb"] = {"", " h ", " min ", " s", ' km/h', " pt", " pts"},
["mk"] = {"", "ч ", "' ", "", ' км/ч', " pt", " pts"},
["nl"] = {"", "u", "'", '"', ' km/u', " pt", " pts"},
["no"] = {"", "t ", "' ", '"', ' km/t', " poeng", " poeng"},
["pt"] = {"", "h", "m", "s", ' km/h', " pt", " pts"},
["ru"] = {"", "ч ", "' ", "", ' км/ч', " очко", " очков"},
["ast"] = {"", " h ", " min ", " s", ' km/h', " pt ", " pts"}
}
local l10n = l10nDef[wiki] or l10nDef["en"] -- en is the default for lv,cs,en,ca,ro,pt,pl,sv
return l10n[x]
end
 
local function headoftable(x) -- En-tête du tableau listant les étapes
local l10nDef={
["ar"] = {"المرحلة", "التاريخ", "الدورة", "المسافة (كم)", "الفائز بالمرحلة", "القائد العام", "الارتفاع (م)"},
["fr"] = {"Étape", "Date", "Villes étapes", "Distance (km)", "Vainqueur d'étape", "Leader du classement général","Dénivelé (m)"},
["en"] = {"Stage", "Date", "Course", "Distance - km (mi)", "Stage winner", "Overall leader","Elevation (m)"},
["br"] = {"Tennad", "Deiziad", "Kêr loc'hañ ha kêr degouezhout", "Hed (km)", "Trec'hour", "E penn ar renkamant hollek","Elevation (m)"},
["ca"] = {"Etapa", "Data", "Ciutats d'etapa", "Distància (km)", "Vencedor de l'etapa", "Líder de la general","Elevation (m)"},
["cs"] = {"Etapa", "Datum", "Trasa", "Vzdálenost (km)", "Vítěz", "Průběžný lídr","Elevation (m)"},
["da"] = {"Etape", "Dato", "Start – Mål", "Afstand (km)", "Etapevinder", "Førende rytter","Elevation (m)"},
["de"] = {"Etappe", "Datum", "Etappenorte", "Länge (km)", "Etappen&shy;sieger", "Gesamt&shy;führender","Elevation (m)"},
["eo"] = {"Etapo", "Dato", "Etapa urbo", "Longo (km)", "Venkinto de la etapo", "Estro de la gxeneralo klasado","Elevation (m)"},
["es"] = {"Etapa", "Fecha", "Recorrido", "Distancia (km)", "Ganador", "Líder","Elevation (m)"},
["eu"] = {"Etapa", "Data", "Ibilbidea", "Distantzia (km)", "Irabazlea", "Liderra","Elevation (m)"},
["fi"] = {"Etappi", "Päivä", "Reitti", "Pituus (km)", "Voittaja", "Kokonaiskilpailun johtaja","Elevation (m)"},
["fo"] = {"Teinur", "Dagur", "Byrjan – Mál", "Vegalongd (km)", "Teina&shy;vinnari", "Gula troyggjan","Elevation (m)"},
["hu"] = {"Szakasz", "Időpont", "Végpontok", "Hossz (km)", "Szakasz&shy;győztes", "Általános vezető","Elevation (m)"},
["it"] = {"Tappa", "Data", "Percorso", "Distanza (km)", "Vincitore di tappa", "Leader cl. generale","Elevation (m)"},
["ja"] = {"ステージ", "開催日", "コース", "距離 (km)", "ステージ勝者", "全体リーダー","Elevation (m)"},
["la"] = {"Statio", "Dies", "Iter", "Distantia (km)", "Victor", "Altiore princeps","Elevation (m)"},
["lb"] = {"Etapp", "Datum", "Etappestied", "Längt (km)", "Gewënner", "General&shy;klassement","Elevation (m)"},
["lv"] = {"Posms", "Datums", "Maršruts", "Posma garums (km)", "Uzvarētājs", "Kopvērtējuma līderis","Elevation (m)"},
["mk"] = {"Етапа", "Датум", "Тек", "Растојание (км)", "Победник", "Cевкупен лидер","Elevation (m)"},
["nl"] = {"Etappe", "Datum", "Start – Finish", "Afstand (km)", "Winnaar", "Klassements&shy;leider","Elevation (m)"},
["no"] = {"Etappe", "Dato", "Start – Målgang", "Distanse (km)", "Etappe&shy;vinner", "Sammenlagt&shy;leder","Elevation (m)"},
["pl"] = {"Etap", "Data", "Start – Meta", "Dystans (km)", "Zwycięzca etapu", "Lider","Elevation (m)"},
["pt"] = {"Etapa", "Data", "Percurso", "Distância (km)", "Vencedor", "Líder geral","Elevation (m)"},
["ro"] = {"Etapa", "Dată", "Start – Sosire", "Distanță (km)", "Câștigător", "Liderul global","Elevation (m)"},
["ru"] = {"Этап", "Дата", "Маршрут", "Длина (км)", "Победитель", "Лидер генеральной классификации","Elevation (m)"},
["sk"] = {"Etapa", "Dátum", "Trasa", "Vzdialenosť (km)", "Víťaz", "Priebežný líder","Elevation (m)"},
["sv"] = {"Etapp", "Datum", "Start – mål", "Distans (km)", "Skede vinnare", "Övergripande ledare","Elevation (m)"},
["ast"] = {"Etapa", "Data", "Percorríu", "Distancia (km)", "Ganador", "Líder","Elevation (m)"},
}
local l10n = l10nDef[wiki]
if not l10n then l10n = l10nDef["en"] end -- default
return l10n[x]
end
 
local function headoftableII(x) -- En-têtes des tableaux générant les classements
local l10nDef = {
["ar"] = {"العداء", "البلد", "الفريق", "الوقت", "إزاحة الوقت", "السرعة", "النقاط", "تصنيف الفرق ضد الساعة", "التصنيف العام", "تصنيف النقاط", "تصنيف الجبال", "تصنيف أفضل عداء", "تصنيف أفضل شاب", "تصنيف الفرق حسب الوقت", "ترتيب الفرق حسب النقاط", "تصنيف المجموعة", "تصنيف أفضل مقاتل", "التصنيف تحت 23","تصنيف UCI"},
["fr"] = {"Coureur", "Pays", "Équipe", "Temps", "Écart de temps", "Vitesse moy.", "Points", "Classement de l'étape", "Classement général", "Classement par points", "Classement de la montagne", "Classement des sprints", "Classement du meilleur jeune", "Classement par équipes", "Classement par équipes aux points", "Classement du combiné", "Classement de la combativité", "Classement du meilleur jeune", "Classement UCI"},
["en"] = {"Rider", "Country", "Team", "Time", "Time Gap", "Speed", "Points", "Stage classification", "General classification", "Points classification", "Mountains classification", "Sprints classification", "Best young classification", "Teams classification", "Points classification for teams", "Combination classification", "Combative classification", "U23 classification", "UCI Ranking"},
["br"] = {"Reder", "Bro", "Skipailh", "Amzer", "Forc'had amzer", "Tizh", "Poentoù", "Renkadur an tennad", "Renkadur hollek", "Renkadur a-boentoù", "Renkadur ar menez", "Renkadur ar sprintoù", "Renkadur ar yaouank gwellañ", "Renkadur a-skipailh", "Renkadur a-skipailh a-boentoù", "Liesrenkadur", "Stourm renkadur", "Dindan 23 renkadur", "UCI renkadur"},
["ca"] = {"Corredor", "País", "Equip", "Temps", "Time Gap", "Velocitat", "Punts", "Classificació de l'etapa", "Classificació general", "Classificació per punts", "Classificació de la muntanya", "Classificació dels esprints", "Classificació del millor jove", "Classificació per equips", "Classificació per equips", "Classificació de la combinada", "Classificació de la combativitat", "Classificació sub-23","Classificació UCI"},
["da"] = {"Rytter", "Land", "Hold", "Tid", "Tidsforskel", "Gns. fart", "Point", "Etaperesultat", "Samlede stilling", "Pointkonkurrence", "Bjergkonkurrence", "Sprintkonkurrence", "Ungdomskonkurrence", "Holdkonkurrence", "Holdkonkurrence efter point", "Kombinationskonkurrence", "Mest angrebsivrige rytter", "U23-konkurrence","UCI Ranking"},
["de"] = {"Fahrer", "Land", "Team", "Zeit", "Zeitabstand", "Geschw.", "Punkte", "Etappenergebnis", "Gesamtwertung", "Punktewertung", "Bergwertung", "Sprintwertung", "Nachwuchswertung", "Mannschaftswertung", "Mannschaftswertung", "Combination classification", "Combative classification", "U23 classification","UCI classification"},
["eo"] = {"Kuranto", "Lando", "Teamo", "Tempo", "Time Gap", "Rapido", "Poentoj", "Etapa klasifiko", "Gxenerala klasifiko", "Klasifiko laux poentoj", "Klasifiko por la montaro", "Klasifiko por la sprintoj", "Klasifiko de la plej bona juno", "Klasifiko po teamo", "Klasifiko po teamo", "Combination classification", "Combative classification", "U23 classification","UCI classification"},
["es"] = {"Ciclista", "País", "Equipo", "Tiempo", "Intervalo de tiempo", "Velocidad media", "Puntos", "Clasificación de la etapa", "Clasificación general", "Clasificación por puntos", "Clasificación de la montaña", "Clasificación de las metas volantes", "Clasificación del mejor joven", "Clasificación por equipos", "Clasificación por equipos", "Clasificación de la combinada", "Clasificación de la combatividad", "Clasificación sub-23", "Clasificación UCI"},
["eu"] = {"Txirrindularia", "Herrialdea", "Taldea", "Denbora", "Time Gap", "Speed", "Puntua", "Etapako sailkapena", "Sailkapen orokorra", "Puntukako sailkapena", "Mendiko sailkapena", "Esprinetako sailkapena", "Gazte onenaren sailkapena", "Taldekako sailkapena", "Taldekako sailkapena", "Combination classification", "Combative classification", "U23 classification","UCI Ranking"},
["fi"] = {"Pyöräilijä", "Maa", "Joukkue", "Aika", "Aikaero", "Nopeus", "Pisteet", "Etapin tulokset", "Kokonaistilanne", "Pistekilpailu", "Vuoristokilpailu", "Sprinttikilpailu", "Nuorten kilpailu", "Joukkuekilpailu", "Joukkuekilpailu", "Combination classification", "Combative classification", "U23 classification","UCI Ranking"},
["fo"] = {"Súkklari", "Land", "Lið", "Tíð", "Time Gap", "Ferð", "Stig", "Teinaplasering", "Samlað plasering", "Stigkappingin", "Fjallakappingin", "Spurtkappingin", "Ungdómskappingin", "Liðkappingin", "Liðkappingin", "Kombinatiónsheiðurkappingin", "Combative classification", "U23 classification","UCI Ranking"},
["hu"] = {"Versenyző", "Ország", "Csapat", "Idő", "Időkülönbség", "Átlagsebesség", "Pont", "Szakasz verseny", "Összetett verseny", "Pontverseny", "Hegyi pontverseny", "Gyorsulverseny", "Fiatalok versenye", "Csapatverseny", "Csapatverseny", "Combination classification", "Combative classification", "U23 classification","UCI Ranking"},
["lb"] = {"Coureur", "Land", "Equipe", "Zäit", "Time Gap", "Vitesse", "Punkten", "Etappeklassement", "Generalklassement", "Klassement no Punkten", "Biergpräis", "Sprintklassement", "Beschte Jonken", "Equippeklassement", "Equippeklassement", "Combinéklassement", "Combative classification", "U23 classification","UCI Ranking"},
["lv"] = {"Braucējs", "Valsts", "Komanda", "Laiks", "laika atstarpe", "Ātrums", "Punkti", "Posma rezultāti", "Kopvērtējums", "Punktu klasifikācija", "Kalnu klasifikācija", "Sprinta klasifikācija", "Jauno braucēju klasifikācija", "Komandu klasifikācija", "Komandu klasifikācija", "Kombinācijas klasifikācija", "Cīnītāja klasifikācija", "U23 klasifikācija","UCI klasifikācija"},
["mk"] = {"Возач", "Земја", "Екипа", "Време", "Разлика", "Брзина", "Бодови", "Етапен резултат", "Генерален пласман", "Бодовен пласман", "Планински пласман", "Спринтерски пласман", "Пласман за млад возач", "Екипен пласман", "Екипен пласман", "Combination classification", "Combative classification", "U23 classification","UCI Ranking"},
["no"] = {"Rytter", "Land", "Lag", "Tid", "Tidsforskjell", "Fart", "Poeng", "Etappeplassering", "Sammenlagtplassering", "Poengkonkurranse", "Klatrekonkurranse", "Spurtkonkurranse", "Ungdomskonkurranse", "Lagkonkurranse", "Lagkonkurranse (poeng)", "Kombinasjonkonkurranse", "Mest offensive rytter", "U23-konkurranse","UCI Ranking"},
["nl"] = {"Renner", "Land", "Ploeg", "Tijd", "Tijdsverschil", "Snelheid", "Punten", "Etappeklassement", "Algemeen Klassement", "Puntenklassement", "Bergklassement", "Sprintklassement", "Jongerenklassement", "Ploegenklassement", "Ploegenklassement", "Combinatieklassement", "Klassement van de strijdlustigste renner", "U23 classification","UCI Ranking"},
["pt"] = {"Ciclista", "País", "Equipe", "Tempo", "Intervalo de tempo", "Rapidez", "Pontos", "Classificação por etapas", "Classificação geral", "Classificação por pontos", "Classificação da montanha", "Classificação por velocidade", "Classificação dos jovens", "Classificação por equipes", "Classificação por equipes", "Classificação de combinados", "Classificação da combatividade", "Classificação U23","Classificação UCI"},
["ro"] = {"Ciclist", "Țară", "Echipă", "Timp", "Time Gap", "Viteză", "Puncte", "Clasamentul etapei", "Clasament general", "Clasament pe puncte", "Clasament cățărători", "Clasament sprinteri", "Clasamentul celui mai bun tânăr", "Clasament pe echipe", "Clasament pe echipe", "Combination classification", "Combative classification", "U23 classification","UCI Ranking"},
["ru"] = {"Гонщик", "Страна", "Команда", "Время", "Отставание", "Скорость", "Очки", "Результаты этапа", "Генеральная классификация", "Очковая классификация", "Горная классификация", "Спринтерская классификация", "Молодёжная классификация", "Командная классификация по времени", "Командная классификация по очкам", "Комбинированная классификация", "Бойцовская классификация", "Классификация U23","Классификация UCI"},
["ast"] = {"Ciclista", "País", "Equipu", "Tiempu", "Intervalu de tiempu", "Velocidá media", "Puntos", "Clasificación de la etapa", "Clasificación xeneral", "Clasificación per puntos", "Clasificación de monte", "Clasificación de les metes volantes", "Clasificación del meyor mozu", "Clasificación per equipos", "Clasificación per equipos", "Clasificación de la combinada", "Clasificación de la combatividá", "Clasificación sub-23","Clasificación UCI"},
}
local l10n = l10nDef[wiki]
if not l10n then l10n = l10nDef["en"] end -- default
return l10n[x]
end
 
local function headoftableIII(x) -- En-tête du tableau listant les équipes participantes (P1923)
local l10nDef = {
["ar"] = {"اسم الفريق", "البلد", "الرمز", "فريق عالمي", "فرق عالمية", "فريق برو", "فرق برو", "فريق قاري محترف", "فرق قارية محترفة", "فريق قاري", "فرق قارية", "فريق وطني", "فرق وطنية", "فريق إقليمي ونادي", "فرق إقليمية وأندية", "فريق دراجات محترف", "فرق دراجات محترفة", "فريق هواة دراجات", "فرق هواة دراجات", "مجموعة رياضية أولى", "مجموعات رياضية أولى", "مجموعة رياضية ثانية", "مجموعات رياضية ثانية", "مجموعة رياضية ثالثة", "مجموعات رياضية ثالثة", "فريق مختلط", "فرق مختلطة", "فريق إناث محترف", "فرق إناث محترفة", "فريق هواة دراجات إناث", "فرق دراجات إناث هواة"},
["fr"] = {"Nom de l'équipe", "Pays", "Code", "WorldTeam", "WorldTeams", "ProTeam", "ProTeams", "Équipe continentale professionnelle", "Équipes continentales professionnelles", "Équipe continentale", "Équipes continentales", "Équipe nationale", "Équipes nationales", "Équipe régionale et de club", "Équipes régionales et de clubs", "Équipe cycliste professionnelle", "Équipes cyclistes professionnelles", "Équipe cycliste amateur", "Équipes cyclistes amateurs", "Groupe sportif I", "Groupes sportifs I", "Groupe sportif II", "Groupes sportifs II", "Groupe sportif III", "Groupes sportifs III", "Équipe mixte", "Équipes mixtes", "Équipe féminine professionnelle", "Équipes féminines professionnelles", "Équipe cycliste amateur féminine", "Équipe cycliste amateur féminines"},
["en"] = {"Team name", "Country", "Code", "WorldTeam", "WorldTeams", "ProTeam", "ProTeams", "Professional continental team", "Professional continental teams", "Continental team", "Continental teams", "National team", "National teams", "Regional and club team", "Regional and club teams", "Professional cycling team", "Professional cycling teams", "Amateur cycling team", "Amateur cycling teams", "Trade Team I", "Trade Teams I", "Trade Team II", "Trade Teams II", "Trade Team III", "Trade Teams III", "Mixed team", "Mixed teams", "Professional woman team", "Professional women teams", "Women's amateur cycling team", "Women's amateur cycling teams"},
["ja"] = {"チーム名", "国", "コード", "ワールドチーム", "ワールドチーム", "プロチーム", "プロチーム", "プロフェッショナルコンチネンタルチーム", "プロフェッショナルコンチネンタルチーム", "コンチネンタルチーム", "コンチネンタルチーム", "ナショナルチーム", "ナショナルチーム", "地域・クラブチーム", "地域・クラブチーム", "プロ自転車チーム", "プロ自転車チーム", "アマ自転車チーム", "アマ自転車チーム", "Groupe sportif I", "Groupes sportifs I", "Groupe sportif II", "Groupes sportifs II", "Groupe sportif III", "Groupes sportifs III", "Mixt team", "Mixt teams", "プロ女子チーム", "プロ女子チーム", "Women's amateur cycling team", "Women's amateur cycling teams"},
["br"] = {"Anv skipailh", "Bro", "Kod", "WorldTeam", "WorldTeams", "ProTeam", "ProTeams", "Skipailh kevandir a-vicher", "Skipailhoù kevandir a-vicher", "Skipailh kevandir", "Skipailhoù kevandir", "Skipailh bro", "Skipailhoù bro", "Skipailh rannvro ha klub", "Skipailhoù rannvro ha klub", "Skipailh marc'h-houarn a-vicher", "Skipailhoù marc'h-houarn a-vicher", "Skipailh marc'h-houarn amatour", "Skipailhoù marc'h-houarn amatour", "Strollad sport I", "Strolladoù sport I", "Strollad sport II", "Strolladoù sport II", "Strollad sport III", "Strolladoù sport III", "Skipailh kemmesk", "Skipailhoù kemmesk", "Skipailh a-vicher merc'hed", "Skipailhoù a-vicher merc'hed", "Skipailh amatour merc'hed", "Skipailhoù amatour merc'hed"},
["ca"] = {"Nom de l'equip", "País", "Codi", "WorldTeam", "WorldTeams", "ProTeam", "ProTeams", "Equip continental professional", "Equips continentals professionals", "Equip continental", "Equips continentals", "Equip nacional", "Equips nacionals", "Equip regional i de club", "Equips regionals i de clubs", "Equip ciclista professional", "Equips ciclistes professionals", "Equip ciclista amateur", "Equips ciclistes amateurs", "Grup esportiu I", "Grups esportius I", "Grup esportiu II", "Grups esportius II", "Grup esportiu III", "Grups esportius III", "Equip mixt", "Equips mixtos", "Equip femení", "Equips femenins", "Equip femení amateur", "Equips femenins amateurs"},
["da"] = {"Holdnavn", "Land", "Kode", "WorldTeam", "WorldTeams", "ProTeam", "ProTeams", "Professionelt kontinentalhold", "Professionelle kontinentalhold", "Kontinentalhold", "Kontinentalhold", "Landshold", "Landshold", "Regional- og klubhold", "Regional- og klubhold", "Prohold", "Prohold", "Amatørhold", "Amatørhold", "Sportsgruppe I", "Sportsgruppe I", "Sportsgruppe II", "Sportsgruppe II", "Sportsgruppe III", "Sportsgruppe III", "Mix-hold", "Mix-hold", "Kvindehold", "Kvindehold", "Amatørkvindehold", "Amatørkvindehold"},
["de"] = {"Team", "Land", "Code", "WorldTeam", "WorldTeams", "ProTeam", "ProTeams", "Professional Continental Team", "Professional Continental Teams", "Continental Team", "Continental Teams", "Nationalmannschaft", "Nationalmannschaften", "Regionale Teams und Vereine", "Regionale Teams und Vereine", "Profi-Radsportteam", "Profi-Radsportteams", "Amateurmannschaft", "Amateurmannschaften", "Groupe Sortif I", "Groupes Sportifs I", "Groupe Sportif II", "Groupes Sportifs II", "Groupe Sportif III", "Groupes Sportifs III", "Mixed Team", "Mixed Teams", "UCI Women's Team", "UCI Women's Teams", "Sonstiges Frauenteam", "Sonstige Frauenteams"},
["eo"] = {"Nomo de la teamo", "Lando", "Kodo", "Monda teamo", "Mondaj teamoj", "ProTeamo", "ProTeamoj", "Profesiista kontinenta teamo", "Profesiistaj kontinentaj teamoj", "Kontinenta teamo", "Kontinentaj teamoj", "Nacia teamo", "Naciaj teamoj", "Regiona aux kluba teamo", "Regionaj aux klubaj teamoj", "Profesiista bicikla teamo", "Profesiistaj biciklaj teamoj", "Amatora bicikla teamo", "Amatoraj biciklaj teamoj", "Sporta grupo 1", "Sportaj grupoj 1", "Sporta grupo 2", "Sportaj grupoj 2", "Sporta grupo 3", "Sportaj grupoj 3", "Miksa teamo", "Miksaj teamoj", "Ina teamo", "Inaj teamoj", "Women's amateur cycling team", "Women's amateur cycling teams"},
["es"] = {"Nombre del equipo", "País", "Código", "WorldTeam", "WorldTeams", "ProTeam", "ProTeams", "Equipo continental profesional", "Equipos continentales profesionales", "Equipo continental", "Equipos continentales", "Equipo nacional", "Equipos nacionales", "Equipo regional y de club", "Equipos regionales y de clubes", "Equipo ciclista profesional", "Equipos ciclistas profesionales", "Equipo ciclista aficionado", "Equipos ciclistas aficionados", "Grupo deportivo I", "Grupos deportivos I", "Grupo deportivo II", "Grupos deportivos II", "Grupo deportivo III", "Grupos deportivos III", "Equipo mixto", "Equipos mixtos", "Equipo femenino", "Equipos femeninos", "Equipo femenino de ciclismo amateur", "Equipos femeninos de ciclismo amateur"},
["eu"] = {"Taldearen izena", "Herrialdea", "Kodea", "Munduko taldea", "Munduko taldeak", "Pro taldea", "Pro taldeak", "Kontinenteko talde profesionala", "Kontinenteko talde profesionala", "Kontinenteko taldea", "Kontinenteko taldeak", "Estatuko taldea", "Estatuko taldeak", "Eskualdeko eta klubeko taldea", "Eskualdeko eta klubeko taldeak", "Txirrindulari talde profesionala", "Txirrindulari talde profesionalak", "Txirrindulari talde amateurra", "Txirrindulari talde amateurrak", "I. mailako kirol taldea", "I. mailako kirol taldeak", "II. mailako kirol taldea", "II. mailako kirol taldeak", "III. mailako kirol taldea", "III. mailako kirol taldeak", "Talde mistoa", "Talde mistoak", "Emakume taldea", "Emakume taldeak", "Women's amateur cycling team", "Women's amateur cycling teams"},
["fi"] = {"Joukkueen nimi", "Maa", "Koodi", "WorldTeam", "WorldTeams", "ProTeam", "ProTeams", "Professional continental -joukkue", "Professional continental -joukkueet", "Continental-joukkue", "Continental-joukkueet", "Maajoukkue", "Maajoukkueet", "Alue- ja seurajoukkue", "Alue- ja seurajoukkueet", "Ammattilaispyöräilytalli", "Ammattilaispyöräilytallit", "Amatööripyöräilytalli", "Amatööripyöräilytallit", "Groupe sportif I", "Groupes sportifs I", "Groupe sportif II", "Groupes sportifs II", "Groupe sportif III", "Groupes sportifs III", "Mixt team", "Mixt teams", "Naisten ammattilaisjoukkue", "Naisten ammattilaisjoukkueet", "Women's amateur cycling team", "Women's amateur cycling teams"},
["fo"] = {"Liðnavn", "Land", "Kota", "WorldTeam", "WorldTeams", "ProTeam", "ProTeams", "Professionelt kontinentallið", "Professionel kontinentallið", "Kontinentallið", "Kontinental lið", "Landslið", "Landslið", "Regional- og klublið", "Regional- og felagslið", "Prolið", "Prolið", "Amatørlið", "Amatørlið", "Ítróttarbólkur I", "Ítróttarbólkur I", "Ítróttarbólkur II", "Ítróttarbólkur II", "Ítróttarbólkur III", "Ítróttarbólkur III", "Blandaðlið", "Blandaðlið", "Kvinulið", "Kvinnulið", "Women's amateur cycling team", "Women's amateur cycling teams"},
["he"] = {"שם קבוצה", "מדינה", "קוד", "WorldTeam", "קבוצות [[UCI World Tour|World Tour]]", "קבוצת פרו", "קבוצות פרו", "קבוצת קונטיננטל-פרו", "קבוצות קונטיננטל-פרו", "קבוצת קונטיננטל", "קבוצות קונטיננטל", "קבוצה לאומית", "קבוצות לאומיות", "Regional and club team", "Regional and club teams", "קבוצת רכיבה מקצועית", "קבוצות רכיבה מקצועיות", "Amateur cycling team", "Amateur cycling teams", "Groupe sportif I", "Groupes sportifs I", "Groupe sportif II", "Groupes sportifs II", "Groupe sportif III", "Groupes sportifs III", "Mixt team", "Mixt teams", "Professional woman team", "Professional women teams", "Women's amateur cycling team", "Women's amateur cycling teams"},
["hu"] = {"Csapat neve", "Ország", "Csapatkód", "WorldTeam", "WorldTeams", "ProTeam", "ProTeams", "Profi Kontinentális Csapat", "Profi Kontinentális Csapatok", "Kontinentális Csapat", "Kontinentális Csapatok", "Nemzeti csapat", "Nemzeti csapatok", "Regional and club team", "Regional and club teams", "Professional cycling team", "Professional cycling teams", "Amateur cycling team", "Amateur cycling teams", "Groupe sportif I", "Groupes sportifs I", "Groupe sportif II", "Groupes sportifs II", "Groupe sportif III", "Groupes sportifs III", "Mixt team", "Mixt teams", "Professional woman team", "Professional women teams", "Women's amateur cycling team", "Women's amateur cycling teams"},
["lb"] = {"Equippennumm", "Land", "Code", "WorldTeam", "WorldTeams", "ProTeam", "ProTeams", "Professionell Kontinentalequipe", "Professionell Kontinentalequippen", "Kontinentalequipe", "Kontinentalequippen", "Nationalequipe", "Nationalequippen", "Regional- a Klubequipe", "Regional- a Klubequippen", "Professionell Vëlosequipe", "Professionell Vëlosequippen", "Amateursequipe", "Amateursequippen", "Sportsgrupp I", "Sportsgruppen I", "Sportsgrupp II", "Sportsgruppen II", "Sportsgrupp III", "Sportsgruppen III", "Gemëscht Equipe", "Gemëscht Equippen", "Dammenequipe", "Dammenequippen", "Women's amateur cycling team", "Women's amateur cycling teams"},
["lv"] = {"Komandas nosaukums", "Valsts", "Kods", "WorldTeam", "WorldTeam komandas", "ProTeam", "ProTeam komandas", "Profesionālā kontinentālā komanda", "Profesionālās kontinentālās komandas", "Kontinentālā komanda", "Kontinentālās komandas", "Nacionālā izlase", "Nacionālās izlases", "Reģionālā vai klubu komanda", "Reģionālās vai klubu komandas", "Profesionāla riteņbraukšanas komanda", "Profesionālas riteņbraukšanas komandas", "Amatieru riteņbraukšanas komanda", "Amatieru riteņbraukšanas komandas", "1. sporta grupa", "1. sporta grupa", "2. sporta grupa", "3. sporta grupa", "3. sporta grupa", "3. sporta grupa", "Jauktā komanda", "Jauktās komandas", "Profesionāla sieviešu komanda", "Profesionālas sieviešu komandas", "Amatieru sieviešu komanda", "Amatieru sieviešu komandas"},
["mk"] = {"Име на екипата", "Земја", "Код", "Екипа од Светската турнеја UCI", "Екипи од Светската турнеја UCI", "ProTeam", "ProTeams", "Професионална континентална екипа", "Професионални континентални екипи", "Континентална екипа", "Континентални екипи", "Национална екипа", "Национални екипи", "Регионална екипа и клуб", "Регионални екипи и клубови", "Професионална велосипедска екипа", "Професионални велосипедски екипи", "Аматерска велосипедска екипа", "Аматерски велосипедски екипи", "Groupe sportif I", "Groupes sportifs I", "Groupe sportif II", "Groupes sportifs II", "Groupe sportif III", "Groupes sportifs III", "Мешана екипа", "Мешани екипи", "Професионална женска екипа", "Професионални женски екипи", "Women's amateur cycling team", "Women's amateur cycling teams"},
["nl"] = {"Ploegnaam", "Land", "Code", "WorldTeam", "WorldTeams", "ProTeam", "ProTeams", "Professionele continentale ploeg", "Professionele continentale ploegen", "Continentaal ploeg", "Continentale ploegen", "Nationale ploeg", "Nationale ploegen", "Regionale ploeg", "Regionale ploegen", "Professioneel wielerteam", "Professionele wielerteams", "Amateurteam", "Amateurteams", "Groupe sportif I", "Groupes sportifs I", "Groupe sportif II", "Groupes sportifs II", "Groupe sportif III", "Groupes sportifs III", "Gemengd team", "Gemengde teams", "Professioneel vrouwenteam", "Professionele vrouwenteams", "Amateur vrouwenteam", "Amateur vrouwenteams"},
["no"] = {"Lagnavn", "Land", "Kode", "WorldTour-lag", "WorldTour-lag", "ProTour-lag", "ProTour-lag", "Profesjonelt kontinentallag", "Profesjonelle kontinentallag", "Kontinentallag", "Kontinentallag", "Landslag", "Landslag", "Regional- og klubblag", "Regional- og klubblag", "Profflag", "Profflag", "Amatørlag", "Amatørlag", "Trade Team I", "Trade Teams I", "Trade Team II", "Trade Teams II", "Trade Team III", "Trade Teams III", "Mix-lag", "Mix-lag", "Profflag", "Profflag", "Amatørlag", "Amatørlag"},
["pt"] = {"Nome da equipe", "País", "Código", "Equipe WorldTeam", "Equipes WorldTeam", "Equipe ProTeam", "Equipes ProTeam", "Equipe profissional Continental", "Equipes profissionais Continentais", "Equipe Continental", "Equipes Continentais", "Equipe nacional", "Equipes nacionais", "Equipe regional e clube", "Equipes regionais e clubes", "Equipe profissional de ciclismo", "Equipes profissionais de ciclismo", "Equipe amadora de ciclismo", "Equipes amadoras de ciclismo", "Grupo esportivo I", "Grupos esportivos I", "Grupo esportivo II", "Grupos esportivos II", "Grupo esportivo III", "Grupos esportivos III", "Equipe mista", "Equipes mistas", "Equipe feminina profissional", "Equipes femininas profissionais", "Equipes femininas amadoras", "Equipes femininas amadoras"},
["ro"] = {"Numele echipei", "Țară", "Cod", "WorldTeam", "WorldTeams", "ProTeam", "ProTeams", "Echipă continentală profesionistă", "Echipe continentale profesioniste", "Echipă continentală", "Echipe continentale", "Echipă națională", "Echipe naționale", "Echipă regională și de club", "Echipe regionale și de club", "Echipă ciclistă profesionistă", "Echipe cicliste profesioniste", "Echipă ciclistă de amatori", "Echipe cicliste de amatori", "Grup sportiv I", "Grupuri sportive I", "Grup sportiv II", "Grupuri sportive II", "Grup sportiv III", "Grupuri sportive III", "Echipă mixtă", "Echipe mixte", "Echipă feminină", "Echipe feminine", "Women's amateur cycling team", "Women's amateur cycling teams"},
["ru"] = {"Команда", "Страна", "Код", "WorldTeam", "WorldTeams", "ProTeam", "ProTeams", "Профессиональная континентальная команда", "Профессиональные континентальные команды", "Континентальная команда", "Континентальные команды", "Национальная команда", "Национальные команды", "Региональная команда или клуб", "Региональные команды и клубы", "Профессиональная велокоманда", "Профессиональные велокоманды", "Любительская велокоманда", "Любительские велокоманды", "Groupe sportif I", "Groupes sportifs I", "Groupe sportif II", "Groupes sportifs II", "Groupe sportif III", "Groupes sportifs III", "Смешанная велокоманда", "Смешанные велокоманды", "Женская профессиональная команда", "Женские профессиональные команды", "Женская любительская велокоманда", "Женские любительские велокоманды"},
["ast"] = {"Nome del equipu", "País", "Códigu", "WorldTeam", "WorldTeams", "ProTeam", "ProTeams", "Equipu continental profesional", "Equipos continentales profesionales", "Equipu continental", "Equipos continentales", "Equipu nacional", "Equipos nacionales", "Equipu rexonal y de club", "Equipos rexonales y de clubes", "Equipu ciclista profesional", "Equipos ciclistes profesionales", "Equipu ciclista aficionáu", "Equipos ciclistes aficionaos", "Grupu deportivu I", "Grupos deportivos I", "Grupu deportivu II", "Grupos deportivos II", "Grupu deportivu III", "Grupos deportivos III", "Equipu mestu", "Equipos mestos", "Equipu femenín", "Equipos femeninos", "Equipu femenín de ciclismu amateur", "Equipos femeninos de ciclismu amateur"},
}
local l10n = l10nDef[wiki]
if not l10n then l10n = l10nDef["en"] end -- default
return l10n[x]
end
 
local function listofwinners_translate(x) -- En-tête du tableau du palmarès d'une course cycliste
local l10nDef = {
["ar"] = {"السنة", "الفائز", "الثاني", "الثالث","النقاط", "الجبال", "سباقات السرعة", "شاب", "تصنيف القتال", "ممتزجة", "الفرق","سباقات سرعة متوسطة", "انتظام", "نقاط الفريق", "Breakaway", "أزوري دي إيطاليا", "صاعد","الهواة","الجنسية"},
["fr"] = {"Année", "Vainqueur", "Deuxième", "Troisième","Classement par points", "Meilleur grimpeur", "Meilleur sprinteur", "Meilleur jeune", "Super-combatif", "Meilleur au combiné", "Meilleure équipe","Étapes volantes", "Régularité", "Meilleure équipe aux points",
"Fuga", "Azzurri d'Italia", "Néophyte", "Amateur","Nationalité"},
["en"] = {"Year", "Winner", "Second", "Third","Points", "Mountains", "Sprints", "Youth", "Combativity", "Combination", "Team","Intermediate sprints", "Regularidad", "Team points", "Breakaway", "Azzurri d'Italia", "Rookie","Amateur","Nationality"},
["br"] = {"Bloavezh", "1añ", "2l", "3de"},
["ca"] = {"Any", "Vencedor", "Segon", "Tercer"},
["cs"] = {"Ročník", "Vítěz", "Druhý", "Třetí"},
["da"] = {"År", "Vinder", "Toer", "Treer"},
["de"] = {"Jahr", "Sieger", "Zweiter", "Dritter"},
["eo"] = {"Jaro", "Venkinto", "Dua pozicio", "Tria pozicio"},
["es"] = {"Año", "Ganador", "Segundo", "Tercero"},
["eu"] = {"Urtea", "Irabazlea", "Bigarrena", "Hirugarrena"},
["fi"] = {"Vuosi", "Voittaja", "Toinen", "Kolmas"},
["fo"] = {"Ár", "Vinnari", "Nr. 2", "Nr. 3"},
["hu"] = {"Év", "Versenyző", "Második", "Harmadik"},
["it"] = {"Anno", "Vincitore", "Secondo", "Terzo"},
["ja"] = {"年", "優勝", "準優勝", "3位"},
["lb"] = {"Joer", "Gewënner", "Zweeten", "Drëtten"},
["lv"] = {"Gads", "Uzvarētājs", "Otrais", "Trešais"},
["mk"] = {"Година", "Победник", "Второпласиран", "Третопласиран"},
["nl"] = {"Jaar", "Winnaar", "Tweede", "Derde"},
["no"] = {"År", "Vinner", "Andreplass", "Tredjeplass"},
["pl"] = {"Rok", "Pierwsze", "Drugie", "Trzecie"},
["pt"] = {"Ano", "Vencedor", "Segundo", "Terceiro"},
["ro"] = {"An", "Câștigător", "Locul doi", "Locul trei"},
["ru"] = {"Год", "Победитель", "Второй", "Третий"},
["sr"] = {"Година", "Победник", "Други", "Трећи"},
["sv"] = {"År", "Vinnare", "Andra", "Tredje"},
["ast"] = {"Añu", "Ganador", "Segundu", "Terceru"},
}
local l10n = l10nDef[wiki]
if not l10n then
l10n = l10nDef["en"]
end
if l10n[x] then
return l10n[x]
else --provisory solution
local index
if x>4 then
if x<12 then
index =x+17
else
index=x+23
end
end
return infobox_translate(index)
end
end
 
local function riderranking_translate(x)
local l10nDef = {
["ar"] = {"السنة", "الفائز", "الثاني", "الثالث"},
["fr"] = {"Année", "Classement UCI","UCI World Tour" ,"Coupe du monde"}, --,"Classement par points", "Meilleur grimpeur", "Meilleur sprinteur", "Meilleur jeune", "Super-combatif", "Meilleur au combiné", "Meilleure équipe","Étapes volantes", "Régularité", "Meilleure équipe aux points",
-- "Fuga", "Azzurri d'Italia", "Néophyte", "Amateur","Nationalité"
["en"] = {"Year", "UCI Ranking", "UCI World Tour","World Cup"},
["br"] = {"Bloavezh", "UCI Ranking", "UCI World Tour","World Cup"},
["ca"] = {"Any", "UCI Ranking", "UCI World Tour","World Cup"},
["cs"] = {"Ročník", "UCI Ranking", "UCI World Tour","World Cup"},
["da"] = {"År", "UCI Ranking", "UCI World Tour","World Cup"},
["de"] = {"Jahr", "UCI Ranking", "UCI World Tour","World Cup"},
["eo"] = {"Jaro", "UCI Ranking", "UCI World Tour","World Cup"},
["es"] = {"Año", "UCI Ranking", "UCI World Tour","World Cup"},
["eu"] = {"Urtea", "UCI Ranking", "UCI World Tour","World Cup"},
["fi"] = {"Vuosi", "UCI Ranking", "UCI World Tour","World Cup"},
["fo"] = {"Ár", "UCI Ranking", "UCI World Tour","World Cup"},
["hu"] = {"Év", "UCI Ranking", "UCI World Tour","World Cup"},
["it"] = {"Anno", "UCI Ranking", "UCI World Tour","World Cup"},
["ja"] = {"年", "UCI Ranking", "UCI World Tour","World Cup"},
["lb"] = {"Joer", "UCI Ranking", "UCI World Tour","World Cup"},
["lv"] = {"Gads", "UCI Ranking", "UCI World Tour","World Cup"},
["mk"] = {"Година", "UCI Ranking", "UCI World Tour","World Cup"},
["nl"] = {"Jaar", "UCI Ranking", "UCI World Tour","World Cup"},
["no"] = {"År", "UCI Ranking", "UCI World Tour","World Cup"},
["pl"] = {"Rok", "UCI Ranking", "UCI World Tour","World Cup"},
["pt"] = {"Ano", "UCI Ranking", "UCI World Tour","World Cup"},
["ro"] = {"An", "UCI Ranking", "UCI World Tour","World Cup"},
["ru"] = {"Год", "UCI Ranking", "UCI World Tour","World Cup"},
["sr"] = {"Година", "UCI Ranking", "UCI World Tour","World Cup"},
["sv"] = {"År", "UCI Ranking", "UCI World Tour","World Cup"},
["ast"] = {"Añu", "UCI Ranking", "UCI World Tour","World Cup"},
}
local l10n = l10nDef[wiki]
if not l10n then
l10n = l10nDef["en"]
end
return l10n[x]
end
 
local function typeofstage(x, typ, noborder)
-- plain, hilly, inter, ... must be "" or "any text"
-- l10nDef[""] = {plain = "", hilly="", inter='', mount='', time_prologue='', time_team='', time_indiv='', uphill='', rest=''}
local l10nDef = {
["ar"] = {plain = "مرحلة مستوية", hilly="مرحلة التلال", inter='مرحلة متوسطة', mount='مرحلة جبلية', time_prologue='مرحلة سباق ضد الساعة', time_team='مرحلة سباق الفرق ضد الساعة', time_indiv='مرحلة سباق فردي ضد الساعة', uphill='مرحلة تسلق الجبل ضد الساعة', rest='يوم راحة'},
["ast"] = {plain = "etapa llana", hilly="etapa escarpada", inter='etapa de mediu monte', mount='etapa de monte', time_prologue='prólogu', time_team='contrarreló per equipos', time_indiv='contrarreló individual', uphill='cronoescalada', rest='xornada de descansu'},
["fr"] = {plain = "étape de plaine", hilly="étape vallonnée", inter='étape de moyenne montagne', mount='étape de montagne', time_prologue='prologue', time_team='contre-la-montre par équipes', time_indiv='contre-la-montre individuel', uphill='contre-la-montre en côte', rest='étape de repos'},
["en"] = {plain = "plain stage", hilly="hilly stage", inter='intermediate stage', mount='mountain stage', time_prologue='time trial stage', time_team='team time trial stage', time_indiv='individual time trial stage', uphill='uphill time trial stage', rest='rest day'},
["br"] = {plain = "tennad plaen", hilly="tennad digompez", inter='tennad damveneziek', mount='tennad meneziek', time_prologue='prolog', time_team='ABEU a-skipailhoù', time_indiv='ABEU', uphill='', rest='devezh diskuizh'},
["ca"] = {plain = "etapa plana", hilly="etapa accidentada", inter='etapa de mitja muntanya', mount='etapa de muntanya', time_prologue='pròleg', time_team='contrarellotge per equips', time_indiv='contrarellotge individual', uphill='', rest='etapa de descans'},
["cs"] = {plain = "rovinatá etapa", hilly="", inter='kopcovitá etapa', mount='horská etapa', time_prologue='prolog', time_team='týmová časovka', time_indiv='individuální časovka', uphill='', rest=''},
["da"] = {plain = "flad etape", hilly="kuperet etape", inter='middel bjergetape', mount='bjergetape', time_prologue='prolog', time_team='holdtidskørsel', time_indiv='enkeltstart', uphill='bjergenkeltstart', rest='hviledag'},
["de"] = {plain = "Flachetappe", hilly="Hügelige Etappe", inter='Mittelschwere Etappe', mount='Hochgebirgsetappe', time_prologue='Prolog', time_team='Teamzeitfahren', time_indiv='Einzelzeitfahren', uphill='Bergzeitfahren', rest='Ruhetag'},
["eo"] = {plain = "ebena etapo", hilly="malebena etapo", inter='mezgranda montaro etapo', mount='montara etapo', time_prologue='prologo', time_team='teama kontraux-la-kronometro', time_indiv='individua kontraux-la-kronometro', uphill='malebena kontraux-la-kronometro', rest='ripoza etapo'},
["es"] = {plain = "etapa llana", hilly="etapa escarpada", inter='etapa de media montaña', mount='etapa de montaña', time_prologue='prólogo', time_team='contrarreloj por equipos', time_indiv='contrarreloj individual', uphill='cronoescalada', rest='jornada de descanso'},
["eu"] = {plain = "etapa laua", hilly="etapa gorabeheratsua", inter='bitarteko etapa', mount='mendiko etapa', time_prologue='aitzinetapa', time_team='taldekako erlojupekoa', time_indiv='banakako erlojupekoa', uphill='erlojupeko igoera', rest='atseden eguna'},
["fi"] = {plain = "Tasamaaetappi", hilly="Mäkietappi", inter='Keskivaikea vuorietappi', mount='Vuorietappi', time_prologue='', time_team='Joukkueaika-ajo', time_indiv='Henkilökohtainen aika-ajo', uphill='mäkiaika-ajo', rest='välipäivä'},
["fo"] = {plain = "Slætt", hilly="Slætt við brúgvasteinum", inter='Óslætt', mount='Fjallateinur', time_prologue='Forteinur', time_team='Liðsúkkling', time_indiv='Einkultstartur', uphill='', rest='Hvílidagur'},
["hu"] = {plain = "sík szakasz", hilly="dombos szakasz", inter='közepes hegyi szakasz', mount='hegyi szakasz', time_prologue='prolog', time_team='csapat időfutam', time_indiv='egyéni időfutam', uphill='hegyi időfutam', rest=''},
["ja"] = {plain = "平坦ステージ", hilly="丘陵ステージ", inter='中間ステージ', mount='山岳ステージ', time_prologue='タイムトライアルステージ', time_team='チームタイムトライアルステージ', time_indiv='個人タイムトライアルステージ', uphill='アップヒルタイムトライアルステージ', rest='休養日'},
["lb"] = {plain = "Flaach Etapp", hilly="Hiwweleg Etapp", inter='Mëttelschwéier Etapp', mount='Biergetapp', time_prologue='Prolog', time_team='Contre-la-montre (Equipe)', time_indiv='Contre-la-montre (Eenzel)', uphill='Biergcourse', rest='Roudag'},
["lv"] = {plain = "līdzenuma posms", hilly="paugurains posms", inter='vidēju kalnu posms', mount='kalnu posms', time_prologue='individuālais brauciens', time_team='komandu brauciens', time_indiv='individuālais brauciens', uphill='individuālais brauciens kalnā', rest='atpūtas diena'},
["mk"] = {plain = "рамна етапа", hilly="ридеста етапа", inter='среднопланинска етапа', mount='планинска етапа', time_prologue='пролог', time_team='екипен хронометар', time_indiv='индивидуален хронометар', uphill='', rest='ден за одмор'},
["nl"] = {plain = "vlakke rit", hilly="heuvelrit", inter='heuvelrit', mount='bergrit', time_prologue='proloog', time_team='ploegentijdrit', time_indiv='individuele tijdrit', uphill='klimtijdrit', rest='rustdag'},
["no"] = {plain = "flat etappe", hilly="kupert etappe", inter='middels klatreetappe', mount='klatreetappe', time_prologue='prolog', time_team='lagtempo', time_indiv='temporitt', uphill='klatretempoetappe', rest='hviledag'},
["pl"] = {plain = "płaski", hilly="", inter='pagórkowaty', mount='górski', time_prologue='prologu', time_team='jazda drużynowa na czas', time_indiv='jazda indywidualna na czas', uphill='', rest=''},
["pt"] = {plain = "etapa plana", hilly="etapa escarpada", inter='média montanha', mount='alta montanha', time_prologue='prólogo', time_team='contrarrelógio por equipes', time_indiv='contrarrelógio individual', uphill='cronoescalada', rest='jornada de descanso'},
["ro"] = {plain = "etapă de plat", hilly="etapă valonată", inter='etapă intermediară', mount='etapă de munte', time_prologue='prolog', time_team='contratimp pe echipe', time_indiv='contratimp individual', uphill='', rest='zi de repaus'},
["ru"] = {plain = "равнинный", hilly="холмистый", inter='среднегорный', mount='горный', time_prologue='пролог', time_team='командная разделка', time_indiv='индивидуальная разделка', uphill='горная разделка', rest='день отдыха'},
["sv"] = {plain = "Flack etapp", hilly="", inter='Kuperat', mount='Bergsetapp', time_prologue='Prolog', time_team='Lagtempoetapp', time_indiv='Tempoetapp', uphill='', rest='Vilodag'},
}
local l10n = l10nDef[wiki]
if not l10n then l10n = l10nDef["en"] end -- default
 
local border
if noborder then border="" else border="|border|right" end
if x=='plain stage' then return "[[File:Plainstage.svg"..border.."|20px|"..l10n.plain.."]]" end
if x=='hilly stage' then return "[[File:Hillystage.svg"..border.."|20px|"..l10n.hilly.."]]" end
if x=='intermediate stage' then return "[[File:Mediummountainstage.svg"..border.."|20px|"..l10n.inter.."]]" end
if x=='mountain stage' then return "[[File:Mountainstage.svg"..border.."|20px|"..l10n.mount.."]]" end
if x=='uphill time trial stage' then return "[[File:Mountain Time Trial Stage.svg"..border.."|20px|"..l10n.uphill.."]]" end
if x=='rest day' then return "[[File:Stage rest day.svg"..border.."|20px|"..l10n.rest.."]]" end
if x=='time trial stage' then
if noborder then border="" else border="|right" end
if typ==2348250 then return "[[File:Team Time Trial Stage.svg"..border.."|20px|"..l10n.time_team.."]]" end
if typ==2266066 then return "[[File:Time Trial.svg"..border.."|20px|"..l10n.time_indiv.."]]" end
if typ==485321 then return "[[File:Time Trial.svg"..border.."|20px|"..l10n.time_prologue.."]]" end
end
end
 
local function func_prologue() -- returns the word "Prologue"
local l10nDef = { ["fr"]="Prologue", ["ar"]="المقدمة", ["en"]="Prologue", ["br"]="Prolog", ["ca"]="Pròleg", ["cs"]="Prolog", ["de"]="Prolog", ["da"]="Prolog", ["eo"]="Prologo",
["es"]="Prólogo", ["eu"]="Aitzinetapa", ["fi"]="Prologi", ["fo"]="Forteinur", ["hu"]="Prológ", ["it"]="Prologo", ["ja"]="プロローグ", ["la"]="Incipit prologus", ["lb"]="Prolog", ["lv"]="Prologs",
["mk"]="Пролог", ["nl"]="Proloog", ["no"]="Prolog", ["pl"]="Prologu", ["pt"]="Prólogo", ["ro"]="Prolog", ["ru"]="Пролог", ["sk"]="Prológ", ["sv"]="Prolog", ["ast"]="Prólogu"}
 
if l10nDef[wiki] ~= nil then return l10nDef[wiki] else return l10nDef["en"] end -- if no translation, show en translation
end
 
local function stageLink(x, a, b) -- x= 10a: a = 10, b = a. x = 5: a = 5, b = ""
local l10nDef = {["fr"]="étape", ["en"]="stage", ["ar"]="مرحلة", ["br"]="Tennad", ["ca"]="etapa", ["cs"]="etapa", ["de"]="Etappe", ["da"]="etape", ["eo"]="Etapo",
["es"]="etapa", ["eu"]="Etapa", ["fi"]="Etappi", ["fo"]="teinur", ["hu"]="szakasz", ["it"]="Tappa", ["ja"]="ステージ", ["la"]="Statio", ["lb"]="etapp",
["lv"]="Posms", ["mk"]="Етапа", ["nl"]="Etappe", ["no"]="etappe", ["pl"]="Etap", ["pt"]="Etapa", ["ro"]="Etapa", ["ru"]="Этап", ["sk"]="Etapa",
["sv"]="Etapp", ["ast"]="etapa" }
 
local word1, word2
word2=l10nDef[wiki]
if word2 == nil then word2=l10nDef["en"] end -- if no translation, show en translation
local word = word2
 
if wiki=="ar" then return word2 .. " " .. ( a or "" ) , "#" .. word2 .. " " .. ( a or "" ) end
 
-- fr: {{1re}} étape, {{2e}} étape
if wiki=="fr" or wiki=="lb" then
if b == "" then -- series_ordinal without character
if a == "1" then word1 = "1<sup>re</sup> "..word else word1 = a.."<sup>e</sup> "..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 = "1<sup>re</sup> "..b.." "..word else word1 = a.."<sup>e</sup> "..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
if wiki=="hu" then
if b == "" then return a..". "..word, "#"..a..". "..word
else return a..b.." "..word, "#"..a..b.." "..word end
end
if wiki=="de" or wiki=="da" or wiki=="fo" or wiki=="no" then return a..". "..b.." "..word, "#"..a..". "..b.." "..word end
if wiki=="ca" then return a.."a "..b.." "..word, "#"..a..". "..b.." "..word end
if wiki=="es" then return a..".ª "..word.." "..b, "#"..a..".ª "..word.." "..b end
if wiki=="ast" then
if b == "" then -- series_ordinal without character
if a == "1" or a == "3" then word1 = a.."ᵉʳ "..word else word1 = a.."ª "..word end -- table text = 1ᵉʳ etapa, 2ª etapa, 3ᵉʳ etapa,
if a == "1" or a == "3" then word2 = "#"..a.."ᵉʳ "..word else word2 = "#"..a.."ª "..word end --text of section header = #1ᵉʳ etapa, #2ª etapa, #3ᵉʳ etapa
return word1, word2
end
if b ~= "" then -- series_ordinal with character: instead of eg "1a re" it is "1re a"
if a == "1" or a == "3" then word1 = a.."ᵉʳ "..b.." "..word else word1 = a.."ª "..b.." "..word end -- table text = {{1ᵉʳ}} etapa, {{2ª}} etapa,
if a == "1" or a == "3" then word2 = "#"..a.."ᵉʳ "..b.." "..word else word2 = "#"..a.."ª"..b.." "..word end --text of section header = #1ᵉʳ etapa, #2ª etapa
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 word1, word2
end
 
local function typeofstagelogo(stageID, noborder)
local sType
p = mw.wikibase.getBestStatements(stageID, 'P31') -- P31 is 'instance of'
for _,t in pairs(p) do
if t.mainsnak.snaktype == 'value' then
local iOf = t.mainsnak.datavalue.value['numeric-id']
if iOf == 20646667 then sType = typeofstage('plain stage', nil, noborder) break end
if iOf == 20646670 then sType = typeofstage('hilly stage', nil,moborder) break end
if iOf == 20680270 then sType = typeofstage('intermediate stage', nil,noborder) break end
if iOf == 20646668 then sType = typeofstage('mountain stage',nil, noborder) break end
if iOf == 485321 then sType = typeofstage('time trial stage', 485321, noborder) break end -- prologue
if iOf == 2266066 then sType = typeofstage('time trial stage', 2266066, noborder) break end -- individual time trial
if iOf == 2348250 then sType = typeofstage('time trial stage', 2348250, noborder) break end -- team time trial
if iOf == 20679712 then sType = typeofstage('uphill time trial stage', nil, noborder) break end
end
end
return sType or ''
end
 
Line 3.264 ⟶ 3.223:
end
if inp == "0" then
this_label = func_prologuetranslate("func_prologue")
else
this_label = stageLink(inp, a, b)
Line 3.325 ⟶ 3.284:
local direction = contentLanguage:getDir()
local outputTableoutTable = mw.html.create('tr')
local tCell=outputTableoutTable:tag('td')
tCell:cssText("text-align:" .. ((direction == 'ltr') and 'left' or 'right')):wikitext(previousText)
if stage ~= nil and wiki=="ar" then
tCell:css('width','50%')
end
tCell=outputTableoutTable:tag('td')
:cssText("text-align:" .. ((direction == 'ltr') and 'right' or 'left')):wikitext( nextText)
if stage ~= nil and wiki=="ar" then
tCell:css('width','50%')
end
return outputTableoutTable
end
 
--== V)Functions Mainfor functionsinfobox
-- functions for infoboxs
local function infoGetOthers(others, entityID)
if not others[1].content then --picture
others[1].content, others[2].content = getLogo(entityID)
if not others[1].content then
others[1].content, others[2].content = getImage(entityID) -- picture, caption
end
end
 
if not others[3].content then -- map
others[3].content, others[5].content = getMap(entityID) -- P242 is 'locator map image'
end
if not others[4].content then -- map
others[4].content, others[6].content = getSectionalView(entityID) -- sectional_view
end
end
 
local function infoGetPlaceOrCountry(details,index, entityID, timeOfRace, PID) --generalized infoGetCountry
if not details[index].content then -- country
-- This function gives countries where the race take place
local place = {}
 
if not place[1] then
for _, p17 in statements(entityID, PID) do -- P17 is 'country'
local countryID = p17.mainsnak.datavalue.value.id
if PID=='P17' then
place[#place + 1] = flag(countryID, timeOfRace) .. ' ' .. getCountryName(countryID)
else
place[#place + 1] = wikibase.getLabel(countryID)
end
end
end
 
if place[1] then
if #place > 1 then
details[index].name = details[index].name_plural
end
details[index].content = table.concat(place, '<br/>')
end
end
end
 
local function infoGetPlace(details,index, entityID, timeOfRace)
infoGetPlaceOrCountry(details,index, entityID, timeOfRace, "P276")
end
 
local function infoGetCountry(details,index, entityID, timeOfRace)
infoGetPlaceOrCountry(details,index, entityID, timeOfRace, "P17")
end
 
local function infoGetStartEnd(details,index, entityID)
if not details[index].content then -- start place
local place = firstValue(entityID, 'P1427', 'id') -- P1427 is 'start point'
details[index].content = place and getPlaceLink(place)
end
 
if not details[index+1].content then -- end place
local place = firstValue(entityID, 'P1444', 'id') -- P1444 is 'destination point'
details[index+1].content = place and getPlaceLink(place)
end
end
 
local function infoGetParticipants(details,index, entityID)
-- Function that give the number of cyclists at the beginning and at the finishing of a race
for _, p1132 in statements(entityID, 'P1132') do -- P1132 is 'number of participants'
local amount = tonumber(p1132.mainsnak.datavalue.value.amount) -- tonumber to remove starting '+'
for _, q in qualifiers(p1132, 'P276') do -- P276 is 'location'
local location = q.value['numeric-id']
if location == 529711 then -- Q529711 is 'beginning'
if not details[index].content then details[index].content = amount end -- participants at start
elseif location == 12769393 then -- Q12769393 is 'end'
if not details[index+1].content then details[index+1].content = amount end -- participants at end
end
end
end
end
 
local function infoInitTab(width, name, icon, cellpadding)
if width==nil then width= '320px' end
local tab = mw.html.create('table')
if wiki == "eo" then
tab:cssText(standardtablecss):css('width','23em')
:addClass('infobox')
else
if cellpadding then
cellpadding=tostring(cellpadding)
else
cellpadding='4'
end
tab:attr('cellpadding',cellpadding)
:attr('cellspacing','0')
:cssText(standardtablecss)
:cssText("float:"..floatinfobox.."; max-width:"..width)
end
local tCell=tab:tag('tr'):tag('td'):attr('colspan','2')
:cssText('border-bottom:5px solid white; font-size:175%; text-align:center')
:css('background-color',backgroundColor)
local topTable = tCell:tag('table')
:cssText('width:100%')
local tRow=topTable:tag('tr')
tRow:tag('td'):wikitext(name or '')
tRow:tag('td'):wikitext(icon or '')
return tab
end
 
local function addARow(name, content)
local tRow
if content then
tRow= mw.html.create('tr'):css('vertical-align','top')
tRow:tag('td'):css('width','40%'):css('font-weight','bold')
:wikitext(name)
tRow:tag('td'):wikitext(content)
end
return tRow
end
 
local function addATitle(title)
local tRow
if title then
tRow= mw.html.create('tr'):tag('td'):attr('colspan','2')
:css('text-align','center')
:css('background-color',backgroundColor)
:css('font-weight','bold')
:wikitext(title)
end
return tRow
end
 
local function infoFillOthersDetails(tab, others, details,title, pxmax)
if not pxmax then
pxmax="300px"
end
if others and others[1].content then -- picture
tab:tag('tr'):tag('td'):attr('colspan','2'):css('text-align','center')
:wikitext("[[File:" .. others[1].content .."|center|"..pxmax.."]]")
if others and others[2].content then -- caption
tab:tag('tr'):tag('td'):attr('colspan','2'):css('text-align','center'):css('font-size','80%')
:wikitext(others[2].content)
end
end
if details then
tab:node(addATitle(title))
for _, row in ipairs(details) do
tab:node(addARow(row.name, row.content)) --node check itself if nil
end
end
end
 
local function infoFillOthersMap(tab, others)
if others[3].content then -- map
tab:tag('tr'):tag('td'):attr('colspan','2'):css('text-align','center')
:wikitext("[[File:".. others[3].content .. "|center|300px]]")
if others[5].content then -- caption
tab:tag('tr'):tag('td'):attr('colspan','2'):css('text-align','center'):css('font-size','80%')
:wikitext(others[5].content)
end
end
if others[4].content then -- map
tab:tag('tr'):tag('td'):attr('colspan','2'):css('text-align','center')
:wikitext("[[File:".. others[4].content .. "|center|300px]]")
if others[6].content then -- caption
tab:tag('tr'):tag('td'):attr('colspan','2'):css('text-align','center'):css('font-size','80%')
:wikitext(others[6].content)
end
end
end
 
local function wdDoc(tab, s, translation, ID, commons_cat)
local tCell=tab:tag('tr'):tag('td')
local tC
if commons_cat then
commons_cat=string.gsub(commons_cat, '%s', '_')
local icon="[[File:Commons-logo.svg|12px|link=https://commons.wikimedia.org/wiki/Category:"..commons_cat.."]]"
tC=tCell:cssText('text-align:left; border-top:3px solid '..backgroundColor..'; font-size:75%')
:wikitext(icon):tag('td')
else
tC=tCell:attr('colspan','2')
end
tC:cssText('text-align:right; border-top:3px solid '..backgroundColor..'; font-size:75%')
:wikitext("[[" .. s .. "|" .. translation .. "]] [[File:Wikidata-logo S.svg|12px|link=d:".. ID .."]]")
end
 
local function listWPlink(details, index, entityID, PID)
local org={}
for _, p in statements(entityID, PID) do
if p and p.mainsnak.snaktype == 'value' then
table.insert(org,WPlinkpure(p.mainsnak.datavalue.value.id))
end
end
if org[1] then
if #org > 1 then
details[index].name = details[index].name_plural
end
details[index].content = table.concat(org, '<br/>')
end
end
 
-- == Functions for team roster
local function getReason(riderReason, riderRef, p527,timeOfRace,riderEnd) --reason for end
local listofproperty={'P1642','P1643','P1534'}
local outTable={}
local seasonYear, endYear
if timeOfRace then
seasonYear=tonumber(string.sub(timeOfRace, 2, 5))
end
if riderEnd then
endYear=tonumber(string.sub(riderEnd, 2, 5))
end
--if not the last season, do not display the reason for end
if (riderReason == nil and (not endYear or
(seasonYear and endYear and (seasonYear== endYear)))) then --if no riderReason before then look for it, otherwise don't touch it
for _,v in ipairs(listofproperty) do
for _, q in qualifiers(p527, v) do
riderReason = q.value.id
end
end
if riderReason then
local label = string.gsub(wikibase.label(riderReason), "%b()", "") or getLabelFallback(riderReason,{'en', 'fr', 'de'})
riderRef = getReference(p527, 1)
riderReason = ', ' .. label
end
end
return riderReason, riderRef
end
 
local function getPosition(riderPosition,v)
local stagiaire
if riderPosition == nil then -- find the 'position' (P39) of a rider
for _, q in qualifiers(v, 'P39') do
stagiaire = q.value.id
local label = string.gsub(wikibase.label(stagiaire), "%b()", "") or getLabelFallback(stagiaire,{'en', 'fr', 'de'})
Sitelink = wikibase.getSitelink('Q2328847')
if Sitelink then
riderPosition=', ' .. "[["..Sitelink .."|"..label.."]]"
else
riderPosition =', ' .. label
end
end
end
return riderPosition
end
 
local function trans(date, month, day)
if date ~= '' and date~=nil then
local _, _, y, m, d = string.find(date, "(%d+)-(%d+)-(%d+)")
if m == '00' then m = month end
if d == '00' then d = day end
date = '+'..y..'-'..m..'-'..d..'T00:00:00Z'
return date
end
return nil
end
 
local function parseDate(date, defaultYear, defaultMonth, defaultDay, errortext, etext)
local y, m, d
local date=trans(date, defaultMonth, defaultDay)
if not date then
date = '+'..defaultYear..'-'..defaultMonth..'-'..defaultDay..'T00:00:00Z'
y=defaultYear
m=defaultMonth
d=defaultDay
errortext=errortext..etext
else
_, _, y, m, d = string.find(date, "(%d+)-(%d+)-(%d+)")
if not y or y=="0000" then
y=defaultYear
errortext=errortext..etext
end
date = '+'..y..'-'..m..'-'..d..'T00:00:00Z'
end
return date, y, m, d, errortext
end
 
local function findLastName(label,wiki)
if not label then label = '' end
local _, count = string.gsub(label, " ", " ")
local names
local a,b,c,d = '', '', '', ''
local done = false
if count ~= nil then count = count + 1 else count = 1 end
 
if count > 1 then
if count == 2 then
if label ~= '' then
a, b = string.match(label, "(%S+)%s+(%S+)")
names = b..' '..a
end
else
local name_parts_mk = {'да', 'ди', 'де', 'Де', 'ла', 'Ле', 'тен', 'ван', 'Ван'}
local name_parts_ru = {'да', 'ди', 'де', 'Де', 'ла', 'Ле', 'тен', 'ван', 'Ван'}
local name_parts = {'da', 'de', 'di', 'De', 'la', 'Le', 'ten', 'van', 'Van'}
if count == 3 and label ~= '' then
a, b, c = string.match(label, "(%S+)%s+(%S+)%s+(%S+)")
if wiki == 'mk' then
for _,v in ipairs(name_parts_mk) do if b == v then names = b..' '..c..' '..a done = true break end end
elseif wiki == 'ru' then
for _,v in ipairs(name_parts_ru) do if b == v then names = b..' '..c..' '..a done = true break end end
else
for _,v in ipairs(name_parts) do if b == v then names = b..' '..c..' '..a done = true break end end
end
if not done then
names = c..' '..a..' '..b
done = true
end
end
if count > 3 and label ~= '' then
a, b, c, d = string.match(label, "(%S+)%s+(%S+)%s+(%S+)%s+(%S+)")
if wiki == 'mk' then
for _,v in ipairs(name_parts_mk) do if c == v then names = c..' '..d..' '..a..' '..b done = true break end end
for _,v in ipairs(name_parts_mk) do if b == v then names = b..' '..c..' '..d..' '..a done = true break end end
elseif wiki == 'ru' then
for _,v in ipairs(name_parts_ru) do if c == v then names = c..' '..d..' '..a..' '..b done = true break end end
for _,v in ipairs(name_parts_ru) do if b == v then names = b..' '..c..' '..d..' '..a done = true break end end
else
for _,v in ipairs(name_parts) do if c == v then names = c..' '..d..' '..a..' '..b done = true break end end
for _,v in ipairs(name_parts) do if b == v then names = b..' '..c..' '..d..' '..a done = true break end end
 
end
if not done then names = label.."%"..b end --b..' '..c..' '..d..' '..a end
end
end
end
return names or ''
end
 
local function findSortKey(riderID, correctlanguage, wikiIsSlavic)
--find the last name to sort
if wikiIsSlavic and correctlanguage then
local label = wikibase.getLabelByLang(riderID, wiki)
if not label then
label = getLabelFallback(riderID, {'en', 'fr', 'de', 'es'})
return findLastName(label,wiki)
else
local nametable = mw.text.split(label, ",")
if nametable[2] then --there is a coma so the lastname is first
return nametable[1]..nametable[2]
else --no coma
return findLastName(label,wiki)
end
end
else
local label = getLabelFallback(riderID, {'en', 'fr', 'de', 'es'})
return findLastName(label,wiki)
end
end
 
--== V) Main functions ==
--=== A) Function race reference ===
local function race_reference(raceID)
Line 3.350 ⟶ 3.662:
}
local links = {}
local ref
for _, base in pairs(bases) do
local p = mw.wikibase.getBestStatements(raceID, base[2])
if p[1] and p[1].mainsnak.snaktype == 'value' then
table.insert(links, ' [' .. if base[32]=="P2648" ..and p[1].mainsnak.datavalue.value=="1" ..then "--code "for ..general base[1]reference ..']')of results
ref=getReference(p[1], 1)
if ref then table.insert(links, ref) end
else
table.insert(links, ' [' .. base[3] .. p[1].mainsnak.datavalue.value .. " " .. base[1] ..']')
end
end
end
if #links == 1 then
return race_reference_translatetranslate(wiki"race_reference", 1) .. table.concat(links)
elseif #links > 1 then
return race_reference_translatetranslate(wiki"race_reference", 2) .. table.concat(links)
else
return ''
Line 3.423 ⟶ 3.741:
 
local s = {
header_function = calendar_translate"calendar", -- translations are in function Calendar_translateCalendar
header_1 = 1000, -- translation 1 in function Calendar_translateCalendar is printed in the upper part of the table header
header_2 = headertemp,-- translations 2, 3, 4, 5, 6 in function Calendar_translateCalendar are printed in this order
title=wikibase.getLabel(calendarID), -- in the lower part of the table header. The second value 3 in {4, 3} tells where the icon will go.
country_column = countrycolumn,
Line 3.450 ⟶ 3.768:
local calendarID
if wiki == "ar" then frame = frame:getParent() end
local UCI = {}data.UCIYearToQ
UCI["WT"] = { -- Q635366
local header_1_tab = {["UWT"]=13 ,["europe"]=14 ,["asia"]=15,["america"]=16 ,["africa"]=17 ,["oceania"]=18, ["WWT"]=11, ["women"]=1, ["Pro"]=22}
['2020'] = 'Q66739340',
local display_code_tab= {["UWT"]=1 ,["europe"]=2 ,["asia"]=2,["america"]=2 ,["africa"]=2 ,["oceania"]=2, ["WWT"]=1, ["women"]=2, ["Pro"]=2}
['2019'] = 'Q56966729',['2018'] = 'Q42317185',['2017'] = 'Q21857932',
['2016'] = 'Q20970765',['2015'] = 'Q18192726',['2014'] = 'Q14979277',
['2013'] = 'Q1031504',['2012'] = 'Q849059', ['2011'] = 'Q849092'
}
UCI["europe"] = { -- Q1194340
['2020'] = 'Q74842812',
['2019'] = 'Q57267776',['2018'] = 'Q44497477',['2017'] = 'Q27915850',
['2016'] = 'Q21029681',['2015'] = 'Q18342122',['2014'] = 'Q15041668',
['2013'] = 'Q1280387',['2012'] = 'Q961709',['2010–11'] = 'Q751208',
['2009–10'] = 'Q212197',['2008–09'] = 'Q1811548',['2007–08'] = 'Q1788011',
['2006–07'] = 'Q1780660',['2005–06'] = 'Q1455600',['2005'] = 'Q1431816'
}
UCI["asia"] = { -- Q1063423
['2020'] = 'Q74121688',
['2019'] = 'Q57267783',['2018'] = 'Q42204070',['2017'] = 'Q27679728',
['2016'] = 'Q21622227',['2015'] = 'Q18341318',['2013–14'] = 'Q15041671',
['2012–13'] = 'Q1606048',['2011–12'] = 'Q2117797',['2010–11'] = 'Q633349',
['2009–10'] = 'Q630798',['2008–09'] = 'Q565160',['2007–08'] = 'Q1506934',
['2006–07'] = 'Q966011',['2005–06'] = 'Q459817',['2005'] = 'Q469479',
}
UCI["america"] = { -- Q1063430
['2020'] = 'Q73175384',
['2019'] = 'Q57267780',['2018'] = 'Q42199340',['2017'] = 'Q27704415',
['2016'] = 'Q21621040',['2015'] = 'Q18413668',['2013–14'] = 'Q15041669',
['2012–13'] = 'Q129177',['2011–12'] = 'Q1239608',['2010–11'] = 'Q1849269',
['2009–10'] = 'Q1303982',['2008–09'] = 'Q1536927',['2007–08'] = 'Q31716',
['2006–07'] = 'Q31714',['2005–06'] = 'Q1429246',['2005'] = 'Q1431880',
}
UCI["africa"] = { -- Q268357
['2020'] = 'Q74124131',
['2019'] = 'Q57267785',['2018'] = 'Q42202027',['2017'] = 'Q27679848',
['2016'] = 'Q21622217',['2015'] = 'Q18342124', ['2013–14'] = 'Q15041670',
['2012–13'] = 'Q327399', ['2011–12'] = 'Q2296721',['2010–11'] = 'Q1386870',
['2009–10'] = 'Q2067266', ['2008–09'] = 'Q1812465',['2007–08'] = 'Q676684',
['2006–07'] = 'Q1436886', ['2005–06'] = 'Q1758917',['2005'] = 'Q1759404',
}
UCI["oceania"] = { -- Q1039648
['2020'] = 'Q74843575',
['2019'] = 'Q57267787',['2018'] = 'Q42205000', ['2017'] = 'Q27887426',
['2016'] = 'Q21559636',['2015'] = 'Q18413671', ['2014'] = 'Q15246814',
['2013'] = 'Q129134',['2011–12'] = 'Q1591132', ['2011'] = 'Q2298207',
['2009–10'] = 'Q665283',['2008–09'] = 'Q964517', ['2007–08'] = 'Q1788621',
['2006–07'] = 'Q1473640',['2005–06'] = 'Q1429165', ['2005'] = 'Q937636',
}
UCI["WWT"] = {
['2020'] = 'Q70443700',
['2019'] = 'Q57277246', ['2018'] = 'Q41787783', ['2017'] = 'Q27431192',
['2016'] = 'Q21034783',
}
UCI["women"] = {
['2020'] = 'Q74127378',
['2019'] = 'Q57267790', ['2018'] = 'Q47005682', ['2017'] = 'Q27765666',
['2016'] = 'Q22696468', ['2015'] = 'Q18348936', ['2014'] = 'Q15831496',
['2013'] = 'Q6425932', ['2012'] = 'Q2466796', ['2011'] = 'Q2466792',
['2010'] = 'Q2933831', ['2009'] = 'Q2933830', ['2008'] = 'Q2933828',
['2007'] = 'Q3650627', ['2006'] = 'Q16154659',
}
UCI["Pro"] = {
['2020'] = 'Q74279750',
}
local header_1_tab = {["WT"]=13 ,["europe"]=14 ,["asia"]=15,["america"]=16 ,["africa"]=17 ,["oceania"]=18, ["WWT"]=11, ["women"]=1}
local display_code_tab= {["WT"]=1 ,["europe"]=2 ,["asia"]=2,["america"]=2 ,["africa"]=2 ,["oceania"]=2, ["WWT"]=1, ["women"]=2}
local header_1_number = 12
Line 3.561 ⟶ 3.817:
 
local s = {
header_function = calendar_translate"calendar", -- translations are in function Calendar_translateCalendar
header_1 = header_1_number, -- t
header_2 = tempdic.header_2,
Line 3.597 ⟶ 3.853:
end
 
function calendar_main(s, resulttableresultTable)--Display the UCI women calendar of one year
localframe=s.frame
local calendarID=s.item
Line 3.607 ⟶ 3.863:
if not temp then s.error_message = 2 return '' end
 
local country=getcoutrybool getCountryBool(s.no_country)
if available_list==false then country=false end --otherwise the display put no "country" column...
 
Line 3.642 ⟶ 3.898:
end
 
return sortandconcatsortAndConcat(t_Body, resulttableresultTable)
end
 
Line 3.653 ⟶ 3.909:
 
UCIroad["women"] = {
['2021']= 'Q104304845', ['2020']='Q78466304', ['2019'] = 'Q66362617',
['2018'] = 'Q66762475', ['2017'] = 'Q66762546', ['2016'] = 'Q66762540',
['2015'] = 'Q66762534', ['2014'] = 'Q66762524', ['2013'] = 'Q66762521',
Line 3.660 ⟶ 3.916:
UCIITT["women"] = {
['2021']= 'Q104305086', ['2020'] = 'Q78466572', ['2019'] = 'Q66736271',
['2018'] = 'Q66762631', ['2017'] = 'Q66762614', ['2016'] = 'Q66762604',
['2015'] = 'Q66762597', ['2014'] = 'Q66762592', ['2013'] = 'Q66762584',
Line 3.688 ⟶ 3.944:
 
local s = {
header_function = calendar_translate"calendar", -- translations are in function Calendar_translateCalendar
header_1 = 19, --
header_2 = {5, 20, 21},
Line 3.707 ⟶ 3.963:
end
 
function nationalchampionships_main(s, resulttableresultTable)--Display the list of national champions for one year
localframe=s.frame
local tableChamp, fn_countrytable, t_Body = {}, {}, {}
Line 3.775 ⟶ 4.031:
end --end list of key
 
return sortandconcatsortAndConcat(t_Body, resulttableresultTable)
end
 
Line 3.781 ⟶ 4.037:
function p.victories(frame)
local s = {
header_function = victories_translate"victories", -- translations are in function victories_translatevictories
header_1 = 2, -- translation 1 in function victories_translatevictories is printed in the upper part of the table header
header_2 = {3, 4, 5, 6, 7},-- translations 2, 3, 4, 5, 6 in function victories_translatevictories are printed in this order
-- in the lower part of the table header. The second value 3 in {4, 3} tells where the icon will go.
data_type = {'date', 'race', 'country', 'class', 'rider'},
Line 3.797 ⟶ 4.053:
end
 
function victory_main(s, resulttableresultTable)
localframe=s.frame
local _
Line 3.805 ⟶ 4.061:
if temp then else s.error_message = 2 return '' end
 
local country=getcoutrybool getCountryBool(s.no_country)
if available_list==false then country=false end
 
Line 3.835 ⟶ 4.091:
end --end list of key
return sortandconcatsortAndConcat(t_Body, resulttableresultTable)
end
 
--== Cbis) Functions for infobox
-- functions for both infoboxs
local function infoGetOthers(others, entityID)
if not others[1].content then --picture
others[1].content, others[2].content = getImage(entityID) -- picture, caption
end
 
if not others[3].content then -- map
others[3].content = firstValue(entityID, 'P242') -- P242 is 'locator map image'
end
if not others[4].content then -- map
others[4].content = firstValue(entityID, 'P2713') -- sectional_view
end
end
 
local function infoGetCountry(details,index, entityID, timeOfRace)
if not details[index].content then -- country
-- This function gives countries where the race take place
local country = {}
for _, p17 in statements(entityID, 'P17') do -- P17 is 'country'
local countryID = p17.mainsnak.datavalue.value.id
country[#country + 1] = flag(countryID, timeOfRace) .. ' ' .. getCountryName(countryID)
end
if country[1] then
if #country > 1 then
details[index].name = details[index].name_plural
end
details[index].content = table.concat(country, '<br/>')
end
end
end
local function infoGetStartEnd(details,index, entityID)
if not details[index].content then -- start place
local place = firstValue(entityID, 'P1427', 'id') -- P1427 is 'start point'
details[index].content = place and getPlaceLink(place)
end
 
if not details[index+1].content then -- end place
local place = firstValue(entityID, 'P1444', 'id') -- P1444 is 'destination point'
details[index+1].content = place and getPlaceLink(place)
end
end
 
local function infoGetParticipants(details,index, entityID)
-- Function that give the number of cyclists at the beginning and at the finishing of a race
for _, p1132 in statements(entityID, 'P1132') do -- P1132 is 'number of participants'
local amount = tonumber(p1132.mainsnak.datavalue.value.amount) -- tonumber to remove starting '+'
for _, q in qualifiers(p1132, 'P276') do -- P276 is 'location'
local location = q.value['numeric-id']
if location == 529711 then -- Q529711 is 'beginning'
if not details[index].content then details[index].content = amount end -- participants at start
elseif location == 12769393 then -- Q12769393 is 'end'
if not details[index+1].content then details[index+1].content = amount end -- participants at end
end
end
end
end
 
local function infoInitTab(width, name, icon)
if width==nil then width= '320px' end
local tab = mw.html.create('table')
if wiki == "eo" then
tab:cssText(standardtablecss):css('width','23em')
:addClass('infobox')
else
tab:attr('cellpadding','4')
:attr('cellspacing','0')
:cssText(standardtablecss)
:cssText("float:"..floatinfobox.."; max-width:"..width)
end
local tCell=tab:tag('tr'):tag('td'):attr('colspan','2')
:cssText('border-bottom:5px solid white; font-size:175%; background:#EAECF0; text-align:center')
local topTable = tCell:tag('table')
:cssText('width:100%')
local tRow=topTable:tag('tr')
tRow:tag('td'):wikitext(name or '')
tRow:tag('td'):wikitext(icon or '')
return tab
end
 
local function infoFillOthersDetails(tab, others, details,title)
if others[1].content then -- picture
tab:tag('tr'):tag('td'):attr('colspan','2'):css('text-align','center')
:wikitext("[[File:" .. others[1].content .."|center|300px]]")
if others[2].content then -- caption
tab:tag('tr'):tag('td'):attr('colspan','2'):css('text-align','center'):css('font-size','80%')
:wikitext(others[2].content)
end
end
tab:tag('tr'):tag('td'):attr('colspan','2'):css('text-align','center'):css('background-color','#EAECF0')
:css('font-weight','bold')
:wikitext(title)
for _, row in ipairs(details) do
if row.content then
tRow= tab:tag('tr'):css('vertical-align','top')
tRow:tag('td'):css('width','40%'):css('font-weight','bold')
:wikitext(row.name)
tRow:tag('td'):wikitext(row.content)
end
end
end
 
local function infoFillOthersMap(tab, others)
if others[3].content then -- map
tab:tag('tr'):tag('td'):attr('colspan','2'):css('text-align','center')
:wikitext("[[File:".. others[3].content .. "|center|300px]]")
end
if others[4].content then -- map
tab:tag('tr'):tag('td'):attr('colspan','2'):css('text-align','center')
:wikitext("[[File:".. others[4].content .. "|center|300px]]")
end
end
 
local function wdDoc(tab, s, translation, ID)
tab:tag('tr'):tag('td'):attr('colspan','2')
:cssText('text-align:right; border-top:3px solid #EAECF0; font-size:75%')
:wikitext("[[" .. s .. "|" .. translation .. "]] [[File:Wikidata-logo S.svg|12px|link=d:".. ID .."]]")
end
 
Line 3.964 ⟶ 4.097:
function p.stageinfobox(frame)
local details = {
{ name = stageinfobox_translatetranslate("stageinfobox",2)}, -- course / not used
{ name = stageinfobox_translatetranslate("stageinfobox",2)}, -- competition
{ name = stageinfobox_translatetranslate("stageinfobox",3), name_plural = infobox_translatetranslate("infobox",4)}, -- stage type
{ name = stageinfobox_translatetranslate("stageinfobox",4), name_plural = infobox_translatetranslate("infobox",7)}, -- date
{ name = stageinfobox_translatetranslate("stageinfobox",6)}, -- distance
{ name = stageinfobox_translatetranslate("stageinfobox",7), name_plural = infobox_translatetranslate("infobox",10)}, -- country
{ name = stageinfobox_translatetranslate("stageinfobox",9)}, -- start place
{ name = stageinfobox_translatetranslate("stageinfobox",10)}, -- endplace
{ name = stageinfobox_translatetranslate("stageinfobox",11)}, -- participants at start
{ name = stageinfobox_translatetranslate("stageinfobox",12)}, -- participants at end
{ name = stageinfobox_translatetranslate("stageinfobox",13)}, -- speed
{ name = stageinfobox_translatetranslate("stageinfobox",44)}, -- elevation
{ name = infobox_translatetranslate("infobox",32), special = true}, -- special 1
{ name = infobox_translatetranslate("infobox",33), special = true}, -- special 2
}
local others = {
{ name = infobox_translatetranslate("infobox",29)}, -- picture
{ name = infobox_translatetranslate("infobox",30)}, -- caption
{ name = infobox_translatetranslate("infobox",31)}, -- map
{ name = 'sectional'}, -- sectional
{ name = translate("infobox",30)}, -- caption map
{ name = translate("infobox",30)}, -- caption sectional
}
--begin of the function
Line 4.026 ⟶ 4.161:
local entityID = mw.text.trim(frame.args[1])
local wikibase = mw.wikibase
if type(entityID) ~= 'string' then error('parameter must be a string') end
if not entityID:match('Q%d+') then error ('parameter must be a valid Wikidata item (ex: Q42)') end
 
local localframe
Line 4.079 ⟶ 4.213:
local pTime = firstValue(entityID, 'P585', 'time') -- P585 is 'point in time'
if pTime then
details[4].content = func_datefuncDate(pTime, 'long')
timeOfRace = pTime
end
Line 4.149 ⟶ 4.283:
if riderId ~= nil then
local riderLink,riderTeam = subwinner(riderId, timeOfRace, q) --sub function to avoid code in double
-- looks into race item if the winner has a P642 statement for showing the type of winner (points, mountain, ..)
if q.P642 and q.P642[1].snaktype == 'value' then
for _, vv in pairs(q.P642) do
Line 4.175 ⟶ 4.309:
t_s.annex.equipe['link']=riderId
end
v['genre'] = getgendercodegetGenderCode(riderId,'f')
end
end
Line 4.214 ⟶ 4.348:
end
v['speed'] = qualifieramount(p2417, 'P2052')
v['genre'] = getgendercodegetGenderCode(thisid, 'f')
end
end
Line 4.235 ⟶ 4.369:
if t_s.annex.show == true and (wiki == 'no' or wiki == '..') then width= '340px' end
tab= infoInitTab(width, name, icon)
infoFillOthersDetails(tab, others, details,stageinfobox_translatetranslate("stageinfobox",1))
 
-- ranking table, general and stage
Line 4.245 ⟶ 4.379:
tTab=tCell:tag('table'):attr('cellpadding','0'):attr('cellspacing','0'):css('width','100%')
tCell=tTab:tag('tr'):tag('td'):attr('colspan','3')
:cssText('border-bottom:5px solid #F4F4F4fff2cc; background-color:#EAECF0FFE7A0; text-align:center')
:css('font-weight','bold')
:wikitext(stageinfobox_translatetranslate("stageinfobox",thistable.header))
 
for key, value in ipairs(thistable.order) do --value is the name of the class
Line 4.253 ⟶ 4.387:
if v['link'] then
local a1
a1, jersey_name, jerseyWPID = jersey_infobox(wiki, value, race, timeOfRace)
if a1~='' then v['jersey'] = a1 end
if v['speed'] then
Line 4.260 ⟶ 4.394:
else
local lang = mw.language.getContentLanguage()
v['speed'] = '('.. lang:formatNum(v['speed'])..unittranslate("unit",5)..')'
end
end
if v['points'] then
if v['points'] > 1 then
temp=unittranslate("unit",7)
else
temp=unittranslate("unit",6)
end
v['points'] = v['points']..temp
end
local title, k = string.gsub(stageinfobox_translatetranslate("stageinfobox",v['translation']), " ", "&nbsp;")
if k > 0 then title = string.gsub(title, "&nbsp;", "<br>", 1) end --&#32;
Line 4.281 ⟶ 4.415:
tCell:attr('rowspan','2')
end
tCell:cssText("width:1%;background-color:#F4F4F4fff2cc;text-align:" ..
textalign .. ";padding:0 2px 0 2px;white-space:nowrap")
Line 4.287 ⟶ 4.421:
if v['jersey'] == nil then
if (value_order=='results') and (value=='winner_fighting' or value=='winner_fighting2' or value=='cima_coppi' or value=='cima_pantanii') then
tCell:wikitext(stageinfobox_translatetranslate("stageinfobox",v['translation']))
else
tCell:wikitext(number(v['genre'], key, wiki))
Line 4.321 ⟶ 4.455:
 
if v['time'] then
tCell:wikitext(calculate_timecalculateTime(v['time']))
end
if v['gap'] then
tCell:wikitext('+ '.. calculate_timecalculateTime(v['gap']))
end
tCell:wikitext(v['points'])
Line 4.352 ⟶ 4.486:
infoFillOthersMap(tab, others)
tab:node(getPreviousNextLine(entityID,true))
wdDoc(tab, "d:Wikidata:WikiProject Cycling/Documentation/stageinfobox", stageinfobox_translatetranslate("stageinfobox",39), frame.args[1])
return tab
end
Line 4.362 ⟶ 4.496:
local WDlink_on = (wiki == "mk" or wiki == "ja")
 
local timeOfRace, errorMessage = gettimeOfRacegetTimeOfRace(raceID)
if not timeOfRace then return errorMessage end
 
local teamCats = { -- {c,d,e} c = singular team type, d = plural team type, e = print order of the team types
["Q6154783"] = {4,5,1}, -- WorldTeam
["Q20638319Q80425135"] = {64,75,2}, -- ProTeamUCI (2005-2014)Women’s WorldTeam
["Q382927Q20638319"] = {86,97,43}, -- UCI Professional Continental TeamProTeam (2005-20192014)
["Q78464255"] = {6,7,34}, -- ProTeam (2020-)
["Q1756006Q382927"] = {108,119,5}, -- UCI Professional Continental Team (2005-2019)
["Q23726798Q1756006"] = {1210,1311,6}, -- nationalUCI cyclingContinental teamTeam
["Q20738667Q20639847"] = {1216,1317,7}, -- nationalprofessional cycling team U23
["Q28492441Q20653563"] = {1220,1321,8}, -- équipeGroupe cyclisteSportif nationale de marqueI
["Q20639848Q20653564"] = {1422,1523,9}, -- clubGroupe cyclingSportif teamII
["Q20639847Q20653566"] = {1624,1725,10}, -- professionalGroupe cyclingSportif teamIII
["Q20652655Q2466826"] = {1828,1929,11}, -- amateurUCI cyclingWomen’s teamTeam
["Q20653563Q23726798"] = {2012,2113,12}, -- Groupenational Sportifcycling Iteam
["Q20653564Q99658502"] = {22,2312,13,12}, -- Groupenational Sportifcycling IIteam "B"
["Q20653566Q20738667"] = {2412,2513,1412}, -- Groupenational Sportifcycling IIIteam U23
["Q80425135Q54555994"] = {412,513,512}, -- UCInational Women’scycling WorldTeamteam U19
["Q2466826Q28492441"] = {2812,2913,13}, -- UCInational cycling team with Women’ssponsor Teamname
["Q26849121Q20652655"] = {3018,3119,14}, -- Women's amateur cycling team
["Q26849121"] = {30,31,14}, -- Women's amateur cycling team
["Q20639848"] = {14,15,15}, -- club and region cycling team
["Q20653570"] = {14,15,15}, -- club and region cycling team
}
 
Line 4.406 ⟶ 4.543:
local header, sitelink
if teamCats[CatID] then
local done=false
if count == 1 then
if CatID=="Q2466826" then --name changed after 2020
header_label = headoftableIII(teamCats[CatID][1]) -- singular name
local year = timeOfRace and tonumber(string.sub(timeOfRace, 2, 5))
else
if year and year>2019 then
header_label = headoftableIII(teamCats[CatID][2]) -- plural name
if count == 1 then
header_label = translate("headoftableIII",32) -- singular name
else
header_label = translate("headoftableIII",33) -- plural name
end
done=true
end
end
if done==false then
if count == 1 then
header_label = translate("headoftableIII",teamCats[CatID][1]) -- singular name
else
header_label = translate("headoftableIII",teamCats[CatID][2]) -- plural name
end
end
if CatID=='Q78464255' then
Line 4.447 ⟶ 4.599:
local header
local resulttableresultTable = mw.html.create('table')
:cssText("max-width:95%; padding:0.5em; margin-right:1em; border:1px solid rgb(200,200,200)")
local tCell = resulttableresultTable:tag('tr'):tag('td')
 
for _, team in ipairs(teams) do
Line 4.461 ⟶ 4.613:
count = 1
oldOrder = order
tOl = mw.html.create('olul') --reinit
else
count = count + 1
Line 4.467 ⟶ 4.619:
oldCatID = team[2]
tOl:tag('li')
:cssText("text-indent:0em;width:20em;display:inline-block;vertical-align:text-top")
:wikitext(team[1])
end
Line 4.479 ⟶ 4.631:
:addClass('navigation-only')
:attr('colspan',2)
:cssText('border-top: 2px #EAECF0'..backgroundColor..' solid; font-size: 80%;')
tCell:tag('span'):css("float",floattable)
:wikitext('[[File:Wikidata-logo S.svg|12px|link=d:' ..raceID .. '#P1923]]')
resulttableresultTable:node(tableFooter1)
return resulttableresultTable
end
 
Line 4.490 ⟶ 4.642:
function p.UCIclassification(frame)
local s = {
header_function = "headoftableII", -- translations are in function headoftableII
header_1 = 19, -- translation 10 in function headoftableII is printed in the upper part of the table header
header_2 = {1, 2, 7}, -- translations 1, 2, 3, 7 in function headoftableII are printed in this order in the lower part of the table header
Line 4.504 ⟶ 4.656:
function p.pointsclassification(frame)
local s = {
header_function = "headoftableII", -- translations are in function headoftableII
header_1 = 10, -- translation 10 in function headoftableII is printed in the upper part of the table header
header_2 = {1, 2, 3, 7}, -- translations 1, 2, 3, 7 in function headoftableII are printed in this order in the lower part of the table header
Line 4.517 ⟶ 4.669:
function p.teamsclassificationbytime(frame)
local s = {
header_function = "headoftableII", -- translations are in function headoftableII
header_1 = 14, -- translation 10 in function headoftableII is printed in the upper part of the table header
header_2 = {3, 2, 4}, -- translations 3, 2, 4 in function headoftableII are printed in this order in the lower part of the table header
Line 4.530 ⟶ 4.682:
function p.teamsclassificationbypoints(frame)
local s = {
header_function = "headoftableII", -- translations are in function headoftableII
header_1 = 15, -- translation 10 in function headoftableII is printed in the upper part of the table header
header_2 = {3, 2, 7}, -- translations 3, 2, 7 in function headoftableII are printed in this order in the lower part of the table header
Line 4.543 ⟶ 4.695:
function p.stageclassification(frame)
local s = {
header_function = "headoftableII", -- translations are in function headoftableII
header_1 = 8, -- translation 10 in function headoftableII is printed in the upper part of the table header
header_2 = {1, 2, 3, 4}, -- translations 1, 2, 3, 4 in function headoftableII are printed in this order in the lower part of the table header
Line 4.557 ⟶ 4.709:
function p.generalclassification(frame)
local s = {
header_function = "headoftableII", -- translations are in function headoftableII
header_1 = 9, -- translation 10 in function headoftableII is printed in the upper part of the table header
header_2 = {1, 2, 3, 4}, -- translations 1, 2, 3, 4 in function headoftableII are printed in this order in the lower part of the table header
Line 4.568 ⟶ 4.720:
return new_classification(frame, s)
end
 
function p.generalclassificationpoint(frame)
local s = {
header_function = "headoftableII", -- translations are in function headoftableII
header_1 = 9, -- translation 10 in function headoftableII is printed in the upper part of the table header
header_2 = {1, 2, 3, 7}, -- translations 1, 2, 3, 7 in function headoftableII are printed in this order in the lower part of the table header
item = frame.args[1],
property = 'P2321', -- property to use for this table
team_classification = false, -- it is not a team classification table, its a rider classification table
background = 'color', -- there is a background color for the first row
display_ref = tonumber(frame.args[2]) == 0 and 0 or 1
}
return new_classification(frame, s)
end
 
function p.generalclassificationforttt(frame)
local s = {
header_function = "headoftableII", -- translations are in function headoftableII
header_1 = 9, -- translation 10 in function headoftableII is printed in the upper part of the table header
header_2 = {3, 2, 4, 5, 6}, -- translations 3, 2, 4, 5, 6 in function headoftableII are printed in this order in the lower part of the table header
Line 4.585 ⟶ 4.751:
function p.teamtimetrialclassification(frame)
local s = {
header_function = "headoftableII", -- translations are in function headoftableII
header_1 = 8, -- translation 10 in function headoftableII is printed in the upper part of the table header
header_2 = {3, 2, 4, 5, 6}, -- translations 3, 2, 4, 5, 6 in function headoftableII are printed in this order in the lower part of the table header
Line 4.599 ⟶ 4.765:
function p.mountainsclassification(frame)
local s = {
header_function = "headoftableII", -- translations are in function headoftableII
header_1 = 11, -- translation 10 in function headoftableII is printed in the upper part of the table header
header_2 = {1, 2, 3, 7}, -- translations 1, 2, 3, 7 in function headoftableII are printed in this order in the lower part of the table header
Line 4.612 ⟶ 4.778:
function p.sprintsclassification(frame)
local s = {
header_function = "headoftableII", -- translations are in function headoftableII
header_1 = 12, -- translation 10 in function headoftableII is printed in the upper part of the table header
header_2 = {1, 2, 3, 7}, -- translations 1, 2, 3, 7 in function headoftableII are printed in this order in the lower part of the table header
Line 4.625 ⟶ 4.791:
function p.bestyoungclassificationbypoints(frame)
local s = {
header_function = "headoftableII", -- translations are in function headoftableII
header_1 = 13, -- translation 10 in function headoftableII is printed in the upper part of the table header
header_2 = {1, 2, 3, 7}, -- translations 1, 2, 3, 7 in function headoftableII are printed in this order in the lower part of the table header
Line 4.638 ⟶ 4.804:
function p.bestyoungclassification(frame)
local s = {
header_function = "headoftableII", -- translations are in function headoftableII
header_1 = 13, -- translation 10 in function headoftableII is printed in the upper part of the table header
header_2 = {1, 2, 3, 4}, -- translations 1, 2, 3, 7 in function headoftableII are printed in this order in the lower part of the table header
Line 4.651 ⟶ 4.817:
function p.u23classification(frame)
local s = {
header_function = "headoftableII", -- translations are in function headoftableII
header_1 = 18, -- translation 10 in function headoftableII is printed in the upper part of the table header
header_2 = {1, 2, 3, 4}, -- translations 1, 2, 3, 7 in function headoftableII are printed in this order in the lower part of the table header
Line 4.664 ⟶ 4.830:
function p.combinationclassification(frame)
local s = {
header_function = "headoftableII", -- translations are in function headoftableII
header_1 = 16, -- translation 10 in function headoftableII is printed in the upper part of the table header
header_2 = {1, 2, 3, 7}, -- translations 1, 2, 3, 7 in function headoftableII are printed in this order in the lower part of the table header
Line 4.677 ⟶ 4.843:
function p.combativeclassification(frame)
local s = {
header_function = "headoftableII", -- translations are in function headoftableII
header_1 = 17, -- translation 10 in function headoftableII is printed in the upper part of the table header
header_2 = {1, 2, 3, 7}, -- translations 1, 2, 3, 7 in function headoftableII are printed in this order in the lower part of the table header
Line 4.690 ⟶ 4.856:
function p.custompointsclassification(frame)
local s = {
header_function = "headoftableII", -- translations are in function headoftableII
header_2 = {1, 2, 3, 7}, -- translations 1, 2, 3, 7 in function headoftableII are printed in this order in the lower part of the table header
header_1_text=string.gsub(frame.args[3], "%c", ""),
Line 4.703 ⟶ 4.869:
function p.customtimeclassification(frame)
local s = {
header_function = "headoftableII", -- translations are in function headoftableII
header_2 = {1, 2, 3, 4}, -- translations 1, 2, 3, 7 in function headoftableII are printed in this order in the lower part of the table header
header_1_text=string.gsub(frame.args[3], "%c", ""),
Line 4.737 ⟶ 4.903:
]=]
 
local timeOfRace, errorMessage = gettimeOfRacegetTimeOfRace(raceID)
if not timeOfRace then return errorMessage end
 
Line 4.751 ⟶ 4.917:
local tableHeader2_size = #s.header_2
 
if s.header_1_text ==nil then s.header_1_text=translate(s.header_function(,s.header_1) end --for custom title
 
local tableBody = mw.html.create('table')
Line 4.761 ⟶ 4.927:
local thisspan= mw.html.create('span'):cssText('float:left;'):wikitext('[[File:Wikidata-logo S.svg|12px|link=d:'.. raceID .. '#' .. s.property..']]')
tableBody:tag('tr'):tag('th')
:attr('colspan', tostring(tableHeader2_size + 1)):cssText("padding:2px 2px; text-align:center; background-color:#EAECF0"..backgroundColor)
:wikitext(tostring(thisspan)..s.header_1_text)
 
Line 4.767 ⟶ 4.933:
for i, k in ipairs(s.header_2) do
if i ~= 2 or (country and available_list) then
local head=header:tag('th'):wikitext(translate(s.header_function(,k))
if i == 1 then
head:attr('colspan','2')
Line 4.792 ⟶ 4.958:
else
rank = ''
end
if q.P1534 and q.P1534[1].snaktype == 'value' then
local dnf=q.P1534[1].datavalue.value.id
if dnf=='Q1210380' then riderDNF =translate("startlist",6)--"HD","NP","DQ"
elseif dnf=='Q54881674' or dnf=='Q7113430' then riderDNF =translate("startlist",7)
elseif dnf=='Q1210382' then riderDNF =translate("startlist",8)
elseif dnf=='Q1229261' then riderDNF =translate("startlist",9)
else riderDNF=''
end
else
riderDNF=''
end
 
Line 4.798 ⟶ 4.976:
if wiki == 'es' or wiki == 'fr' or wiki == 'ast' then
--[[ These wikis need the gender to display the rank correct. Other wikis can skip this. ]]
gender = getgendercodegetGenderCode(riderID, 'n')
end
 
Line 4.903 ⟶ 5.081:
end
 
if s.header_2[4] == 4 then -- for table stageclassification, generalclassification, adds time and time gap
if rank riderDNF== 1 and h.value[2]'' then
tempif rank =calculate_time(= 1 and h.value[2]) then
temp=calculateTime(h.value[2])
elseif rank == 1 and h.value[3]==nil then --avoid a plus with nothing
temp=''
else
temp=plus .. calculateTime(h.value[3])
end
else
temp=plus .. calculate_time(h.value[3])riderDNF
end
tBody:tag('td'):cssText("text-align:right;padding:0 0.2em 0 0.2em"):wikitext(temp)
Line 4.916 ⟶ 5.098:
if s.header_2[4] == 7 or (s.header_2[3] == 7 and s.header_2[1] == 1) then -- for table pointsclassification, adds points
--trick for UCI classification
if riderDNF=='' then
if h.value[1] then temp=h.value[1] else temp='' end
tCell=tBody:tag('td'):cssText("text-align:right;padding:0 0.2em 0 0.2em")
:wikitext(temp)
if type(h.value[1]) == "number" then
if h.value[1] > 1 then
temp2=unittranslate("unit",7)
else
temp2=unittranslate("unit",6)
end
tCell:tag('span'):cssText("font-size:80%"):wikitext(temp2)
end
else
tCell:tag('span'):cssText("font-size:80%"):wikitext(temp2)
tBody:tag('td'):cssText("text-align:right;padding:0 0.2em 0 0.2em"):wikitext(riderDNF)
end
end
Line 4.933 ⟶ 5.119:
-- for tables teamtimetrialclassification or generaltttclassification, adds time
tBody:tag('td'):cssText("text-align:right;padding:0 0.2em 0 0.2em")
:wikitext(calculate_timecalculateTime(h.value[2]))
end
end
Line 4.939 ⟶ 5.125:
if s.property == 'P3497' then -- for table teambytimeclassification, adds time and time gap
if rank == 1 then
temp=calculate_timecalculateTime(h.value[2])
else
temp=calculate_timeplus .. calculateTime(h.value[3])
end
tBody:tag('td'):cssText("text-align:right;padding:0 0.2em 0 0.2em"):wikitext(temp)
Line 4.951 ⟶ 5.137:
if type(h.value[1]) == "number" then
if h.value[1] > 1 then
temp2=unittranslate("unit",7)
else
temp2=unittranslate("unit",6)
end
tCell:tag('span'):cssText("font-size:80%"):wikitext(temp2)
Line 4.961 ⟶ 5.147:
if s.header_2[4] == 5 then -- for table teamtimetrialclassification, adds time gap
if l > 1 then temp= plus else temp='' end
tBody:tag('td'):cssText("text-align:right;padding:0 0.2em 0 0.2em"):wikitext(temp..calculate_timecalculateTime(h.value[3]))
end
 
Line 4.968 ⟶ 5.154:
if type(h.value[4]) == "number" then
tCell:wikitext(mw.ustring.format('%.3f', h.value[4]))
:tag('span'):cssText("font-size:80%"):wikitext(unittranslate("unit",5))
end
end
if riderDNF=='' then
t_Body[#t_Body + 1] = {(type(rank) == 'number') and rank or 999, tostring(tBody)}
t_Body[#t_Body + 1] = {(type(rank) == 'number') and rank or 999, tostring(tBody)}
else --disqualified should be higher than not disqualified if the ranking was revided
t_Body[#t_Body + 1] = {(type(rank) == 'number') and rank-0.1 or 999, tostring(tBody)}
end
end
end
tableBody=sortandconcatsortAndConcat(t_Body, tableBody)
local tableFooter1,tableFooter2
if s.display_ref == 1 then
Line 4.982 ⟶ 5.172:
:addClass('navigation-only')
:attr('colspan',tostring(tableHeader2_size + 1))
:cssText('border-top: 2px #EAECF0'..backgroundColor..' solid; font-size: 80%;')
tableFooter2=mw.html.create('tr')
tCell=tableFooter2:tag('td')
Line 5.024 ⟶ 5.214:
--=== G) Infobox ===
function p.infobox(frame)
return infobox_main(frame,0)
end
 
function p.infoboxseason(frame)
return infobox_main(frame,1)
end
 
function p.infoboxChamp(frame)
return infobox_main(frame,2)
end
 
function infobox_main(frame, selector)
localframe = frame
-- If true, winners will have Wikidata logos with link to Wikidata
Line 5.030 ⟶ 5.232:
-- If true, winners will the team of the cyclist
local team = true
local details, others, winners
 
local details = {
if selector==0 then --normal infobox
{ name = infobox_translate(2)}, -- course
details = {
{ name = infobox_translate(3), name_plural = infobox_translate(4)}, -- competition
{ name = infobox_translatetranslate(5"infobox",2)}, -- stagescourse
{ name = infobox_translatetranslate(6"infobox",3), name_plural = infobox_translatetranslate(7"infobox",4)}, -- datecompetition
{ name = infobox_translatetranslate(8"infobox",5)}, -- distancestages
{ name = infobox_translatetranslate(9"infobox",6), name_plural = infobox_translatetranslate(10"infobox",7)}, -- countrydate
{ name = infobox_translatetranslate(11"infobox",8)}, -- start placedistance
{ name = translate("infobox",9), name_plural = translate("infobox",10)}, -- country
{ name = infobox_translate(12)}, -- endplace
{ name = infobox_translatetranslate(13"infobox",11)}, -- teamsstart place
{ name = infobox_translatetranslate(14"infobox",12)}, -- participants at startendplace
{ name = infobox_translatetranslate(15"infobox",13)}, -- participants at endteams
{ name = infobox_translatetranslate(16"infobox",14)}, -- speedparticipants at start
{ name = infobox_translatetranslate(43"infobox",15)}, -- elevationparticipants at end
{ name = infobox_translatetranslate(17"infobox",16)}, -- costspeed
{ name = infobox_translatetranslate(32"infobox",43), special = true}, -- special 1elevation
{ name = infobox_translatetranslate(33"infobox",17), special = true}, -- special 2cost
{ name = translate("infobox",32), special = true}, -- special 1
}
{ name = translate("infobox",33), special = true}, -- special 2
local others = {
}
{ name = infobox_translate(29)}, -- picture
elseif selector==1 then --season infobox
{ name = infobox_translate(30)}, -- caption
details = {
{ name = infobox_translate(31)}, -- map
{ name = 'sectional_view 'translate("infobox",46)}, -- edition (1)
{ name = translate("infobox",3), name_plural = translate("infobox",4)}, -- competition (2)
}
{ name = translate("infobox",6), name_plural = translate("infobox",7)}, -- date (3)
local winners = {
{ name = infobox_translatetranslate(19"infobox",45), QID = 'Q20882667' }, -- firstrasing (4)
{ name = infobox_translatetranslate(20"infobox",47), QIDname_plural = 'Q20882668' translate("infobox",48)}, -- secondlocation (country) (5)
{ name = infobox_translatetranslate(21"infobox",49), QIDname_plural = 'Q20882669' translate("infobox",50)}, -- thirdorganizer (6)
{ name = infobox_translatetranslate(22"infobox",63), QIDname_plural = 'Q20883007' translate("infobox",63)}, -- pointsteam class (7)
{ name = infobox_translatetranslate(23"infobox",32), QIDspecial = 'Q20883212' true}, -- mountainsspecial 1
{ name = infobox_translatetranslate(24"infobox",33), QIDspecial = 'Q20883328' true}, -- sprintsspecial 2
}
{ name = infobox_translate(25), QID = 'Q20883139' }, -- youth
else --champ
{ name = infobox_translate(26), QID = 'Q20893983' }, -- combativity
details = {
{ name = infobox_translate(35), QID = 'Q27067359' }, -- volantes
{ name = infobox_translatetranslate(36"infobox",46), QID = 'Q27067170' }, -- regularityedition (1)
{ name = infobox_translatetranslate(27"infobox",6), QIDname_plural = 'Q20893979' translate("infobox",7)}, -- combinationdate (2)
{ name = infobox_translatetranslate(38"infobox",9), QIDname_plural = 'Q27907715' translate("infobox",10)}, -- breakawaycountry (3)
{ name = infobox_translatetranslate(39"infobox",67), QIDname_plural = 'Q27907747' translate("infobox",68)}, -- azzurrilocation (city) (4)
{ name = infobox_translatetranslate(40"infobox",61), QIDname_plural = 'Q28092831' translate("infobox",62)}, -- rookiearena / stadion (5)
{ name = infobox_translatetranslate(28"infobox",60), QID = 'Q20882921' }, -- teamsmedals (6)
{ name = infobox_translatetranslate(37"infobox",13), QID = 'Q27104269' }, -- teamspointsteam (7)
{ name = infobox_translatetranslate(41"infobox",49), QIDname_plural ='Q61976850' translate("infobox",50)}, -- amateurorganizer (8)
{ name = infobox_translatetranslate(42"infobox",32), QIDspecial ='Q61976872' true}, --nationality special 1
{ name = translate("infobox",33), special = true}, -- special 2
}
end
others = { --same for 3 infobox
{ name = translate("infobox",29)}, -- picture
{ name = translate("infobox",30)}, -- caption
{ name = translate("infobox",31)}, -- map
{ name = 'sectional'}, -- sectional
{ name = translate("infobox",30)}, -- caption map
{ name = translate("infobox",30)}, -- caption sectional
}
 
if selector==0 then
winners = {
{ name = translate("infobox",19), QID = 'Q20882667' }, -- first
{ name = translate("infobox",20), QID = 'Q20882668' }, -- second
{ name = translate("infobox",21), QID = 'Q20882669' }, -- third
{ name = translate("infobox",22), QID = 'Q20883007' }, -- points
{ name = translate("infobox",23), QID = 'Q20883212' }, -- mountains
{ name = translate("infobox",24), QID = 'Q20883328' }, -- sprints
{ name = translate("infobox",25), QID = 'Q20883139' }, -- youth
{ name = translate("infobox",26), QID = 'Q20893983' }, -- combativity
{ name = translate("infobox",35), QID = 'Q27067359' }, -- volantes
{ name = translate("infobox",36), QID = 'Q27067170' }, -- regularity
{ name = translate("infobox",27), QID = 'Q20893979' }, -- combination
{ name = translate("infobox",38), QID = 'Q27907715' }, -- breakaway
{ name = translate("infobox",39), QID = 'Q27907747' }, -- azzurri
{ name = translate("infobox",40), QID = 'Q28092831' }, -- rookie
{ name = translate("infobox",28), QID = 'Q20882921' }, -- teams
{ name = translate("infobox",37), QID = 'Q27104269' }, -- teamspoints
{ name = translate("infobox",41), QID ='Q61976850' },-- amateur
{ name = translate("infobox",42), QID ='Q61976872' } --nationality
}
elseif selector==1 then
winners = {
{ name = translate("infobox",52), QID = 'Q20882667' }, -- individual (first)
{ name = translate("infobox",53), QID = 'Q20883139' }, -- youth
{ name = translate("infobox",54), QID = 'Q27104269' }, -- team (teamspoints)
{ name = translate("infobox",55), QID = 'Q98959152' }, -- team GS-I
{ name = translate("infobox",56), QID = 'Q98959153' }, -- team GS-II
{ name = translate("infobox",57), QID = 'Q98959155' }, -- team GS-III
{ name = translate("infobox",58), QID = 'Q72068715' }, -- country
{ name = translate("infobox",59), QID = 'Q72068724' } -- country U23
}
end --Champ has no winners
 
local entityID = mw.text.trim(frame.args[1])
local wikibase = mw.wikibase
if type(entityID) ~= 'string' then error('parameter must be a string') end
if not entityID:match('Q%d+') then error ('parameter must be a valid Wikidata item (ex: Q42)') end
Line 5.089 ⟶ 5.335:
getLocalContent(details, localframe.args)
getLocalContent(others, localframe.args)
getLocalContent(winners, localframe.args)
if selector==0 or selector==1 then
getLocalContent(winners, localframe.args)
end
 
local timeOfRace, class
Line 5.100 ⟶ 5.349:
if not details[1].content then -- course
-- For FR Wiki and Wikidata, exception that permit to display 1er, 2e... for the edition number ;
-- for RU Wiki, -й is written after the value of P393
local nr = firstValue(entityID, 'P393') -- P393 is 'edition number'
if nr then
Line 5.112 ⟶ 5.361:
end
local is_a
--system with P2094 and P3450
for _, p31 in statements(entityID, 'P31') do -- P31 is 'instance of'
local instanceOfclassID = p31.mainsnak.datavalue.value.firstValue(entityID, 'P2094', 'id')
if classID then
if instanceOf == 'Q27968055' then -- Q27968055 is 'recurrent event edition'
class = classLinkFn(classID)
-- do nothing
else
elseif classes[instanceOf] then
for _, p31 in statements(entityID, 'P31') do -- P31 is 'instance of'
class = classLink(instanceOf)
local instanceOf = p31.mainsnak.datavalue.value.id
elseif instanceOf == "Q27020041" then -- Q27020041 is 'sports season'
if classes[instanceOf] then
local season = firstValue(entityID, 'P3450', 'id') -- P3450 is 'sports season of league or competition'
class = classLinkFn(instanceOf)
if season then
break
is_a = raceLink(season)
end
else
is_a = raceLink(instanceOf)
end
end
local season = firstValue(entityID, 'P3450', 'id') -- P3450 is 'sports season of league or competition'
if season then
is_a = raceLink(season)
else
for _, p31 in statements(entityID, 'P31') do -- P31 is 'instance of'
local instanceOf = p31.mainsnak.datavalue.value.id
if instanceOf ~= 'Q27968055' and classes[instanceOf] == nil then -- Q27020041 is 'sports season'
is_a = raceLink(instanceOf)
break
end
end
end
 
if nr and is_a then
details[1].content = nr .. ' ' .. is_a
Line 5.132 ⟶ 5.393:
end
 
if selector==0 or selector==1 then
if not details[2].content then -- competition
if not details[2].content then -- competition
-- Class of a cycling race. Class is: 1.UWT, 2.UWT, 1.HC, ... add new classes, no problem
-- CompetitionClass of thea cycling race. Class is: UCI1.UWT, World Tour2.UWT, 20161.HC, UCI Europe Tour 2016... add new classes, no problem
-- Competition of the cycling race : UCI World Tour 2016, UCI Europe Tour 2016...
local tours = {}
local tours = {}
for _, p361 in statements(entityID, 'P361') do -- P361 is 'part of'
for _, p361 in statements(entityID, 'P361') do -- P361 is 'part of'
tours[#tours + 1] = raceLink(p361.mainsnak.datavalue.value.id)
tours[#tours + 1] = raceLink(p361.mainsnak.datavalue.value.id)
end
if tours[1] then
if #tours > 1 then
details[2].name = details[2].name_plural
end
if classtours[1] then
if #tours[1] => tours[1] .. ' ' .. classthen
details[2].name = details[2].name_plural
end
if class then
tours[1] = tours[1] .. ' ' .. class
end
details[2].content = table.concat(tours, '<br/>')
end
details[2].content = table.concat(tours, '<br/>')
end
end
 
if selector==0 then
if not details[3].content then -- stages
local stages = #wikibase.getAllStatements(entityID, 'P527') -- P527 is 'has part'
if stages > 0 then
details[3].content = stages
end
end
end
local index_date
if selector==0 then
index_date=4
elseif selector==1 then
index_date=3
else
index_date=2
end
 
if notselector==0 details[4].contentor selector==1 then -- date
if not details[index_date].content then -- date
local sTime = firstValue(entityID, 'P580', 'time') -- P580 is 'start time'
local eTimesTime = firstValue(entityID, 'P582P580', 'time') -- P582P580 is 'endstart time'
local eTime = firstValue(entityID, 'P582', 'time') -- P582 is 'end time'
if sTime and eTime then
if sTime and eTime then
local startTime, endTime = getStartEndTime(sTime, eTime)
details[4index_date].content = startTime .. ' – ' .. endTime
details[4index_date].name = details[4index_date].name_plural
timeOfRace = eTime
else
-- This function give a format to dates when P585 (date) is used in a single day race
local pTime = firstValue(entityID, 'P585', 'time') -- P585 is 'point in time'
if pTime then
details[4index_date].content = func_datefuncDate(pTime, 'long')
timeOfRace = pTime
end
end
end
end
--from this point the functions differ fundamentally
local kmdistance
if selector==0 then
if not details[5].content then details[5].content, kmdistance = getDistance(entityID, true) end -- distance
local kmdistance
 
if not details[5].content then details[5].content, kmdistance = getDistance(entityID, true) end -- distance
infoGetCountry(details,6, entityID, timeOfRace)
infoGetStartEnd(details,7, entityID)
infoGetCountry(details,6, entityID, timeOfRace)
 
infoGetStartEnd(details,7, entityID)
if not details[9].content then -- teams
local teams = #wikibase.getBestStatements(entityID, 'P1923') -- P1923 is 'participating teams'
if teamsnot > 0details[9].content then -- teams
local teams = #wikibase.getBestStatements(entityID, 'P1923') -- P1923 is 'participating teams'
details[9].content = teams
if teams > 0 then
details[9].content = teams
end
end
end
infoGetParticipants(details,10, entityID)
 
if not details[10].content or not details[11].content then
infoGetParticipants(details,10, entityID)
local Allp710= wikibase.getAllStatements(entityID, 'P710')
if not details[10].content or not details[11].content then
if Allp710 and #Allp710~=0 then
local Allp710= wikibase.getAllStatements(entityID, 'P710')
if Allp710not anddetails[10].content then details[10].content=#Allp710~=0 thenend
if not details[1011].content then details[10].content=#Allp710 end
local maxrank=1
if not details[11].content then
for _, p710 in pairs(Allp710) do -- look into all statements
local maxrank=1
local q = p710.qualifiers
for _, p710 in pairs(Allp710) do -- look into all statements
if q and q.P1352 and q.P1352[1].snaktype == 'value' then -- P1352 is ranking
local q = p710.qualifiers
if local qriderRank and q.P1352 and= tonumber(q.P1352[1].snaktype == 'datavalue.value' then -- P1352 is ranking.amount)
local if riderRank > maxrank then maxrank = tonumber(q.P1352[1].datavalue.value.amount)riderRank end
end
if riderRank > maxrank then maxrank = riderRank end
end
if maxrank~=1 then details[11].content=maxrank end
end
if maxrank~=1 then details[11].content=maxrank end
end
end
end
 
if not details[12].content then details[12].content = getSpeed(entityID, true, kmdistance, 'P2321') end --speed
if not details[13].content then
local elevation=getElevation(entityID)
if elevation then details[13].content =elevation else details[13].content = nil end
end --Elevation
if not details[1412].content then details[12].content = getSpeed(entityID, true, kmdistance, 'P2321') end -- costspeed
if not details[13].content then
local cost = firstValue(entityID, 'P2130') -- P2130 is cost
local elevation=getElevation(entityID)
if cost then
if elevation then details[13].content =elevation else details[13].content = nil end
local unit = cost.unit
end --Elevation
cost = contentLanguage:formatNum(tonumber(cost.amount))
if wiki == 'fo' then cost = string.gsub(cost, "%.", ",") end
if unitnot == "http://wwwdetails[14].wikidata.org/entity/Q4916"content then cost =-- cost .. ' €'
local cost = firstValue(entityID, 'P2130') -- P2130 is cost
elseif unit == "http://www.wikidata.org/entity/Q4917" then cost = cost .. ' $'
if cost then
local unit = cost.unit
cost = contentLanguage:formatNum(tonumber(cost.amount))
if wiki == 'fo' then cost = string.gsub(cost, "%.", ",") end
if unit == "http://www.wikidata.org/entity/Q4916" then cost = cost .. ' €'
elseif unit == "http://www.wikidata.org/entity/Q4917" then cost = cost .. ' $'
end
details[14].content = cost
end
end
details[14].content = cost
 
elseif selector==1 then
if not details[4].content then -- racing
local stages = #wikibase.getAllStatements(entityID, 'P527') -- P527 is 'has part'
if stages > 0 then
details[4].content = stages
end
end
if not details[5].content then -- location
infoGetPlace(details,5, entityID, timeOfRace) --in GAN version, the separator is , not <br />
end
if not details[6].content then -- organizer sitelink
listWPlink(details, 6, entityID,'P644') --org
end
if not details[7].content then -- organizer sitelink
listWPlink(details, 7, entityID,'P2670') --team ????
end
else --champ
infoGetCountry(details,3, entityID, timeOfRace)
if not details[4].content then -- location
infoGetPlace(details,4, entityID, timeOfRace) --in GAN version, the separator is , not <br />
end
if not details[5].content then -- arena / stadion
listWPlink(details, 5, entityID,'P115')
end
if not details[6].content then -- racing
local stages = #wikibase.getAllStatements(entityID, 'P527') -- P527 is 'has part'
if stages > 0 then
details[6].content = stages
end
end
if not details[7].content then -- teams
local teams = #wikibase.getBestStatements(entityID, 'P1923') -- P1923 is 'participating teams'
if teams > 0 then
details[7].content = teams
end
end
if not details[8].content then -- organizer sitelink
listWPlink(details, 8, entityID,'P644') --org
end
end
 
tab = infoInitTab("300px", name, icon)
infoFillOthersDetails(tab, others, details,infobox_translatetranslate("infobox",1))
if selector==0 or selector==1 then --no winners for champ
local winRows=''
local win winRows= {}''
local win = {}
for _, v in pairs(winners) do
for _, v in pairs(winners) do
if not v.content then
win[if not v.QID] =content ''then
win[v.QID] = ''
end
end
winner(entityID, win, timeOfRace, false, WDlink_on, team, true)
end
for _, v in pairs(winners) do
winner(entityID, win, timeOfRace, false, WDlink_on, team, true)
if not v.content then
for _, v in pairs(winners) do
if not win[v.contentQID] ~= '' then
if v.content = win[v.QID] ~= '' then
end
v.content = win[v.QID]
end
if v.content then
tRow= mw.html.create('tr') :css('vertical-align','top')
tRow:tag('td'):css('font-weight','bold'):wikitext(v.name)
tRow:tag('td'):wikitext(v.content)
winRows=winRows..tostring(tRow) --not elegant
end
end
if v.contentwinRows~= '' then
tRow= mw.html.createtab:tag('tr') :csstag('td'):attr('vertical-aligncolspan','top2')
:cssText('border-bottom:5px solid white; background-color:'..backgroundColor..'; text-align:center')
tRow:tag('td'):css('font-weight','bold'):wikitext(v.name)
:css('font-weight','bold')
tRow:tag('td'):wikitext(v.content)
:wikitext(translate("infobox",18))
winRows=winRows..tostring(tRow) --not elegant
tab:wikitext(winRows)
end
end
if winRows~= '' then
tab:tag('tr'):tag('td'):attr('colspan','2')
:cssText('border-bottom:5px solid white; background-color:#EAECF0; text-align:center')
:css('font-weight','bold')
:wikitext(infobox_translate(18))
tab:wikitext(winRows)
end
 
Line 5.261 ⟶ 5.582:
tab:tag('tr'):tag('td'):attr('colspan','2'):css('text-align','center')
:wikitext("[[File:".. others[3].content .. "|center|300px]]")
if others[5].content then -- caption
tab:tag('tr'):tag('td'):attr('colspan','2'):css('text-align','center'):css('font-size','80%')
:wikitext(others[5].content)
end
end
tab:node(getPreviousNextLine(entityID))
wdDoc(tab, "d:Wikidata:WikiProject Cycling/Documentation/infobox", infobox_translatetranslate("infobox",34), entityID)
return tab
end
 
--=== H) Teamrace rosterinfobox
function p.teamrosterraceinfobox(frame)
localframe = frame
local squadIDlang = contentLanguage
-- If true, winners will have Wikidata logos with link to Wikidata
if frame.args[1] then squadID = string.gsub(frame.args[1], "%c", "") end
local flags,WDlink_on pays= (wiki == {},"mk" or wiki == {}"ja")
local riderName, riderBirthday,riderTeam, timeTeam, correctlanguage,riderStart, riderEnd
local tRace = {race={
local riderPosition, riderReason, riderRef, errorbool, errortext
raceId,
local riderReasonTable, riderTablecorrect, riderTablenotcorrect, riderTable = {}, {}, {}, {}
raceDate,
local labelMissing = false
future,
local teamID, startOfSeason, stagiaire
},
vainqueur= {},
lastEditionMonth,
lastEditionYear,
numberOfEditions,
lastLink,
nextLink,
lastWinner,
maxWinner,
}
local details = {
{ name = translate("raceinfobox",4)}, -- sport
{ name = translate("raceinfobox",5)}, -- creation date
{ name = translate("raceinfobox",6)}, -- disparition date
{ name = translate("raceinfobox",7)}, -- number of editions
{ name = translate("raceinfobox",8)}, -- periodicity
{ name = translate("raceinfobox",9)}, -- type , name_plural = translate("infobox",10)
{ name = translate("victories",5)}, --country
{ name = translate("raceinfobox",10), name_plural = translate("raceinfobox",11)}, -- place
{ name = translate("raceinfobox",12), name_plural = translate("raceinfobox",13)}, --org
{ name = translate("raceinfobox",27), name_plural = translate("raceinfobox",28)}, --race director
{ name = translate("raceinfobox",14)}, -- official web site
{ name = translate("raceinfobox",15), name_plural = translate("raceinfobox",16)}, -- Cat
{ name = translate("raceinfobox",17)}, -- circuit
}
local others = {
{ name = translate("infobox",29)}, -- picture
{ name = translate("infobox",30)}, -- caption
{ name = translate("infobox",31)}, -- map
{ name = 'sectional'}, -- sectional
{ name = translate("infobox",30)}, -- caption map
{ name = translate("infobox",30)}, -- caption sectional
}
 
local slavicWikisentityID = {mk = true, ru = true}mw.text.trim(frame.args[1])
if type(entityID) ~= 'string' then error('parameter must be a string') end
local wikiisslavic = slavicWikis[wiki]
if not entityID:match('Q%d+') then error('parameter must be a valid Wikidata item (ex: Q42)') end
local WDlink_on = wiki == "mk" or wiki == "ja" or wiki == "ru" or wiki == "he"
local tableEndText = ''
local name = getLabelFallback(entityID, {wikilang, 'en', 'fr', 'de'}) or ''
infoGetOthers(others, entityID)
local localframe
if string.match(frame:getParent():getTitle(), '%P+') == mw.site.namespaces.Template.name then
localframe = frame:getParent()
else
localframe = frame
end
getLocalContent(details, localframe.args)
getLocalContent(others, localframe.args)
local timeOfRace, class
 
local listOfNames=getFormerNames(entityID, 'P1448')
local sport_id=firstValue(entityID, 'P641', 'id')
local icon = (sport_id == "Q3609") and -- P641 is 'sport', Q3609 is 'road bicycle racing'
' [[File:Cycling (road) pictogram.svg|35px]]' or ''
 
--1st ist sport
local function getreason(riderReason, riderRef, p527)
if not details[1].content and sport_id then
local listofproperty={'P1642','P1643','P1534'}
details[1].content = WPlinkpure(sport_id)
local outputTable={}
end
--creation
local creation=firstValue(entityID, 'P571', 'time')
if not details[2].content and creation then
details[2].content = funcDate(creation, "Y" )
end
 
--disparition
if riderReason == nil then --if no riderReason before then look for it, otherwise don't touch it
local disparition=firstValue(entityID, 'P576', 'time')
for _,v in ipairs(listofproperty) do
if not details[3].content and disparition then
for _, q in qualifiers(p527, v) do
details[3].content = funcDate(disparition,"Y")
riderReason = q.value.id
end
end
--populate tRace
if riderReason then
listOfWinners(entityID, tRace)
local label = string.gsub(wikibase.label(riderReason), "%b()", "") or getLabelFallback(riderReason,{'en', 'fr', 'de'})
riderRef = getReference(p527, 1)
--number of editions
riderReason = ', ' .. label
if not details[4].content and tRace.numberOfEditions and tRace.lastEditionYear then
details[4].content = tostring(tRace.numberOfEditions).." (" .. translate("raceinfobox",31) .. " "..tostring(tRace.lastEditionYear)..")"
end
--periodicity
if not details[5].content then
details[5].content = getPeriodicity(entityID, tRace)
end
--type
if not details[6].content then
details[6].content = getType(entityID)
end
timeOfRace=nil --could be from last edition
if not details[7].content then
infoGetCountry(details,7, entityID, timeOfRace)
end
if not details[8].content then
infoGetPlace(details,7, entityID, timeOfRace)
end
if not details[9].content then
listWPlink(details, 9, entityID,'P644') --organiser
end
if not details[10].content then
listWPlink(details, 10, entityID,'P488') --race dir
end
if not details[11].content then
details[11].content = officialSite(entityID)
end
--Class and circuit
local classContent, circuitLink, numberClass= getClass(entityID)
if not details[12].content then
details[12].content = classContent
if numberClass >1 then
details[12].name = details[12].name_plural
end
end
if not details[13].content then
details[13].content = circuitLink
end
--Build the table
tab = infoInitTab("300px", name, icon)
--former names
wiki_listOfNamesAtBottom={'ru'}
local listOfNamesAtBottom = false
for _, value in pairs(wiki_listOfNamesAtBottom) do --
if value == wiki then listOfNamesAtBottom = true end
end
--picture at the top
infoFillOthersDetails(tab, others, nil,translate("raceinfobox",19),"260px")
if not listOfNamesAtBottom then
if listOfNames and #listOfNames>1 then
tab:node(addATitle(translate("raceinfobox",18)))
for _, v in pairs(listOfNames) do
tab:node(addARow(v[2],v[3])) --period, name
end
end
return riderReason, riderRef
end
infoFillOthersDetails(tab, nil, details,translate("raceinfobox",19),"260px")
 
if listOfNamesAtBottom then
local function getposition(riderPosition,v)
if listOfNames and #listOfNames>1 then
local stagiaire
tab:node(addATitle(translate("raceinfobox",18)))
if riderPosition == nil then -- find the 'position' (P39) of a rider
for _, qv in qualifierspairs(v, 'P39'listOfNames) do
tab:node(addARow(v[2],v[3])) --period, name
stagiaire = q.value.id
local label = string.gsub(wikibase.label(stagiaire), "%b()", "") or getLabelFallback(stagiaire,{'en', 'fr', 'de'})
riderPosition = ', ' .. label
end
end
return riderPosition
end
 
if (tRace.lastWinner and tRace.lastWinner~='') or
local function trans(date, month, day)
(tRace.maxWinner and tRace.maxWinner~='') then
if date ~= '' and date~=nil then
tab:node(addATitle(translate("raceinfobox",20)))
local _, _, y, m, d = string.find(date, "(%d+)-(%d+)-(%d+)")
if (tRace.lastWinner and tRace.lastWinner~='') then
if m == '00' then m = month end
tab:node(addARow(translate("raceinfobox",21),tRace.lastWinner))
if d == '00' then d = day end
end
date = '+'..y..'-'..m..'-'..d..'T00:00:00Z'
if (tRace.maxWinner and tRace.maxWinner~='') then
return date
tab:node(addARow(translate("raceinfobox",22),tRace.maxWinner))
end
return ''
end
 
if tRace.nextLink or tRace.lastLink then
local function findlastname(label,wiki)
tab:node(addATitle(translate("raceinfobox",23)))
if not label then label = '' end
local outTable
local _, count = string.gsub(label, " ", " ")
local names
local a,b,c,d = '', '', '', ''
local done = false
if count ~= nil then count = count + 1 else count = 1 end
 
if count > 1tRace.lastLink then
outTable = mw.html.create('tr')
if count == 2 then
local tCell=outTable:tag('td'):attr('colspan','2'):css('text-align','center')
if label ~= '' then
local lastText="[[File:Crystal Clear app kworldclock.png|left|37px]]"..
a, b = string.match(label, "(%S+)%s+(%S+)")
translate("raceinfobox",24)..
names = b..' '..a
":<br>'''"..
end
tRace.lastLink.."'''"
else
tCell:wikitext(lastText)
local name_parts_mk = {'да', 'ди', 'де', 'Де', 'ла', 'Ле', 'тен', 'ван', 'Ван'}
tab:node(outTable)
local name_parts_ru = {'да', 'ди', 'де', 'Де', 'ла', 'Ле', 'тен', 'ван', 'Ван'}
end
local name_parts = {'da', 'de', 'di', 'De', 'la', 'Le', 'ten', 'van', 'Van'}
if count == 3 and label ~= '' then
if tRace.nextLink then
a, b, c = string.match(label, "(%S+)%s+(%S+)%s+(%S+)")
outTable = mw.html.create('tr')
if wiki == 'mk' then
local tCell=outTable:tag('td'):attr('colspan','2'):css('text-align','center')
for _,v in ipairs(name_parts_mk) do if b == v then names = b..' '..c..' '..a done = true break end end
local nextText = "[[File:Crystal Clear app kworldclock.png|left|37px]]"..
elseif wiki == 'ru' then
translate("raceinfobox",25)..
for _,v in ipairs(name_parts_ru) do if b == v then names = b..' '..c..' '..a done = true break end end
":<br>'''"..
else
tRace.nextLink.."'''"
for _,v in ipairs(name_parts) do if b == v then names = b..' '..c..' '..a done = true break end end
tCell:cssText("text-align:center"):wikitext(nextText)
end
tab:node(outTable)
if not done then
names = c..' '..a..' '..b
done = true
end
end
if count > 3 and label ~= '' then
a, b, c, d = string.find(label, "(%S+)%s+(%S+)%s+(%S+)%s+(%S+)")
if wiki == 'mk' then
for _,v in ipairs(name_parts_mk) do if c == v then names = c..' '..d..' '..a..' '..b done = true break end end
for _,v in ipairs(name_parts_mk) do if b == v then names = b..' '..c..' '..d..' '..a done = true break end end
elseif wiki == 'ru' then
for _,v in ipairs(name_parts_ru) do if c == v then names = c..' '..d..' '..a..' '..b done = true break end end
for _,v in ipairs(name_parts_ru) do if b == v then names = b..' '..c..' '..d..' '..a done = true break end end
else
for _,v in ipairs(name_parts) do if c == v then names = c..' '..d..' '..a..' '..b done = true break end end
for _,v in ipairs(name_parts) do if b == v then names = b..' '..c..' '..d..' '..a done = true break end end
end
if not done then names = b..' '..c..' '..d..' '..a end
end
end
end
return names or ''
end
wdDoc(tab, "d:Wikidata:WikiProject Cycling/Documentation/raceinfobox", translate("raceinfobox",26), entityID)
return tab
end
 
--=== I) Team roster
local function findsortkey(riderID, correctlanguage, wiki,wikiisslavic)
function p.teamroster(frame)
--find the last name to sort
localframe=frame
if wikiisslavic and correctlanguage then
local squadID
local label = wikibase.getLabelByLang(riderID, wiki)
if frame.args[1] then squadID = string.gsub(frame.args[1], "%c", "") end
if not label then
local flags, pays = {}, {}
label = getLabelFallback(riderID, {'en', 'fr', 'de', 'es'})
local riderName, riderBirthday,riderTeam, timeTeam, correctlanguage,riderStart, riderEnd
return findlastname(label,wiki)
local riderPosition, riderReason, riderRef, errortext
else
local riderReasonTable, riderTablecorrect, riderTablenotcorrect, riderTable = {}, {}, {}, {}
local nametable = mw.text.split(label, ",")
local labelMissing = false
if nametable[2] then --there is a coma so the lastname is first
local teamID, startOfSeason, stagiaire
return nametable[1]..nametable[2]
 
else --no coma
local slavicWikis = {mk = true, ru = true}
return findlastname(label,wiki)
local wikiIsSlavic = slavicWikis[wiki]
end
local WDlink_on = wiki == "mk" or wiki == "ja" or wiki == "ru" or wiki == "he"
end
local tableEndText = ''
else
local label = getLabelFallback(riderID, {'en', 'fr', 'de', 'es'})
return findlastname(label,wiki)
end
end
 
local sort
Line 5.407 ⟶ 5.824:
}}
A rider called 'Laurens De Vreese' is sorted after 'De Vreese Laurens'. If you want to sort after 'Vreese Laurens De'
change that in the code. In lvWiki,lv mkWiki and ruWiki sorting is standard, there is no need to switch sorting on in the article
]]
if string.match(frame:getParent():getTitle(), '%P+') == mw.site.namespaces.Template.name
Line 5.435 ⟶ 5.852:
riderStart, riderEnd=nil, nil
 
errortext=''
local riderID = p527.mainsnak.datavalue.value.id
riderName, correctlanguage =getRiderLink(riderID, startOfSeason) --label
if WDlink_on==true then riderName=riderName..wdLink(riderID) end
local timeOfRace = startOfSeason
_, startOfSeasonYear, startOfSeasonMonth, startOfSeasonDay, _=parseDate(startOfSeason, '2040', '12', '31', '','')
 
riderBirthday=firstValue(riderID, 'P569','time')
 
if not wikiisslavicwikiIsSlavic then correctlanguage=true end --actually we never take a cyrillic name if no latin is found
local sortkey = findsortkeyfindSortKey(riderID, correctlanguage, wiki, wikiisslavicwikiIsSlavic)
 
riderReason, iderRef=getreason(riderReason,riderRef,p527)
 
for _, q in qualifiers(p527, 'P580') do
local startdate = q.value['time']
timeOfRace = startdate
riderStart = func_datefuncDate(trans(startdate,'01', '01') or '', 'small')
end
for _, q in qualifiers(p527, 'P582') do
local enddate=q.value['time']
riderEnd = func_datefuncDate(trans(enddate,'12', '31') or '', 'small')
end
riderPosition=getpositiongetPosition(riderPosition,p527)
riderReason, riderRef=getReason(riderReason,riderRef,p527, timeOfRace,enddate)
 
local y1beginYear, m1beginMonth, d1beginDay, y2endYear, m2endMonth, d2endDay, y3beginDate, m3endDate, d3endDatefound, date1, date2, date2tempendDatetemp
local changedTime = '+0000-00-00'
 
Line 5.467 ⟶ 5.883:
else
for _, v in statements(riderID, 'P54') do -- look into all P54 teams
date1=nil date2=nil date2temp=nil stagiaire=nil errorbool=nil
errortext=''
local thisteamID = v.mainsnak.datavalue.value.id
if thisteamID == teamID then
endDatefound=true
riderReason, riderRef=getreason(riderReason,riderRef,v)
beginDate, endDate = getStartEndfromQuali(v.qualifiers)
if v.qualifiers and v.qualifiers["P580"] and v.qualifiers["P580"][1].snaktype == 'value' then
beginDate, beginYear, beginMonth, beginDay, errortext = parseDate(beginDate, '2040', '01', '01', errortext, ' missing qualifiers by rider')
date1=v.qualifiers["P580"][1].datavalue.value.time
 
end
if not endDate then endDatefound=false end
date1 = trans(date1,'01','01')
endDate, endYear, endMonth, endDay, _ = parseDate(endDate, beginYear, '12', '31', errortext,'')
_, _, y1, m1, d1 = string.find(date1, "(%d+)-(%d+)-(%d+)")
riderReason, riderRef=getReason(riderReason,riderRef,v,timeOfRace,endDate)
if v.qualifiers and v.qualifiers["P582"] and v.qualifiers["P582"][1].snaktype == 'value' then
 
date2temp=v.qualifiers["P582"][1].datavalue.value.time
if (beginYear == startOfSeasonYear or endYear == startOfSeasonYear) and ((beginYear == startOfSeasonYear and (beginMonth ~= '01' or beginDay ~= '01')) or (endYear == startOfSeasonYear and (endMonth ~= '12' or endDay ~= '31'))) then
end
if date2temp==nil then
if y1==nil then y1='2040' errorbool=2 end
date2='+'..y1..'-12-31T00:00:00Z'
else date2=date2temp end
date2 = trans(date2,'12','31')
_, _, y2, m2, d2 = string.find(date2, "(%d+)-(%d+)-(%d+)")
_, _, y3, m3, d3 = string.find(startOfSeason, "(%d+)-(%d+)-(%d+)")
if (y1 == y3 or y2 == y3) and ((y1 == y3 and (m1 ~= '01' or d1 ~= '01')) or (y2 == y3 and (m2 ~= '12' or d2 ~= '31'))) then
-- riders who start after 1 January or end earlier then 31 December in the season
riderStart = func_datefuncDate(date1beginDate, 'small')
if date2temp==nilendDatefound then
riderEnd = funcDate(endDate, 'small')
if y1==nil then y1='2040' errorbool=1 end
riderEnd = func_date('+'..y1..'-12-31T00:00:00Z', 'small')
else
riderEnd = func_datefuncDate(date2temp'+'..beginYear..'-12-31T00:00:00Z', 'small')
end
riderPosition=getpositiongetPosition(riderPosition,v)
end
else
Line 5.502 ⟶ 5.910:
end
if not stagiaire then
endDatefound=true
if v.qualifiers and v.qualifiers["P580"] and v.qualifiers["P580"][1].snaktype == 'value' then
date1beginDate, endDatetemp=getStartEndfromQuali(v.qualifiers["P580"][1].datavalue.value.time)
if not endDatetemp then endDatefound=false end
end
beginDate, beginYear, beginMonth, beginDay, errortext = parseDate(beginDate, '2040', '01', '01', errortext, ' missing qualifiers by rider')
date1 = trans(date1,'01','01')
endDate, endYear, endMonth, endDay, _ = parseDate(endDatetemp, beginYear, '12', '31', errortext, '')
_, _, y1, m1, d1 = string.find(date1, "(%d+)-(%d+)-(%d+)")
 
if y1==nil then y1='2040' errorbool=2 end
if beginYear < startOfSeasonYear or (beginYear == startOfSeasonYear and beginMonth < startOfSeasonMonth) or
if v.qualifiers and v.qualifiers["P582"] and v.qualifiers["P582"][1].snaktype == 'value' then
(beginYear == startOfSeasonYear and beginMonth == startOfSeasonMonth and beginDay < startOfSeasonDay) then -- start time < season time
date2temp=v.qualifiers["P582"][1].datavalue.value.time
date2=date2tempif endDatefound then
if (endDate or '') >= changedTime then -- find maximum end time
else
date2='+'..y1..'-12-31T00:00:00Z'
end
date2 = trans(date2,'12','31')
_, _, y2, m2, d2 = string.find(date2, "(%d+)-(%d+)-(%d+)")
_, _, y3, m3, d3 = string.find(startOfSeason, "(%d+)-(%d+)-(%d+)")
if y1 <= y3 then -- start time < season time
if date2temp~=nil then
local timeP582 = trans(date2temp,'12', '31')
if timeP582 >= changedTime then -- find maximum end time
-- Case Pierre-Roger Latour: Chambéry CF (2012 - 2014), time season at 2013
-- Task: changedTime should be after start time, but before startOfSeason
localif y4endYear => string.match(timeP582,startOfSeasonYear then "(%d+)-%d+-%d+")
if y4 > y3 then changedTime = '+'..y3startOfSeasonYear..'-12-31T00:00:00Z' else changedTime = timeP582 end
else
changedTime = endDate or ''
end
end
end
Line 5.530 ⟶ 5.932:
if changedTime ~= '+0000-00-00' then
riderTeam = getTeam(riderID, changedTime, nil)
local _, _, y1endYear, _, _ = string.find(changedTime, "(%d+)-(%d+)-(%d+)")
timeTeam = ' ('..y1endYear..')'
end
end
end
if errorbool==1 then
errortext=errortext..' missing qualifiers by team'
elseif errorbool==2 then
errortext=errortext..' missing qualifiers by rider'
end
end
Line 5.553 ⟶ 5.950:
end
--save
local tRider={
sortkey=sortkey,
riderName=riderName,
riderBirthday=riderBirthday,
riderTeam=riderTeam,
timeTeam=timeTeam,
riderStart=riderStart,
riderEnd=riderEnd,
riderPosition=riderPosition,
riderReason=riderReason,
riderRef=riderRef,
errortext=errortext,
pays=pays,
flags=flags
}
if correctlanguage == true then
table.insert(riderTablecorrect,tRider )
table.insert(riderTablecorrect, {sortkey, riderName, riderBirthday, riderTeam, timeTeam, riderStart, riderEnd, riderPosition, riderReason, riderRef, errorbool, errortext, pays,flags})
else
table.insert(riderTablenotcorrect, {sortkey, riderName, riderBirthday, riderTeam, timeTeam, riderStart, riderEnd, riderPosition, riderReason, riderRef, errorbool, errortext, pays,flags}tRider)
end
end
Line 5.573 ⟶ 5.986:
end
 
local outputTableoutTable = mw.html.create('table')
:addClass('sortable')
:attr('cellpadding', '2')
Line 5.579 ⟶ 5.992:
:css('border' , '1px solid rgb(200,200,200)')
:css('padding', '3px')
outputTableoutTable:tag('tr'):cssTextcss('background-color:#EAECF0;line-height:','1.8em;')
:css('background-color',backgroundColor)
:tag('th'):attr('colspan', 4):cssText('text-align:center;white-space:nowrap')
:wikitext('<span style="float:left">[[File:Wikidata-logo S.svg|12px|link=d:'.. frame.args[1].. '#P527]]</span>')
:wikitext(getSquadTableColumntranslate("getSquadTableColumn",7))
local header = outputTableoutTable:tag('tr')
header:tag('th'):cssText('text-align:center;padding:2px 20px 2px 2px;white-space:nowrap'):wikitext(getSquadTableColumntranslate("getSquadTableColumn",1))
header:tag('th'):cssText('text-align:center;padding:2px 20px 2px 2px;white-space:nowrap'):wikitext(getSquadTableColumntranslate("getSquadTableColumn",2))
if available_list and wiki ~= 'lv' then
header:tag('th'):cssText('text-align:center;padding:2px 20px 2px 2px;white-space:nowrap'):wikitext(getSquadTableColumntranslate("getSquadTableColumn",6))
end
header:tag('th'):cssText('text-align:center;padding:2px 20px 2px 2px;white-space:nowrap'):wikitext(getSquadTableColumntranslate("getSquadTableColumn",3))
 
local temp
local iii = 1
for i, v in pairs (riderTable) do
local tRow=outTable:tag('tr'):css('line-height','1.8em')
sortkey=v[1]
riderName=v[2]
riderBirthday=v[3]
riderTeam=v[4]
timeTeam=v[5]
riderStart=v[6]
riderEnd=v[7]
riderPosition=v[8]
riderReason=v[9]
riderRef=v[10]
errorbool=v[11]
errortext=v[12]
pays=v[13]
flags=v[14]
local tRow=outputTable:tag('tr'):css('line-height','1.8em')
local tCell= tRow:tag('td'):cssText("padding:0 1em 0 0;white-space:nowrap")
 
if not available_list or wiki == 'lv' then temp=v['flags']..' ' else temp='' end
tCell:wikitext(temp..v['riderName']):attr('data-sort-value',v['sortkey'])
 
if v['riderStart']~=nil or v['riderEnd']~=nil then
tCell:tag('span'):cssText("font-size:80%; color:#686868")
local note=''
if v['riderReason'] ~= nil then
note = ', [[#tr_'..i..frame.args[1]..'|'..getSquadTableColumntranslate("getSquadTableColumn",4)..']]'
if wiki == "ar" then note = '، [[#tr_'..i..frame.args[1]..'|'..getSquadTableColumntranslate("getSquadTableColumn",4)..']]' end
end
tCell:wikitext(' ('..(v['riderStart'] or '')..'–'..(v['riderEnd'] or '')
local temp
.. (v['riderPosition'] or '')..note..')')
if riderStart~=nil and riderEnd~=nil then
elseif v['riderReason'] then
temp=' ('..riderStart..'–'..riderEnd.. (riderPosition or '')..note..')'
elseif riderStart~=nil then
temp=' ('..riderStart..'–'..(riderPosition or '')..note..')'
else
temp=' ('..'–'..(riderPosition or '')..note..')'
end
tCell:wikitext(temp)
elseif riderReason then
tCell:tag('span'):cssText("font-size:80%; color:#686868")
:wikitext('([[#tr_'..i..frame.args[1]..'|'..getSquadTableColumntranslate("getSquadTableColumn",4)..']]'.. ')')
end
tCell=tRow:tag('td'):cssText("text-align:right;white-space:nowrap")
if wiki == 'lv' then
local _, _, y1beginYear, m1beginMonth, d1beginDay = string.find(startOfSeason,"(%d+)-(%d+)-0*(%d+)")
local _, _, y2endYear, m2endMonth, d2endDay = string.find(v['riderBirthday'] or '',"(%d+)-(%d+)-0*(%d+)")
tCell:wikitext(frame:expandTemplate{ title = 'Template:Birth date and age2', args = { y1beginYear, m1beginMonth, d1beginDay, y2endYear, m2endMonth, d2endDay } })
else
tCell:wikitext(func_datefuncDate(v['riderBirthday'] or '', 'long'))
if available_list then
tRow:tag('td'):wikitext(v['flags'].. ' '..v['pays'])
end
end
 
if wiki =='he' then
local isRtl = (mw.ustring.find(v['riderTeam'], '|.*[א-ת]') or (not mw.ustring.find(v['riderTeam'], '|') and mw.ustring.find(riderTeam, '[א-ת]')))
if isRtl then
tCell=tRow:tag('td'):cssText("padding:0 0.5em; text-align:right")
Line 5.658 ⟶ 6.050:
tCell=tRow:tag('td'):cssText("padding:0 0.5em; text-align:left")
end
if v['riderTeam'] then
tCell:wikitext(v['riderTeam'].. v['timeTeam']..v['errortext'])
end
--tableEndText is not a table
if v['riderReason'] ~= nil or v['errortext'] ~= '' then
local temp=(v['riderReason'] or '')..(v['errortext'] or '')
if riderReason and errortext then
temp=riderReason ..errortext
elseif riderReason then
temp=riderReason
end
if iii == 1 then
tableEndText = tableEndText.. getSquadTableColumntranslate("getSquadTableColumn",5)..': '.. v['riderName'].. temp
else
tableEndText = tableEndText.. '<span style="color:white">'.. getSquadTableColumntranslate("getSquadTableColumn",5)..': </span>'.. riderName.. temp
end
iii = iii + 1
if riderRef ~= nil then tableEndText = tableEndText..
frame:extensionTag{name='ref', content=v['riderRef'], args = {name='tr_'..iii..frame.args[1]}} end
tableEndText = tableEndText.. '<br>'
end
end
if labelMissing then outputTableoutTable:wikitext(getMissingLabelTrackingCategory()) end
local UCIlink
Line 5.689 ⟶ 6.076:
end
outputTableoutTable:tag('tr'):tag('td'):addClass("navigation-only")
:attr('data-sort-value','zz')
:attr('colspan',4)
:cssText("border-top: 2px #EAECF0"..backgroundColor.." solid; font-size: 80%;")
:tag('tr')
:tag('td'):attr('colspan',4)
:attr('data-sort-value','zzz')
:cssText("text-align:right")
:tag('small'):wikitext(race_reference_translatetranslate(wiki"race_reference", 1).."["..UCIlink..' UCI]')
return tostring(outputTableoutTable)..tableEndText
end
 
--== IJ) List of winners ==
function p.listofwinnerscountrylistofwinners(frame)
local winnersProperty = {'Q72068715Q20882667','Q72068718Q20882668','Q72068721Q20882669'}
local displayteamtemp = false -- display of a rider without a team
if tonumber(frame.args[5]) ==1 then displayteamtemp = true end -- display of the rider with the team
local s = {
countryflag=true,
beginyear=tonumber(frame.args[2]),
endyear=0,
endyear=tonumber(frame.args[3]),
beginyear=0,
shapka=tonumber(frame.args[4]),
displayteam=displayteamtemp,
winnersProperty=winnersProperty,
custom=false
displayteam = true
}
return listofwinners_main(frame, s)
end
 
function p.listofwinnerscountryU23(frame)
local winnersProperty = {'Q72068724','Q72068725','Q72068729'}
local s = {
countryflag=true,
endyear=0,
beginyear=0,
winnersProperty=winnersProperty,
displayteam = false
}
return listofwinners_main(frame, s)
end
 
function p.generalclassificationpoint(frame)
local s = {
header_function = headoftableII, -- translations are in function headoftableII
header_1 = 9, -- translation 10 in function headoftableII is printed in the upper part of the table header
header_2 = {1, 2, 3, 7}, -- translations 1, 2, 3, 7 in function headoftableII are printed in this order in the lower part of the table header
item = frame.args[1],
property = 'P2321', -- property to use for this table
team_classification = false, -- it is not a team classification table, its a rider classification table
background = 'color', -- there is a background color for the first row
display_ref = tonumber(frame.args[2]) == 0 and 0 or 1
}
return new_classification(frame, s)
end
 
function p.listofwinnersyoung(frame)
local winnersProperty = {'Q20883139','Q72099969','Q72099972'}
local displayteamtemp = false -- display of a rider without a team
if tonumber(frame.args[4]) ==1 then displayteamtemp = true end -- display of the rider with the team
local s = {
countryflag=true,
beginyear=tonumber(frame.args[2]),
endyear=0,
endyear=tonumber(frame.args[3]),
beginyear=0,
shapka=tonumber(frame.args[4]),
displayteam=tonumber(frame.args[5]), -- since the answer is "args[4]"
winnersProperty=winnersProperty,
displayteam custom= false
}
return listofwinners_main(frame, s)
Line 5.757 ⟶ 6.126:
local s = {
countryflag=false,
beginyear=tonumber(frame.args[2]),
endyear=0,
endyear=tonumber(frame.args[3]),
beginyear=0,
shapka=tonumber(frame.args[4]),
winnersProperty=winnersProperty,
displayteam = false,
custom=false
}
return listofwinners_main(frame, s)
end
 
function--listofwinnerssecondpart and so on can be coded with p.listofwinners(frame)
function p.listofwinnersnowiki(frame)
local winnersProperty = {'Q20882667','Q20882668','Q20882669'}
local displayteamtemp = false -- display of a rider without a team
if tonumber(frame.args[5]) ==1 then displayteamtemp = true end -- display of the rider with the team
local s = {
countryflag=true,
beginyear=tonumber(frame.args[2]),
endyear=0,
endyear=tonumber(frame.args[3]),
beginyear=0,
shapka=tonumber(frame.args[4]),
displayteam=displayteamtemp, -- since the answer is "args[4]"
winnersProperty=winnersProperty,
displayteam custom= false
}
return frame:extensionTag{ name = 'nowiki', content = listofwinners_main(frame, s)}
end
 
function p.listofwinnersteamofpoint(frame)
function p.listofwinnersfirstpart(frame) --return a html table to be copied directly in wikipedia
local winnersProperty = {'Q20882667Q27104269','Q20882668Q72065970','Q20882669Q72065977'}
local displayteamtemp = false -- display of a rider without a team
if tonumber(frame.args[5]) ==1 then displayteamtemp = true end -- display of the rider with the team
local s = {
countryflag=true,
endyearbeginyear=tonumber(frame.args[2]) or 0,
endyear=tonumber(frame.args[3]),
beginyear=0,
shapka=tonumber(frame.args[4]),
displayteam=displayteamtemp, -- since the answer is "args[4]"
winnersProperty=winnersProperty,
displayteam custom= false
}
return frame:extensionTag{ name = 'nowiki', content = listofwinners_main(frame, s)}
end
 
function p.listofwinnerssecondpartlistofwinnersGSI(frame)--start the list winners from a given year
local winnersProperty = {'Q20882667Q98959152','Q20882668Q98959192','Q20882669Q98959196'}
local displayteamtemp = false -- display of a rider without a team
if tonumber(frame.args[5]) ==1 then displayteamtemp = true end -- display of the rider with the team
local s = {
countryflag=true,
beginyear=tonumber(frame.args[2]),
endyear=0,
beginyearendyear=tonumber(frame.args[23]) or 0,
shapka=tonumber(frame.args[4]),
displayteam=displayteamtemp, -- since the answer is "args[4]"
winnersProperty=winnersProperty,
displayteam custom= false
}
return listofwinners_main(frame, s)
end
 
function p.listofwinnersChampfirstpartlistofwinnersGSII(frame)
local winnersProperty = {'Q20882667Q98959153','Q20882668Q98959194','Q20882669Q98959197'}
local displayteamtemp = false -- display of a rider without a team
local s = {
if tonumber(frame.args[5]) ==1 then displayteamtemp = true end -- display of the rider with the team
countryflag=false,
endyear=tonumber(frame.args[2]) or 0,
beginyear=0,
displayteam = false,
winnersProperty=winnersProperty
}
return frame:extensionTag{ name = 'nowiki', content = listofwinners_main(frame, s)}
end
 
function p.listofwinnersChampsecondpart(frame)
local winnersProperty = {'Q20882667','Q20882668','Q20882669'}
local s = {
countryflag=false,
endyear=0,
displayteam = false,
beginyear=tonumber(frame.args[2]) or 0,
winnersProperty=winnersProperty
}
return listofwinners_main(frame, s)
end
 
function p.listofpointswinners(frame)
local winnersProperty = {'Q20883007'}
local s = {
countryflag=true,
beginyear=tonumber(frame.args[2]),
endyear=0,
endyear=tonumber(frame.args[3]),
beginyear=0,
shapka=tonumber(frame.args[4]),
displayteam = false,
displayteam=displayteamtemp, -- since the answer is "args[4]"
winnersProperty=winnersProperty
winnersProperty=winnersProperty,
custom=false
}
return listofwinners_main(frame, s)
end
 
function p.listofmountainwinnerslistofwinnersGSIII(frame)
local winnersProperty = {'Q20883212Q98959155','Q98959195','Q98959198'}
local displayteamtemp = false -- display of a rider without a team
if tonumber(frame.args[5]) ==1 then displayteamtemp = true end -- display of the rider with the team
local s = {
countryflag=true,
beginyear=tonumber(frame.args[2]),
endyear=0,
endyear=tonumber(frame.args[3]),
beginyear=0,
shapka=tonumber(frame.args[4]),
displayteam = false,
displayteam=displayteamtemp, -- since the answer is "args[4]"
winnersProperty=winnersProperty
winnersProperty=winnersProperty,
custom=false
}
return listofwinners_main(frame, s)
end
 
function p.listofyoungwinnerslistofwinnerscountry(frame)
local winnersProperty = {'Q20883139Q72068715','Q72068718','Q72068721'}
local displayteamtemp = false -- display of a rider without a team
if tonumber(frame.args[5]) ==1 then displayteamtemp = true end -- display of the rider with the team
local s = {
countryflag=true,
beginyear=tonumber(frame.args[2]),
endyear=0,
endyear=tonumber(frame.args[3]),
beginyear=0,
shapka=tonumber(frame.args[4]),
displayteam = false,
displayteam=displayteamtemp, -- since the answer is "args[4]"
winnersProperty=winnersProperty
winnersProperty=winnersProperty,
custom=false
}
return listofwinners_main(frame, s)
end
 
function p.listofwinnerswithteamlistofwinnerscountryU23(frame)
local winnersProperty = {'Q20882667Q72068724','Q20882668Q72068725','Q20882669Q72068729'}
local displayteamtemp = false -- display of a rider without a team
if tonumber(frame.args[5]) ==1 then displayteamtemp = true end -- display of the rider with the team
local s = {
countryflag=true,
beginyear=tonumber(frame.args[2]),
endyear=0,
endyear=tonumber(frame.args[3]),
beginyear=0,
shapka=tonumber(frame.args[4]),
displayteam = true,
displayteam=displayteamtemp, -- since the answer is "args[4]"
winnersProperty=winnersProperty
winnersProperty=winnersProperty,
custom=false
}
return listofwinners_main(frame, s)
Line 5.876 ⟶ 6.252:
local winnersProperty ={}
--general
if frame.args[25] ~= nil and tonumber(frame.args[25]) ==1 then table.insert( winnersProperty,'Q20882667') end
--podium
if frame.args[36] ~= nil and tonumber(frame.args[36]) ==1 then
table.insert( winnersProperty,'Q20882668')
table.insert( winnersProperty,'Q20882669')
end
--points
if frame.args[47] ~= nil and tonumber(frame.args[47]) ==1 then table.insert( winnersProperty, 'Q20883007' ) end
--mounstain
if frame.args[58] ~= nil and tonumber(frame.args[58]) ==1 then table.insert( winnersProperty, 'Q20883212' ) end
-- sprints
if frame.args[69] ~= nil and tonumber(frame.args[69]) ==1 then table.insert( winnersProperty, 'Q20883328' ) end
-- youth
if frame.args[710] ~= nil and tonumber(frame.args[710]) ==1 then table.insert( winnersProperty, 'Q20883139' ) end
-- combativity
if frame.args[811] ~= nil and tonumber(frame.args[811]) ==1 then table.insert( winnersProperty, 'Q20893983' ) end
-- volante
if frame.args[912] ~= nil and tonumber(frame.args[912]) ==1 then table.insert( winnersProperty, 'Q27067359' ) end
-- regularity
if frame.args[1013] ~= nil and tonumber(frame.args[1013]) ==1 then table.insert( winnersProperty, 'Q27067170' ) end
-- combination
if frame.args[1114] ~= nil and tonumber(frame.args[1114]) ==1 then table.insert( winnersProperty, 'Q20893979' ) end
-- breakaway
if frame.args[1215] ~= nil and tonumber(frame.args[1215]) ==1 then table.insert( winnersProperty, 'Q27907715' ) end
-- azzurri
if frame.args[1316] ~= nil and tonumber(frame.args[1316]) ==1 then table.insert( winnersProperty, 'Q27907747' ) end
-- rookie
if frame.args[1417] ~= nil and tonumber(frame.args[1417]) ==1 then table.insert( winnersProperty, 'Q28092831' ) end
-- teams
if frame.args[1518] ~= nil and tonumber(frame.args[1518]) ==1 then table.insert( winnersProperty, 'Q20882921' ) end
-- teamspoints
if frame.args[1619] ~= nil and tonumber(frame.args[1619]) ==1 then table.insert( winnersProperty, 'Q27104269' ) end
-- amateur
if frame.args[1720] ~= nil and tonumber(frame.args[1720]) ==1 then table.insert( winnersProperty, 'Q61976850' ) end
--nationality
if frame.args[1821] ~= nil and tonumber(frame.args[1821]) ==1 then table.insert( winnersProperty, 'Q61976872' ) end
-- country
if frame.args[22] ~= nil and tonumber(frame.args[22]) ==1 then table.insert( winnersProperty, 'Q72068715' ) end
-- country U-23
if frame.args[23] ~= nil and tonumber(frame.args[23]) ==1 then table.insert( winnersProperty, 'Q72068724' ) end
local s = {
countryflag=true,
beginyear=tonumber(frame.args[2]),
endyear=0,
endyear=tonumber(frame.args[3]),
beginyear=0,
shapka=tonumber(frame.args[4]),
displayteam = false,
winnersProperty=winnersProperty,
custom=true
}
return listofwinners_main(frame, s)
Line 5.934 ⟶ 6.316:
local beginyear=s.beginyear or 0
local endyear=s.endyear or 0
local shapka=s.shapka or 0
 
local titletable={
['Q20882667']=listofwinners_translate(2), --winner
[ 'Q27104269' ]=listofwinners_translate(2), --winner team
[ 'Q20883139' ]=listofwinners_translate(2), --winner young
[ 'Q72068715' ]=listofwinners_translate(2), --winner country
[ 'Q72068724' ]=listofwinners_translate(2), --winner countryU23
['Q20882668']=listofwinners_translate(3), --second
 
['Q20882669']=listofwinners_translate(4), --third
if s.custom then
[ 'Q20883007' ]=listofwinners_translate(5), -- points
titletable={
[ 'Q20883212' ]=listofwinners_translate(6), -- mountains
[ 'Q20883328Q20882667' ]=listofwinners_translatetranslate(7"listofwinners",2), -- sprintswinner
[ 'Q20883139Q20882668' ]=listofwinners_translatetranslate(8"listofwinners",3), -- youthsecond
[ 'Q20893983Q20882669' ]=listofwinners_translatetranslate(9"listofwinners",4), -- combativitythird
[ 'Q20893979Q20883007' ]=listofwinners_translatetranslate(10"listofwinners",5), -- combinationpoints
[ 'Q20882921Q20883212' ]=listofwinners_translatetranslate(11"listofwinners",6), -- teamsmountains
[ 'Q27067359Q20883328' ]=listofwinners_translatetranslate(12"listofwinners",7), -- volantessprints
[ 'Q27067170Q20883139' ]=listofwinners_translatetranslate(13"listofwinners",8), -- regularityyouth
[ 'Q27104269Q20893983' ]=listofwinners_translatetranslate(14"listofwinners",9), -- teamspointscombativity
[ 'Q27907715Q20893979' ]=listofwinners_translatetranslate(15"listofwinners",10), -- breakawaycombination
[ 'Q27907747Q20882921' ]=listofwinners_translatetranslate(16"listofwinners",11), -- azzurriteams
[ 'Q28092831Q27067359' ]=listofwinners_translatetranslate(17"listofwinners",12), -- rookievolantes
[ 'Q61976850Q27067170' ]=listofwinners_translatetranslate(18"listofwinners",13), -- amateurregularity
[ 'Q61976872Q27104269' ]=listofwinners_translatetranslate(19"listofwinners",14), -- nationalityteamspoints
[ 'Q27907715' ]=translate("listofwinners",15), -- breakaway
-- 1, 2 and 3 place of team, young, country, countryU23 :
[ 'Q27907747' ]=translate("listofwinners",16), -- azzurri
[ 'Q72065970' ]=listofwinners_translate(3), --second team
[ 'Q28092831' ]=translate("listofwinners",17), -- rookie
[ 'Q72099969' ]=listofwinners_translate(3), --second young
[ 'Q61976850' ]=translate("listofwinners",18), -- amateur
[ 'Q72068718' ]=listofwinners_translate(3), --second country
[ 'Q61976872' ]=translate("listofwinners",19), -- nationality
[ 'Q72068725' ]=listofwinners_translate(3), --second countryU23
[ 'Q72068715' ]=translate("listofwinners",23), -- winner country
[ 'Q72068724' ]=translate("listofwinners",24), -- winner countryU23
[ 'Q72065977' ]=listofwinners_translate(4), --third team
[ 'Q72099972' ]=listofwinners_translate(4), --third young
[ 'Q72068721' ]=listofwinners_translate(4), --third country
[ 'Q72068729' ]=listofwinners_translate(4), --third countryU23
}
else --main
titletable={
-- winner:
[ 'Q20882667' ]=translate("listofwinners",2), -- winner
[ 'Q20883007' ]=translate("listofwinners",2), -- points
[ 'Q20883212' ]=translate("listofwinners",2), -- mountains
[ 'Q20883328' ]=translate("listofwinners",2), -- sprints
[ 'Q20883139' ]=translate("listofwinners",2), -- youth (time or point)
[ 'Q20893983' ]=translate("listofwinners",2), -- combativity
[ 'Q20893979' ]=translate("listofwinners",2), -- combination
[ 'Q20882921' ]=translate("listofwinners",2), -- team (time)
[ 'Q27067359' ]=translate("listofwinners",2), -- volantes
[ 'Q27067170' ]=translate("listofwinners",2), -- regularity
[ 'Q27104269' ]=translate("listofwinners",2), -- teampoints
[ 'Q27907715' ]=translate("listofwinners",2), -- breakaway
[ 'Q27907747' ]=translate("listofwinners",2), -- azzurri
[ 'Q28092831' ]=translate("listofwinners",2), -- rookie
[ 'Q61976850' ]=translate("listofwinners",2), -- amateur
[ 'Q61976872' ]=translate("listofwinners",2), -- nationality
[ 'Q72068715' ]=translate("listofwinners",2), -- winner country
[ 'Q72068724' ]=translate("listofwinners",2), -- winner countryU23
[ 'Q98959152' ]=translate("listofwinners",2), -- winner team GS-I
[ 'Q98959153' ]=translate("listofwinners",2), -- winner team GS-II
[ 'Q98959155' ]=translate("listofwinners",2), -- winner team GS-III
-- 2 place:
[ 'Q20882668' ]=translate("listofwinners",3), -- second
[ 'Q72065970' ]=translate("listofwinners",3), -- second teampoints
[ 'Q72099969' ]=translate("listofwinners",3), -- youth (time or point)
[ 'Q72068718' ]=translate("listofwinners",3), -- second country
[ 'Q72068725' ]=translate("listofwinners",3), -- second countryU23
[ 'Q98959192' ]=translate("listofwinners",3), -- second team GS-I
[ 'Q98959194' ]=translate("listofwinners",3), -- second team GS-II
[ 'Q98959195' ]=translate("listofwinners",3), -- second team GS-III
-- 3 place:
[ 'Q20882669' ]=translate("listofwinners",4), -- third
[ 'Q72065977' ]=translate("listofwinners",4), -- third teampoints
[ 'Q72099972' ]=translate("listofwinners",4), -- youth (time or point)
[ 'Q72068721' ]=translate("listofwinners",4), -- third country
[ 'Q72068729' ]=translate("listofwinners",4), -- third countryU23
[ 'Q98959196' ]=translate("listofwinners",4), -- third team GS-I
[ 'Q98959197' ]=translate("listofwinners",4), -- third team GS-II
[ 'Q98959198' ]=translate("listofwinners",4), -- third team GS-III
}
end
 
--localframe defined as global for references
Line 5.991 ⟶ 6.406:
for num, _ in pairs(localframe.args) do
if num > 1 and mw.ustring.find(mw.ustring.lower(localframe.args[num]), 'row') then
local _, _, key1kebeginYear, val = mw.ustring.find(localframe.args[num], "([^:]+)%s*:%s*(%C+)")
local _, _, key01, key11kebeginYear1, key12kebeginYear2 = mw.ustring.find(key1kebeginYear, "(%a+)%s*(%a+)%s*(%d+)")
key12kebeginYear2 = tonumber(key12kebeginYear2) key11kebeginYear1 = mw.ustring.lower(key01..key11kebeginYear1)
if key11kebeginYear1 == 'aboverow' then WPcontent.row[key12kebeginYear2] = val WPcontent.code[key12kebeginYear2] = 0 end --0 is above
if key11kebeginYear1 == 'belowrow' then WPcontent.row[key12kebeginYear2] = val WPcontent.code[key12kebeginYear2] = 1 end --0 is above
end
end
Line 6.005 ⟶ 6.420:
if part.rank ~= 'deprecated' and part.mainsnak.snaktype == 'value' then
local partID = part.mainsnak.datavalue.value.id
local timeOfRace=getTimeOfRace(partID) --original P585 and P580 inverted here
local p = mw.wikibase.getBestStatements(partID, 'P585') -- P585 is 'point in time'
if p[1] and p[1].mainsnak.snaktype == 'value' then
timeOfRace = p[1].mainsnak.datavalue.value.time
else
p = mw.wikibase.getBestStatements(partID, 'P580') -- P580 is 'start time'
if p[1] and p[1].mainsnak.snaktype == 'value' then
timeOfRace = p[1].mainsnak.datavalue.value.time
end
end
local year = timeOfRace and string.sub(timeOfRace, 2, 5) or '?'
local month = timeOfRace and string.sub(timeOfRace, 7, 8) or '01'
Line 6.070 ⟶ 6.476:
 
local tTitleRow=mw.html.create('tr')
:cssTextcss('background:#EAECF0; text-align:','center')
:css('background-color',backgroundColor)
local tCell=tTitleRow:tag('th')
if WDlink_on == false then
Line 6.076 ⟶ 6.483:
:wikitext("[[File:Wikidata-logo S.svg|12px|link=d:"..raceID .. "#P527]]")
end
tCell:wikitext(listofwinners_translatetranslate("listofwinners",1)) --year
for _, pp in ipairs(s.winnersProperty) do
tTitleRow:tag('th'):wikitext(titletable[pp])
Line 6.118 ⟶ 6.525:
end
--firstpart with header no foot
if endyearshapka >== 01 then -- standard header
return table_firsttable_center .. tostring(tTitleRow) .. table_center"</table>"
elseif shapka == 2 then -- you need to add a title and you can add text at the beginning
elseif beginyear > 0 then
return table_center .. "</table>"
else -- you need to add a title and you can add anything and anywhere
else
return table_first .. tostring(tTitleRow) .. table_center .. "</table>"
end
end
 
--== JK) List of stages
function p.listofstages(frame)
-- WDlink_on is used to decide if a Wikidata logo will be shown
Line 6.166 ⟶ 6.573:
local WProw, WPnew_row, WPcourse, WPtext, WPdate, WPwinner, WPicon, WPdistance
= 'row', 'afterrow', 'location', 'text', 'date', 'winner', 'icon', 'distance'
local _, key1kebeginYear, key2, val
local key01, key11kebeginYear1, key12kebeginYear2
local key21, key22
for num, var in pairs(localframe.args) do
if num > 1 and mw.ustring.find(mw.ustring.lower(var), WProw) then
_, _, key1kebeginYear, key2, val = mw.ustring.find(var, "([^:]+)%s*:?%s*([^:]*)%s*:%s*(%C+)")
_, _, key01, key11kebeginYear1, key12kebeginYear2 = mw.ustring.find(key1kebeginYear, "(%a+)%s*(%a+)%s*(%d+)")
key12kebeginYear2 = tonumber(key12kebeginYear2)
key11kebeginYear1 = mw.ustring.lower(key01 .. key11kebeginYear1)
key2 = mw.ustring.lower(mw.text.trim(key2))
_, _, key21, key22 = mw.ustring.find(key2, "(%a+)%s*(%a*)")
 
if not WPcontent[key12kebeginYear2] then WPcontent[key12kebeginYear2] = {} end
if key11kebeginYear1 == WProw and key21 == WPcourse then WPcontent[key12kebeginYear2][key22] = val end
if key11kebeginYear1 == WPnew_row and key2 == WPdate then
WPcontent[key12kebeginYear2]['date'] = val
WPcontent[key12kebeginYear2]['text'] = WPcontent[key12kebeginYear2]['text'] or ''
WPcontent[key12kebeginYear2]['icon (new row)'] = WPcontent[key12kebeginYear2]['icon (new row)'] or ''
end
if key11kebeginYear1 == WPnew_row and key2 == WPtext then
WPcontent[key12kebeginYear2]['text'] = val
WPcontent[key12kebeginYear2]['date'] = WPcontent[key12kebeginYear2]['date'] or ''
WPcontent[key12kebeginYear2]['icon (new row)'] = WPcontent[key12kebeginYear2]['icon (new row)'] or ''
end
if key11kebeginYear1 == WPnew_row and key2 == WPicon then
val = string.gsub(val, "|", "|border|right|20px|", 1)
WPcontent[key12kebeginYear2]['icon (new row)'] = val
WPcontent[key12kebeginYear2]['date'] = WPcontent[key12kebeginYear2]['date'] or ''
WPcontent[key12kebeginYear2]['text'] = WPcontent[key12kebeginYear2]['text'] or ''
end
if key11kebeginYear1 == WProw and key21 == WPwinner and key22 == 'a' then WPcontent[key12kebeginYear2]['stage winner'] = val end
if key11kebeginYear1 == WProw and key21 == WPwinner and key22 == 'b' then WPcontent[key12kebeginYear2]['general winner'] = val end
if key11kebeginYear1 == WProw and key21 == WPicon then
val = string.gsub(val, "|", "|border|right|20px|", 1)
WPcontent[key12kebeginYear2]['icon'] = val end
if key11kebeginYear1 == WProw and key21 == WPdistance then WPcontent[key12kebeginYear2]['distance'] = val end
end
end
Line 6.276 ⟶ 6.683:
local label, section_title
if sOrdinal == "0" then
label, section_title = func_prologuetranslate("func_prologue"), "#" .. func_prologuetranslate("func_prologue")
else
label, section_title = stageLink(sOrdinal, sNumber, sLetter)
Line 6.284 ⟶ 6.691:
("[[" .. section_title .. "|" .. label .. "]]")
 
local sDate = func_datefuncDate(timeOfRace, 'small')
local tempoverall
if winners['Q20882763']~='' then tempoverall=winners['Q20882763'] else tempoverall=winners['Q20882667'] end
Line 6.304 ⟶ 6.711:
:cssText(standardtablecss)
 
local tRow=tab:tag('tr'):cssTextcss('background:#EAECF0; text-align:center;color',backgroundColor)
:css('text-align','center')
tRow:tag('th'):css('white-space','nowrap')
:wikitext(((not WDlink_on and wdLink(string.gsub(raceID, '%s', '') .. "#P527")) or "")..
translate("headoftable",1))
headoftable(1))
tRow:tag('th'):wikitext(headoftabletranslate("headoftable",2))
tRow:tag('th'):wikitext(headoftabletranslate("headoftable",3))
tRow:tag('th'):css('color','#EAECF0'backgroundColor):wikitext("type")
tRow:tag('th'):wikitext(headoftabletranslate("headoftable",4))
if thereiselevation then
tRow:tag('th'):wikitext(headoftabletranslate("headoftable",7))
end
tRow:tag('th'):wikitext(headoftabletranslate("headoftable",5))
tRow:tag('th'):wikitext(headoftabletranslate("headoftable",6))
 
for num, row in pairs(rows) do
Line 6.469 ⟶ 6.877:
ITTtemp=true
else
local RacelabelraceLabel = mw.wikibase.getLabelByLang(v,"fr")
if RacelabelraceLabel then
local testMenRoadrace, testMenITT, testWomenRoadrace, testWomenITT
local RacelabelmodraceLabelmod = string.gsub(RacelabelraceLabel, '-', 'x')
testMenRoadrace = string.find( RacelabelraceLabel, 'Course en ligne masculine aux' )
testMenITT = string.find( RacelabelmodraceLabelmod, 'Contrexlaxmontre masculin aux' )
testWomenRoadrace = string.find( RacelabelraceLabel, 'Course en ligne féminine aux' )
testWomenITT = string.find( RacelabelmodraceLabelmod, 'Contrexlaxmontre féminin aux' )
if testWomenRoadrace or testMenRoadrace then road = true roadtemp=true end
if testWomenITT or testMenITT then ITT = true ITTtemp=true end
Line 6.505 ⟶ 6.913:
end
--avoid double display of jersey
result = "<small>("..startlist_translatetranslate("startlist",10).." "..startlist_translatetranslate("startlist",12).." "..startlist_translatetranslate("startlist",11)..")</small>"
elseif road then
result = "<small>("..startlist_translatetranslate("startlist",10)..")</small>"
elseif ITT then
result = "<small>("..startlist_translatetranslate("startlist",11)..")</small>"
else
result = ""
Line 6.516 ⟶ 6.924:
end
 
-- KL) List of stages classification
local function winnerjersey(raceID, winners)
local jerseytable, bgcolortable={}, {}
Line 6.573 ⟶ 6.981:
if thisGT=='Q33881' then
Sitelink = wikibase.getSitelink('Q2267539')
if Sitelink then overallname="[["..Sitelink .."|"..headoftableIItranslate("headoftableII",9).."]]" end
Sitelink = wikibase.getSitelink('Q175399')
if Sitelink then pointsname="[["..Sitelink .."|"..infobox_translatetranslate("infobox",22).."]]" end
Sitelink = wikibase.getSitelink('Q927157')
if Sitelink then mountainname="[["..Sitelink .."|"..infobox_translatetranslate("infobox",23).."]]" end
Sitelink = wikibase.getSitelink('Q641662')
if Sitelink then youngname="[["..Sitelink .."|"..infobox_translatetranslate("infobox",25).."]]" end
Sitelink = wikibase.getSitelink('Q1436680')
if Sitelink then teamname="[["..Sitelink .."|"..infobox_translatetranslate("infobox",28).."]]" end
Sitelink = wikibase.getSitelink('Q2094179')
if Sitelink then combativityname="[["..Sitelink .."|"..infobox_translatetranslate("infobox",26).."]]" end
Sitelink = wikibase.getSitelink('Q1835362')
if Sitelink then combinedname="[["..Sitelink .."|"..infobox_translatetranslate("infobox",27).."]]" end
elseif thisGT=='Q33861' then
Sitelink = wikibase.getSitelink('Q1164275')
if Sitelink then overallname="[["..Sitelink .."|"..headoftableIItranslate("headoftableII",9).."]]" end
Sitelink = wikibase.getSitelink('Q641083')
if Sitelink then pointsname="[["..Sitelink .."|"..infobox_translatetranslate("infobox",22).."]]" end
Sitelink = wikibase.getSitelink('Q641060')
if Sitelink then mountainname="[["..Sitelink .."|"..infobox_translatetranslate("infobox",23).."]]" end
Sitelink = wikibase.getSitelink('Q641662')
if Sitelink then youngname="[["..Sitelink .."|"..infobox_translatetranslate("infobox",25).."]]" end
else
Sitelink = wikibase.getSitelink('Q2532554')
if Sitelink then overallname="[["..Sitelink .."|"..headoftableIItranslate("headoftableII",9).."]]" end
Sitelink = wikibase.getSitelink('Q2241695')
if Sitelink then pointsname="[["..Sitelink .."|"..infobox_translatetranslate("infobox",22).."]]" end
Sitelink = wikibase.getSitelink('Q1118296')
if Sitelink then mountainname="[["..Sitelink .."|"..infobox_translatetranslate("infobox",23).."]]" end
Sitelink = wikibase.getSitelink('Q2330008')
if Sitelink then combinedname="[["..Sitelink .."|"..infobox_translatetranslate("infobox",27).."]]" end
end
end
 
local winners = {
{ name = infobox_translatetranslate("infobox",19), QID = 'Q20882747'}, -- stage
{ name = overallname or headoftableIItranslate("headoftableII",9), QID = 'Q20882763' }, -- overall
{ name = pointsname or infobox_translatetranslate("infobox",22), QID = 'Q20883008' }, -- points
{ name = mountainname or infobox_translatetranslate("infobox",23), QID = 'Q20883213' }, -- mountains
{ name = infobox_translatetranslate("infobox",24), QID= 'Q20883329' }, -- sprints
{ name = youngname or infobox_translatetranslate("infobox",25), QID='Q20883140' }, -- youth
{ name = combativityname or infobox_translatetranslate("infobox",26), QID= 'Q20893984' }, -- combativity
{ name = infobox_translatetranslate("infobox",35), QID= 'Q27104688' }, -- volantes
{ name = infobox_translatetranslate("infobox",36), QID= 'Q27104684' }, -- regularity
{ name = combinedname or infobox_translatetranslate("infobox",27), QID='Q20965880' }, -- combination
{ name = infobox_translatetranslate("infobox",38), QID='Q27907714' }, -- breakaway
{ name = infobox_translatetranslate("infobox",39), QID='Q27907748' }, -- azzurri
{ name = infobox_translatetranslate("infobox",40), QID='Q28096780'}, -- rookie
{ name = teamname or infobox_translatetranslate("infobox",28), QID='Q20882922' }, -- teams
{ name = infobox_translatetranslate("infobox",37), QID ='Q27104271' }, -- teamspoints
{ name = infobox_translatetranslate("infobox",41), QID ='Q61976847' },-- amateur
{ name = infobox_translatetranslate("infobox",42), QID ='Q61976871' } --nationality
}
 
Line 6.673 ⟶ 7.081:
local t = {key=ii, name=v.name, jersey='', bg_color='', used=false}
for ii = 1, #stages+1 do
t[ii] = { {}, {}, {} } -- ?leader, first stage, number of stages consecutive (for rowspan)
end
columntable[v.QID] = t
Line 6.695 ⟶ 7.103:
for ii, v in pairs(stages) do
if v.mainsnak.snaktype == 'value' then
local somewinner = false --show the stage
local stageID = v.mainsnak.datavalue.value.id
local sitelink = mw.wikibase.getSitelink(stageID)
Line 6.710 ⟶ 7.118:
local label, section_title
if sOrdinal == "0" then
label, section_title = func_prologuetranslate("func_prologue"), "#" .. func_prologuetranslate("func_prologue")
else
label, section_title = stageLink(sOrdinal, sNumber, sLetter)
Line 6.745 ⟶ 7.153:
columntable[v.QID][ii][1]=win[v.QID]
if ii==1 then --first stage
columntable[v.QID][ii][2]=1 --start at row 1
columntable[v.QID][ii][3]=1 --1 consecutive stage
elseif columntable[v.QID][ii-1][1]==win[v.QID] then --same winner as past stage
local initialstage=columntable[v.QID][ii-1][2]
columntable[v.QID][ii][2]=initialstage --no change of the first stage
columntable[v.QID][initialstage][3]=columntable[v.QID][initialstage][3]+1 --one more consecutive stage
columntable[v.QID][ii][3]=0
else --new winner
columntable[v.QID][ii][2]=ii --start at this row/stage
columntable[v.QID][ii][3]=1 --1 consecutive stage
end
columntable[v.QID].used=true
if ii==1 then --read the jersey in the first stage of a race
columntable[v.QID].jersey=jerseytable[v.QID]
columntable[v.QID].bg_color=bgcolortable[v.QID]
Line 6.783 ⟶ 7.191:
somewinner=true
thiskey=generaltoleader[v.QID]
--fill the final classification
columntable[thiskey][#stages+1][1]=win[v.QID]
columntable[thiskey][#stages+1][2]=#stages+1
columntable[thiskey][#stages+1][3]=1
--#stages is the last stage
if type(columntable[thiskey][#stages][1])~="string" then --check nil actually, but it is a table..
if type(columntable[thiskey][#stages][1])~=win[v.QID]"string" --no need to fill last stage ofcombativity ais stagenot raceextrapolated
and thiskey~='Q20893984'
if type(columntable[thiskey][#stages-1][1])=="string" and win[v.QID]==columntable[thiskey][#stages-1][1] then
then --check nil actually, but it is a table..
columntable[thiskey][#stages][1]= win[v.QID] --extrapolate the winner
if type(columntable[thiskey][#stages-1][1])=="string" and
win[v.QID]==columntable[thiskey][#stages-1][1]
then --if there is a leader at forelast stage
local initialstage=columntable[thiskey][#stages-1][2]
columntable[thiskey][#stages][2]=initialstage
Line 6.798 ⟶ 7.212:
end
end
columntable[thiskey].used=true
if jerseytable[v.QID] and jerseytable[v.QID]~='' then
columntable[thiskey].jersey=jerseytable[v.QID]
Line 6.805 ⟶ 7.218:
end
end
table.insert(stageinfotable,{sLink=listofstagesclassification_translatetranslate("listofstagesclassification",2), sType=nil, somewinner=somewinner})
 
--build the table
Line 6.812 ⟶ 7.225:
:attr('cellspacing','0')
:cssText(standardtablecss)
local tRow=tab:tag('tr'):cssTextcss('background:#EAECF0; text-align:center;color',backgroundColor)
:css('text-align','center')
tRow:tag('th'):css('white-space','nowrap')
:wikitext(((not WDlink_on and wdLink(string.gsub(raceID, '%s', '') .. "#P527")) or "")..
translate("headoftable",1))
headoftable(1))
if displaytypeofstage==true then tRow:tag('th') end
Line 6.838 ⟶ 7.252:
tCell=tRow:tag('td')
if ii==#stageinfotable then --general row
tCell:cssText('font-weight:bold; border-top: 2px black solid;')
end
Line 6.863 ⟶ 7.277:
tCell=tRow:tag('td')
if ii~=#stageinfotable and v.somewinner==true then
tCell:wikitext(listofstagesclassification_translatetranslate("listofstagesclassification",1)) --not attributed
elseif ii~=#stageinfotable then
--empty
elseif v.somewinner==true then --general row
tCell:cssText('border-top: 2px black solid')
:wikitext(translate("listofstagesclassification",1)) --not attributed
:wikitext(listofstagesclassification_translate(1))
else
tCell:cssText('border-top: 2px black solid') --empty
Line 6.879 ⟶ 7.293:
end
 
--IM) Start list
function p.startlist(frame)
local IDtemp
Line 6.887 ⟶ 7.301:
 
local s = {
header_function = startlist_translate"startlist",
header_1 = 1, -- translation 1 in function victories_translatevictories is printed in the upper part of the table header
header_2 = {2, 3,4,5},
item=IDtemp,
Line 6.897 ⟶ 7.311:
}
 
local resulttableresultTable, tag = tableB(s)
return startlist_main(s, resulttableresultTable, tag)
end
 
Line 6.908 ⟶ 7.322:
 
local s = {
header_function = startlisttable_translate"startlisttable",
header_1 = 1, -- translation 1 in function victories_translatevictories is printed in the upper part of the table header
header_2 = {2, 3,4,5},-- translations 2, 3, 4, 5, 6 in function victories_translatevictories are printed in this order
item=IDtemp,
title="Start list", -- in the lower part of the table header. The second value 3 in {4, 3} tells where the icon will go.
Line 6.922 ⟶ 7.336:
 
local function startlist_sub(p710, timeOfRace, WDlink_on, istable)
local h, resulttableresultTable= {}, {}
local tBody = '' --row in our case
local riderID, riderTeamriderTeamLink, riderTeamID, riderDossard, riderLink, riderRank, q, gender, riderTeamCode, riderDNF, DSQ
 
riderID = p710.mainsnak.datavalue.value.id
Line 6.944 ⟶ 7.358:
if q and q.P1534 and q.P1534[1].snaktype == 'value' then
local dnf=q.P1534[1].datavalue.value.id
if dnf=='Q1210380' then riderDNF =startlist_translatetranslate("startlist",6)--"HD","NP","DQ"
elseif dnf=='Q54881674' or dnf=='Q7113430' then riderDNF =startlist_translatetranslate("startlist",7)
elseif dnf=='Q1210382' then riderDNF =startlist_translatetranslate("startlist",8)
elseif dnf=='Q1229261' then riderDNF =startlist_translatetranslate("startlist",9)
else riderDNF=''
end
Line 6.976 ⟶ 7.390:
if wiki == 'es' or wiki == 'fr' or wiki == 'ast' then
--[[ These wikis need the gender to display the rank correct. Other wikis can skip this. ]]
gender = getgendercodegetGenderCode(riderID, 'n')
end
 
Line 6.984 ⟶ 7.398:
if countryID then
if wiki ~= "ar" then
riderLink = riderLink .. ucicodeCountryuciCodeCountry(countryID)
end
riderLink = flag(countryID, timeOfRace) ..' '.. riderLink
Line 6.994 ⟶ 7.408:
end
riderTeamriderTeamLink, riderTeamID = getTeam(riderID, timeOfRace, q)
riderTeamID=seasonToTeamID(riderTeamID)
riderTeamCode= getTeamCode(riderID, timeOfRace, q)
if riderTeamriderTeamLink == nil then riderTeamriderTeamLink ="" end
local sortkey = riderDossard == "" and 0 or tonumber(riderDossard)
 
Line 7.004 ⟶ 7.419:
tBody:tag('td'):cssText('text-align:'..textalign.. ';padding:0 0.5em;'..DSQ):wikitext(riderLink)
if istable then
tBody:tag('td'):cssText("text-align:right;padding:0 0.5em"):wikitext(riderTeamriderTeamLink)
end
tBody:tag('td'):cssText('text-align:'..textalign.. ';padding:0 0.5em;'..DSQ):wikitext(number(gender,riderRank,wiki)..riderDNF)
 
table.insert(resulttableresultTable, {sortkey=sortkey, riderTeamriderTeamLink=riderTeamriderTeamLink,riderTeamID=riderTeamID,riderTeamCode=riderTeamCode, tBody=tBody})
return resulttableresultTable
end
 
function startlist_main(s, resulttableresultTable, tag)
local ridertable, DStable, subtable = {}, {}, {}, {}
local DSID, DSLink, DSteamID, DSteam
Line 7.026 ⟶ 7.441:
if q.P642 and q.P642[1].snaktype == 'value' then
DSteamID=q.P642[1].datavalue.value.id
DSteamDSteamID=getTeamLinkCatseasonToTeamID(DSteamID, timeOfRace)
end
table.insert(DStable, {DSLink=DSLink, DSteamDSteamID=DSteamDSteamID})
end
 
for _, p710 in statements(s.item, 'P710') do -- P710 is participants
subtable=startlist_sub(p710, timeOfRace, WDlink_on, false)
ridertable[#ridertable + 1] = {subtable[1].sortkey, riderTeam=subtable[1].riderTeam,riderTeamCode=subtable[1].riderTeamCode, tBody=subtable[1].tBody}
subtable[1].sortkey,
riderTeamLink=subtable[1].riderTeamLink,
riderTeamID=subtable[1].riderTeamID,
riderTeamCode=subtable[1].riderTeamCode,
tBody=subtable[1].tBody
}
end
Line 7.046 ⟶ 7.467:
tSubtitle:tag('td'):attr('width','30px')
:css("align:right;text-align:right")
:wikitext(startlist_translatetranslate("startlist",2))
tSubtitle:tag('td'):attr('width','200px')
:css("align:right;text-align:right")
:wikitext(startlist_translatetranslate("startlist",3))
tSubtitle:tag('td'):attr('width','85px')
:css("align:right;text-align:right")
:wikitext(startlist_translatetranslate("startlist",4))
else
tSubtitle=mw.html.create('tr')
tSubtitle:tag('td'):attr('width','30px'):wikitext(startlist_translatetranslate("startlist",2))
tSubtitle:tag('td'):attr('width','250px'):wikitext(startlist_translatetranslate("startlist",3))
tSubtitle:tag('td'):attr('width','35px'):wikitext(startlist_translatetranslate("startlist",4))
end
 
--look for transition between teams
local numberofteam=0
local tDS
 
if #ridertable==0 then--empty table
Line 7.067 ⟶ 7.489:
else
for ii=1,#ridertable do
if ridertable[ii].riderTeamriderTeamLink==nil then ridertable[ii].riderTeamriderTeamLink=startlist_translatetranslate("startlist",13) end
if ii~=1 and ridertable[ii].riderTeamriderTeamID and ridertable[ii].riderTeamriderTeamID==ridertable[ii-1].riderTeamriderTeamID then test=0 else test=1 end--team change
--new team
if test==1 or ii==1 then
Line 7.074 ⟶ 7.496:
tDS=insideTable:tag('tr')
tDS:tag('td'):attr('colspan','3'):attr('align','center')
:wikitext(startlist_translatetranslate("startlist",5).." "..thisDS)
thisDS=nil
end
Line 7.096 ⟶ 7.518:
:attr('clear',floattable)
 
tTitle = mw.html.create('tr')
:cssTextcss("background-color:#EAECF0",backgroundColor)
:attr('align','center')
local tCell=tTitle:tag('th'):attr('colspan','3')
tCell:tag('big'):wikitext(ridertable[ii].riderTeamriderTeamLink.."<br/>"..(ridertable[ii].riderTeamCode or "___"))
insideTable:node(tTitle)
Line 7.106 ⟶ 7.530:
--look for the DS of this team
for _,v in pairs(DStable) do
if v.DSteamDSteamID==ridertable[ii].riderTeamriderTeamID then thisDS=v.DSLink break end
end
end
Line 7.112 ⟶ 7.536:
end
--last DS
if tDSthisDS then thisTeamTable:node(tDS) end
tDS=insideTable:tag('tr')
tDS:tag('td'):attr('colspan','3'):attr('align','center')
:wikitext(translate("startlist",5).." "..thisDS)
end
tag:node(thisTableRow)
 
return resulttableresultTable
end
end
 
function startlisttable_main(s, resulttableresultTable)
local t_Body, fn_datetable, subtable = {}, {}, {}, {}
local WDlink_on = (wiki == "mk" or wiki == "ja" or wiki == "ru")
Line 7.130 ⟶ 7.558:
t_Body[#t_Body + 1] = {subtable[1].sortkey, tostring(subtable[1].tBody)}
end
return sortandconcatsortAndConcat(t_Body, resulttableresultTable)
end
 
-- JN) Rider ranking
local function checkminmaxyear(minmaxyear,thisyear)
if minmaxyear.minimum ==0 or thisyear<minmaxyear.minimum then
Line 7.146 ⟶ 7.574:
function p.riderranking(frame)
local s = {
gender = 1, --tonumber(frame.args[2]) 0 = men, 1 = women
item = string.gsub(frame.args[1], "%c", ""),
}
return riderranking_main(frame, s)
end
 
 
function riderranking_main(frame,s)
local thisCompetition, rank, thisyear, sitelink, q, gender, DSQ
local ResulttableresultTable, listofcalendar, UCIUCImaster, UCImasterUCImasterlimist={},{},{}, {}
local minmaxyear= {
minimum = 0, -- lots of jerseyID
Line 7.160 ⟶ 7.588:
}
local calendarlistpresent={
["UCIwomen"]=false,
["UCImen"]=false
}
local UCI = {}
UCI["UCIwomen"] = { ['Q57267790']='2019',['Q47005682']='2018',['Q27765666']='2017',
--inverse the table
['Q22696468']='2016',['Q18348936']='2015', ['Q15831496']='2014',
for k,v in pairs(data.UCIYearToQ) do
['Q6425932']='2013',[ 'Q2466796']='2012',['Q2466792']='2011',
UCI[k]={}
['Q2933831']='2010',['Q2933830']='2009',['Q2933828']='2008',
for kk, vv in pairs(v) do
['Q3650627']='2007',[ 'Q16154659']='2006'}
UCI[k][vv]=kk
end
end
local UCImaster=data.UCImaster
UCI["WWT"] = { ['Q57277246']='2019', ['Q41787783']='2018', ['Q27431192']='2017',
 
['Q21034783']='2016'
UCImastername={
}
["women"]=translate("riderranking",2), ['WWT']=translate("riderranking",3),
['WWC']=translate("riderranking",4), ["UWT"]= translate("riderranking",5),
UCI["WWC"] = { ['Q18589848']='2015', ['Q15076094']='2014', ['Q3000659']='2013',
["europe"]=translate("riderranking",6), ["asia"]=translate("riderranking",7),
['Q326406']='2012',['Q326401']='2011',['Q120210']='2010',['Q326012']='2009',
["oceania"]=translate("riderranking",8),["america"]=translate("riderranking",9) ,
['Q326006']='2008',['Q326001']='2007',['Q325995']='2006',['Q127681']='2005',
["africa"]=translate("riderranking",10), ["WR"]=translate("riderranking",11),
['Q80792']='2004',['Q16451']='2003',['Q746107']='2002',['Q979663']='2001',
["WC"]=translate("riderranking",12), ["UPT"]=translate("riderranking",13), --WC is world calendar here
['Q44096']='2000',['Q44095']='1999',['Q39077']='1998'
["UCImen"]=translate("riderranking",14), ["WCmen"]=translate("riderranking",15), --UCImen = UCI ranking 1984-2004, WC= World cup men
}
["Pernod"]=translate("riderranking",16), ["Desgrange"]=translate("riderranking",17),
}
--missing: men world cup, men UCI ranking, pernod, Desgrange-Colombo
UCImasterlimit={
UCImaster={["UCIwomen"]='Q1693153', ['WWT']='Q21075974', ['WWC']='Q1517550'}
["women"]= {b=1989, e=0}, --women=Calendrier international féminin UCI, begin/end 0 = no end
UCImastername={["UCIwomen"]=riderranking_translate(2), ['WWT']=riderranking_translate(3), ['WWC']=riderranking_translate(4)}
["WWT"]= {b=2016, e=0},
["WWC"]= {b=1998, e=2015},
["UWT"]= {b=2011, e=2018},
["europe"]= {b=2005, e=0},
["asia"]= {b=2005, e=0},
["oceania"]={b=2005, e=0},
["america"]={b=2005, e=0},
["africa"]= {b=2005, e=0},
["WR"]= {b=2016, e=0},
["WC"]= {b=2009, e=2010},
["UPT"]= {b=2005, e=2008},
["UCImen"]= {b=1984, e=2004},
["WCmen"]= {b=1989, e=2004},
["Pernod"]= {b=1959, e=1987},
["Desgrange"]= {b=1948, e=1958},
}
local listofwomencalendar={"UCIwomenwomen", "WWC", "WWT"} --"women" is in fact UCIwomen
local listofmencalendar={"Desgrange","Pernod","UCImen","WCmen","UPT",
 
"WC","UWT","WR","europe","asia","america","oceania","africa","Pro"}
if s.gender==1 then
local gender=getGenderCode(s.item, 'm')
if gender=="f" then
listofcalendar=listofwomencalendar
gender='f'
else
listofcalendar=listofmencalendar
gender='m'
end
ff=1
--init table
for ii=1900,2100,1 do
ResulttableresultTable[tostring(ii)]={}
for _, calendar in pairs(listofcalendar) do
ResulttableresultTable[tostring(ii)][calendar]={
rank=nil,
sitelink=nil
Line 7.215 ⟶ 7.667:
if q and q.P1352 and q.P1352[1].snaktype == 'value' then --rank
rank = tonumber(q.P1352[1].datavalue.value.amount)
DSQ = isdisqualified(p1344, q)
else
else
rank= nil
end
if rank then
ResulttableresultTable[thisyear][calendar]["rank"]=tostring(rank)
resultTable[thisyear][calendar]["DSQ"]=DSQ or ""
calendarlistpresent[calendar]=true
sitelink=mw.wikibase.getSitelink(thisCompetition)
ResulttableresultTable[thisyear][calendar]["sitelink"]=sitelink
end
end
Line 7.234 ⟶ 7.688:
local wdLin = wdLink(string.gsub(s.item, '%s', '') .. "#P1344")
local tRow= finalTable:tag('tr'):tag('th'):cssText("background-color:#EAECF0"):wikitext(wdLin..' '..riderranking_translate(1))
:css("background-color",backgroundColor)
:wikitext(wdLin..' '..translate("riderranking",1))
 
for ii=minmaxyear.minimum,minmaxyear.maximum,1 do
tRow:tag('th'):attr("width","50px"):cssText("text-align:center; background-color:#EAECF0;padding:1px 1px;")
:css('background-color',backgroundColor)
:css("text-align","center")
:css("padding","1px 1px")
:wikitext(tostring(ii))
end
Line 7.252 ⟶ 7.711:
end
for iiyy=minmaxyear.minimum,minmaxyear.maximum,1 do
thisyear=tostring(iiyy)
color="white"
if ResulttableresultTable[ thisyear][calendar]["rank"] then
if ResulttableresultTable[thisyear][calendar]["rank"]=="1" then
color="gold"
elseif (2<=tonumber(ResulttableresultTable[thisyear][calendar]["rank"])) and (tonumber(ResulttableresultTable[thisyear][calendar]["rank"])<=3) then
color="YellowGreen"
elseif (4<=tonumber(ResulttableresultTable[thisyear][calendar]["rank"])) and (tonumber(ResulttableresultTable[thisyear][calendar]["rank"])<=10) then
color="silver"
end
 
tCell=tRow:tag('td'):attr("bgcolor",color):cssText(resultTable[thisyear][calendar]["DSQ"])
iflocal Resulttablerank=tonumber(resultTable[thisyear][calendar]["sitelinkrank"] then)
rank=number(gender,rank,wiki)
tCell:wikitext('[['..Resulttable[thisyear][calendar]["sitelink"]..'|'..
number(gender,Resulttableif resultTable[thisyear][calendar]["ranksitelink"],wiki)..']]') then
tCell:wikitext('[['..resultTable[thisyear][calendar]["sitelink"]..'|'..rank..']]')
else
tCell:wikitext(number(gender,Resulttable[thisyear][calendar]["rank"],wiki))
end
--this ranking exist for this year, but the rider is not ranked
else
elseif yy>=UCImasterlimit[calendar].b and
tRow:tag('td'):wikitext(' - ')
(UCImasterlimit[calendar].e==0 or yy<=UCImasterlimit[calendar].e) then
if wiki=="fr" then
tRow:tag('td'):wikitext(' nc ')
else
tRow:tag('td'):wikitext(' - ')
end
--this ranking does not exist for this year
else
tRow:tag('td'):css('background-color',backgroundColorLight)
end
end
Line 7.278 ⟶ 7.747:
end
 
local UCIlink, legend
if wiki=="fr" then
UCIlink="https://www.uci.org/fr/route/classements"
legend= " Légende : nc = non classé"
else
UCIlink="https://www.uci.org/road/rankings"
legend=""
end
Line 7.289 ⟶ 7.760:
finalTable:tag('tr'):tag('td'):addClass("navigation-only")
:attr('colspan',tostring(tableyearsize))
:cssText("border-top: 2px #EAECF0"..backgroundColor.." solid; font-size: 80%;")
:tag('tr')
tCell=finalTable:tag('tr'):tag('td'):attr('colspan',tostring(tableyearsize))
:tag('small')
:cssText("text-align:right")
:tag('small'):wikitext(race_reference_translate(wiki, 1).."["..UCIlink..' UCI]')
tCell:tag('span'):css("float","left")
:wikitext(legend)
tCell:tag('span'):css("float","right")
:wikitext(translate("race_reference", 1).."["..UCIlink..' UCI]')
 
return finalTable
end
end
 
 
local function toboolean(str)
if str=="true" then
return true
elseif str=="false" then
return false
else
return str
end
end
 
--=== O) Rider infobox
local function convertDate(date1, beginOrEnd, initialYear, finalYear)
if not date1 then
if beginOrEnd==0 then --begin
y1=tostring(initialYear)
m1="01"
d1="01"
else
y1=tostring(finalYear)
m1="12"
d1="31"
end
else
_, _, y1,m1,d1 = string.find(date1, "(%d+)-(%d+)-(%d+)")
if m1 ==nil or m1=="00" then
if beginOrEnd==0 then --begin
m1="01"
d1="01"
else--end
m1="12"
d1="31"
end
end
end
return '+'..y1.."-"..m1.."-"..d1.."T00:00:00Z"
end
 
local function listofTeam(itemID, initialYear, finalYear, PID)
--first we have to read P54 of the rider
--alternative P6087 for managed team
local riderteam={}
local stagiaire
 
for ii, p54 in statements(itemID, PID) do --itemID loaded in presentTeam
if p54 then
teamId=p54.mainsnak.datavalue.value.id
else
teamId=nil
end
local q = p54.qualifiers
if q then
local sTime, eTime=getStartEndfromQuali(q)
sTime=convertDate(sTime, 0, initialYear, finalYear)
eTime=convertDate(eTime, 1, initialYear, finalYear)
if q.P39 and q.P39[1] and q.P39[1].snaktype == 'value' then
stagiaire = q.P39[1].datavalue.value
else
stagiaire = nil
end
dis=checkDis(q)
table.insert(riderteam,{teamId=teamId, startTime=sTime, endTime=eTime, stagiaire=stagiaire, dis=dis})
end
end
return riderteam
end
 
--format the date for display of the team
local function riderFormatDate(thisDate)
if thisDate=='' then
return ''
else
local month=math.ceil(thisDate['month']/2)
if month==12 or month==1 then
return thisDate['year']
else
local date1='+'..thisDate['year'].."-"..month.."-".."01".."T00:00:00Z"
-- local newobj = Complexedate.splitDate(date1)
if month == 0 or month==nil then
return thisDate['year']
else
return month..'.'..thisDate['year']
end
end
end
end
 
local function getTeamInfo(teamId,mm,yy,dd,managedTeam)
--get the nature and name of the team for the date mm,yy
mm=tostring(mm)
yy=tostring(yy)
dd=tostring(dd)
if mw.ustring.len(mm)==1 then mm='0'..mm end
thistime='+'..yy.."-"..mm.."-"..dd.."T00:00:00Z"
local sitelink, teamNature=getTeamLinkCat(teamId, thistime, false)
local cat, boolean
local amateurcat={Q20639848=true,Q20652655=true,Q26849121=true}
local nationalcat={Q23726798=true, Q20738667=true, Q54660600=true, Q54555994=true, Q99658502=true}
if managedTeam then
cat=nationalcat
else
cat=amateurcat
end
 
if cat[teamNature] then --club
boolean=true--amateur / national selection
else
boolean=false--pro / not national selection
end
return boolean, sitelink
end
 
--for managed team, the table should be splat, as we can be national trainer and team trainer at the same time
local function analyzeManagedTeam(teamRider, initialYear,finalYear)
local natTeamOut, managedTeamOut={},{}
local dis="road"
local managedTeam=true
for i=1,24 do --init table
natTeamOut[i]={}
managedTeamOut[i]={}
for j=initialYear,finalYear do
natTeamOut[i][j]={ amateurTeam, link, stagiaire=nil}
managedTeamOut[i][j]={amateurTeam,link, stagiaire=nil}
end
end
 
local teamId, natTeam, sitelink
local sYear, sMonth,eYear, eMonth, sDay, eDay
 
if teamRider==nil then return nil end
for _, v in pairs(teamRider) do --for each team where was the rider
if v['dis']==dis then
--exception managed at the reading
_, _, sYear,sMonth,sDay = string.find(v['startTime'], "(%d+)-(%d+)-(%d+)")
_, _, eYear,eMonth,eDay = string.find(v['endTime'], "(%d+)-(%d+)-(%d+)")
sYear=tonumber(sYear)
sMonth=tonumber(sMonth)
eYear=tonumber(eYear)
eMonth=tonumber(eMonth)
if sYear<=eYear then --test of congruence
for yy=sYear,eYear do
for mm=1,12 do
local mmindex=(mm-1)*2+1
--avoid reading info where the team is not the one of the rider
getinfo=true
if (yy==sYear and mm<sMonth) or (yy==eYear and mm>eMonth) then
getinfo=false
end
if getinfo then
if (yy==sYear) and (mm==sMonth) and (sDay~='01' and sDay~='00' and sDay~=nil)then
natTeam, sitelink=getTeamInfo(v['teamId'],mm,yy,sDay, managedTeam)
if natTeam then
natTeamOut[mmindex+1][yy]['amateurTeam']=true
natTeamOut[mmindex+1][yy]['link']=sitelink
else
managedTeamOut[mmindex+1][yy]['amateurTeam']=false
managedTeamOut[mmindex+1][yy]['link']=sitelink
end
else
natTeam, sitelink=getTeamInfo(v['teamId'],mm,yy,1, managedTeam)
if natTeam then
natTeamOut[mmindex][yy]['amateurTeam']=true
natTeamOut[mmindex][yy]['link']=sitelink
if natTeamOut[mmindex+1][yy]['amateurTeam']==nil or v['stagiaire'] then --to avoid problem with team name change during the month
natTeam, sitelink=getTeamInfo(v['teamId'],mm,yy,30,managedTeam)
natTeamOut[mmindex+1][yy]['amateurTeam']=true --a nat team stays a nat team
natTeamOut[mmindex+1][yy]['link']=sitelink
end
else
managedTeamOut[mmindex][yy]['amateurTeam']=false
managedTeamOut[mmindex][yy]['link']=sitelink
if managedTeamOut[mmindex+1][yy]['amateurTeam']==nil or v['stagiaire'] then --to avoid problem with team name change during the month
natTeam, sitelink=getTeamInfo(v['teamId'],mm,yy,30,managedTeam)
managedTeamOut[mmindex+1][yy]['amateurTeam']=false --a nat team stays a nat team
managedTeamOut[mmindex+1][yy]['link']=sitelink
end
end
end
end
end
end
end
end
end
return natTeamOut, managedTeamOut --a filled matrix with the link and nature of the teams
end
 
local function analyzeTeam(teamRider, initialYear,finalYear, dis)
local teamOut={}
local managedTeam=false
for i=1,24 do --init table
teamOut[i]={}
for j=initialYear,finalYear do
teamOut[i][j]={ amateurTeam, link, stagiaire}
end
end
 
local teamId, amateurTeam, sitelink
local sYear, sMonth,eYear, eMonth, sDay, eDay
 
if teamRider==nil then return nil end
for _, v in pairs(teamRider) do --for each team where was the rider
if v['dis']==dis then
--exception managed at the reading
_, _, sYear,sMonth,sDay = string.find(v['startTime'], "(%d+)-(%d+)-(%d+)")
_, _, eYear,eMonth,eDay = string.find(v['endTime'], "(%d+)-(%d+)-(%d+)")
sYear=tonumber(sYear)
sMonth=tonumber(sMonth)
eYear=tonumber(eYear)
eMonth=tonumber(eMonth)
if sYear<=eYear then --test of congruence
for yy=sYear,eYear do
for mm=1,12 do
local mmindex=(mm-1)*2+1
--avoid reading info where the team is not the one of the rider
getinfo=true
if (yy==sYear and mm<sMonth) or (yy==eYear and mm>eMonth) then
getinfo=false
end
if getinfo then
if (yy==sYear) and (mm==sMonth) and (sDay~='01' and sDay~='00' and sDay~=nil)then
amateurTeam, sitelink=getTeamInfo(v['teamId'],mm,yy,sDay, managedTeam)
teamOut[mmindex+1][yy]['amateurTeam']=amateurTeam
teamOut[mmindex+1][yy]['link']=sitelink
teamOut[mmindex+1][yy]['stagiaire']=v['stagiaire']
else
amateurTeam, sitelink=getTeamInfo(v['teamId'],mm,yy,1, managedTeam)
teamOut[mmindex][yy]['amateurTeam']=amateurTeam
teamOut[mmindex][yy]['link']=sitelink
teamOut[mmindex][yy]['stagiaire']=v['stagiaire']
if teamOut[mmindex+1][yy]['amateurTeam']==nil or v['stagiaire'] then --to avoid problem with team name change during the month
amateurTeam, sitelink=getTeamInfo(v['teamId'],mm,yy,30,managedTeam)
teamOut[mmindex+1][yy]['amateurTeam']=amateurTeam
teamOut[mmindex+1][yy]['link']=sitelink
teamOut[mmindex+1][yy]['stagiaire']=v['stagiaire']
end
end
end
end
end
end
end
end
return teamOut --a filled matrix with the link and nature of the teams
end
 
local function insertTeam(teamAmateur,teamPro,sDate,eDate,v)
local sDate2=riderFormatDate(sDate)
local eDate2=riderFormatDate(eDate)
local ins = {link=v['link'], sDate=sDate2,eDate=eDate2,stagiaire=v['stagiaire']}
if v['amateurTeam'] then
table.insert(teamAmateur,ins)
else
table.insert(teamPro,ins)
end
return teamAmateur,teamPro
end
 
local function synthetizeTable(analyzedTeam, initialYear,finalYear)
local teamPro, teamAmateur, tempTeam, tempsDate, tempeDate={}, {},{},{},{}
local empty=true
local active=false
--bring together successive month with identical content
for yy=initialYear,finalYear do
for mm=1,24 do
local v=analyzedTeam[mm][yy]
if v['amateurTeam']~=nil then
if empty then --first line
active=true
empty=false
tempTeam=v
tempsDate['month']=mm
tempsDate['year']=yy
else
if tempTeam['amateurTeam']==v['amateurTeam'] and tempTeam['link']==v['link']
and tempTeam['stagiaire']==v['stagiaire'] then --no change
if yy==finalYear and mm==24 then--present team
teamAmateur,teamPro=insertTeam(teamAmateur,teamPro,tempsDate,'',tempTeam)
end
else--change
--save the old
if active then --if active false then it was already saved
if mm==1 then
tempeDate['year']=yy-1
tempeDate['month']=24
else
tempeDate['year']=yy
tempeDate['month']=mm-1
end
teamAmateur,teamPro=insertTeam(teamAmateur,teamPro,tempsDate,tempeDate,tempTeam)
end
--save the new
active=true
tempTeam=v
tempsDate['month']=mm
tempsDate['year']=yy
end --change
end--first line
elseif active then --there was a team and now there is an empty period
active=false
--save the old
if mm==1 then
tempeDate['year']=yy-1
tempeDate['month']=24
else
tempeDate['year']=yy
tempeDate['month']=mm-1
end
teamAmateur,teamPro=insertTeam(teamAmateur,teamPro,tempsDate,tempeDate,tempTeam)
tempTeam['link']=nil --avoid problem if the rider comes back in the same team
end
end-- for mm
end--for yy
return teamAmateur,teamPro
end
 
local function listOfManagedTeamTable(itemID, initialYear,finalYear)
local managedTeamRider = listofTeam(itemID, initialYear,finalYear,'P6087')--raw list of team
if not managedTeamRider then
return nil, nil
end
local natTeamOut, managedTeamOut=analyzeManagedTeam(managedTeamRider, initialYear,finalYear) --table with links and nature of teams
local nationalTeam,_=synthetizeTable(natTeamOut, initialYear,finalYear)
local _,managedTeam=synthetizeTable(managedTeamOut, initialYear,finalYear)
return nationalTeam,managedTeam
end
 
local function listOfTeamTable(itemID, initialYear,finalYear)
local teamRider = listofTeam(itemID, initialYear,finalYear,'P54')--raw list of team
if not teamRider then
return nil, nil
end
local analyzedTeam1=analyzeTeam(teamRider, initialYear,finalYear, "road") --table with links and nature of teams
local teamAmateur,teamPro=synthetizeTable(analyzedTeam1, initialYear,finalYear) --table formated, global
local analyzedTeam2=analyzeTeam(teamRider, initialYear,finalYear, "mountainBike")
local _, teamMountainBike=synthetizeTable(analyzedTeam2, initialYear,finalYear)
local analyzedTeam3=analyzeTeam(teamRider, initialYear,finalYear, "cycloCross")
local _, teamCycloCross=synthetizeTable(analyzedTeam3, initialYear,finalYear)
local analyzedTeam4=analyzeTeam(teamRider, initialYear,finalYear, "track")
local _, teamTrack=synthetizeTable(analyzedTeam4, initialYear,finalYear)
return teamAmateur,teamPro, teamMountainBike, teamCycloCross, teamTrack
end
 
function getBirthDeathDate(entityID)
local birthDate=firstValue(entityID, 'P569', 'time')
local deathDate=firstValue(entityID, 'P570', 'time')
local temp2, temp3, birth, death, initialYear, finalYear, age
 
if birthDate then
local birthDateFormatted= funcDate(birthDate, 'long')
age, initialYear, finalYear=calculateAge(birthDate)
local birthPlace = firstValue(entityID, 'P19', 'id')
local birthPlaceLink=''
if birthPlace then birthPlaceLink=getPlaceLink(birthPlace, birthDate) end
 
local plural, gen_singular, gen_plural = plural(age)
local ans
if gen_singular then
ans=translate("riderinfobox",48)
elseif gen_plural then
ans=translate("riderinfobox",49)
else
ans=translate("riderinfobox",50)
end
 
if not deathDate then
temp2=' ('..tostring(age)..' '..ans..')<br/>'
else
temp2='<br/>'
end
birth=birthDateFormatted..temp2..birthPlaceLink
else
birth=nil
end
if deathDate then
local deathDateFormatted= funcDate(deathDate, 'long')
local deathPlace= firstValue(entityID, 'P20', 'id')
local deathPlaceLink=''
if deathPlace then deathPlaceLink=getPlaceLink(deathPlace, deathDate) end
if birthDate then
local age=calculateAge(birthDate, deathDate)
local plural, gen_singular, gen_plural = plural(age)
local ans
if gen_singular then
ans=translate("riderinfobox",48)
elseif gen_plural then
ans=translate("riderinfobox",49)
else
ans=translate("riderinfobox",50)
end
temp2=' ('..tostring(age)..' '..ans..')<br/>'
else
temp2='<br/>'
end
 
death=deathDateFormatted..temp2..deathPlaceLink
else
death=nil
end
 
return birth, death, initialYear, finalYear
end
 
local function presentTeam(itemID)
local tToday=os.date("*t")
if mw.ustring.len(tToday["month"])==1 then tToday["month"]='0'..tToday["month"] end
if mw.ustring.len(tToday["day"])==1 then tToday["day"]='0'..tToday["day"] end
local today='+'..tToday["year"].."-"..tToday["month"].."-"..tToday["day"].."T00:00:00Z"
local plural=false
local teamId, result, teamLink, teamLinkRoad, row
 
for _, s in statements(itemID, 'P54') do
p54 =checktime(s, s.qualifiers, today) --present Team
if p54 then
teamId= p54.mainsnak.datavalue.value.id
teamLink=getTeamLinkCat(teamId, today)
dis=checkDis(p54.qualifiers)
row=nil
if dis=='road' then
teamLinkRoad=teamLink
elseif dis=='mountainBike' then
row=teamLink..' (VTT)'
elseif dis=='cycloCross' then
row=teamLink..' (cyclo-cross)'
else
row=teamLink..' (piste)'
end
if row then
if not result then
result = row
else
result= result..'<br/>'..row
plural = true
end
end
end
end
if teamLinkRoad and result then --put road first
result = teamLinkRoad..' (route)<br/>'..result
plural= true
elseif teamLinkRoad then
result = teamLinkRoad
end
return result, plural
end
 
local function getSomeNames(details,entityID, PID, index, display_language)
local rows={}
if not details[index].content then
local listOfNames=getFormerNames(entityID, PID)
if listOfNames then
for _, v in pairs(listOfNames) do
rows[#rows + 1]=v[3]
if v[2] and v[2]~='' then
rows[#rows]=rows[#rows]..' <small>('..v[2]..')</small>'
end
if display_language then
rows[#rows]=rows[#rows]..' <b><small>('..v[4]..')</small></b>'
end
end
if #rows>0 then
details[index].content = table.concat(rows, '<br/>')
end
end
end
end
 
--for wikidata input
function teamTable(tab, teamAmateur, title_singular, title_plural)
if teamAmateur and #teamAmateur>0 then
if #teamAmateur==1 then
tab:node(addATitle(title_singular))
else
tab:node(addATitle(title_plural))
end
for _, v in pairs(teamAmateur) do
local nametemp=v['link']
if v['sDate']==v['eDate'] then
periodtemp=v['sDate']
else
periodtemp=v['sDate']..'-'..v['eDate']
end
if v['stagiaire'] then
local stagiaire = string.gsub(wikibase.label('Q2328847'), "%b()", "") or getLabelFallback('Q2328847',{'en', 'fr', 'de'})
nametemp=nametemp..' ('..stagiaire..')'
end
tab:node(addARow(periodtemp or '',nametemp)) --period, name
end
end
end
 
--for local data
function localTeamTable(tab, names, periods, title_singular, title_plural)
if names then
names = mw.text.split(names, '<br />')
periods = mw.text.split(periods or '', '<br />')
if #names==1 then
tab:node(addATitle(title_singular))
else
tab:node(addATitle(title_plural))
end
for i, name in pairs(names) do
tab:node(addARow(periods[i] or '', name))
end
end
end
 
local function dispArrayLabel(details, index, entityID, PID)
if not details[index].content then
for _, p in statements(entityID, PID) do
if p and p.mainsnak.snaktype == 'value' then
local label=wikibase.getLabelByLang(p.mainsnak.datavalue.value.id, wiki)
if label then
if not details[index].content then
details[index].content=label
else
details[index].content=details[index].content..'<br/>'..label
if details[index].name_plural then
details[index].name = details[index].name_plural
end
end
end
end
end
end
end
 
function p.riderinfobox(frame)
local frame = frame
local lang = contentLanguage
-- If true, winners will have Wikidata logos with link to Wikidata
local WDlink_on = (wiki == "mk" or wiki == "ja")
 
local localframe
if string.match(frame:getParent():getTitle(), '%P+') == mw.site.namespaces.Template.name then
localframe = frame:getParent()
else
localframe = frame
end
 
local details = {
{ name = translate("riderinfobox",1), name_plural =translate("riderinfobox",2)}, -- birth name
{ name = translate("riderinfobox",3), name_plural =translate("riderinfobox",4)}, -- nick name
{ name = translate("riderinfobox",5), name_plural =translate("riderinfobox",6)}, -- official name
{ name = translate("riderinfobox",7), name_plural =translate("riderinfobox",8)}, -- official name
{ name = translate("riderinfobox",9) }, -- birth translate("riderinfobox",9)
{ name = translate("riderinfobox",10)}, -- death
{ name = translate("riderinfobox",11), name_plural =translate("riderinfobox",12)}, -- country
{ name = translate("riderinfobox",13), name_plural =translate("riderinfobox",14)}, -- present team
{ name = translate("riderinfobox",15), name_plural =translate("riderinfobox",16)}, -- speciality
{ name = translate("riderinfobox",17) }, -- lateralisation
{ name = translate("riderinfobox",18) }, -- blood group
{ name = translate("riderinfobox",19) }, -- height
{ name = translate("riderinfobox",20) }, -- weight
{ name = translate("riderinfobox",21), name_plural =translate("riderinfobox",22)}, -- awards
}
local teams = {
{ name = translate("riderinfobox",23), name_plural =translate("riderinfobox",24)}, -- directed teams
{ name = translate("riderinfobox",25)}, -- directed years
{ name = translate("riderinfobox",26), name_plural =translate("riderinfobox",27)}, -- amateur names
{ name = translate("riderinfobox",28)}, -- amateur periods
{ name = translate("riderinfobox",29), name_plural =translate("riderinfobox",30)}, -- nonUCI names
{ name = translate("riderinfobox",31)}, -- nonUCI periods
{ name = translate("riderinfobox",32), name_plural =translate("riderinfobox",33)}, -- pro names
{ name = translate("riderinfobox",34)}, -- pro periods
{ name = translate("riderinfobox",35), name_plural =translate("riderinfobox",36)}, -- UCI names
{ name = translate("riderinfobox",37)}, -- UCI periods
{ name = translate("riderinfobox",52), name_plural =translate("riderinfobox",53)}, -- national selections
{ name = translate("riderinfobox",54)}, -- national selection years
}
 
--separated to have a title
local subtitle = {
{ name = translate("riderinfobox",51)}, -- insertion of a sub-title
}
--separated to have a title
local victories = {
{ name = translate("riderinfobox",38)}, -- main victories
}
--separated to have a title
local medals = {
{ name = translate("riderinfobox",47)}, -- main victories
}
 
local others = {
{ name = translate("infobox",29)}, -- picture
{ name = translate("infobox",30)}, -- caption
{ name = translate("infobox",31)}, -- map
{ name = 'sectional'}, -- sectional
{ name = translate("infobox",30)}, -- caption map
{ name = translate("infobox",30)}, -- caption sectional
}
 
local entityID = mw.text.trim(frame.args[1])
if type(entityID) ~= 'string' then error('parameter must be a string') end
if not entityID:match('Q%d+') then error('parameter must be a valid Wikidata item (ex: Q42)') end
 
local name = getLabelFallback(entityID, {wikilang, 'en', 'fr', 'de'}) or ''
 
local display_birthnameastitle=false
for _, value in pairs(display_birthnameastitle_in_riderinfobox) do -- get data if country should be printed in this wiki
if value == wiki then display_birthnameastitle=true end
end
getLocalContent(subtitle, localframe.args)
if not subtitle[1].content and display_birthnameastitle then
local p1477 = mw.wikibase.getBestStatements(entityID, "P1477")
if p1477[1] and p1477[1].mainsnak.snaktype == 'value' then
subtitle[1].content = p1477[1].mainsnak.datavalue.value.text..' <b><small>('..
p1477[1].mainsnak.datavalue.value.language..')</small></b>'
end
if not subtitle[1].content then
local p1559 = mw.wikibase.getBestStatements(entityID, "P1559") -- P580 is start time
if p1559[1] and p1559[1].mainsnak.snaktype == 'value' then
subtitle[1].content = p1559[1].mainsnak.datavalue.value.text..' <b><small>('..
p1559[1].mainsnak.datavalue.value.language..')</small></b>'
end
end
end
local commons_cat=firstValue(entityID, 'P373', 'id')
infoGetOthers(others, entityID)
 
getLocalContent(details, localframe.args)
getLocalContent(teams, localframe.args)
getLocalContent(others, localframe.args)
getLocalContent(victories, localframe.args)
getLocalContent(medals, localframe.args)
 
local listOfBirthNames, listOfNickNames, listOfOfficialNames, listOfShortNames
local icon = ' [[File:Cycling (road) pictogram.svg|35px]]'
 
local display_language=false
for _, value in pairs(display_language_in_riderinfobox) do -- get data if country should be printed in this wiki
if value == wiki then display_language=true end
end
 
-- getSomeNames(details, entityID, 'P1477', 1, display_language) --birthname
--less prio than P1477
getSomeNames(details, entityID, 'P1559', 1, display_language) --birthname, bis
getSomeNames(details, entityID, 'P1449', 2, display_language) --nick name
getSomeNames(details, entityID, 'P1448', 3, display_language) --official name
getSomeNames(details, entityID, 'P1813', 4, display_language) --short name
 
local birth, death, initialYear, finalYear=getBirthDeathDate(entityID)
if not details[5].content then
details[5].content=birth
end
if not details[6].content then
details[6].content= death
end
 
local display_flag=false
for _, value in pairs(display_flag_in_riderinfobox) do -- get data if country should be printed in this wiki
if value == wiki then display_flag=true end
end
 
if not details[7].content then
local listOfProperty={'P1532','P27'}
local countryID
local countryList={}
for _, prop in ipairs(listOfProperty) do
if #countryList==0 then --if P1532 is used P17 is not used
for _, p1532 in statements(entityID, prop) do
countryID = p1532.mainsnak.datavalue.value.id
local period, sTime=getPeriod( p1532.qualifiers, true)
if not sTime then sTime="+"..initialYear.."-01-01T00:00:00Z" end --first
local temp
if display_flag then
temp= flag(countryID, sTime).." "..getCountryName(countryID)
else
temp=getCountryName(countryID)
end
table.insert(countryList,{sTime, period,temp})
end
end
end
table.sort(countryList, function(a, b) return a[1] < b[1] end)
if countryList and #countryList==1 then
details[7].content=countryList[1][3]
elseif countryList then
details[7].name = details[7].name_plural
details[7].content=''
for _, v in pairs(countryList) do
details[7].content= details[7].content..v[3] ..' <small>'..v[2]..'</small><br/>'
end
end
end
 
if not details[8].content then
local plural
details[8].content, plural=presentTeam(entityID)
if plural then
details[8].name = details[8].name_plural
end
end
 
--speciality
dispArrayLabel(details, 9, entityID, 'P413')
 
--lateralisation, for cycling not very interesting
--dispArrayLabel(details, 10, entityID, 'P552')
 
--blood group, idem
--dispArrayLabel(details, 11, entityID, 'P1853')
 
--height
if not details[12].content then
details[12].content=getHeight(entityID)
end
 
local display_weight=true
for _, value in pairs(display_noweight_in_riderinfobox) do -- get data if country should be printed in this wiki
if value == wiki then display_weight=false end
end
--weight
if not details[13].content and display_weight then
details[13].content=getWeight(entityID)
end
 
--award, should be table
--awards look weird
--if not details[14].content then
-- dispArrayLabel(details, 14, entityID, 'P166')
--end
 
local amateurTeam, nonUCITeam, proTeam, UCITeam --local data
local amateurWD=true
local proWD=true
local managedWD=true
local teamAmateur,teamPro, teamMountainBike, teamCycloCross, teamTrack=listOfTeamTable(entityID, initialYear, finalYear)
local nationalTeam, managedTeam=listOfManagedTeamTable(entityID, initialYear, finalYear)
local managedTeam_names, managedTeam_periods, amateurTeam_names, amateurTeam_periods
local nonUCITeam_names, nonUCITeam_periods, proTeam_names, proTeam_periods
local nationalTeam_names, nationalTeam_periods
local UCITeam_names, UCITeam_periods
 
if teams[1].content then
managedTeam_names=teams[1].content
managedTeam_periods=teams[2].content
managedWD=false
end
 
if teams[3].content then
amateurWD=false
amateurTeam_names=teams[3].content
amateurTeam_periods=teams[4].content
end
if teams[5].content then
amateurWD=false
nonUCITeam_names=teams[5].content
nonUCITeam_periods=teams[6].content
end
 
if teams[7].content then
proWD=false
proTeam_names=teams[7].content
proTeam_periods=teams[8].content
end
if teams[9].content then
proWD=false
UCITeam_names=teams[9].content
UCITeam_periods=teams[10].content
end
if teams[11].content then
nationalTeam_names=teams[11].content
nationalTeam_periods=teams[12].content
managedWD=false
end
 
--plate and grab
tab = infoInitTab("300px", name, icon, 2)
if subtitle[1].content then
tCell=tab:tag('tr'):tag('td'):attr('colspan','2')
:cssText('solid white; text-align:center')
:wikitext(subtitle[1].content)
end
 
infoFillOthersDetails(tab, others, details,"Information","260px")
if amateurWD then
teamTable(tab, teamAmateur, translate("riderinfobox",26), translate("riderinfobox",27))
else
localTeamTable(tab,amateurTeam_names, amateurTeam_periods, translate("riderinfobox",26), translate("riderinfobox",27))
localTeamTable(tab,nonUCITeam_names, nonUCITeam_periods, translate("riderinfobox",29), translate("riderinfobox",30))
end
if proWD then
teamTable(tab, teamPro, translate("riderinfobox",45),translate("riderinfobox",46))
teamTable(tab, teamMountainBike, translate("riderinfobox",39), translate("riderinfobox",40))
teamTable(tab, teamCycloCross, translate("riderinfobox",41), translate("riderinfobox",42))
teamTable(tab, teamTrack, translate("riderinfobox",43), translate("riderinfobox",44))
else
localTeamTable(tab,proTeam_names, proTeam_periods,translate("riderinfobox",45), translate("riderinfobox",46))
localTeamTable(tab,UCITeam_names, UCITeam_periods, translate("riderinfobox",35), translate("riderinfobox",36))
end
 
--managed teams
if managedWD then
teamTable(tab, nationalTeam, translate("riderinfobox",52), translate("riderinfobox",53))
teamTable(tab, managedTeam, translate("riderinfobox",23), translate("riderinfobox",24))
else
localTeamTable(tab,managedTeam_names, managedTeam_periods,translate("riderinfobox",23), translate("riderinfobox",24))
end
if victories[1].content then
tab:node(addATitle(translate("riderinfobox",38)))
tab:tag('tr'):tag('td')
:css('vertical-align','top'):attr('colspan','2')
:wikitext(victories[1].content)
end
if medals[1].content then
tab:node(addATitle(translate("riderinfobox",47)))
tab:tag('tr'):tag('td')
:css('vertical-align','top'):attr('colspan','2')
:wikitext(medals[1].content)
end
wdDoc(tab, "d:Wikidata:WikiProject Cycling/Documentation/riderinfobox", translate("raceinfobox",26), entityID,commons_cat)
return tab
end
 
function p.testlocal(frame) --function to test local functions
local function_name=frame.args[1]
local argu=frame.args
local temp, temp2
 
 
if function_name=='firstValue' then
return firstValue(argu[2],argu[3],argu[4])
elseif function_name=='getOfficialName' then
return getOfficialName(argu[2],argu[3],argu[4])
elseif function_name=='getRiderLink' then
temp=getRiderLink(argu[2],argu[3]) --only first arg returned
return temp
elseif function_name=='funcDate' then
return funcDate(argu[2],argu[3])
elseif function_name=='getTeam' then
temp=getTeam(argu[2],argu[3],argu[4])
if temp then return temp else return 'nil' end
elseif function_name=='getStatementForTime' then
temp=getStatementForTime(argu[2],argu[3],argu[4])
if temp then
return temp.mainsnak.datavalue.value.id
else
return 'nil'
end
elseif function_name=='getTeamLinkCat' then
temp=getTeamLinkCat(argu[2],argu[3],toboolean(argu[4]),toboolean(argu[5]))
if temp then return temp else return 'nil' end
elseif function_name=='seasonToTeamID' then
if argu[2]=="nil" then arg2=nil else arg2=argu[2] end
return tostring(seasonToTeamID(arg2))
elseif function_name=='translate' then
return translate(argu[2],tonumber(argu[3]))
elseif function_name=="classLinkFn" then
return classLinkFn(argu[2])
elseif function_name=='raceLink' then
return tostring(raceLink(argu[2]))
elseif function_name=='getMainRaceLink' then
if argu[5]=="nil" then arg5=nil else arg5=argu[5] end
return tostring(getMainRaceLink(argu[2],argu[3],argu[4], arg5,argu[6]))
elseif function_name=='fn_getClassInfo1' then
local temp= fn_getClassInfo(argu[2],argu[3],nil)
return temp[1]
elseif function_name=='fn_getClassInfo2' then
local temp= fn_getClassInfo(argu[2],argu[3],nil)
return temp[2]
elseif function_name=='fn_getClassInfo4' then
local temp= fn_getClassInfo(argu[2],argu[3],nil)
return temp[4]
elseif function_name=='getYear' then
return getYear(argu[2])
elseif function_name=='getCountryName' then
return tostring(getCountryName(argu[2]))
elseif function_name=='getTeamCodeCat' then
return tostring(getTeamCodeCat(argu[2],argu[3]))
elseif function_name=='getTeamCode' then
return tostring(getTeamCode(argu[2],argu[3],argu[4]))
elseif function_name=='getCountryBool' then
return tostring(getCountryBool({argu[2],argu[3]}))
elseif function_name=='WPlinkpure' then
return WPlinkpure(argu[2])
elseif function_name=='uciCodeCountry' then
return uciCodeCountry(argu[2])
elseif function_name=='isHuman' then
return tostring(isHuman(argu[2]))
elseif function_name=='isCountry' then
return tostring(isCountry(argu[2]))
elseif function_name=='commaStage' then
temp =commaStage(argu[2],argu[3])
return temp[1]
elseif function_name=='number' then
return number(argu[2],tonumber(argu[3]), argu[4])
elseif function_name=='classToCircuit1' then
temp, temp2= classToCircuit(argu[2], argu[3], argu[4], toboolean(argu[5]), nil)
return temp
elseif function_name=='classToCircuit2' then
temp, temp2= classToCircuit(argu[2], argu[3], argu[4], toboolean(argu[5]), nil)
return temp2
elseif function_name=='getGenderCode' then
return tostring(getGenderCode(argu[2], argu[3]))
elseif function_name=='calculateTime' then
return calculateTime(argu[2])
elseif function_name=='getClass1' then
temp, temp2 = getClass(argu[2])
return temp
elseif function_name=='getClass2' then
temp, temp2 = getClass(argu[2])
return temp2
elseif function_name=='infoGetPlace' then
local details = {{ name = "test", name_plural="tests"}} -- course / not used
infoGetPlace(details,1, argu[2], argu[3], argu[4])
return details[1].content
elseif function_name=='getFormerNames1' then
temp=getFormerNames(argu[2],'P1448')
if temp[1] then
return temp[1][2] --period
else
return ""
end
elseif function_name=='getFormerNames2' then
temp=getFormerNames(argu[2],'P1448')
if temp[1] then
return temp[1][3] --name
else
return ""
end
elseif function_name=='getType' then
return getType(argu[2])
elseif function_name=='compareDate' then
return tostring(compareDate(argu[2]))
elseif function_name=='officialSite' then
return officialSite(argu[2])
elseif function_name=='trans' then
return tostring(trans(argu[2], argu[3], argu[4]))
elseif function_name=='parseDate1' then
temp1, temp2, temp3, temp4, temp5= parseDate(argu[2], argu[3], argu[4], argu[5], "", "error text")
return temp1
elseif function_name=='parseDate2' then
temp1, temp2, temp3, temp4, temp5= parseDate(argu[2], argu[3], argu[4], argu[5], "", "error text")
return temp2
elseif function_name=='parseDate5' then
temp1, temp2, temp3, temp4, temp5= parseDate(argu[2], argu[3], argu[4], argu[5], "", "error text")
return temp5
elseif function_name=='findLastName' then
return findLastName(argu[2],wiki)
elseif function_name=='findSortKey' then
if wiki=="ru" or wiki=="mk" then
return findSortKey(argu[2],false, true)
else
return findSortKey(argu[2],true, false)
end
elseif function_name=='calculateAge' then
temp1, _, _ =calculateAge(argu[2])
return temp1
elseif function_name=='getBirthDeathDate1' then
temp1, temp2 = getBirthDeathDate(argu[2])
return temp1
elseif function_name=='getBirthDeathDate2' then
temp1, temp2 = getBirthDeathDate(argu[2])
return temp2
elseif function_name=='getLocalContent' then
local details = {
{ name = argu[2], name_plural= argu[3]}
}
local arguments = {}
arguments[argu[4]]="test"
 
getLocalContent(details, arguments)
return details[1].content
elseif function_name=='plural1' then
_, temp1, temp2=plural(tonumber(argu[2]))
return temp1
elseif function_name=='plural2' then
_, temp1, temp2=plural(tonumber(argu[2]))
return temp2
end
end
 
function p.test_import(frame)
local function_name=frame.args[1]
local argu=frame.args
 
if function_name=='class' then
return tostring(class[tonumber(argu[2])])
elseif function_name=='class_2x' then
return tostring(class_2x[tonumber(argu[2])])
elseif function_name=='class_without2x' then
return tostring(class_without2x[tonumber(argu[2])])
elseif function_name=="class_sort" then
return tostring(class_sort[argu[2]])
elseif function_name=='classes' then
return tostring(classes[argu[2]])
elseif function_name=='stages' then
return tostring(stages[tonumber(argu[2])])
elseif function_name=='bg_color_table' then
local temp = bg_color_table[argu[2]]
temp=string.gsub(temp,'#',"")
return temp
end
end
 
return p