Diferència entre revisions de la pàgina «Mòdul:Cycling race»

update
(fix prologue)
(update)
flag_table = {}
wiki = string.match(mw.site.server, "%a+")
if wiki == "www" then available, translations = pcall( require, "Module:Cycling race-WD" )
wiki = "fr"
else available, translations = pcall( require, "Module:Cycling race/lang" )
onwikidata = true
else
onwikidata = false
end
 
-- Classes declared as global --
-- Class of a cycling race. Class is: 1.UWT, 2.UWT, 1.HC, ... add new classes, no problem
class = { "Q22231106", "Q22231107", "Q22231108", "Q22231109", "Q22231110", "Q22231111", "Q22231112",
"Q22231113", "Q22231114", "Q22231115", "Q22231116", "Q22231117", "Q22231118", "Q22231119", "Q23015458", "Q23005601", "Q23005603" }
class_2x = {"Q22231107", "Q23005603", "Q22231115", "Q22231109", "Q22231112", "Q22231113", "Q22231117"} --multi stage races
class_sort={["Q22231106"]='01', ["Q22231107"]='01', ["Q23005601"]='01', ["Q23005603"]='01', ["Q22231115"]='01', -- 1.UWT, 2.UWT, 1.WWT, 2.WWT, 2.Ncup
["Q22231114"]='02', ["Q22231109"]='03', ["Q22231108"]='04', ["Q22231112"]='05', ["Q22231110"]='06', -- 1.Ncup, 2.HC, 1.HC, 2.1, 1.1
["Q22231113"]='07', ["Q22231117"]='07', ["Q22231111"]='08', ["Q22231116"]='08', ["Q22231119"]='09', --2.2, 2.2U, 1.2, 1.2U, CN
["Q22231118"]='13', ["Q23015458"]='15' }
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
UCI_Circuits = {'Q1194340', 'Q1063423', 'Q1063430', 'Q268357', 'Q1039648', 'Q1329578', 'Q12270097', 'Q635366', 'Q21075974', 'Q1693153'}
 
 
 
 
available, translations = pcall( require, "Module:Cycling race/lang" )
if available == true and type( translations.list ) == "function" then available_list = true else available_list = false end
if available == true and type( translations.lang_priority ) == "table" then available_lang_priority = true else available_lang_priority = false end
 
local textalign = "left"
local floattable = "left"
local floatinfobox = "right"
if wiki == "ar" or wiki == "fa" or wiki == "ur" then
textalign = "right"
floattable = "right"
floatinfobox = "left"
end
function race_reference_translate(wiki, x)
local l10nDef = { }
l10nDef["fr"] = {"Source : ", "Sources : "}
l10nDef["en"] = {"Source: ", "Sources: "}
l10nDef["de"] = {"Quelle: ","Quellen: "}
l10nDef["da"] = {"Kilde: ","Kilder: "}
l10nDef["es"] = {"Fuente: ","Fuentes: "}
local l10n = l10nDef[wiki]
if not l10n then l10n = l10nDef["fr"] end -- default
return l10n[x]
end
 
function victories_translaterace_reference(wiki,xentity)
-- Allow to display the reference below the classifications --
l10nDef["fr"] = {"Date", "Course", "Pays", "Classe", "Vainqueur"}
local bases={
l10nDef["en"] = {"Date", "Race", "Country", "Class", "Winner"}
{"ProCyclingStats", "P2327", "http://www.procyclingstats.com/race.php?id="},
l10nDef["da"] = {"Dato", "Løb", "Land", "Klasse", "Vinder"}
{"Cycling Quotient", "P2648", "http://www.cqranking.com/men/asp/gen/race.asp?raceid="},
l10nDef["es"] = {"Fecha", "Carrera", "País", "Clase", "Ganador"}
{"Cycling Archives", "P2330", "http://www.siteducyclisme.net/ritfiche.php?ritid="},
l10nDef["ja"] = {"開催日", "レース", "国", "国", "勝者"}
{"Cycling Quotient", "P2708", "http://www.cqranking.com/women/asp/gen/race.asp?raceid="}
l10nDef["mk"] = {"Датум", "Трка", "Земја", "Класа", "Победник"}
}
l10nDef["no"] = {"Dato", "Løp", "Land", "Klasse", "Vinner"}
local linklist =''
local a,b
for i, base in pairs(bases) do
a, b =pcall(fooA, 'value', entity, base[2], 1) -- --
if a==true and b~=nil then
if linklist=='' then
linklist_singular=race_reference_translate(wiki, 1)..'['..base[3]..b.." "..base[1]..']'
linklist_plural=race_reference_translate(wiki, 2)..'['..base[3]..b.." "..base[1]..']'
linklist=linklist_singular
else
linklist_plural=linklist_plural..", "..'['..base[3]..b.." "..base[1]..']'
linklist=linklist_plural
end
end
end
return linklist
end
 
function Calendar_translate(wiki, x)
local l10nDef = { }
l10nDef["ar"] = { "تقويم الاتحاد الدولي للدراجات", "التاريخ", "#", "السباق", "البلد", "الصنف", "الفائز", "الثاني", "الثالث", "متصدر الترتيب العام", "طواف العالم للدراجات للنساء", "", "طواف العالم للدراجات" , "طواف أوروبا للدراجات" , "طواف آسيا للدراجات" , "طواف أمريكا للدراجات" , "طواف أفريقيا للدراجات" , "طواف أوقيانوسيا للدراجات", "بطولات وطنية", "سباق الطريق", "سباق فردي ضد الساعة" }
l10nDef["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"}
l10nDef["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"}
l10nDef["de"] = {"UCI Kalender", "Datum", "Nr.","Rennen", "Staat", "Klasse", "Sieger", "Zweiter", "Dritter", "Gesamt­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"}
l10nDef["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"}
l10nDef["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"}
l10nDef["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"}
l10nDef["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"}
l10nDef["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"}
l10nDef["no"] = {"", "Dato", "#","Ritt", "Land", "Klasse", "Vinner","Andreplass", "Tredjeplass", "Sammenlagt­leder","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","Landevei","Tempo"}
l10nDef["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["fr"] end -- default
if x==1000 then --code
return title
else
return l10n[x]
end
end
 
function p.calendarcustom(frame)
----- function to display calendar óf any competition -----
----- based on victories function -----
----- author: psemdel -----
local countryflagonlytemp, numberingtemp, displayclasstemp,onlywinnertemp
local displayteamtemp, displayleadertemp
local headertemp={}
local data_typetemp={}
local ll=1
 
if frame.args[1] ~= nil then
calendarID= string.gsub(frame.args[1], "%c", "")
end
--date
headertemp[ll]=2
data_typetemp[ll] = ''
ll=ll+1
if frame.args[2] ~= nil then
if tonumber(frame.args[2]) ==1 then
numberingtemp =true
headertemp[ll]=3
data_typetemp[ll] = ''
ll=ll+1
else
numberingtemp =false
end
else
numberingtemp=false
end
 
if frame.args[3] ~= nil then
if tonumber(frame.args[3]) ==1 then
countryflagonlytemp =false
else
countryflagonlytemp =true
end
else
countryflagonlytemp=true
end
-- country --
headertemp[ll]=5
data_typetemp[ll] = ''
ll=ll+1
 
--race--
headertemp[ll]=4
data_typetemp[ll] = ''
ll=ll+1
 
if frame.args[4] ~= nil then
if tonumber(frame.args[4]) ==1 then
displayclasstemp =true
headertemp[ll]=6
data_typetemp[ll] = ''
ll=ll+1
else
displayclasstemp =false
end
else
displayclasstemp =false
end
 
if frame.args[5] ~= nil then
if tonumber(frame.args[5]) ==1 then
onlywinnertemp =false
headertemp[ll]=7
data_typetemp[ll] = ''
ll=ll+1
headertemp[ll]=8
data_typetemp[ll] = ''
ll=ll+1
headertemp[ll]=9
data_typetemp[ll] = ''
ll=ll+1
else
onlywinnertemp =true
headertemp[ll]=7
data_typetemp[ll] = ''
ll=ll+1
end
else
onlywinnertemp=true
headertemp[ll]=7
data_typetemp[ll] = ''
ll=ll+1
end
if frame.args[6] ~= nil then
if tonumber(frame.args[6]) ==1 then
displayleadertemp=true
headertemp[ll]=10
data_typetemp[ll] = ''
ll=ll+1
else
displayleadertemp =false
end
else
displayleadertemp =false
end
 
if frame.args[7] ~= nil then
if tonumber(frame.args[7]) ==1 then
displayteamtemp =true
else
displayteamtemp =false
end
else
displayteamtemp =false
end
 
local entity = mw.wikibase.getEntityObject( calendarID )
local titletemp=entity:getLabel()
 
local s = {
header_function = Calendar_translate, -- translations are in function victories_translate
header_1 = 1000, -- translation 1 in function victories_translate is printed in the upper part of the table header
header_2 = headertemp,-- translations 2, 3, 4, 5, 6 in function victories_translate are printed in this order
title=titletemp, -- in the lower part of the table header. The second value 3 in {4, 3} tells where the icon will go.
country_column = 2,
flag_column = 2,
data_sort_type = data_typetemp, -- see https://meta.wikimedia.org/wiki/Help:Sorting
item = calendarID,
property = 'P527',
no_country = {},
country = true,
countryflagonly=countryflagonlytemp,
error_message = 0,
country = true,
only_winner = onlywinnertemp,
numbering = numberingtemp,
error_message = 0,
displayed_class =nil,
displayteam=displayteamtemp,
displayclass=displayclasstemp,
leadercolumn=displayleadertemp,
}
return tableA(s, calendar_main(s))
end
 
function p.calendar(frame)
----- function to display UCI calendar of one year ----
----- based on WWTcalendar function -----
----- author: Mr. Ibrahem -----
local calendarID = ""
if wiki == "ar" then
frame = frame:getParent()
end
UCI = {}
UCI["WT"] = { -- Q635366
['2018'] = 'Q42317185',['2017'] = 'Q21857932',['2016'] = 'Q20970765',
['2015'] = 'Q18192726',['2014'] = 'Q14979277',['2013'] = 'Q1031504',
['2012'] = 'Q849059', ['2011'] = 'Q849092'
}
UCI["europe"] = { -- Q1194340
['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
['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
['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
['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
['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"] = {
['2018'] = 'Q41787783', ['2017'] = 'Q27431192', ['2016'] = 'Q21034783',
}
UCI["women"] = {
['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',
}
 
header_1_tab = {["WT"]=13 ,["europe"]=14 ,["asia"]=15,["america"]=16 ,["africa"]=17 ,["oceania"]=18, ["WWT"]=11, ["women"]=1}
header_1_number = 12
display_code_tab ={["WT"]=1 ,["europe"]=2 ,["asia"]=2,["america"]=2 ,["africa"]=2 ,["oceania"]=2, ["WWT"]=1, ["women"]=2}
--Can depends on the wiki
header_2_tab_code1= {2, 3,5, 4, 7, 8, 9, 10}
header_2_tab_code2= {2, 5, 4, 6, 7}
data_sort_type_code1={'', 'unsortable', '', '', '','',''}
data_sort_type_code2={'', 'unsortable', '', '', '','',''}
only_winner_code1 = false
only_winner_code2 = true
numbering_code1= true
numbering_code2=false
displayteam_code1=false
displayteam_code2=true
displayclass_code1=false
displayclass_code2=true
leadercolumn_code1=true
leadercolumn_code2=false
for key, v in pairs(UCI) do
if calendarID == "" and frame.args[key] then
--mw.log("find arg " .. key)
year = frame.args[key]
year = string.gsub( year , "%c", "")
if v[year] then
calendarID = v[year]
header_1_number = header_1_tab[key]
display_code=display_code_tab[key]
end
end
end
if wiki == "ar" and calendarID == "" then
return ""
end
if display_code==1 then
header_2temp= header_2_tab_code1
data_sort_typetemp=data_sort_type_code1
only_winnertemp=only_winner_code1
numberingtemp=numbering_code1
displayteamtemp=displayteam_code1
displayclasstemp=displayclass_code1
leadercolumntemp=leadercolumn_code1
else
header_2temp= header_2_tab_code2
data_sort_typetemp=data_sort_type_code2
only_winnertemp=only_winner_code2
numberingtemp=numbering_code2
displayteamtemp=displayteam_code2
displayclasstemp=displayclass_code2
leadercolumntemp=leadercolumn_code2
end
 
local s = {
header_function = Calendar_translate, -- translations are in function victories_translate
header_1 = header_1_number, -- translation 12 in function victories_translate is empty
header_2 = header_2temp,-- translations 2, 3, 4, 5, 6 in function victories_translate 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.
country_column = 2,
flag_column = 2,
data_sort_type ={'', 'unsortable', '', '', '','',''}, -- -- see https://meta.wikimedia.org/wiki/Help:Sorting
item = calendarID,
property = 'P527',
no_country = {},
country = true,
countryflagonly=true,
only_winner = only_winnertemp,
numbering = numberingtemp,
error_message = 0,
displayed_class = {
"Q23005603", --
"Q22231110", -- 1.1
"Q22231109", -- 2.HC
"Q22231111", -- 1.2
"Q22231108", -- 1.HC
"Q22231106", -- 1.UWT
"Q22231107", -- 2.UWT
"Q22231113", -- 2.2
"Q22231112", -- 2.1
"Q22231113", -- 2.2
"Q22231109", -- 2.HC
"Q22231118", -- CC
},
displayteam=displayteamtemp,
displayclass=displayclasstemp,
leadercolumn=leadercolumntemp
}
return tableA(s, calendar_main(s))
end
 
function calendar_main(s)--Display the UCI women calendar of one year, function similar to listofwinners
local calendarID=s.item
local h = {}
local country = s.country
local countryflagonly= s.countryflagonly
local sortkey, sortkey_class
local tBody = ''
local tableBody, sortindex = {}, {}
local a1, b1, c1
local timeofrace
local displayed_class
local displayteam
local numbering
if displayed_class==nil then
displayed_class=class
else
displayed_class=s.displayed_class
end
displayteam=s.displayteam
displayclass=s.displayclass
numbering=s.numbering
----- Test if everything is fine -----
_, _, s.item = string.find(s.item, "(%w+)")
local entity = mw.wikibase.getEntityObject( s.item )
pcall(function() test = entity.claims[s.property][1].mainsnak.snaktype end)
if test == 'somevalue' or test == 'novalue' then s.error_message = 2 return '' end
if pcall(function() test = entity.claims[s.property][1].mainsnak.datavalue.value['numeric-id'] end)
then else s.error_message = 1 return ''
end
for _, value in pairs(s.no_country) do -- get data if country should be printed in this wiki
if value == wiki then country = false end
end
--------- Definition local functions ------
function fn_date(h,entity_race) --write all the end of the race
local i
sortkey=''
--first look for end date
for _,property in ipairs({"P582"}) do
-- give time dates, when property 'point in time', 'start time' or 'end time' is used
d1, e1, f1 = pcall(fooA, 'time', entity_race, property, 1)
if d1 == true and h['endtime'] == '' then i = 1
while d1 == true and c1 == 'deprecated' do
i = i + 1
d1, e1, f1 = pcall(fooA, 'time', entity_race, property, i)
end
local _, _, y, m, d = string.find(e1, "(%d+)%p(%d+)%p(%d+)")
if m ~= '00' and d =='00' then h['time'] = mw.language.getContentLanguage():formatDate("M", '+'..y.."-"..m.."-31")
elseif m == '00' and d =='00' then h['endtime'] = ''
else h['endtime'] = func_date (e1, 'small')
end
break
end
end
for _,property in ipairs({"P585","P580"}) do
-- give time dates, when property 'point in time', 'start time' or 'end time' is used
a1, b1, c1 = pcall(fooA, 'time', entity_race, property, 1)
if a1 == true and h['time'] == '' then i = 1
while a1 == true and c1 == 'deprecated' do
i = i + 1
a1, b1, c1 = pcall(fooA, 'time', entity_race, property, i)
end
local _, _, y, m, d = string.find(b1, "(%d+)%p(%d+)%p(%d+)")
if m ~= '00' and d =='00'
then
sortkey = y..m..'32' h['time'] = mw.language.getContentLanguage():formatDate("M", '+'..y.."-"..m.."-31")
if wiki == "ar" then sortkey = y..m..'32' h['time'] = mw.language.getContentLanguage():formatDate("F", '+'..y.."-"..m.."-31") end
elseif m == '00' and d =='00' then sortkey = y..'12'..'32' h['time'] = ''
else sortkey = y..m..d
if h['endtime']=='' then --if no end date then show the month
h['time'] = func_date (b1, 'small')
else --otherwise only day
h['time'] = func_date (b1, 'onlyday')--d
end
end
timeofrace = b1
break
end
end
if h['endtime']=='' then
return '<td data-sort-value="'..sortkey.. '" style="text-align:right;padding:0 0.5em">'..h['time'].. '</td>'
else
return '<td data-sort-value="'..sortkey.. '" style="text-align:right;padding:0 0.5em">'..h['time'].."-"..h['endtime'].. '</td>'
end
end
 
local function fn2_country()
a,b = timeStartEnd(h['raceID'], "P17", 'numeric-id', timeofrace)
h['countryID'] = 'Q'..b
if available_list == true and country == true then
if type( translations.list ) == "function" then h['countryName'] = translations.list('Q'..b) h['countryID'] = 'Q'..b end
if h['countryName'] == '' then
local country = mw.wikibase.getEntityObject( 'Q'..b )
h['countryName'] = country:getLabel() or country:getLabel('en') .. ' (en)'
end
end
--no stage in UCI calendar
end
 
local function fn_country(h)
local str
if available_list==true and country == true then
fn2_country()
if countryflagonly==true then
h['countryName'] = '' --go to the case only flag
end
if h['countryID'] ~= '' and h['countryName'] ~= '' then str = '<td style="text-align:' .. textalign .. ';padding:0 0.5em data-sort-value="'..h['countryName'].. '>'..flag(h['countryID'], timeofrace).. ' '.. h['countryName'].. '</td>'
elseif h['countryID'] == '' and h['countryName'] ~= '' then str = '<td style="text-align:' .. textalign .. ';padding:0 0.5em data-sort-value="'..h['countryName'].. '>'.. ' '.. h['countryName'].. '</td>'
elseif h['countryID'] ~= '' and h['countryName'] == '' then str = '<td style="text-align:' .. textalign .. ';padding:0 0.5em data-sort-value="'..'0'.. '>'..flag(h['countryID'], timeofrace).. '</td>'
elseif h['countryID'] ~= '' and h['countryName'] ~= '' then str = '<td style="text-align:' .. textalign .. ';padding:0 0.5em data-sort-value="'..h['countryName'].. '>'.. ' '.. '</td>'
end
else str = ''
end
return str
end
 
local function fn_race(h)
local str, a, b, a1, b1, a2, b2, a3, b3
local label_x = ''
local entity_x1
local Sitelink_x, Sitelink_x0, Sitelink_x1, Sitelink_x2 = '', '', ''
local entity_race = mw.wikibase.getEntityObject( h['raceID'] )
local entity_type, entity_num = '', 0
local level = -1
local link
local multi_stage = false
a, b = pcall(fooA, 'numeric-id', entity_race, 'P31', 1)
--no stage race
if a == true then
-- test for 'no stage item' - item
a1, b1 = pcall(fooA, 'numeric-id', entity_race, 'P31', 1) -- first value for P31
a2, b2 = pcall(fooA, 'numeric-id', entity_race, 'P31', 2) -- second value for P31
if a1 == true and a2 == true then -- for two values
if "Q"..b1 == "Q22231119" or "Q"..b1 == "Q23015458" or "Q"..b1=="Q22231118" then entity_num = 2 entity_type = 'championship' end
if "Q"..b2 == "Q22231119" or "Q"..b2 == "Q23015458" or "Q"..b2=="Q22231118" then entity_num = 1 entity_type = 'championship' end
if entity_type == '' then
for i=1,#class do -- #class = number of elements in class
if "Q"..b1 == class[i] then
for ii=1,#class_2x do
if "Q"..b1 == class_2x[ii] then multi_stage = "Q"..b1 break end
end
entity_num = 2 entity_type = 'no stage item' break
end
if "Q"..b2 == class[i] then
for ii=1,#class_2x do
if "Q"..b2 == class_2x[ii] then multi_stage = "Q"..b2 break end
end
entity_num = 1 entity_type = 'no stage item' break
end
end
end
end
 
-- else A
if entity_type == '' and a1 == true and a2 == false then -- for one value
entity_type = 'else A'
end
-- else B
 
end
 
if entity_type == 'else A' then
local entity_l
a1, b1 = pcall(fooA, 'text', entity_race, 'P1448', 1) -- show the "official name"
if a1 == true then
local lang_WD, text_WD
for _,v in pairs(entity_race.claims["P1448"]) do
lang_WD = v.mainsnak.datavalue.value.language
text_WD = v.mainsnak.datavalue.value.text
if lang_WD == wiki or lang_WD == 'en' or lang_WD == 'fr' then label_x =text_WD break end
end
end
 
if label_x == '' then
a1, b1 = pcall(fooA, 'numeric-id', entity_race, 'P31', 1)
if a1 == true then
entity_l = mw.wikibase.getEntityObject( 'Q'..b1 )
label_x = entity_l:getLabel( ) or
entity_l:getLabel( 'en' ) or
entity_l:getLabel( 'de' ) or
entity_l:getLabel( 'fr' ) or ''
end
end
if entity_l~= nil then Sitelink_x1 = entity_l:getSitelink(wiki..'wiki') end
if entity_race~= nil then Sitelink_x0 = entity_race:getSitelink(wiki..'wiki') end
if Sitelink_x0 ~= nil then Sitelink_x = Sitelink_x0 level = 0
elseif Sitelink_x1 ~= nil then Sitelink_x = Sitelink_x1 level = 1
end
end
 
if entity_type == 'no stage item' then
a1, b1 = pcall(fooA, 'numeric-id', entity_race, 'P31', entity_num)
if a1 == true then
entity_l = mw.wikibase.getEntityObject( 'Q'..b1 )
label_x = entity_l:getLabel( ) or
entity_l:getLabel( 'en' ) or
entity_l:getLabel( 'de' ) or
entity_l:getLabel( 'fr' ) or ''
end
if entity_l~= nil then Sitelink_x1 = entity_l:getSitelink(wiki..'wiki') end
if entity_race~= nil then Sitelink_x0 = entity_race:getSitelink(wiki..'wiki') end
if Sitelink_x0 ~= nil then Sitelink_x = Sitelink_x0 level = 0
elseif Sitelink_x1 ~= nil then Sitelink_x = Sitelink_x1 level = 1
end
end
 
if entity_type == 'championship' then
a1, b1 = pcall(fooA, 'numeric-id', entity_race, 'P31', entity_num)
if a1 == true then
entity_l = mw.wikibase.getEntityObject( 'Q'..b1 )
a2, b2 = pcall(fooA, 'text', entity_l, 'P2561', 1) -- show the "name"
if a2 == true then
local lang_WD, text_WD
for _,v in pairs(entity_l.claims["P2561"]) do
lang_WD = v.mainsnak.datavalue.value.language
text_WD = v.mainsnak.datavalue.value.text
if wiki == lang_WD then label_x =text_WD break end
end
end
if label_x == '' then
label_x = entity_l:getLabel( ) or
entity_l:getLabel( 'en' ) or
entity_l:getLabel( 'de' ) or
entity_l:getLabel( 'fr' ) or ''
end
end
 
a1, b1 = pcall(fooA, 'numeric-id', entity_l, 'P361', 1)
if a1 == true then
entity_x = mw.wikibase.getEntityObject( 'Q'..b1 )
if entity_x ~= nil then
Sitelink_x = entity_x:getSitelink(wiki..'wiki')
if Sitelink_x~=nil then link = '[['..Sitelink_x..'|'.. label_x.. ']]' else link = label_x end
if wiki == 'ar' then
Sitelink_x = entity_x:getSitelink('arwiki')
if Sitelink_x~=nil then link = '[['..Sitelink_x..'|'.. label_x.. ']]'
else link = mw.getCurrentFrame():expandTemplate{ title = 'Ill-WD2', args = {id='Q'..b1,target='en',label=label_x} }
end
end
end
end
end
 
if level == -1 and link == nil then
local Sitelink = ''
local entity_k = mw.wikibase.getEntityObject( h['raceID'] )
Sitelink = entity_k:getSitelink(wiki..'wiki')
if Sitelink ~= '' and Sitelink ~= nil then
link = '[['..Sitelink..'|'..label_x..']]'
end
end
mw.log(multi_stage, entity_type)
if level >= 0 and link == nil and Sitelink_x ~= '' then
--change for calendar, no need for "general classification,..."
if onwikidata == true then link = '[[:fr:'..Sitelink_x..'|'..label_x..']]'
else
link = '[['..Sitelink_x..'|'..label_x..']]'
end
end
if link == nil then link = label_x end
if available_list==true and country == true then str = '<td style="text-align:'.. textalign ..';padding:0 0.5em">'..link.. '</td>'
else
fn2_country()
if h['countryID'] ~= '' then str = '<td style="text-align:'.. textalign ..';padding:0 0.5em">'.. flag(h['countryID'], timeofrace).. ' '.. link.. '</td>'
else str = '<td style="text-align:'.. textalign ..';padding:0 2.3em">'..link.. '</td>'
end
end
return str
end --end fn
local function fn_classtester(h)
local entity_race = mw.wikibase.getEntityObject( h['raceID'] )
local display=false
local a, b, c, d
 
a, b = pcall(fooA, 'numeric-id', entity_race, 'P31', 1) -- first value for P31
c, d = pcall(fooA, 'numeric-id', entity_race, 'P31', 2) -- second value for P31
if a == true and c == true then -- for two values
for i=1,#class do -- #class = number of elements in class
if "Q"..b == displayed_class[i] then display=true break end
if "Q"..d == displayed_class[i] then display=true break end
end
elseif a == true then
for i=1,#class do -- #class = number of elements in class
if "Q"..b == displayed_class[i] then display=true break end
end
elseif c==true then
for i=1,#class do -- #class = number of elements in class
if "Q"..d == displayed_class[i] then display=true break end
end
end
return display
end
 
local function fn_class(h)
local entity_race = mw.wikibase.getEntityObject( h['raceID'] )
local entity_type, entity_num = '', 0
local class_text = ''
local link = ''
local Sitelink
sortkey_class = ''
a, b = pcall(fooA, 'numeric-id', entity_race, 'P31', 1)
if a == true then
end
 
local a, b, c, d, e, f
a, b = pcall(fooA, 'numeric-id', entity_race, 'P31', 1) -- first value for P31
c, d = pcall(fooA, 'numeric-id', entity_race, 'P31', 2) -- second value for P31
if a == true and c == true then -- for two values
for i=1,#class do -- #class = number of elements in class
if "Q"..d == class[i] then class_text = mw.wikibase.label('Q'..d) sortkey_class = class_sort['Q'..d] break end
end
end
link = class_text
if link ~= '' then
a, b = pcall(fooA, 'numeric-id', entity_race, 'P361', 1) -- first value for P361
if a == true then entity_circuit = mw.wikibase.getEntityObject('Q'..b) end
end
 
if link ~= '' then
e, f = pcall(fooA, 'numeric-id', entity_circuit, 'P31', 1)
if e == true then
for i=1,#UCI_Circuits do -- abcd
if "Q"..f == UCI_Circuits[i] then
if onwikidata == true then
Sitelink = entity_circuit:getSitelink('frwiki')
if Sitelink~= nil then link = '[[:fr:'..Sitelink..'|'..link..']]' end
else
Sitelink = entity_circuit:getSitelink(wiki..'wiki')
if Sitelink~=nil then link = '[['..Sitelink..'|'..link..']]' end
end
break
end
end
end
end
return '<td data-sort-value="'..sortkey_class.. '" style="text-align:center;padding:0 0.5em">'..link.. '</td>'
end--end fn class
local function fn_rider(h,entity_race,order,displayteam)
local qual
local winner= ''
local winner_flag=''
local propertyID
if order==1 or order==nil then
propertyID=20882667
elseif order==2 then
propertyID=20882668
elseif order==3 then
propertyID=20882669
elseif order==4 then
propertyID=47640757
end
 
a, b = pcall(fooC, 'numeric-id', entity_race, 'P1346', 1, 'P642', 1)
if a == true then
winner = '' winner_flag = ''
for k, v in ipairs(entity_race.claims["P1346"]) do
for kk, vv in ipairs(v.qualifiers['P642']) do
if vv.datavalue.value['numeric-id'] == propertyID then -- overall winner general classification
winner = 'Q'.. v.mainsnak.datavalue.value['numeric-id']
end
end
end
if winner ~= '' then
local a, b = timeStartEnd(winner, "P27", 'numeric-id', timeofrace)
if a == true then
winner_flag = flag('Q'..b, timeofrace).. ' '
end
end
end
if winner ~= '' then
local winner_team = false
local entity_winner = mw.wikibase.getEntityObject( winner )
a, b = pcall(fooA, 'numeric-id', entity_winner, 'P31', 1) -- looking if winner is a person
if a == true and b ~= 5 then winner_team = true end
if winner_team == false then
if displayteam==false or displayteam==nil then
return '<td style="text-align:'.. textalign ..';padding:0 0.5em">'..winner_flag.. WPlink(winner).. '</td>'
else
local team
a, b = timeStartEnd(winner, 'P54', 'numeric-id', timeofrace) --winner 'Q4505812'
if a == true and b~=nil then
--teamOftheWinner = mw.wikibase.getEntity( 'Q'..b )
-- g.team[rank] = national_team:getLabel() or g.country[rank].. s
team = WPlink('Q'..b, 'team', timeofrace)
return '<td style="text-align:'.. textalign ..';padding:0 0.5em">'..winner_flag.. WPlink(winner).." ("..team..")".. '</td>'
else
return '<td style="text-align:'.. textalign ..';padding:0 0.5em">'..winner_flag.. WPlink(winner).. '</td>'
end
end
else
winner_flag = ''
local a, b = timeStartEnd(winner, "P17", 'numeric-id', timeofrace) -- flag of team
if a == true then
winner_flag = flag('Q'..b, timeofrace).. ' '
end
return '<td style="text-align:'.. textalign ..';padding:0 0.5em">'..winner_flag ..WPlink(winner, 'team', timeofrace).. '</td>'
end
else return '<td style="text-align:'.. textalign ..';padding:0 0.5em">'..''.. '</td>'
end
end
----- Begin of the main part of the code
if calendarID ~= nil then
local entity = mw.wikibase.getEntity(calendarID)
local WDlink_on
local WPcontent = {}
local num = 0
local kk=0
 
if pcall(fooA, 'numeric-id', entity, 'P527', 1) == true then
for k, v1 in pairs(entity.claims['P527']) do
kk=kk+1
--For all races in the UCI calendar--
h['time'] = '' h['countryID'] = '' h['countryName'] = '' h['endtime'] = ''
h['raceID'] = 'Q'.. v1.mainsnak.datavalue.value['numeric-id']
h['item1ID'] = h['raceID'] h['item2ID'] = '' h['item3ID'] = ''
local entity_race = mw.wikibase.getEntityObject( h['raceID'] )
---- Create a row ----
tBody = '<tr style= "line-height: 1.8em; padding: 5px;">'
if fn_classtester(h)==true then
tBody = tBody..fn_date(h,entity_race)
if numbering==true then
tBody = tBody..'<td style="text-align:center;padding:0 0.5em">'..tostring(kk).. '</td>'
end
tBody = tBody..fn_country(h)
tBody = tBody..fn_race(h)
if displayclass==true then
tBody = tBody..fn_class(h)
end
if s.only_winner==false then
tBody = tBody..fn_rider(h,entity_race,1,displayteam)
tBody = tBody..fn_rider(h,entity_race,2,displayteam)
tBody = tBody..fn_rider(h,entity_race,3,displayteam)
else
tBody = tBody..fn_rider(h,entity_race,1,displayteam)
end
if s.leadercolumn==true then
tBody = tBody..fn_rider(h,entity_race,4,displayteam)
end
tBody = tBody.. '</tr>'
---- Add the row to the table
table.insert(sortindex, sortkey)
table.insert(tableBody, tBody)
end
end
end -- for k, v1
return table.concat (tableBody)
end -- no calendar
end
 
function p.nationalchampionships(frame)
local calendarID = ""
local mode = ""
if wiki == "ar" then
frame = frame:getParent()
end
UCI = {}
UCI["women"] = {
['2018'] = 'Q47088675', ['2017'] = 'Q28005879', ['2016'] = 'Q22021840',
['2015'] = 'Q19296998', ['2014'] = 'Q15621925', ['2013'] = 'Q3339162',
['2012'] = 'Q1333003', ['2011'] = 'Q1143844', ['2010'] = 'Q1568490',
['2009'] = 'Q263224', ['2008'] = 'Q826505', ['2007'] = 'Q43286248',
['2006'] = 'Q43286261', ['2005'] = 'Q1335357', ['2004'] = 'Q43286272',
['2003'] = 'Q43286289', ['2002'] = 'Q43286297', ['2001'] = 'Q43286309'
}
UCI["men"] =UCI["women"]
for key, v in pairs(UCI) do
if calendarID == "" and frame.args[key] then
--mw.log("find arg " .. key)
year = frame.args[key]
year = string.gsub( year , "%c", "")
modetemp=key
if v[year] then
calendarID = v[year]
end
end
end
 
local s = {
header_function = Calendar_translate, -- translations are in function victories_translate
header_1 = 19, -- translation 1 in function victories_translate is printed in the upper part of the table header
header_2 = {5, 20, 21},-- translations 2, 3, 4, 5, 6 in function victories_translate 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.
country_column = 1,
flag_column = 1,
data_sort_type ={'', '', ''}, -- -- see https://meta.wikimedia.org/wiki/Help:Sorting
item = calendarID,
property = 'P527',
mode=modetemp,
no_country = {},
error_message = 0,
displayteam=true
}
return tableA(s, nationalchampionships_main(s))
end
 
function nationalchampionships_main(s)--Display the UCI women calendar of one year, function similar to listofwinners
local calendarID=s.item
local h = {}
local sortkey, sortkey_class
local tBody = ''
local tableBody, sortindex = {}, {}
local a1, b1, c1
local timeofrace
local displayteam
local country=true --otherwise makes no sence
 
displayteam=s.displayteam
----- Test if everything is fine -----
_, _, s.item = string.find(s.item, "(%w+)")
local entity = mw.wikibase.getEntityObject(s.item )
pcall(function() test = entity.claims[s.property][1].mainsnak.snaktype end)
if test == 'somevalue' or test == 'novalue' then s.error_message = 2 return '' end
if pcall(function() test = entity.claims[s.property][1].mainsnak.datavalue.value['numeric-id'] end)
then else s.error_message = 1 return ''
end
for _, value in pairs(s.no_country) do -- get data if country should be printed in this wiki
if value == wiki then country = false end
end
--------- Definition local functions ------
function fn_date(h,entity_race) --only to get timeofrace
local i
sortkey=''
for _,property in ipairs({"P585","P580"}) do
-- give time dates, when property 'point in time', 'start time' or 'end time' is used
a1, b1, c1 = pcall(fooA, 'time', entity_race, property, 1)
if a1 == true then
timeofrace = b1
end
end
end
 
local function fn2_country()
local entity=mw.wikibase.getEntityObject(h['raceID'])
a, b = pcall(fooA, 'numeric-id', entity, 'P17', 1)
--a,b = pcall(timeStartEnd(h['raceID'], "P17", 'numeric-id', timeofrace))
h['countryID'] =''
if a==true then
h['countryID'] = 'Q'..b
if available_list == true and country == true then
if type( translations.list ) == "function" then h['countryName'] = translations.list('Q'..b) h['countryID'] = 'Q'..b end
if h['countryName'] == '' then
local country = mw.wikibase.getEntityObject( 'Q'..b )
h['countryName'] = country:getLabel() or country:getLabel('en') .. ' (en)'
end
end
end
--no stage in UCI calendar
end
 
local function fn_country(h)
local str
if available_list==true and country == true then
fn2_country()
if h['countryID'] ~= '' and h['countryName'] ~= '' then str = '<td style="text-align:' .. textalign .. ';padding:0 0.5em data-sort-value="'..h['countryName'].. '>'..flag(h['countryID'], timeofrace).. ' '.. h['countryName'].. '</td>'
elseif h['countryID'] == '' and h['countryName'] ~= '' then str = '<td style="text-align:' .. textalign .. ';padding:0 0.5em data-sort-value="'..h['countryName'].. '>'.. ' '.. h['countryName'].. '</td>'
elseif h['countryID'] ~= '' and h['countryName'] == '' then str = '<td style="text-align:' .. textalign .. ';padding:0 0.5em data-sort-value="'..'0'.. '>'..flag(h['countryID'], timeofrace).. '</td>'
elseif h['countryID'] ~= '' and h['countryName'] ~= '' then str = '<td style="text-align:' .. textalign .. ';padding:0 0.5em data-sort-value="'..h['countryName'].. '>'.. ' '.. '</td>'
end
else str = '<td>'..''..'</td>'
end
return str
end
 
local function fn_rider(h,entity_race,displayteam)
local qual
local winner= ''
local winner_flag=''
local propertyID=20882667
 
a, b = pcall(fooC, 'numeric-id', entity_race, 'P1346', 1, 'P642', 1)
if a == true then
winner = '' winner_flag = ''
for k, v in ipairs(entity_race.claims["P1346"]) do
for kk, vv in ipairs(v.qualifiers['P642']) do
if vv.datavalue.value['numeric-id'] == propertyID then -- overall winner general classification
winner = 'Q'.. v.mainsnak.datavalue.value['numeric-id']
end
end
end
--no need for winner flag, it is clear
end
if winner ~= '' then
local winner_team = false
local entity_winner = mw.wikibase.getEntityObject( winner )
a, b = pcall(fooA, 'numeric-id', entity_winner, 'P31', 1) -- looking if winner is a person
if a == true and b ~= 5 then winner_team = true end
if winner_team == false then
if displayteam==false or displayteam==nil then
return '<td style="text-align:'.. textalign ..';padding:0 0.5em">'.. WPlink(winner).. '</td>'
else
local team
a, b = timeStartEnd(winner, 'P54', 'numeric-id', timeofrace) --winner 'Q4505812'
if a == true and b~=nil then
--teamOftheWinner = mw.wikibase.getEntity( 'Q'..b )
-- g.team[rank] = national_team:getLabel() or g.country[rank].. s
team = WPlink('Q'..b, 'team', timeofrace)
return '<td style="text-align:'.. textalign ..';padding:0 0.5em">'.. WPlink(winner).." ("..team..")".. '</td>'
else
return '<td style="text-align:'.. textalign ..';padding:0 0.5em">'.. WPlink(winner).. '</td>'
end
end
else
return '<td style="text-align:'.. textalign ..';padding:0 0.5em">'..WPlink(winner, 'team', timeofrace).. '</td>'
end
else return '<td style="text-align:'.. textalign ..';padding:0 0.5em">'..''.. '</td>'
end
end
if calendarID ~= nil then
local entity = mw.wikibase.getEntity(calendarID)
local WDlink_on
local WPcontent = {}
local num = 0
local kk=0
 
if pcall(fooA, 'numeric-id', entity, 'P527', 1) == true then
--for each country
for k, v1 in pairs(entity.claims['P527']) do
kk=kk+1
--For all races in the UCI calendar--
championshipID = 'Q'.. v1.mainsnak.datavalue.value['numeric-id']
local entity_championship = mw.wikibase.getEntityObject( championshipID )
h['raceID']=championshipID
if pcall(fooA, 'numeric-id', entity_championship, 'P527', 1) == true then
--look for the correct races
h['countryID'] = '' h['countryName'] = ''
tRoadrace=''
tITT=''
for j, w1 in pairs(entity_championship.claims['P527']) do
tempID = 'Q'.. w1.mainsnak.datavalue.value['numeric-id']
temp = mw.wikibase.getEntityObject( tempID )
templabel= temp:getLabel('fr')
if templabel~=nil then
templabelmod=mw.ustring.gsub( templabel, '-', 'x' )
testMenRoadrace=string.find( templabel, 'Course en ligne masculine aux' )
testMenITT=string.find( templabelmod, 'Contrexlaxmontre masculin aux' )
testWomenRoadrace=string.find( templabel, 'Course en ligne féminine aux' )
testWomenITT=string.find( templabelmod, 'Contrexlaxmontre féminin aux' )
end
if s.mode=="women" then
if testWomenRoadrace ~= nil then
entityRoadrace=temp
h['time'] = ''
fn_date(h,entityRoadrace) --get the date only
tRoadrace=fn_rider(h,entityRoadrace,displayteam)
end
if testWomenITT ~= nil then
entityITT=temp
h['time'] = ''
fn_date(h,entityITT) --get the date only
tITT=fn_rider(h,entityITT,displayteam)
end
else--men
if testMenRoadrace ~= nil then
entityRoadrace=temp
h['time'] = ''
fn_date(h,entityRoadrace) --get the date only
tRoadrace=fn_rider(h,entityRoadrace,displayteam)
end
if testMenITT ~= nil then
entityITT=temp
h['time'] = ''
fn_date(h,entityITT) --get the date only
tITT=fn_rider(h,entityITT,displayteam)
end
end
if fn_country(h)==nil then
tBody='<td></td>'..tRoadrace..tITT --
else
tBody=fn_country(h)..tRoadrace..tITT
end
end
end --this championship
tBody = tBody.. '</tr>'
---- Add the row to the table
table.insert(sortindex, sortkey)
table.insert(tableBody, tBody)
end
end
return table.concat (tableBody)
end -- no calendar
end
 
 
function victories_translate(wiki, x)
local l10nDef = { }
l10nDef["ar"] = {"التصنيف العام", "سجل الفوز", "التاريخ", "السباق", "البلد", "الصنف", "الفائز"}
l10nDef["fr"] = {"Classement général", "Victoires", "Date", "Course", "Pays", "Classe", "Vainqueur"}
l10nDef["en"] = {"General classification", "Victories", "Date", "Race", "Country", "Class", "Winner"}
l10nDef["de"] = {"Gesamtwertung", "Siege", "Datum", "Rennen", "Staat", "Klasse", "Sieger"}
l10nDef["da"] = {"Samlede stilling", "Sejre", "Dato", "Løb", "Land", "Klasse", "Vinder"}
l10nDef["es"] = {"Clasificación general", "Victorias", "Fecha", "Carrera", "País", "Clase", "Ganador"}
l10nDef["ja"] = {"General classification", "Victories", "開催日", "レース", "国", "国", "勝者"}
l10nDef["lv"] = {"Kopvērtējums", "Uzvaras", "Datums", "Sacensības", "Valsts", "Kategorija", "Uzvarētājs"}
l10nDef["mk"] = {"General classification", "Victories", "Датум", "Трка", "Земја", "Класа", "Победник"}
l10nDef["no"] = {"Sammenlagt", "Seire", "Dato", "Ritt", "Land", "Klasse", "Vinner"}
l10nDef["ru"] = {"Генеральная классификация", "Победы", "Дата", "Гонка", "Страна", "Класс", "Победитель"}
local l10n = l10nDef[wiki]
end
 
function stageinfobox_translatefunc_error_message(wiki,x)
local l10nDef = { }
l10nDef["en"] = {'Property <1> is missing in item "<2>" (<3>)'}
l10nDef["ar"] = {'الخاصية <1> غير موجودة في العنصر "<2>" (<3>)'}
local l10n = l10nDef[wiki]
if not l10n then l10n = l10nDef["en"] end -- default
return l10n[x]
end
 
function p.victories(frame)
local s = {
header_function = victories_translate, -- translations are in function victories_translate
header_1 = 2, -- translation 1 in function victories_translate 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_translate 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'},
country_column = 3,
flag_column = 2,
data_sort_type = {'', 'unsortable', '', '', ''}, -- see https://meta.wikimedia.org/wiki/Help:Sorting
item = frame.args[1],
property = 'P2522',
no_country = {},
error_message = 0
}
return tableA(s, victory_main(s, Qnumber))
end
 
function victory_main(s, Qnumber)
local s = s
local h = {} -- time, raceID, countryID, countryName
local test
_, _, s.item = string.find(s.item, "(%w+)")
local entity = mw.wikibase.getEntityObject( s.item )
pcall(function() test = entity.claims[s.property][1].mainsnak.snaktype end)
if test == 'somevalue' or test == 'novalue' then s.error_message = 2 return '' end
if pcall(function() test = entity.claims[s.property][1].mainsnak.datavalue.value['numeric-id'] end)
then else s.error_message = 1 return ''
end
 
local country = true
for _, value in pairs(s.no_country) do -- get data if country should be printed in this wiki
if value == wiki then country = false end
end
local sortkey, sortkey_class
local tBody = ''
local tableBody, sortindex = {}, {}
local a1, b1, c1
local timeofrace
 
for l, m in pairs(entity.claims[s.property]) do -- look into all statements
h['time'] = '' h['countryID'] = '' h['countryName'] = ''
h['raceID'] = 'Q'.. m.mainsnak.datavalue.value['numeric-id']
h['item1ID'] = h['raceID'] h['item2ID'] = '' h['item3ID'] = ''
local entity_race = mw.wikibase.getEntityObject( h['raceID'] )
local function fn2_country()
local raceID
local a, b = timeStartEnd(h['raceID'], "P17", 'numeric-id', timeofrace)
if a == true then
h['countryID'] = 'Q'..b
if available_list == true and country == true then
if type( translations.list ) == "function" then h['countryName'] = translations.list('Q'..b) h['countryID'] = 'Q'..b end
if h['countryName'] == '' then
local country = mw.wikibase.getEntityObject( 'Q'..b )
h['countryName'] = country:getLabel() or country:getLabel('en') .. ' (en)'
end
end
else --go from stage item to race item
a, b = pcall(fooA, 'numeric-id', entity_race, 'P361', 1)
if a == true then h['item2ID'] = 'Q'..b end
if a == false then
a, b = pcall(fooA, 'numeric-id', entity_race, 'P31', 1)
if a == true then h['item3ID'] = 'Q'..b end
end
if a == true then
local a, b = timeStartEnd('Q'..b, "P17", 'numeric-id', timeofrace)
if a == true then h['countryID'] = 'Q'..b
if available_list == true and country == true then
if type( translations.list ) == "function" then h['countryName'] = translations.list('Q'..b) end
if h['countryName'] == '' then
local country = mw.wikibase.getEntityObject( 'Q'..b )
h['countryName'] = country:getLabel() or country:getLabel('en') .. ' (en)'
end
end
end
end
end
end
local function fn_date(h)
local i
sortkey=''
for _,property in ipairs({"P585","P582", "P580"}) do
-- give time dates, when property 'point in time', 'start time' or 'end time' is used
a1, b1, c1 = pcall(fooA, 'time', entity_race, property, 1)
if a1 == true and h['time'] == '' then i = 1
while a1 == true and c1 == 'deprecated' do
i = i + 1
a1, b1, c1 = pcall(fooA, 'time', entity_race, property, i)
end
local _, _, y, m, d = string.find(b1, "(%d+)%p(%d+)%p(%d+)")
if m ~= '00' and d =='00'
then
sortkey = y..m..'32' h['time'] = mw.language.getContentLanguage():formatDate("M", '+'..y.."-"..m.."-31")
if wiki == "ar" then sortkey = y..m..'32' h['time'] = mw.language.getContentLanguage():formatDate("F", '+'..y.."-"..m.."-31") end
elseif m == '00' and d =='00' then sortkey = y..'12'..'32' h['time'] = ''
else sortkey = y..m..d h['time'] = func_date (b1, 'small')
end
timeofrace = b1
break
end
end
return '<td data-sort-value="'..sortkey.. '" style="text-align:right;padding:0 0.5em">'.. h['time'].. '</td>'
end
local function fn_race(h)
local str, a, b, a1, b1, a2, b2, a3, b3
local label_x = ''
local entity_x1
local Sitelink_x, Sitelink_x0, Sitelink_x1, Sitelink_x2 = '', '', ''
local entity_race = mw.wikibase.getEntityObject( h['raceID'] )
local entity_type, entity_num = '', 0
local level = -1
local link
local multi_stage = false
a, b = pcall(fooA, 'numeric-id', entity_race, 'P31', 1)
if a == true then
-- test for stage item
for i=1,#stages do
if "Q"..b == stages[i] then entity_type = 'stage item' end -- stage article
end
-- test for 'no stage item' - item
a1, b1 = pcall(fooA, 'numeric-id', entity_race, 'P31', 1) -- first value for P31
a2, b2 = pcall(fooA, 'numeric-id', entity_race, 'P31', 2) -- second value for P31
if a1 == true and a2 == true then -- for two values
if "Q"..b1 == "Q22231119" or "Q"..b1 == "Q23015458" or "Q"..b1=="Q22231118" then entity_num = 2 entity_type = 'championship' end
if "Q"..b2 == "Q22231119" or "Q"..b2 == "Q23015458" or "Q"..b2=="Q22231118" then entity_num = 1 entity_type = 'championship' end
if entity_type == '' then
for i=1,#class do -- #class = number of elements in class
if "Q"..b1 == class[i] then
for ii=1,#class_2x do
if "Q"..b1 == class_2x[ii] then multi_stage = "Q"..b1 break end
end
entity_num = 2 entity_type = 'no stage item' break
end
if "Q"..b2 == class[i] then
for ii=1,#class_2x do
if "Q"..b2 == class_2x[ii] then multi_stage = "Q"..b2 break end
end
entity_num = 1 entity_type = 'no stage item' break
end
end
end
end
-- else A
if entity_type == '' and a1 == true and a2 == false then -- for one value
entity_type = 'else A'
end
-- else B
end
if entity_type == 'else A' then
local entity_l
a1, b1 = pcall(fooA, 'text', entity_race, 'P1448', 1) -- show the "official name"
if a1 == true then
local lang_WD, text_WD
for _,v in pairs(entity_race.claims["P1448"]) do
lang_WD = v.mainsnak.datavalue.value.language
text_WD = v.mainsnak.datavalue.value.text
if lang_WD == wiki or lang_WD == 'en' or lang_WD == 'fr' then label_x =text_WD break end
end
end
if label_x == '' then
a1, b1 = pcall(fooA, 'numeric-id', entity_race, 'P31', 1)
if a1 == true then
entity_l = mw.wikibase.getEntityObject( 'Q'..b1 )
label_x = entity_l:getLabel( ) or
entity_l:getLabel( 'en' ) or
entity_l:getLabel( 'de' ) or
entity_l:getLabel( 'fr' ) or ''
end
end
if entity_l~= nil then Sitelink_x1 = entity_l:getSitelink(wiki..'wiki') end
if entity_race~= nil then Sitelink_x0 = entity_race:getSitelink(wiki..'wiki') end
if Sitelink_x0 ~= nil then Sitelink_x = Sitelink_x0 level = 0
elseif Sitelink_x1 ~= nil then Sitelink_x = Sitelink_x1 level = 1
end
end
if entity_type == 'no stage item' then
a1, b1 = pcall(fooA, 'numeric-id', entity_race, 'P31', entity_num)
if a1 == true then
entity_l = mw.wikibase.getEntityObject( 'Q'..b1 )
label_x = entity_l:getLabel( ) or
entity_l:getLabel( 'en' ) or
entity_l:getLabel( 'de' ) or
entity_l:getLabel( 'fr' ) or ''
end
if entity_l~= nil then Sitelink_x1 = entity_l:getSitelink(wiki..'wiki') end
if entity_race~= nil then Sitelink_x0 = entity_race:getSitelink(wiki..'wiki') end
if Sitelink_x0 ~= nil then Sitelink_x = Sitelink_x0 level = 0
elseif Sitelink_x1 ~= nil then Sitelink_x = Sitelink_x1 level = 1
end
end
if entity_type == 'championship' then
a1, b1 = pcall(fooA, 'numeric-id', entity_race, 'P31', entity_num)
if a1 == true then
entity_l = mw.wikibase.getEntityObject( 'Q'..b1 )
a2, b2 = pcall(fooA, 'text', entity_l, 'P2561', 1) -- show the "name"
if a2 == true then
local lang_WD, text_WD
for _,v in pairs(entity_l.claims["P2561"]) do
lang_WD = v.mainsnak.datavalue.value.language
text_WD = v.mainsnak.datavalue.value.text
if wiki == lang_WD then label_x =text_WD break end
end
end
if label_x == '' then
label_x = entity_l:getLabel( ) or
entity_l:getLabel( 'en' ) or
entity_l:getLabel( 'de' ) or
entity_l:getLabel( 'fr' ) or ''
end
end
a1, b1 = pcall(fooA, 'numeric-id', entity_l, 'P361', 1)
if a1 == true then
entity_x = mw.wikibase.getEntityObject( 'Q'..b1 )
if entity_x ~= nil then
Sitelink_x = entity_x:getSitelink(wiki..'wiki')
if Sitelink_x~=nil then link = '[['..Sitelink_x..'|'.. label_x.. ']]' else link = label_x end
if wiki == 'ar' then
Sitelink_x = entity_x:getSitelink('arwiki')
if Sitelink_x~=nil then link = '[['..Sitelink_x..'|'.. label_x.. ']]'
else link = mw.getCurrentFrame():expandTemplate{ title = 'Ill-WD2', args = {id='Q'..b1,target='en',label=label_x} }
end
end
end
end
end
if entity_type == 'stage item' then
local entity_l
a1, b1 = pcall(fooA, 'numeric-id', entity_race, 'P361', 1)
if a1 == true then
entity_x1 = mw.wikibase.getEntityObject( 'Q'..b1 )
a2, b2 = pcall(fooA, 'numeric-id', entity_x1, 'P31', 1)
if a2 == true then
local is_class = false
for i=1,#class do
if "Q"..b2 == class[i] then is_class = true break end
end
if is_class == false then entity_l = mw.wikibase.getEntityObject( 'Q'..b2 )
else
a3, b3 = pcall(fooA, 'numeric-id', "Q"..b2, 'P31', 2)
if a3 == true then entity_l = mw.wikibase.getEntityObject( 'Q'..b3 ) end
end
end
label_x = entity_l:getLabel( ) or
entity_l:getLabel( 'en' ) or
entity_l:getLabel( 'de' ) or
entity_l:getLabel( 'fr' ) or ''
end
entity_stage = mw.wikibase.getEntityObject( 'Q18131152' )
entity_prolog = mw.wikibase.getEntityObject( 'Q485321' )
local comma = ", "
if wiki == 'ar' then comma = " ، " end
if wiki == 'fr' then
for _,v in ipairs({"^Trois", "^Quatre", "^Boucles"}) do -- ^ match only at the beginning
local i, _ = mw.ustring.find(label_x , v)
if i ~= nil then comma = " des " end
end
for _,v in ipairs({"^Triptyque", "^Tour", "^Grand Prix", "^Circuit", "^Mémorial", "^Trophée"}) do
local i, _ = mw.ustring.find(label_x , v)
if i ~= nil then comma = " du " end
end
for _,v in ipairs({"^Ronde", "^Semaine", "^Classica", "^Flèche", "^Course", "^Classique"}) do
local i, _ = mw.ustring.find(label_x , v)
if i ~= nil then comma = " de la " end
end
for _,v in ipairs({"^Étoile"}) do
local i, _ = mw.ustring.find(label_x , v)
if i ~= nil then comma = " de l'" end
end
end
a, b = pcall(fooA, 'value', entity_race, 'P1545', 1)
if a == false then b = '?' end
if b ~= '0' then
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" }
local stage_label = l10nDef[wiki]
if stage_label == nil
then
stage_label = entity_stage:getLabel(wiki) or entity_stage:getLabel('fr')
if wiki == "ar" then stage_label = entity_stage:getLabel(wiki) or entity_stage:getLabel('en') end
end
local substage = ' '
local i,j = string.find(b, "%a+")
local k,l = string.find(b, "%d+")
local value1, value2
value2 = string.sub(b, k, l)
if i ~= nil then value1 = string.sub(b, i, j) end
if value1 ~= nil then substage = value1..' ' b = value2 end
if entity_l~= nil then Sitelink_x2 = entity_l:getSitelink(wiki..'wiki') end
if entity_x1~=nil then Sitelink_x1 = entity_x1:getSitelink(wiki..'wiki') end
if entity_race~=nil then Sitelink_x0 = entity_race:getSitelink(wiki..'wiki') end
if Sitelink_x0 ~= nil then Sitelink_x = Sitelink_x0 level = 0
elseif Sitelink_x1 ~= nil then Sitelink_x = Sitelink_x1 level = 1
elseif Sitelink_x2 ~= nil then Sitelink_x = Sitelink_x2 level = 2
end
if wiki=="de" or wiki=="da" or wiki=="fo" or wiki=="no" then --label_x = label_x.. ', '.. b.. '. '.. stage_label
if level == 1 or level == 2 then link = '[['..Sitelink_x..'|'.. label_x.. ']]' ..', '.. b.. '. '.. substage.. stage_label end
if level == 0 then link = '[['..Sitelink_x.. '|'.. label_x.. ', '.. b.. '. '.. substage.. stage_label.. ']]' end
if level == -1 then link = label_x.. ', '.. b.. '. '.. substage.. stage_label end
elseif wiki=='en' or wiki=='br' then label_x = label_x.. ', '.. stage_label.. ' '.. b
elseif wiki=='ar' then
label_x = label_x .. '، ' .. stage_label .. ' '.. b
if entity_l~= nil then Sitelink_x2 = (entity_l:getSitelink('arwiki') or entity_l:getSitelink('enwiki')) end
if entity_x1~=nil then Sitelink_x1 = (entity_x1:getSitelink('arwiki') or entity_x1:getSitelink('enwiki')) end
if entity_race~=nil then Sitelink_x0 = (entity_race:getSitelink('arwiki') or entity_race:getSitelink('enwiki')) end
 
elseif wiki == 'fr' then
if level == 1 or level == 2 then
if b == '1' then link = b.. '<sup>re</sup>'.. substage.. stage_label.. comma.. '[[:fr:'..Sitelink_x..'#1re.C2.A0.C3.A9tape'..'|'.. label_x.. ']]'
else link = b.. '<sup>e</sup>'.. substage.. stage_label.. comma.. '[[:fr:'..Sitelink_x..'#'.. b.. 'e.C2.A0.C3.A9tape'..'|'.. label_x..']]'
end
end
if level == 0 then
if b == '1' then link = '[[:fr:'..Sitelink_x.. '|'.. b.. '<sup>re</sup>'.. substage.. stage_label.. comma.. label_x.. ']]'
else link = '[[:fr:'..Sitelink_x.. '|'.. b.. '<sup>e</sup>'.. substage.. stage_label.. comma.. label_x..']]'
end
end
if level == -1 then
if b == '1' then link = b.. '<sup>re</sup>'.. substage.. stage_label.. comma.. label_x
else link = b.. '<sup>e</sup>'.. substage.. stage_label.. comma.. label_x
end
end
elseif wiki == "lb" then
if level == 1 or level == 2 then
if b == '1' then link = b.. '<sup>re</sup>'.. substage.. stage_label.. comma.. '[[:'..wiki..':'..Sitelink_x..'#1re.C2.A0.C3.A9tape'..'|'.. label_x.. ']]'
else link = b.. '<sup>e</sup>'.. substage.. stage_label.. comma.. '[[:'..wiki..':'..Sitelink_x..'#'.. b.. 'e.C2.A0.C3.A9tape'..'|'.. label_x..']]'
end
end
if level == 0 then
if b == '1' then link = '[[:'..wiki..':'..Sitelink_x.. '|'.. b.. '<sup>re</sup>'.. substage.. stage_label.. comma.. label_x.. ']]'
else link = '[[:'..wiki..':'..Sitelink_x.. '|'.. b.. '<sup>e</sup>'.. substage.. stage_label.. comma.. label_x..']]'
end
end
if level == -1 then
if b == '1' then link = b.. '<sup>re</sup>'.. substage.. stage_label.. comma.. label_x
else link = b.. '<sup>e</sup>'.. substage.. stage_label.. comma.. label_x
end
end
elseif wiki=="ca" then label_x = b.. 'a '.. stage_label.. ' del '.. label_x
elseif wiki=="es" then label_x = b.. "<sup>a</sup> ".. stage_label.. ', '.. label_x
else label_x = stage_label.. ' '.. b..', '.. label_x
end
else -- Prolog
if entity_l~= nil then Sitelink_x2 = entity_l:getSitelink(wiki..'wiki') end
if entity_x1~=nil then Sitelink_x1 = entity_x1:getSitelink(wiki..'wiki') end
if entity_race~=nil then Sitelink_x0 = entity_race:getSitelink(wiki..'wiki') end
if Sitelink_x0 ~= nil then Sitelink_x = Sitelink_x0 level = 0
elseif Sitelink_x1 ~= nil then Sitelink_x = Sitelink_x1 level = 1
elseif Sitelink_x2 ~= nil then Sitelink_x = Sitelink_x2 level = 2
end
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"]="Prolog", ["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" }
local prolog_label
prolog_label = l10nDef[wiki]
if prolog_label == nil then
prolog_label = entity_prolog:getLabel() or entity_prolog:getLabel('en') or entity_prolog:getLabel('fr') or
entity_prolog:getLabel('de')
prolog_label = mw.ustring.gsub(prolog_label, "^(%a)",function (x) return mw.ustring.upper(x) end)
end
if wiki=="de" or wiki=="da" or wiki=="fo" or wiki=="no" then
-- label_x = label_x.. ', '.. prolog_label
if level >= 0 then link = '[['..Sitelink_x.. '|'.. label_x.. ']]'.. ', '.. prolog_label end
elseif wiki == 'en' then label_x = label_x.. ', '.. prolog_label
elseif wiki == 'ar' then label_x = label_x.. '، '.. prolog_label
elseif wiki == 'fr' then
if level > 0 then link = prolog_label.. comma.. '[[:fr:'..Sitelink_x..'#'..prolog_label.. '|'.. label_x.. ']]' end
if level == 0 then link = '[[:fr:'..Sitelink_x..'#'..prolog_label.. '|'.. prolog_label.. comma.. label_x.. ']]' end
if level == -1 then link = prolog_label.. comma.. label_x end
elseif wiki == 'lb' then
if level > 0 then link = prolog_label.. comma.. '[[:'..wiki..':'..Sitelink_x..'#'..prolog_label.. '|'.. label_x.. ']]' end
if level == 0 then link = '[[:'..wiki..':'..Sitelink_x..'#'..prolog_label.. '|'.. prolog_label.. comma.. label_x.. ']]' end
if level == -1 then link = prolog_label.. comma.. label_x end
else label_x = prolog_label.. ', '.. label_x
end
end
end
if level == -1 and link == nil then
local Sitelink = ''
local entity_k = mw.wikibase.getEntityObject( h['raceID'] )
Sitelink = entity_k:getSitelink(wiki..'wiki')
if Sitelink ~= '' and Sitelink ~= nil then
link = '[['..Sitelink..'|'..label_x..']]'
end
end
mw.log(multi_stage, entity_type)
if level >= 0 and link == nil and Sitelink_x ~= '' then
if multi_stage ~= false then
if onwikidata == true then link = victories_translate(wiki,1).. ', '.. '[[:fr:'..Sitelink_x..'|'..label_x..']]'
else
if wiki == 'fr' then link = victories_translate(wiki,1).. ', '.. '[['..Sitelink_x..'|'..label_x..']]'
else link = '[['..Sitelink_x..'|'..label_x..']]'.. ', '.. victories_translate(wiki,1) end
end
else
if onwikidata == true then link = '[[:fr:'..Sitelink_x..'|'..label_x..']]'
else
link = '[['..Sitelink_x..'|'..label_x..']]'
end
end
end
if link == nil then link = label_x end
if available_list==true and country == true then str = '<td style="text-align:'.. textalign ..';padding:0 0.5em">'..link.. '</td>'
else
fn2_country()
if h['countryID'] ~= '' then str = '<td style="text-align:'.. textalign ..';padding:0 0.5em">'.. flag(h['countryID'], timeofrace).. ' '.. link.. '</td>'
else str = '<td style="text-align:'.. textalign ..';padding:0 2.3em">'..link.. '</td>'
end
end
return str
end
local function fn_country(h)
local str
if available_list==true and country == true then
fn2_country()
if h['countryID'] ~= '' and h['countryName'] ~= '' then str = '<td style="text-align:' .. textalign .. ';padding:0 0.5em">'..flag(h['countryID'], timeofrace).. ' '.. h['countryName'].. '</td>'
elseif h['countryID'] == '' and h['countryName'] ~= '' then str = '<td style="text-align:' .. textalign .. ';padding:0 0.5em">'.. ' '.. h['countryName'].. '</td>'
elseif h['countryID'] ~= '' and h['countryName'] == '' then str = '<td style="text-align:' .. textalign .. ';padding:0 0.5em">'..flag(h['countryID'], timeofrace).. '</td>'
elseif h['countryID'] ~= '' and h['countryName'] ~= '' then str = '<td style="text-align:' .. textalign .. ';padding:0 0.5em">'.. ' '.. '</td>'
end
else str = ''
end
return str
end
local function fn_class(h)
local entity_race = mw.wikibase.getEntityObject( h['raceID'] )
local entity_type, entity_num = '', 0
local class_text = ''
local link = ''
local Sitelink
sortkey_class = ''
a, b = pcall(fooA, 'numeric-id', entity_race, 'P31', 1)
if a == true then
-- test for stage item
for i=1,#stages do
if "Q"..b == stages[i] then entity_type = 'stage item' end
end
end
if entity_type == 'stage item' then
local a1, b1
a1, b1 = pcall(fooA, 'numeric-id', entity_race, 'P361', 1)
if a1 == true then
local a, b, c, d
local entity = mw.wikibase.getEntityObject( 'Q'..b1 )
a, b = pcall(fooA, 'numeric-id', entity, 'P31', 1) -- first value for P31
c, d = pcall(fooA, 'numeric-id', entity, 'P31', 2) -- second value for P31
if a == true and c == true then -- for two values
for i=1,#class do -- #class = number of elements in class
if "Q"..d == class[i] then class_text = mw.wikibase.label('Q'..d) sortkey_class = class_sort['Q'..d] break end
end -- for i
end -- if a
end
link = class_text
if link ~= '' then
a, b = pcall(fooA, 'numeric-id', entity_race, 'P361', 1) -- first value for P361
if a == true then
entity_II = mw.wikibase.getEntityObject('Q'..b)
c, d = pcall(fooA, 'numeric-id', entity_II, 'P361', 1) -- first value for P361
if c == true then entity_circuit = mw.wikibase.getEntityObject('Q'..d) end
end
end
else -- not a stage item
local a, b, c, d, e, f
a, b = pcall(fooA, 'numeric-id', entity_race, 'P31', 1) -- first value for P31
c, d = pcall(fooA, 'numeric-id', entity_race, 'P31', 2) -- second value for P31
if a == true and c == true then -- for two values
for i=1,#class do -- #class = number of elements in class
if "Q"..d == class[i] then class_text = mw.wikibase.label('Q'..d) sortkey_class = class_sort['Q'..d] break end
if "Q"..b == class[i] then class_text = mw.wikibase.label('Q'..b) sortkey_class = class_sort['Q'..b] break end
end
end
link = class_text
if link ~= '' then
a, b = pcall(fooA, 'numeric-id', entity_race, 'P361', 1) -- first value for P361
if a == true then entity_circuit = mw.wikibase.getEntityObject('Q'..b) end
end
end
if link ~= '' then
e, f = pcall(fooA, 'numeric-id', entity_circuit, 'P31', 1)
if e == true then
for i=1,#UCI_Circuits do -- abcd
if "Q"..f == UCI_Circuits[i] then
if onwikidata == true then
Sitelink = entity_circuit:getSitelink('frwiki')
if Sitelink~= nil then link = '[[:fr:'..Sitelink..'|'..link..']]' end
else
Sitelink = entity_circuit:getSitelink(wiki..'wiki')
if Sitelink~=nil then link = '[['..Sitelink..'|'..link..']]' end
end
break
end
end
end
end
return '<td data-sort-value="'..sortkey_class.. '" style="text-align:center;padding:0 0.5em">'..link.. '</td>'
end
local function fn_rider(h)
local qual
local winner= ''
local winner_flag=''
a, b = pcall(fooC, 'numeric-id', entity_race, 'P1346', 1, 'P642', 1)
if a == true then
winner = '' winner_flag = ''
for k, v in ipairs(entity_race.claims["P1346"]) do
for kk, vv in ipairs(v.qualifiers['P642']) do
if vv.datavalue.value['numeric-id'] == 20882667 then -- overall winner general classification
winner = 'Q'.. v.mainsnak.datavalue.value['numeric-id']
end
if vv.datavalue.value['numeric-id'] == 20882747 then -- stagewinner
if winner == '' then winner = 'Q'.. v.mainsnak.datavalue.value['numeric-id'] end
end
end
end
winner_flag = ''
local a, b = timeStartEnd(winner, "P27", 'numeric-id', timeofrace)
if a == true then
winner_flag = flag('Q'..b, timeofrace).. ' '
end
end
if winner ~= '' then
local winner_team = false
local entity_winner = mw.wikibase.getEntityObject( winner )
a, b = pcall(fooA, 'numeric-id', entity_winner, 'P31', 1) -- looking if winner is a person
if a == true and b ~= 5 then winner_team = true end
if winner_team == false then return '<td style="text-align:'.. textalign ..';padding:0 0.5em">'..winner_flag.. WPlink(winner).. '</td>'
else
winner_flag = ''
local a, b = timeStartEnd(winner, "P17", 'numeric-id', timeofrace) -- flag of team
if a == true then
winner_flag = flag('Q'..b, timeofrace).. ' '
end
return '<td style="text-align:'.. textalign ..';padding:0 0.5em">'..winner_flag ..WPlink(winner, 'team', timeofrace).. '</td>'
end
else return '<td style="text-align:'.. textalign ..';padding:0 0.5em">'..''.. '</td>'
end
end
tBody = '<tr style= "line-height: 1.8em; padding: 5px;">' -- start the table row
for k,v in ipairs({fn_date(h), fn_race(h), fn_country(h), fn_class(h), fn_rider(h)}) do
tBody = tBody.. v
end
tBody = tBody.. '</tr>' -- end the table row
local number = table.getn(tableBody)
--Insertion sort
if number == 0 then
table.insert(sortindex, sortkey)
table.insert(tableBody, tBody)
elseif sortkey >= sortindex[number] then
table.insert(sortindex, sortkey)
table.insert(tableBody, tBody)
else
for i=number,2,-1 do
if sortkey >= sortindex[i] then
table.insert(sortindex, i+1, sortkey)
table.insert(tableBody, i+1, tBody)
break
end
end
end
end
return table.concat (tableBody)
end
 
function tableA(s, tableBody)
local s = s
local tableBody = tableBody
local available_list = available_list
local entity = mw.wikibase.getEntityObject( s.item )
local error_message = ''
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 ))
error_message = mw.ustring.gsub(error_message, "<3>", s.item)
error_message = ' [[File:Exclam icon.svg|12px|'.. error_message .. ']]'
end
local tableHeader2_size = table.getn(s.header_2)
local tableStart = '<table border="0" cellspacing="0" cellpadding="0" class="sortable"><tr><th colspan="' .. tostring(tableHeader2_size + 1) .. '"' ..
' style="padding:2px 2px; text-align:center; background-color:#FFDF80; line-height: 1.8em;">'
local tableHeader1 = '<span style="float:left">[[File:Wikidata-logo S.svg|12px|link=d:'.. s.item.. '#'.. s.property..']]'.. error_message .. '</span>' ..
s.header_function (wiki, s.header_1, s.title) .. '</th></tr>'
local tableHeader2 = '<tr>'
 
local country = true
for _, value in pairs(s.no_country) do -- get data if country should be printed in this wiki
if value == wiki then country = false end
end
 
for i,k in ipairs(s.header_2) do
if i == s.country_column then
if available_list==true and country == true then
tableHeader2 = tableHeader2.. '<th style="text-align:center;padding:2px 20px 2px 2px;white-space:nowrap">'.. s.header_function (wiki, k) .. '</th>' end
end
if i ~= s.country_column then
if s.data_sort_type[i] == 'unsortable' then tableHeader2 = tableHeader2.. '<th class="unsortable" style="text-align:center;padding:2px 20px 2px 2px;white-space:nowrap">' .. s.header_function (wiki, k) .. '</th>'
else tableHeader2 = tableHeader2.. '<th style="text-align:center;padding:2px 20px 2px 2px;white-space:nowrap">' .. s.header_function (wiki, k) .. '</th>'
end
end
end
 
tableHeader2 = tableHeader2 .. '</tr>'
local tableEnd = '</table>'
return '<table style="border:1px solid rgb(200,200,200)"><tr><td>' .. tableStart .. tableHeader1 .. tableHeader2 .. tableBody .. tableEnd .. '</td></tr></table>'
end
 
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 = { }
"Équipe", "Équipe aux points",
"Image", "Légende", "Carte", "Vue en coupe", "Documentation", "Cima Coppi", "Cima Pantani", "Azzurri d'Italia", "Fuga Pinarello"}
l10nDef["ar"] = {"تفاصيل السباق", "سباق", "نوع", "تاريخ", "تاريخ", "مسافة", "بلد", "بلدان", "نقطة البداية", "نقطة النهاية", "الدراجين في البداية",
"الدراجين في النهاية", "متوسط السرعة", "الكلفة", "نتائج المرحلة", "الفائز", "الثاني", "الثالث", "متمرس",
"التصنيف العام بعد المرحلة", "القائد", "الثاني", "الثالث",
"التصنيفات الثانوية بعد المرحلة", "النقاط", "الجبل", "سباقات السرعة", "شاب", "تصنيف القتال", "ممتزجة", "سباقات السرعة", "الانتظام",
"فريق", "فريق حسب النقاط", "صورة", "أسطورة", "بطاقة", "عرض الاقسام", "توثيق"
, "سيما كوبي", "سيما بانتاني", "أزوري دي إيطاليا", "فوجا بيناريلو"}
l10nDef["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", "MetasIntermediate volantessprints", "Regularity",
"Team", "Team by points",
"Image", "Legend", "Card", "Sectional view", "Documentation", "Cima Coppi", "Cima Pantani", "Azzurri d'Italia", "Fuga Pinarello"}
"Fichier", "Legend", "Kaart", "Profil", "Dokumentatioun", "Cima Coppi", "Cima Pantani", "Azzurri d'Italia", "Fuga Pinarello"}
l10nDef["no"] = {"Etappedetaljer", "Etappe", "Type", "Dato", "Datoer", "Distanse", "Land", "Land", "Startby", "Målby", "Startende ryttere",
"Fullførende ryttere", "Snittfart", "Omkostninger", "Etapperesultat", "Vinner", "ToerAndre", "TreerTredje", "Mest offensive rytterOffensiv",
"Sammenlagtstilling etter etappen", "Sammenlagtleder", "ToerAndre", "TreerTredje",
"Klassifisering etter etappen", "PoengtrøyePoeng", "KlatretrøyeKlatring", "SprinttrøyeSpurt", "UngdomstrøyeUngdom", "Mest offensive rytterOffensiv", "KombinasjonstrøyeKombinasjon", "Étapes volantes", "RégularitéRegularitet",
"LagkonkurranseLag", "Lagkonkurranse etterLag (poeng)",
"Bilde", "Bildetekst", "Kart", "Profil", "Dokumentasjon", "Cima Coppi", "Cima Pantani", "Azzurri d'Italia", "Fuga Pinarello"}
l10nDef["pt"] = {"Detalhes da corrida", "Corrida", "Tipo", "Data", "Datas", "Distância", "País", "Países", "Origem da viagem", "Local de chegada", "Partida dos ciclistas",
"Team", "Team by points",
"Afbeelding", "Legend", "Card", "Sectional view", "Documentation", "Cima Coppi", "Cima Pantani", "Azzurri d'Italia", "Fuga Pinarello"}
l10nDef["ru"] = {"Детали гонки", "Гонка", "Тип", "Дата", "Даты", "Дистанция", "Страна", "Страны", "Место старта", "Место финиша", "Стартовало гонщиков",
"Финишировало гонщиков", "Средняя скорость", "Затраты", "Результаты этапа", "Победитель", "Второй", "Третий", "Боец",
"Генеральная классификация после этапа", "Лидер", "Второй", "Третий",
"Классификации после этапа", "Очки", "Горная", "Спринтерская", "Молодёжная", "Бойцовская", "Комбинированная", "Промежуточные финиши", "Регулярность",
"Командная по времени", "Командная по очкам",
"Изображение", "Описание", "Карта", "Сектора", "Документация", "Cima Coppi", "Cima Pantani", "Azzurri d'Italia", "Fuga Pinarello"}
 
local l10n = l10nDef[wiki]
return l10n[x]
end
 
function headoftableIII(wiki,x) -- En-tête du tableau listant les équipes participantes (P1923)
local l10nDef = { }
l10nDef["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"}
l10nDef["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", "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"}
l10nDef["ja"] = {"チーム名", "国", "コード", "ワールドチーム", "ワールドチーム", "プロチーム", "プロチーム", "プロフェッショナルコンチネンタルチーム", "プロフェッショナルコンチネンタルチーム", "コンチネンタルチーム", "コンチネンタルチーム", "ナショナルチーム", "ナショナルチーム", "地域・クラブチーム", "地域・クラブチーム", "プロ自転車チーム", "プロ自転車チーム", "アマ自転車チーム", "アマ自転車チーム", "Groupe sportif I", "Groupes sportifs I", "Groupe sportif II", "Groupes sportifs II", "Groupe sportif III", "Groupes sportifs III", "Mixt team", "Mixt teams", "プロ女子チーム", "プロ女子チーム"}
l10nDef["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 club", "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 merc'hed", "Skipailhoù merc'hed"}
l10nDef["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"}
l10nDef["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"}
l10nDef["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", "Profi-Radsportteam der Frauen", "Profi-Radsportteams der Frauen"}
l10nDef["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"}
l10nDef["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"}
l10nDef["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"}
l10nDef["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"}
l10nDef["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ð"}
l10nDef["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"}
l10nDef["mk"] = {"Име на екипата", "Земја", "Код", "Екипа од Светската турнеја UCI", "Екипи од Светската турнеја UCI", "ProTeam", "ProTeams", "Професионална континентална екипа", "Професионални континентални екипи", "Континентална екипа", "Континентални екипи", "Национална екипа", "Национални екипи", "Регионална екипа и клуб", "Регионални екипи и клубови", "Професионална велосипедска екипа", "Професионални велосипедски екипи", "Аматерска велосипедска екипа", "Аматерски велосипедски екипи", "Groupe sportif I", "Groupes sportifs I", "Groupe sportif II", "Groupes sportifs II", "Groupe sportif III", "Groupes sportifs III", "Мешана екипа", "Мешани екипи", "Професионална женска екипа", "Професионални женски екипи"}
l10nDef["nl"] = {"Teamnaam", "Land", "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", "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"}
l10nDef["no"] = {"Lagnavn", "Land", "Kode", "WorldTeam", "WorldTeams", "ProTeam", "ProTeams", "Profesjonelt kontinentallag", "Profesjonelle kontinentallag", "Kontinentallag", "Kontinentale lag", "Nasjonallag", "Nasjonale lag", "Équipe régionale et de club", "Équipes régionales et de clubs", "Profflag", "Profflag", "Amatørlag", "Amatørlag", "Sportsgruppe I", "Sportsgruppe I", "Sportsgruppe II", "Sportsgruppe II", "Sportsgruppe III", "Sportsgruppe III", "Mix-lag", "Mix-lag", "Kvinnelag", "Kvinnelag"}
l10nDef["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"}
l10nDef["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"}
l10nDef["ru"] = {"Команда", "Страна", "Код", "WorldTeam", "WorldTeams", "ProTeam", "ProTeams", "Профессиональная континентальная команда", "Профессиональные континентальные команды", "Континентальная команда", "Континентальные команды", "Национальная команда", "Национальные команды", "Региональная команда или клуб", "Региональные команды и клубы", "Профессиональная велокоманда", "Профессиональные велокоманды", "Любительская велокоманда", "Любительские велокоманды", "Groupe sportif I", "Groupes sportifs I", "Groupe sportif II", "Groupes sportifs II", "Groupe sportif III", "Groupes sportifs III", "Смешанная велокоманда", "Смешанные велокоманды", "Профессиональная женская велокоманда", "Профессиональные женские велокоманды"}
l10nDef["www"] = l10nDef["fr"]
 
return l10nDef[wiki][x]
end
 
function jersey(wiki, winner_classification, item, timeofrace)
local starttime, endtime = '', '+2500'
local a1, b1
if wiki == 'www' then wiki = 'fr' end
 
-- 1. Item of race, e.g. Tour de France = 'Q33881'
{'Q33861', 'points', '+1967', '+1968', 'Q26919974', 'Q641083'}, -- Jersey red.svg
{'Q33861', 'points', '+1969', '+2009', 'Q26945272', 'Q641083'}, -- Jersey violet.svg
{'Q33861', 'points', '+2010', '+25002016', 'Q26919974', 'Q641083'}, -- Jersey red.svg
{'Q33861', 'points', '+2017', '+2500', 'Q26945272', 'Q641083'}, -- Jersey violet.svg
{'Q33861', 'montagne', '+1974', '+2011', 'Q24645209', 'Q641060'}, -- Jersey green.svg
{'Q33861', 'montagne', '+2012', '+2500', 'Q24687409', 'Q641060'}, -- Jersey blue.svg
{'Q33937', 'montagne', '+2006', '+2008', 'Q27670174', 'Q3278226'}, -- Jersey orange.svg
{'Q33937', 'montagne', '+2009', '+2009', 'Q27670126', 'Q27670163'}, -- Jersey granate.svg
{'Q33937', 'montagne', '+2010', '+2500', 'Q25265959', 'Q27670167'}}, -- Jersey bluedots.svg
{'Q2091354', 'leader', '+2011', '+2500', 'Q24257871', 'Q30020298'}, -- Tour of Norway, Jersey yellow.svg
{'Q2091354', 'points', '+2011', '+2500', 'Q24645209', 'Q30020298'}, -- Jersey green.svg
{'Q2091354', 'montagne', '+2011', '+2015', 'Q25265958', 'Q30020298'}, -- Jersey polkadot.svg
{'Q2091354', 'montagne', '+2016', '+2500', 'Q27670174', 'Q30020298'}, -- Jersey orange.svg
{'Q2091354', 'jeune', '+2011', '+2500', 'Q24645383', 'Q30020298'}, -- Jersey white.svg
{'Q2091354', 'winner_fighting', '+2017', '+2500', 'Q29957114', 'Q30020298'}, -- MaillotCyan.PNG
{'Q128713', 'leader', '+2013', '+2500', 'Q24257871', 'Q30020299'}, -- Tour des Fjords, Jersey yellow.svg
{'Q128713', 'points', '+2013', '+2014', 'Q24645209', 'Q30020299'}, -- Jersey green.svg
{'Q128713', 'points', '+2015', '+2500', 'Q24687409', 'Q30020299'}, -- Jersey blue.svg
{'Q128713', 'montagne', '+2013', '+2500', 'Q25265958', 'Q30020299'}, -- Jersey polkadot.svg
{'Q128713', 'jeune', '+2013', '+2500', 'Q24645383', 'Q30020299'}, -- Jersey white.svg
{'Q128713', 'winner_fighting', '+2015', '+2015', 'Q30035038', 'Q30020299'}, -- Jersey green.svg
{'Q128713', 'winner_fighting', '+2016', '+2500', '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'
local vvv= ''
local tab
local wiki = string.match(mw.site.server, "%a+")
local entityId = frame.args[1]
local lang = mw.language.getContentLanguage()
a1, b1, c1 = pcall(fooA, 'time', entity, 'P585', i)
end
t_g.time = func_date (b1, wiki, 'long')
timeofrace = b1
end
end
 
-- This function permits to display an unity (the kilometer) for a distance, with exceptions for macedionan, russian and japanese
-- that have other symbols
a1, b1, c1 = pcall(fooA, 'amount', entity, 'P3157', 1)
if a1 == true and t_g.length == "" then i = 1
while a1 == true and c1 == 'deprecated' do
i = i + 1
a1, b1, c1 = pcall(fooA, 'amount', entity, 'P3157', i)
end
t_g.length = b1
a1, b1, _ = pcall(fooA, 'unit', entity, 'P3157', 1)
if b1 == "http://www.wikidata.org/entity/Q828224" then
t_g.length_unit = 'km'
if wiki == "ar" then t_g.length_unit = 'كم' end
if wiki == "mk" then t_g.length_unit = 'км' end
if wiki == "ru" then t_g.length_unit = 'км' end
if wiki == "ja" then t_g.length_unit = 'キロメートル' end
end
end
 
a1, b1, c1 = pcall(fooA, 'amount', entity, 'P2043', 1)
if a1 == true and t_g.length == "" then i = 1
if b1 == "http://www.wikidata.org/entity/Q828224" then
t_g.length_unit = 'km'
if wiki == "ar" then t_g.length_unit = 'كم' end
if wiki == "mk" then t_g.length_unit = 'км' end
if wiki == "ru" then t_g.length_unit = 'км' end
if b1 == "http://www.wikidata.org/entity/Q180154" then
t_g.speed_unit = 'km/h'
if wiki == "ar" then t_g.speed_unit = 'كم/س' end
if wiki == "da" then t_g.speed_unit = 'km/t' end
if wiki == "fo" then t_g.speed_unit = 'km/t' end
if wiki == "mk" then t_g.speed_unit = 'км/ч' end
if wiki == "ru" then t_g.speed_unit = 'км/ч' end
if wiki == "ja" then t_g.speed_unit = 'キロメートル毎時' end
end
end -- if a1
pcall(function()
for _, vv in pairs(entity.claims["P1346"][k].qualifiers['P54']) do
id_team = national_team(wiki, 'Q'..id, timeofrace, entity, 'P1346', k) -- timeofrace -> startOfSeason ?????
if id_team == nil then id_team = '' end
end
end
 
local miles
local miles_h
if t_g.length ~= "" then
if wiki == 'en' then -- To show distance in kilometers and miles
miles = math.modf(10*t_g.length/1.609344)/10
miles = lang:formatNum(tonumber(miles)) -- formats t_g.miles in the way it is done in the local Wiki
end
t_g.length, _ = string.gsub(t_g.length, "[+]", "") -- delets "+" sign
t_g.length = lang:formatNum(tonumber(t_g.length)) -- formats t_g.length in the way it is done in the local Wiki
end
if t_g.speed ~= "" then
if wiki == 'en' then -- To show speed in kilometers per hour and miles per hour
miles_h = math.modf(1000*t_g.speed/1.609344)/1000
miles_h = lang:formatNum(tonumber(miles_h)) -- formats t_g.miles in the way it is done in the local Wiki
end
t_g.speed, _ = string.gsub(t_g.speed, "[+]", "")
t_g.speed = lang:formatNum(tonumber(t_g.speed))
if i ~= nil and j ~= nil then
t_g.previous = string.sub(k, 1, i) .. span1 .. label_previous .. string.sub(k, j)
else if wiki == "ar" then t_g.previous = span1string.sub(k, 1, i) .. span2 .. label_previous .. string.sub(k, j) end
else
else t_g.previous = span1 .. label_previous end
if wiki == 'www' then t_g.previous = span1 .. label_previous end
if wiki == "ar" then t_g.previous = span2 .. label_previous end
end
else
t_g.previous = span1 .. label_previous
if wiki == "ar" then t_g.previous = span2 .. label_previous end
end
else t_g.previous = ''
end
if i ~= nil and j ~= nil then
t_g.next = string.sub(k, 1, i) .. label_next.. span2 .. string.sub(k, j)
else if wiki == "ar" then t_g.next = string.sub(k, 1, i) .. label_next.. span2span1 .. string.sub(k, j) end
else
else t_g.next = label_next.. span2 end
if wiki == 'www' then t_g.next = label_next .. span2 end
if wiki == "ar" then t_g.next = label_next .. span1 end
end
else
t_g.next = label_next.. span2
if wiki == "ar" then t_g.next = label_next .. span1 end
end
else t_g.next = ''
end
if a2 == true then
t_g.course = t_g.course .. ', '.. WPlink('Q'..b2,'pure')
if wiki == "ar" then t_g.course = t_g.course .. '، '.. WPlink('Q'..b2,'pure') end
--t_g.race = 'Q'..b2
if t_s.classement_annex.show == true and (wiki == 'no' or wiki == '..') then width= '340px' end
tab = "<table border='0' cellpadding='4' cellspacing='0' style='float:right"..floatinfobox.."; max-width:"..width.."; border:1px solid rgb(200,200,200);"
tab = tab .. "margin:0 0 0.5em 0.5em; background-color:rgb(255, 255, 255); color:black; padding:5px; clear:left; "
tab = tab .. "text-align:left" .. textalign .. "; font-size:85%; line-height:1.6em;'>"
tab = tab .. "<tr><td colspan='2' style='border-bottom:5px solid white; font-size:175%; background:#FFE7A0; text-align:center'>"
tab = tab .. "<table style='width:100%'><tr><td>" .. t_g.name .."</td><td>" .. t_g.icon .. "</td></tr></table></td></tr>"
if t_g.picture ~= "" and t_g.caption ~= "" then tab = tab .. "<tr><td colspan='2' style='text-align:center; font-size:80%'>"..t_g.caption.."</td></tr>" end
if t_g.course~="" or t_g.is_a~="" or t_g.time~="" or t_g.length~="" or t_g.startplace~="" or t_g.endplace~="" then
tab=tab.."<tr><td colspan='2' style='background-color:#FFE7A0; text-align:center'>'''"..stageinfobox_translate(wiki,1).."'''</td></tr>" end
if t_g.course ~= "" then tab = tab.."<tr><td>'''"..stageinfobox_translate(wiki,2).."'''</td><td>" .. t_g.course .. "</td></tr>" end
if t_g.is_a ~= "" then tab = tab.."<tr><td>'''"..stageinfobox_translate(wiki,3).."'''</td><td>" ..stage_icon(t_g.is_a).. WPlink(t_g.is_a,'pure').. "</td></tr>" end
if t_g.time~="" then tab = tab.."<tr><td>'''"..stageinfobox_translate(wiki,4).."'''</td><td>" .. t_g.time.."</td></tr>" end
if wiki ~= 'en' then -- As default show only kilometers, but if 'en.wiki' show kilometers and miles
if t_g.length ~= "" then tab = tab.."<tr><td>'''"..stageinfobox_translate(wiki,6).."'''</td><td>" .. t_g.length.." "..t_g.length_unit.."</td></tr>" end
if t_g.startplacelength ~= "" then tab = tab.."<tr><td>'''"..stageinfobox_translate(wiki,96).."'''</td><td>" .. WPlink(t_g.startplace,'pure')length.." "..t_g.length_unit.."</td></tr>" end
else
if t_g.endplace ~= "" then tab = tab.."<tr><td>'''"..stageinfobox_translate(wiki,10).."'''</td><td>" .. WPlink(t_g.endplace,'pure').. "</td></tr>" end
if t_g.length ~= "" then tab = tab.."<tr><td>'''"..stageinfobox_translate(6).."'''</td><td>"..t_g.length.." "..t_g.length_unit.." ("..miles.." mi)".."</td></tr>" end
end
if t_g.startplace ~= "" then tab = tab.."<tr><td>'''"..stageinfobox_translate(9).."'''</td><td>" .. WPlink(t_g.startplace,'pure').. "</td></tr>" end
if t_g.endplace ~= "" then tab = tab.."<tr><td>'''"..stageinfobox_translate(10).."'''</td><td>" .. WPlink(t_g.endplace,'pure').. "</td></tr>" end
if t_g.country ~= nil then for i=1,#t_g.country do t_g.country[i] = flag(t_g.country[i], timeofrace).." ".. WPlink( t_g.country[i],'pure') end end
if t_g.country[1] ~= nil then tab = tab.."<tr><td style= 'vertical-align:top'>'''"
if #t_g.country == 1 then tab = tab..stageinfobox_translate(wiki,7).."'''</td><td>" else tab = tab..stageinfobox_translate(wiki,8).."'''</td><td>" end
for i=1,#t_g.country-1 do tab = tab .. t_g.country[i].."<br>" end tab = tab .. t_g.country[#t_g.country].."</td></tr>" end
if t_g.nr_participants_start ~= "" then tab = tab.."<tr><td>'''"..stageinfobox_translate(wiki,11).."'''</td><td>" .. t_g.nr_participants_start .. "</td></tr>" end
if t_g.nr_participants_end ~= "" then tab = tab.."<tr><td>'''"..stageinfobox_translate(wiki,12).."'''</td><td>" .. t_g.nr_participants_end .. "</td></tr>" end
if wiki ~= 'en' then --As default show only kilometers/hour, but if 'en.wiki' show kilometers/hour and miles/hour
if t_g.speed ~= "" then tab = tab.."<tr><td>'''"..stageinfobox_translate(wiki,13).."'''</td><td>" .. t_g.speed .. " "..t_g.speed_unit.."</td></tr>" end
if t_g.speed ~= "" then tab = tab.."<tr><td>'''"..stageinfobox_translate(13).."'''</td><td>" .. t_g.speed .. " "..t_g.speed_unit.."</td></tr>" end
else
if t_g.speed ~= "" then tab = tab.."<tr><td>'''"..stageinfobox_translate(13).."'''</td><td>" .. t_g.speed .. " "..t_g.speed_unit.." ("..miles_h.." mi/h)".."</td></tr>" end
end
 
for _, value_order in ipairs(t_s.order) do
tab=tab.."<table border='0' cellpadding='0' cellspacing='0' style='width:100%'>"
tab=tab.."<tr><td colspan='3' style='border-bottom:5px solid #fff2cc; background-color:#FFE7A0; text-align:center'>'''"..
stageinfobox_translate(wiki,t_s[value_order].header).."'''</td></tr>"
 
for key, value in ipairs(t_s[value_order].order) do
if a1~='' then t_s[value_order][value][4] = a1 end
if t_s[value_order][value][9] ~= '' then
t_s[value_order][value][9] = '('.. lang:formatNum(t_s[value_order][value][9])..unit(wiki,5)..')'
if wiki == 'fo' then t_s[value_order][value][9] = string.gsub(t_s[value_order][value][9], "%.", ",") end
end
if t_s[value_order][value][8] ~= '' then
if t_s[value_order][value][8] > 1 then t_s[value_order][value][8] = t_s[value_order][value][8]..unit(wiki,7)
else t_s[value_order][value][8] = t_s[value_order][value][8]..unit(wiki,6) end end
local title, k =mw.ustring.gsub(stageinfobox_translate(wiki,t_s[value_order][value][2]), " ", "&nbsp;")
if k > 0 then title=mw.ustring.gsub(title, "&nbsp;", "<br>", 1) end --&#32;
if t_s[value_order][value][5]=="" and t_s[value_order][value][9] =="" then
tab=tab.."<tr style='vertical-align:top;'><td nowrap style='width:1%;background-color:#fff2cc;text-align:left" .. textalign .. ";padding:0 2px 0 2px;white-space:nowrap'>'''"
else tab=tab.."<tr style='vertical-align:top;'><td nowrap rowspan='2' style='width:1%;background-color:#fff2cc;text-align:left" .. textalign .. ";padding:0 2px 0 2px;white-space:nowrap'>'''"
end
if value_order~='classement_annex' and t_s[value_order][value][2]~=40 and t_s[value_order][value][2]~=41 then -- Cima Coppi, Cima Pantani with a line break
if t_s[value_order][value][4] == "" then
if (value_order=='results') and (value=='winner_fighting' or value=='winner_fighting2' or value=='cima_coppi' or value=='cima_pantanii') then
tab=tab..stageinfobox_translate(wiki,t_s[value_order][value][2])
else tab=tab..number(t_s[value_order][value][3], key, wiki) end
else
end
if t_s[value_order][value][10] == 'deprecated' then
tab=tab.."</span>".. "'''</td><td style='padding:0 0.5em 0 0.5em'>".. '<s>' .. transform(t_s[value_order][value][1],'f', timeofrace) .. '</s>'
else tab=tab.."</span>".. "'''</td><td style='padding:0 0.5em 0 0.5em'>".. transform(t_s[value_order][value][1],'f', timeofrace) end
tab=tab.."</td><td nowrap style='text-align:right;font-size:85%;white-space:nowrap'>"
if t_s[value_order][value][6]~='' then tab=tab.. calculate_time(wiki,t_s[value_order][value][6]) end
if t_s[value_order][value][7]~='' then tab=tab..'+ '.. calculate_time(wiki,t_s[value_order][value][7]) end
tab=tab.."<tr><td colspan='2'>"
tab = tab.. "<table border='0' cellpadding='0' cellspacing='0' style='width:100%'>"
tab = tab.. "<tr><td style='width:100%;text-align:left" .. textalign .. ";padding-left:2px'>("..transform(t_s[value_order][value][5],'t', timeofrace)..
")</td><td nowrap style='font-size:85%;vertical-align:top;white-space:nowrap'>"..t_s[value_order][value][9] .. "</td></tr></table></td></tr>"
else
if t_s[value_order][value][5]~="" or t_s[value_order][value][9] ~="" then -- team row
tab=tab.."<tr><td colspan='2' style='text-align:left" .. textalign .. ";padding-left:2px'>"
if t_s[value_order][value][5] ~= '' then tab=tab..'('..transform(t_s[value_order][value][5],'t', timeofrace)..')' end
tab = tab.. '<span style="float:right;font-size:85%;">'.. t_s[value_order][value][9].."</span></td></tr>"
if t_g.map ~= "" then tab = tab .. "<tr><td colspan='2' style='text-align:center'>".." [[File:".. t_g.map .."|center|300px]]".."</td></tr>" end
if t_g.sectional_view ~= "" then tab = tab .. "<tr><td colspan='2' style='text-align:center'>".." [[File:".. t_g.sectional_view .."|center|300px]]".."</td></tr>" end
 
tab = tab.."<tr><td>"..t_g.previous.."</td><td style='text-align:right'>" .. t_g.next .. "</td></tr>"
prevNextLine = "<tr><td>"..t_g.previous.."</td><td style='text-align:right'>" .. t_g.next .. "</td></tr>"
if wiki == "ar" then prevNextLine = "<tr><td width='50%' style='text-align:right'>"..t_g.previous.."</td><td width='50%' style='text-align:left'>" .. t_g.next .. "</td></tr>" end
tab = tab .. prevNextLine
local s = "d:Wikidata:WikiProject Cycling/Documentation/stageinfobox"
tab = tab .. "<tr><td colspan='2' style='text-align:right; border-top:3px solid #FFDF80; font-size:75%'>".. --infobox_bottom(1)
"[[" .. s .. "|" .. stageinfobox_translate(wiki,39).. "]] [[File:Wikidata-logo S.svg|12px|link=d:".. frame.args[1] .. "]]"
tab = tab .. "</span></td></tr>"
tab= tab.."</table>"
return tab
--look into P17 (country) to get the Qnumber of that country
a, b = pcall(fooA, 'numeric-id', mw.wikibase.getEntity( q_number ), 'P17', 1)
if a == true then return flag("Q"..b, timeofrace).." "..WPlink( q_number, 'winner_teamteam', timeofrace )
else return WPlink( q_number, 'winner_teamteam', timeofrace ) end
end
end
if command == "c" then return WPlink( q_number, "Q22348500" ) end -- find "class"-items
if command == "t" then return WPlink( q_number, 'team', timeofrace ) end
 
function p.listofteams(frame)
--local entity = mw.wikibase.getEntityObject( frame.args[1] = 'Q19753550')
local mt = {}
local entity = mw.wikibase.getEntityObject( frame.args[1] )
local tempID, k, u, v, v1, w, new, teamcategory, entity2, len, len2
local mt = {}
local tempID, k, u, v, v1, w, new, teamcategory, entity2, len, len2
local wiki = string.match(mw.site.server, "%a+")
 
local startOfSeason = '' --'+2016-01-01T00:00:00Z'
pcall(function() startOfSeason = entity.claims["P580"][1].mainsnak.datavalue.value.time end)
if startOfSeason == '' then
if pcall(function() startOfSeason = entity.claims["P585"][1].mainsnak.datavalue.value.time end) then
else
local Sitelink = entity:getSitelink(wiki .. 'wiki') or entity:getSitelink('enwiki') or entity:getSitelink('frwiki') or entity:getSitelink('dewiki') or ''
if Sitelink == '' then return '> Wikidata is missing data about the start time (P580) and end time (P582) of the season'
else startOfSeason = '+'..string.match(Sitelink, '%d%d%d%d' ) ..'-01-01T00:00:00Z'
end
end
end
end
v = ''
 
v mt[1] = ''{}
mt[1][1], mt[1][2], mt[1][3] = '', 0, ''
mt[1] = {}
local mu = {}
mt[1][1], mt[1][2], mt[1][3] = '', 0, ''
local mua, = {}b
local a,cache b= {}
if pcall(fooA, 'numeric-id', entity, 'P1923', 1) == true then
 
if for pcall(fooAk, 'numeric-id',v1 in pairs(entity, .claims['P1923', 1]) == true thendo
if v1.mainsnak and v1.mainsnak.datavalue and v1.mainsnak.datavalue.value and v1.mainsnak.datavalue.value['numeric-id'] then
for k, v1 in pairs(entity.claims['P1923']) do
new = true
teamcategory, tempID, len = '', '', 0
tempID = 'Q'.. v1.mainsnak.datavalue.value['numeric-id']
entity2 = mw.wikibase.getEntityObject( tempID )
cache[tempID] = entity2
 
a, b = timeStartEndpcall(tempID, "P31"fooA, 'numeric-id', startOfSeasonentity2, 'P31', 1)
if a == true then teamcategory = 'Q'..b else new = false end
 
for w in pairs(mt) do
len = table.getn(mt[w])
if mt[w][1] == teamcategory then new=false mt[w][2]=mt[w][2]+1 len=len+1 mt[w][len]=tempID len2=len-2 end
end
if new == true then
local size = table.getn(mt)
mt[size+1] = {}
mt[size+1][1] = teamcategory
mt[size+1][2] = 1
mt[size+1][3] = tempID
end
end
end -- if pcall(fooA
 
local list = { -- c:d:e c = singular team type, d = plural team type, e = print order of the team types
["Q6154783"] = "4:5:1", -- WorldTeam
["Q20638319"] = "6:7:2", -- ProTeam
["Q382927"] = "8:9:3", -- UCI Professional Continental Team
["Q1756006"] = "10:11:4", -- UCI Continental Team
["Q23726798"] = "12:13:6", -- national cycling team
["Q20738667"] = "12:13:6", -- national cycling team U23
["Q20639848"] = "14:15:7", -- club cycling team
["Q20639847"] = "16:17:8", -- professional cycling team
["Q20652655"] = "18:19:9", -- amateur cycling team
["Q20653563"] = "20:21:10", -- Groupe Sportif I
["Q20653564"] = "22:23:11", -- Groupe Sportif II
["Q20653566"] = "24:25:12", -- Groupe Sportif III
["Q2466826"] = "28:29:5" -- UCI Women’s Team
}
local a, b, c, d, e, ii, jj
for i=1, table.getn(mt) do
mu[i] = {}
mu[i]['index']= 100 mu[i]['val'] = ''
if mt[i][1] ~= '' then
if list[mt[i][1]] ~= nil then
_, _, c, d, e = string.find(list[mt[i][1]], "(%d+):(%d+):(%d+)")
mu[i]['index'] = tonumber( e )
if mt[i][2] == 1 then mu[i]['val'] = mu[i]['val'] .. '<span style="font-size:1.2em;font-weight:bold">'..headoftableIII(wiki,tonumber( c ))..'</span>'
else mu[i]['val'] = mu[i]['val'] .. '<span style="font-size:1.2em;font-weight:bold">'..headoftableIII(wiki,tonumber( d )).. '</span>'
end
else -- fall back headings (ProTeam, ...) in case no value in function headoftableIII
mu[i]['val'] = mu[i]['val'] .. '<span style="font-size:1.2em;font-weight:bold;text-transform: capitalize;">' .. WPlink(mt[i][1])..'</span>'
end
end -- if pcall(fooA
mu[i]['val'] = mu[i]['val'] .. ' <small>('..mt[i][2]..')</small>'
 
local list = { -- c:d:e c = singular team type, d = plural team type, e = print order of the team types
mu[i]['val'] = mu[i]['val'].. '<ol>'
["Q6154783"] = "4:5:1", -- WorldTeam
for w in pairs(mt[i]) do
["Q20638319"] = "6:7:2", -- ProTeam
if w > 2 then
["Q382927"] = "8:9:3", -- UCI Professional Continental Team
mu[i]['val'] = mu[i]['val'] .. '<li style="text-indent:-1.5em;width:20em;display:inline-block;">'
["Q1756006"] = "10:11:4", -- UCI Continental Team
a, b = timeStartEnd(mt[i][w], "P17", 'numeric-id', startOfSeason)
["Q23726798"] = "12:13:6", -- national cycling team
if a == true then mu[i]['val'] = mu[i]['val'].. flag('Q'..b, startOfSeason).. ' ' end
["Q20738667"] = "12:13:6", -- national cycling team U23
if mt[i][1] ~= 'Q23726798' and mt[i][1] ~= 'Q20738667' then mu[i]['val'] = mu[i]['val'].. WPlink(mt[i][w],'winner_team', startOfSeason).. '</li>'
["Q28492441"] = "12:13:6", -- équipe cycliste nationale de marque
else
["Q20639848"] = "14:15:7", -- club cycling team
national_team = mw.wikibase.getEntity( mt[i][w] )
["Q20639847"] = "16:17:8", -- professional cycling team
-- calculate s for national team item
["Q20652655"] = "18:19:9", -- amateur cycling team
a, b = pcall(fooA, 'numeric-id', national_team, 'P31', 1) -- test if country
["Q20653563"] = "20:21:10", -- Groupe Sportif I
if a == true and b == 20738667 then -- Q20738667 = national cycling team U23
["Q20653564"] = "22:23:11", -- Groupe Sportif II
if wiki == 'fr' or wiki == 'www' then s = ' espoirs' else s = ' U23' end
["Q20653566"] = "24:25:12", -- Groupe Sportif III
elseif a == true and b == 23726798 then s = '' end -- Q23726798 = national cycling team
["Q2466826"] = "28:29:5", -- UCI Women’s Team
 
["Q26849121"] = "30:31:13" -- Women's amateur cycling team
a, b = pcall(fooA, 'numeric-id', national_team, 'P17', 1) -- test if country
}
if a == true then
local a, b, c, d, e, ii, jj
local nation = mw.wikibase.getEntityObject( 'Q'..b )
for i=1, table.getn(mt) do
nationality = nation:getLabel() or nation:getLabel('en') or nation:getLabel('fr') or nation:getLabel('de')
mu[i] = {}
end
mu[i]['index']= 100 mu[i]['val'] = ''
 
if national_team:getSitelink()mt[i][1] =~= nil'' then
if list[mt[i][1]] ~= nil then
team = nationality.. s
_, _, c, d, e = string.find(list[mt[i][1]], "(%d+):(%d+):(%d+)")
mu[i]['index'] = tonumber( e )
if mt[i][2] == 1 then mu[i]['val'] = mu[i]['val'] .. '<span style="font-size:1.2em;font-weight:bold">'..headoftableIII(tonumber( c ))..'</span>'
else mu[i]['val'] = mu[i]['val'] .. '<span style="font-size:1.2em;font-weight:bold">'..headoftableIII(tonumber( d )).. '</span>'
end
else -- fall back headings (ProTeam, ...) in case no value in function headoftableIII
mu[i]['val'] = mu[i]['val'] .. '<span style="font-size:1.2em;font-weight:bold;text-transform: capitalize;">' .. WPlink(mt[i][1])..'</span>'
end
-- Set parameter to show team counter in front of each category
local showcounter = 2
if mt[i][2] >= showcounter then mu[i]['val'] = mu[i]['val'] .. ' <small>('..mt[i][2]..')</small>' end
mu[i]['val'] = mu[i]['val'].. '<ol>'
for w in pairs(mt[i]) do
if w > 2 then
mu[i]['val'] = mu[i]['val'] .. '<li style="text-indent:0em;width:20em;display:inline-block;">'
a, b = pcall(fooA, 'numeric-id', cache[mt[i][w]], 'P17', 1)
if a == true then mu[i]['val'] = mu[i]['val'].. flag('Q'..b, startOfSeason).. ' ' end
if mt[i][1] ~= 'Q23726798' and mt[i][1] ~= 'Q20738667' then mu[i]['val'] = mu[i]['val'].. WPlink_entity(cache[mt[i][w]],'team', startOfSeason).. '</li>'
else
teamnational_team = WPlink(cache[mt[i][w], 'team',] startOfSeason)
ii,-- jjcalculate =s for national mw.ustring.find(team, "|")item
a, b = pcall(fooA, 'numeric-id', national_team, 'P31', 1) -- test if country
if ii ~= nil and jj ~= nil then
if a == true and b == 20738667 then -- Q20738667 = national cycling team U23
jj=jj+1
if wiki == 'fr' then s = ' espoirs' else s = ' U23' end
team = mw.ustring.sub(team,1,ii).. nationality..s.. ']]'
if wiki == 'mk' then s = ' под 23 години' end
if wiki == 'ar' then s = ' تحت 23' end
elseif a == true and b == 23726798 then s = '' end -- Q23726798 = national cycling team
a, b = pcall(fooA, 'numeric-id', national_team, 'P17', 1) -- test if country
if a == true then
local nation = mw.wikibase.getEntityObject( 'Q'..b )
nationality = nation:getLabel() or nation:getLabel('en') or nation:getLabel('fr') or nation:getLabel('de')
end
if nationality and national_team:getSitelink() == nil then
team = nationality.. s
else
team = WPlink_entity(cache[mt[i][w]], 'team', startOfSeason)
ii, jj = mw.ustring.find(team, "|")
if ii ~= nil and jj ~= nil then
jj=jj+1
team = mw.ustring.sub(team,1,ii).. nationality..s.. ']]'
end
end
mu[i]['val'] = mu[i]['val'] .. team ..'</li>'
end
mu[i]['val'] = mu[i]['val'] .. team ..'</li>'
end
end
mu[i]['val'] = mu[i]['val'] .. '</ol>'
end
mu[i]['val']end =--if mumt[i]['val'1] ..~= '</ol>'
end
end --if mt[i][1] ~= ''
table.sort(mu, function(a,b) return a.index<b.index end)
for i=1, table.getn(mu) do
if mu[i].val ~= nil then v = v .. mu[i].val end
end
v = v .. '<table border="0" cellspacing="0" cellpadding="0" style="line-height:0em;width:20em;margin:0.5em 0em;border-top:2px solid #FFDF80;"><tr><th>'..
'<span style="float:left">[[File:Wikidata-logo S.svg|12px|link=d:'.. frame.args[1].. '#P1923]]</span></th></tr></table>'
return '<table style="max-width:95%; padding:0.5em; margin-right:1em; border:1px solid rgb(200,200,200)"><tr><td>' .. v .. '</td></tr></table>'
end
 
function WPlinkrider(Qnumber, ...)
table.sort(mu, function(a,b) return a.index<b.index end)
local link=''
local entity = mw.wikibase.getEntity( Qnumber )
local Sitelink = entity:getSitelink() -- link to WParticle
local Sitelink2 = Sitelink
local Label = entity:getLabel() or ''
local Label_fr = entity:getLabel( 'fr' ) or ''
local a, b
local official_name = ""
if pcall(foo1, Qnumber) then
if Sitelink ~= nil then
if arg[1]~=nil then --check for official name
a, b = pcall(fooA, 'text', entity, 'P1448', 2) -- test if more then two official names
if a == true then
a, b = timeStartEnd_entity(entity, 'P1448', 'text', arg[1]) --officialName(entity)
if a == true then official_name = b end
else
a, b = pcall(fooA, 'text', entity, 'P1448', 1)
if a == true then official_name = b end
end
if official_name=='' then
else
Sitelink2 = official_name --official_name
end
end
link = "[[" .. Sitelink .. "|" .. mw.text.trim(mw.ustring.gsub(Sitelink2, "%b()", "")..' ') .. "]]"
if wiki == "de" then -- ru riders get label as alias, to shorten the name
local a, b = pcall(fooA, 'numeric-id', entity, 'P27', 1)
if a == true and (b==159 or b==184 or b==212 or b==232) then link = "[[" .. Sitelink .. "|" .. Label .. "]]" end
end
elseif Label ~= '' then
if wiki == 'ar' then
local title = mw.title.new(Label)
if title.exists
then link = Label
else link = mw.getCurrentFrame():expandTemplate{ title = 'Ill-WD2', args = {id=Qnumber,en='true'} }--"[[" .. Label.. "]]"
end
else
if black_list(wiki, Label) == true then
link = Label -- function black_list: articles that are printed as text, not wikilinks
else -- detect if there is a different local article with the same name
local title = mw.title.new(Label)
if title.exists then link = Label else link = "[[" .. Label.. "]]" end
end
end
else link = Label end
else return "unknown ID in function WPlink" end
if link == '' then
link = entity:getLabel('fr') or entity:getLabel('en') or entity:getLabel('de') or ''
if wiki == "ar" then link = entity:getLabel() or entity:getLabel('en') or entity:getLabel('fr') or entity:getLabel('de') or '' end
if link ~= '' then link = mw.ustring.gsub(link, "%b()", "")
else link = "(label missing)" end
end
return link
end
 
function WPlink_entity(entity, ...)
for i=1, table.getn(mu) do
local link=''
if mu[i].val ~= nil then v = v .. mu[i].val end
local Sitelink = entity:getSitelink() -- link to WParticle
local Sitelink2 = Sitelink
local Label = entity:getLabel() or ''
local Label_fr = entity:getLabel( 'fr' ) or ''
local a, b
local official_name = ""
if arg[1] == 'team' then -- add '(team of the winner)'
a, b = timeStartEnd_entity(entity, 'P1448', 'text', arg[2]) --officialName(entity)
local a1, b1 = pcall(fooA, 'numeric-id', entity, 'P361', 1)
if a1== true then
entity = mw.wikibase.getEntity( 'Q'..b1 )
local a2, b2 = timeStartEnd_entity(entity, 'P1448', 'text', arg[2])
if a2== true then a = a2 b = b2 end
Sitelink2 = entity:getSitelink() -- link to WParticle
end
if a == true then official_name = b end
if available_lang_priority == false then
a, b = pcall(fooA, 'text', entity, 'P1448', 2) -- test if more then two official names
if a == true then
a, b = timeStartEnd_entity(entity, 'P1448', 'text', arg[2]) --officialName(entity)
if a == true then official_name = b end
else
a, b = pcall(fooA, 'text', entity, 'P1448', 1)
if a == true then official_name = b end
end
end
if Sitelink ~= nil then
if official_name == nil then
link = "[[".. Sitelink.. "|".. mw.text.trim(mw.ustring.gsub(Sitelink,"%b()","").. ' ').. "]]"
else
if wiki=="en" then --delete string ", ..." from e.g. "Unley, South Australia"
local i, _ = mw.ustring.find(Sitelink, ",")
if i ~= nil then Sitelink = mw.ustring.sub(Sitelink, 1, i-1) end
end
link = link .. '[['.. Sitelink.. "|".. official_name.. ']]'
end
end
if link == '' and Sitelink2 ~= nil then -- code goes from season item to team item
if official_name == nil then
link = "[[".. Sitelink2.. "|".. mw.text.trim(mw.ustring.gsub(Sitelink2,"%b()","").. ' ').. "]]"
else
if wiki=="en" then --delete string ", ..." from e.g. "Unley, South Australia"
local i, _ = mw.ustring.find(Sitelink2, ",")
if i ~= nil then Sitelink2 = mw.ustring.sub(Sitelink2, 1, i-1) end
end
link = link .. '[['.. Sitelink2.."|".. official_name.. ']]'
end
end
if Sitelink == nil and Sitelink2 == nil then
if official_name ~='' then link = official_name else link = entity:getLabel() end
if link == nil then link = "(label missing)" end
end
end -- end arg[1]
return link
end
 
function timeStartEnd_entity(entity, property, mode, timeofrace)
v = v .. '<table border="0" cellspacing="0" cellpadding="0" style="line-height:0em;width:20em;margin:0.5em 0em;border-top:2px solid #FFDF80;"><th>'..
-- mode = 'numeric-id', property = 'P54', Qid = 'Q123'
'<span style="float:left">[[File:Wikidata-logo S.svg|12px|link=d:'.. frame.args[1].. '#P1923]]</span></th></table>'
--local entity = mw.wikibase.getEntity(Qid)
 
local a, b = pcall(fooA, mode, entity, property, 1)
return '<table style="max-width:95%; padding:0.5em; margin-right:1em; border:1px solid rgb(200,200,200)"><tr><td>'..
local starttime, endtime
v.. '</td></tr></table>'
local available_lang_priority = available_lang_priority
if a == true then
local timeStartEnd = {}
local num = 1
local v
for _, v in pairs(entity.claims[property]) do
if pcall(function () local test = v.mainsnak.datavalue.value[mode] end) then -- test if not 'unnown value'
if pcall(function () starttime = v.qualifiers["P580"][1].datavalue.value.time end) then
starttime = v.qualifiers["P580"][1].datavalue.value.time
local _,_,year,m,d = string.find(starttime,"(%d+)-(%d+)-(%d+)")
if m == '00' and d == '00' then starttime = '+'..year..'-01-01T00:00:00Z' end
end
if pcall(function () endtime = v.qualifiers["P582"][1].datavalue.value.time end) then
endtime = v.qualifiers["P582"][1].datavalue.value.time
local _,_,year,m,d = string.find(endtime,"(%d+)-(%d+)-(%d+)")
if m == '00' and d == '00' then endtime = '+'..year..'-12-31T00:00:00Z' end
if m == '01' and d == '01' then endtime = '+'..year..'-12-31T00:00:00Z' end
end
if v.qualifiers then
if (not v.qualifiers["P580"] or starttime <= timeofrace)
and
(not v.qualifiers["P582"] or endtime >= timeofrace)
then
if available_lang_priority == true and property == "P1448" then
local test = false
pcall(function () if type( v.qualifiers["P1448"])=='table' then test=true end end)
if test == false then
timeStartEnd[num] = v.mainsnak.datavalue.value[mode]
else
local lang_module, lang_WD
local language= ''
local zaehler
for i,j in ipairs(translations.lang_priority) do
lang_module = j
for number in pairs(v.qualifiers["P1448"]) do
lang_WD = v.qualifiers["P1448"][number].datavalue.value.language
if lang_WD == lang_module then zaehler = number break end
end -- for number in pairs
if lang_WD == lang_module then language = lang_WD break end
end -- for i,j
if language~='' then -- a WD translation matching translations.lang_priority exist
local t = v.qualifiers["P1448"][zaehler].datavalue.value.text
timeStartEnd[num] = t
else timeStartEnd[num] = v.mainsnak.datavalue.value[mode]-- no matching between lang module and "official name" qualifier
end -- if language~=''
end -- test if official name qualifier exist
else timeStartEnd[num] = v.mainsnak.datavalue.value[mode]
end -- if property == "P1448"
num = num + 1
end
else
timeStartEnd[num] = v.mainsnak.datavalue.value[mode]
num = num + 1
end
end
end
return a, timeStartEnd[1]
else return false, '' end
end
 
function getSquadTableColumn(x)
local l10nDef = { } -- note (in the table), note (below the table)
l10nDef["frar"] = {"Cyclisteالمتسابق", "Dateتاريخ de naissanceالولادة", "Équipeالفريق précédenteالسابق", "noteملاحظة", "noteملاحظة", "Paysالبلد", "قائمة الفريق"}
l10nDef["enfr"] = {"RiderCycliste", "Date ofde birthnaissance", "PreviousÉquipe teamprécédente", "note", "note", "CountryPays", "Effectif"}
l10nDef["bren"] = {"RederRider", "DeiziadDate genelof birth", "Previous team", "note", "note", "BroCountry", "Team roster"}
l10nDef["cabr"] = {"CiclistaReder", "DataDeiziad de naixementgenel", "EquipPrevious previteam", "Notanote", "Notanote", "PaisBro", "Team roster"}
l10nDef["csca"] = {"CyklistaCiclista", "DatumData narozeníde naixement", "PreviousEquip teamprevi", "noteNota", "noteNota", "StátPais", "Team roster"}
l10nDef["dacs"] = {"RytterCyklista", "FødselsdagDatum narození", "SenestePrevious holdteam", "note", "note", "LandStát", "Team roster"}
l10nDef["deda"] = {"NameRytter", "GeburtsdatumFødselsdag", "VorherigesSeneste Teamhold", "Anm.note", "Anmerkungnote", "Land", "Trup"}
l10nDef["eode"] = {"Antaŭnomo NomoName", "NaskiĝtagoGeburtsdatum", "PreviousVorheriges teamTeam", "noteAnm.", "noteAnmerkung", "LandoLand", "Team roster"}
l10nDef["eseo"] = {"CorredorAntaŭnomo Nomo", "FechaNaskiĝtago", de"Previous nacimientoteam", "Equipo previonote", "Notanote", "NotaLando", "PaisTeam roster"}
l10nDef["eues"] = {"IzenaCorredor", "Jaiotze-dataFecha de nacimiento", "PreviousEquipo teamprevio", "noteNota", "noteNota", "HerrialdePais", "Integrantes del Equipo"}
l10nDef["fieu"] = {"AjajaIzena", "SyntymäaikaJaiotze-data", "EdellinenAurreko joukkuetaldea", "huomioOharra", "huomioOharra", "MaaHerrialdea", "Team roster"}
l10nDef["fofi"] = {"SúkklariAjaja", "FøðingardagurSyntymäaika", "UndanfarnaEdellinen liðjoukkue", "notehuomio", "notehuomio", "LandMaa", "Team roster"}
l10nDef["hufo"] = {"NévSúkklari", "SzületésnapFøðingardagur", "ElőzőUndanfarna csapatlið", "jegyzetnote", "jegyzetnote", "OrszágLand", "Team roster"}
l10nDef["ithu"] = {"CiclistaNév", "DataSzületésnap", di"Előző nascitacsapat", "Previous teamjegyzet", "Notajegyzet", "NotaOrszág", "PaeseTeam roster"}
l10nDef["jait"] = {"選手名Ciclista", "生年月日Data di nascita", "前所属Previous team", "脚注Nota", "脚注Nota", "Paese", "Team roster"}
l10nDef["lbja"] = {"Coureur選手名", "Gebuertsdatum生年月日", "Equipe前所属", virdrun"脚注", "Nott脚注", "Nott", "StaatTeam roster"}
l10nDef["lvlb"] = {"BraucējsCoureur", "Dzimšanas datumsGebuertsdatum", "IepriekšējāEquipe komandavirdrun", "piezīmeNott", "piezīmeNott", "ValstsStaat", "Team roster"}
l10nDef["mklv"] = {"ВелосипедистBraucējs", "ДатумDzimšanas на раѓањеdatums", "ПретходнаIepriekšējā екипаkomanda", "Фуснотаpiezīme", "Фуснотаpiezīme", "ДржаваValsts", "Komandas sastāvs"}
l10nDef["nlmk"] = {"NaamВелосипедист", "GeboortedatumДатум на раѓање", "PreviousПретходна teamекипа", "nootФуснота", "nootФуснота", "LandДржава", "Team roster"}
l10nDef["nonl"] = {"RytterNaam", "FødselsdatoGeboortedatum", "TidligereVorige lagploeg", "notenoot", "notenoot", "StatNationaliteit", "Renners"}
l10nDef["plno"] = {"Imię iRytter", nazwisko"Fødselsdato", "DataTidligere urodzenialag", "Previous teamnote", "Przypisnote", "PrzypisLand", "PaństwoTeam roster"}
l10nDef["ptpl"] = {"CiclistaImię i nazwisko", "Data de nascimentourodzenia", "EquipePoprzednia anteriorgrupa", "NotaPrzypis", "NotaPrzypis", "PaisPaństwo", "Team roster"}
l10nDef["ropt"] = {"CiclistCiclista", "Data nașteriide nascimento", "PreviousEquipe teamanterior", "noteNota", "noteNota", "ȚarăPais", "Integrantes da equipe"}
l10nDef["ruro"] = {"ГонщикCiclist", "ДатаData рожденияnașterii", "ПредыдущаяPrevious командаteam", "Примечаниеnote", "Примечаниеnote", "СтранаȚară", "Team roster"}
l10nDef["svru"] = {"NamnГонщик", "FödelsedatumДата рождения", "PreviousПредыдущая teamкоманда", "Примечание", "notПримечание", "notСтрана", "LandСостав"}
l10nDef["zhsv"] = {"車手Namn", "出生日期Födelsedatum", "Previous team", "脚注not", "脚注not", "国家Land", "Team roster"}
l10nDef["zh"] = {"車手", "出生日期", "Previous team", "脚注", "脚注", "国家", "Team roster"}
 
local wiki,l10n =mw.site.server l10nDef[wiki]
if wiki=='//www.wikidata.org'not l10n then l10n = l10nDef["fren"] end -- default
else l10n=l10nDef[string.sub(wiki,string.find(wiki,"%a+"))] end
return l10n[x]
end
-- "METAS VOLANTES", "REGULARIDAD", "TEAM POINTS"}
local l10nDef = { }
l10nDef["//fr.wikipedia.orgar"] = {"Généralitésتفاصيل السباق", "Courseسلسلة", "Compétitionمنافسة", "Compétitionsمسابقات", "Étapesمراحل", "Dateالتاريخ", "Datesالتواريخ", "Distanceالمسافات", "Paysالبلد", "Paysالبلدان",
"نقطة البداية", "نقطة النهاية", "الفرق", "عدد المتسابقين في البداية", "عدد المتسابقين في النهاية", "متوسط السرعة", "الكلفة", "المنصة", "الفائز", "الثاني",
"الثالث", "حسب النقاط", "تسلق الجبل", "سباقات السرعة", "أفضل شاب", "تصنيف القتال", "مجموعة", "الفريق", "صورة", "تعليق", "خريطة", "مميز 1", "مميز 2", "توثيق", "سباقات السرعة", "انتظام", "نقاط الفريق", "فوجا بيناريلو", "أزوري دي إيطاليا"}
l10nDef["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 Pinarello", "Azzurri d'Italia"}
l10nDef["//en.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", "MetasIntermediate volantessprints", "Regularidad", "Team points", "Fuga Pinarello", "Azzurri d'Italia"}
l10nDef["//ja.wikipedia.org"] = {"レース詳細", "コース", "競技", "競技", "ステージ", "日付", "日付", "距離", "距離", "国",
"スタート", "ゴール", "チーム", "参加人数", "完走人数", "平均速度", "Cost", "結果", "優勝", "準優勝",
"3位", "ポイント賞", "山岳賞", "スプリント賞", "新人賞", "敢闘賞", "チーム総合時間賞", "チーム", "画像", "キャプション", "地図", "Special 1", "Special 2",
"ドキュメンテーション", "Metas volantes", "Regularidad", "チームポイント", "Fuga Pinarello", "Azzurri d'Italia"}
l10nDef["//br.wikipedia.org"] = {"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ñ",
"Picture", "Caption", "Map", "Special 1", "Special 2", "Documentation", "Metas volantes", "Regularidad", "Team points", "Fuga Pinarello", "Azzurri d'Italia"}
l10nDef["//ca.wikipedia.org"] = {"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ó", "Metas volantes",
"Regularidad", "Team points", "Fuga Pinarello", "Azzurri d'Italia"}
l10nDef["//cs.wikipedia.org"] = {"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", "Fuga Pinarello", "Azzurri d'Italia"}
l10nDef["//da.wikipedia.org"] = {"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", "MetasIndlagt volantesspurt", "RegularidadRegularitet", "Holdkonkurrence efter point", "Fuga Pinarello", "Azzurri d'Italia"}
l10nDef["//de.wikipedia.org"] = {"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", "SiegerErgebnis",
"GesamtwertungSieger", "Zweiter", "Dritter", "Punktewertung", "Bergwertung", "Sprintwertung", "Nachwuchswertung", "Kämpferischster Fahrer", "Kombinationswertung",
"Teamwertung", "Bild", "Beschriftung", "Karte", "Special 1", "Special 2", "Dokumentation", "Metas volantes", "Regularidad", "Teamwertung (Punkte)",
"Fuga Pinarello", "Azzurri d'Italia"}
l10nDef["//eo.wikipedia.org"] = {"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", "Fuga Pinarello", "Azzurri d'Italia"}
l10nDef["//es.wikipedia.org"] = {"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 Pinarello", "Azzurri d'Italia"}
l10nDef["//eu.wikipedia.org"] = {"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", "Fuga Pinarello", "Azzurri d'Italia"}
l10nDef["//fi.wikipedia.org"] = {"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", "Fuga Pinarello", "Azzurri d'Italia"}
l10nDef["//fo.wikipedia.org"] = {"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", "Fuga Pinarello", "Azzurri d'Italia"}
l10nDef["//lb.wikipedia.org"] = {"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", "Fuga Pinarello", "Azzurri d'Italia"}
l10nDef["//lv.wikipedia.org"] = {"Sacensību informācija", "MaršrutsSacensības", "SacensībaKategorija", "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", "Fuga Pinarello", "Azzurri d'Italia"}
l10nDef["//mk.wikipedia.org"] = {"Детали за трката", "Издание", "Натпреварување", "Натпреварувања", "Етапи", "Датум", "Датуми", "Растојание",
"Држава", "Држави", "Поаѓалиште", "Одредиште", "Екипи", "Возачи на почеток", "Возачи на крај", "Просечна брзина", "Трошоци", "Добитници на наградите",
"Победник", "Второпласиран", "Третопласиран", "Бодовен", "Планински", "Спринтерски", "Младински", "Борбеност", "Комбиниран", "Екипен", "слика", "опис",
"местоположбена карта", "Special 1", "Special 2", "Документација", "Metas volantes", "Regularidad", "Team points", "Fuga Pinarello", "Azzurri d'Italia"}
l10nDef["//nl.wikipedia.org"] = {"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", "Picture", "Caption", "Map", "Special 1",
"Special 2", "Documentatie", "Metas volantes", "Regularidad", "Teampunten", "Fuga Pinarello", "Azzurri d'Italia"}
l10nDef["//no.wikipedia.org"] = {"Detaljer", "Ritt", "Konkurranse", "Konkurranser", "Etapper", "Dato", "Datoer", "Distanse", "Land", "Land", "Startby",
"Målby", "Lag", "Startende ryttere", "Fullførende ryttere", "Gjennomsnittsfart", "Kostnad", "Resultater", "Vinner", "2. plass", "3. plass", "Poeng",
"KlatreKlatring", "SprintSpurt", "Ungdom", "Mest offensive", "Kombinasjon", "Lagkonkurranse", "Bilde", "Bildetekst", "Kart", "SpecialSpesial 1", "SpecialSpesial 2", "Dokumentasjon",
"Metas volantes", "RegularidadRegularitet", "TeamLagkonkurranse points(poeng)", "Fuga Pinarello", "Azzurri d'Italia"}
l10nDef["//pl.wikipedia.org"] = {"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", "Fuga Pinarello", "Azzurri d'Italia"}
l10nDef["//pt.wikipedia.org"] = {"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", "Fuga Pinarello", "Azzurri d'Italia"}
l10nDef["//ro.wikipedia.org"] = {"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", "Fuga Pinarello", "Azzurri d'Italia"}
l10nDef["//ru.wikipedia.org"] = {"Детали гонки", "Маршрут", "Соревнование", "Соревнования", "Этапы", "Дата", "Даты", "Дистанция", "Страна", "Страны",
"Место старта", "Пункт назначения", "Команды", "Вышло на старт гонщиков", "Финишировало гонщиков", "Средняя скорость", "Призовые", "Призёры", "Победитель",
"Второй", "Третий", "Очковая", "Горная", "Спринтерская", "Молодёжная", "Бойцовская", "Комбинированная", "Командная", "Вид", "Описание", "Карта", "SpecialСектор 1",
"SpecialСектор 2", "Документация", "MetasПромежуточные volantesфиниши", "RegularidadРегулярность", "TeamКомандные pointsочки", "Fuga Pinarello", "Azzurri d'Italia"}
l10nDef["//sv.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", "Fuga Pinarello", "Azzurri d'Italia"}
 
l10nDef["//www.wikidata.org"] = l10nDef["//en.wikipedia.org"]
local l10n = l10nDef[mw.site.serverwiki]
if not l10n then l10n = l10nDef["//en.wikipedia.org"] end -- default
return l10n[x]
end
 
function unit(wiki,x)
local l10nDef = { }
l10nDef["ar"] = {"", " س ", " دقيقة ", " ث", ' كم/س', " نقطة", " نقطة"}
l10nDef["fr"] = {"en", " h ", " min ", " s", ' km/h', " pt", " pts"}
l10nDef["br"] = {"", "e ", "' ", '"', ' km/h', " pt", " pts"}
l10nDef["da"] = {"", "t ", "' ", '"', ' km/t', " point", " point"}
l10nDef["de"] = {"", " h ", " min ", " s", ' km/h', " P.", " P."}
l10nDef["esen"] = {"", " h ", " min' ", '" s"', ' km/h', " pt", " pts"}
l10nDef["eues"] = {"", " oh ", " min ", " s", ' km/h', " pt&nbsp;&nbsp;", " pts"}
l10nDef["eu"] = {"", " h ", " min ", " s", ' km/h', " pt", " pt"}
l10nDef["fo"] = {"", "t ", "' ", '"', ' km/t', " pt", " pts"}
l10nDef["fi"] = {"", ".", ".", "", ' km/h', " pt", " pts"}
l10nDef["mk"] = {"", "ч ", "' ", "", ' км/ч', " pt", " pts"}
l10nDef["nl"] = {"", "u", "'", '"', ' km/u', " pt", " pts"}
l10nDef["no"] = {"", "t ", "' ", '"', ' km/t', " ptpoeng", " ptspoeng"}
l10nDef["pt"] = {"", "h", "m", "s", ' km/h', " pt", " pts"}
l10nDef["ru"] = {"", "ч ", "' ", "", ' км/ч', " очко", " очкоочков"}
l10nDef["www"] = {"", "h ", "' ", '"', ' km/h', " pt", " pts"} -- wikidata
 
local l10n = l10nDef[wiki]
if not l10n then l10n = l10nDef["wwwen"] end -- default for lv,cs,en,ca,ro,pt,pl,sv
return l10n[x]
end
 
function number(gender, b, wiki)
local str
if b=="" then return "" end
str = b .. ". "
if wiki == "ca" then
if b==1 then str = b.."r" end
if b==2 then str = b.."n" end
if b==3 then str = b.."r" end
if b==4 then str = b.."t" end
if b>4 then str = b.."è" end
end
if wiki=="es" then str = b..".º" end
if wiki=="fr" orthen wiki=="www" then
if b==1 then
if gender == 'm' then str="1<sup>er</sup>"
elseif gender == 'f' or gender == 'n' then str="1<sup>re</sup>"
else str="1<sup>e</sup>" end
else str=b.."<sup>e</sup>" end
end
if wiki=="nl" then str=b.."e" end
if wiki=="ru" then str=b.."-й" end
if wiki=="eo" then str=b.."-a" end
return str
end
 
function calculate_time(wiki, t)
local time = tonumber(t)
local h, m, s = 0, 0, 0
local str = ''
if time == nil then return '' end
if time < 60 then s = time
elseif time < 3600 then m = math.modf(time/60) s = time - m*60
else h = math.modf(time/3600) m = math.modf((time - h*3600)/60) s = time - h*3600 - m*60
end
if h>0 then str = str..mw.ustring.format ('%i'..unit(2), h) end
if m>=0 and h>0 then str = str.. mw.ustring.format('%02i'..unit(3), m) end
if m>0 and h==0 then str = str.. mw.ustring.format('%i'..unit(3), m) end
if s>=0 and (h>0 or m>0) then str = str.. mw.ustring.format('%02i'..unit(4), s) end
if s>=0 and h==0 and m==0 then str = str.. mw.ustring.format('%i'..unit(4), s) end
return str --time..': '..h..' '..m..' '..s
end
 
function p.pointsclassification(frame)
if time == nil then return '' end
local s = {
if time < 60 then s = time
header_function = headoftableII, -- translations are in function headoftaböleII
elseif time < 3600 then m = math.modf(time/60) s = time - m*60
header_1 = 10, -- translation 10 in function headoftableII is printed in the upper part of the table header
else h = math.modf(time/3600) m = math.modf((time - h*3600)/60) s = time - h*3600 - m*60
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 = string.gsub(frame.args[1], "%c", ""),
property = 'P3494', -- 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
}
return new_classification(frame, s)
end
 
function p.teamsclassificationbytime(frame)
if h>0 then str = str..mw.ustring.format ('%i'..unit(wiki,2), h) end
local s = {
if m>0 and h>0 then str = str.. mw.ustring.format('%02i'..unit(wiki,3), m) end
header_function = headoftableII, -- translations are in function headoftaböleII
if m>0 and h==0 then str = str.. mw.ustring.format('%i'..unit(wiki,3), m) end
header_1 = 14, -- translation 10 in function headoftableII is printed in the upper part of the table header
if s>=0 and (h>0 or m>0) then str = str.. mw.ustring.format('%02i'..unit(wiki,4), s) end
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
if s>=0 and h==0 and m==0 then str = str.. mw.ustring.format('%i'..unit(wiki,4), s) end
item = frame.args[1],
return str --time..': '..h..' '..m..' '..s
property = 'P3497', -- property to use for this table
team_classification = true, -- it is a team classification table, its not a rider classification table
background = 'strong' -- there is no background color for the first row, but the first row is formated strong
}
return new_classification(frame, s)
end
 
function p.teamtimetrialclassificationteamsclassificationbypoints(frame)
local s = {
local entity = mw.wikibase.getEntityObject( frame.args[1] )
header_function = headoftableII, -- translations are in function headoftaböleII
local WDlink_on
header_1 = 15, -- translation 10 in function headoftableII is printed in the upper part of the table header
local wiki = string.match(mw.site.server, "%a+")
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
local cont = {nr={}, teamIDs={}, teamNames={}, flags={}, country={}, time={}, time_gap={}, speed={}, time_date=false, no_country=true }
item = frame.args[1],
local startOfSeason = '' --'+2016-01-01T00:00:00Z'
property = 'P3496', -- property to use for this table
team_classification = true, -- it is a team classification table, its not a rider classification table
background = 'strong' -- there is no background color for the first row, but the first row is formated strong
}
return new_classification(frame, s)
end
 
function p.stageclassification(frame)
if wiki == "mk" or wiki == "ja" or wiki == "lv" or wiki == "ru" then WDlink_on = true else WDlink_on = false end
if frame.args[2]~= nil then
display_reftemp=tonumber(frame.args[2])
else
display_reftemp=0
end
local s = {
header_function = headoftableII, -- translations are in function headoftaböleII
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
item = frame.args[1],
property = 'P2417', -- property to use for this table
team_classification = false, -- it is not a team classification table, its a rider classification table
background = false, -- there is no background color for the first row
display_ref=display_reftemp
}
return new_classification(frame, s)
end
 
function p.generalclassification(frame)
pcall(function() startOfSeason = entity.claims["P580"][1].mainsnak.datavalue.value.time end)
if startOfSeason =frame.args[2]~= ''nil then
display_reftemp=tonumber(frame.args[2])
if pcall(function() startOfSeason = entity.claims["P585"][1].mainsnak.datavalue.value.time end) then
else
display_reftemp=0
local Sitelink = entity:getSitelink('enwiki') or entity:getSitelink('frwiki') or entity:getSitelink('dewiki') or ''
if Sitelink == '' then return '> Wikidata is missing data about the start time (P580) and end time (P582) of the season'
else startOfSeason = '+'..string.match(Sitelink, '%d%d%d%d' ) ..'-01-01T00:00:00Z'
end
end
local s = {
header_function = headoftableII, -- translations are in function headoftaböleII
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
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=display_reftemp
}
return new_classification(frame, s)
end
 
function p.teamtimetrialclassification(frame)
local k, v, a, b, rank
if frame.args[2]~= nil then
local max_rank = 0
display_reftemp=tonumber(frame.args[2])
pcall(function()
else
for k, _ in pairs(entity.claims['P2417']) do -- look into all statements
display_reftemp=0
for _, v in pairs(entity.claims['P2417'][k].qualifiers['P1352']) do -- for property 'rank'
end
rank = tonumber(v.datavalue.value.amount) break
end
if rank > max_rank then max_rank = rank end
cont.nr[rank] = rank
 
local s = {
cont.teamIDs[rank] = 'Q' .. entity.claims['P2417'][k].mainsnak.datavalue.value['numeric-id']
header_function = headoftableII, -- translations are in function headoftaböleII
cont.teamNames[rank] = WPlink(cont.teamIDs[rank], 'winner_team', startOfSeason)
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
item = frame.args[1],
property = 'P2417', -- property to use for this table
team_classification = true, -- it is a team classification table, its not a rider classification table
background = false, -- there is no background color for the first row
display_ref=display_reftemp
}
return new_classification(frame, s)
end
 
function p.mountainsclassification(frame)
a, b = pcall(fooA, 'numeric-id', mw.wikibase.getEntityObject( cont.teamIDs[rank] ), 'P17', 1)
local s = {
if a == true then
header_function = headoftableII, -- translations are in function headoftableII
if available == true then
header_1 = 11, -- translation 10 in function headoftableII is printed in the upper part of the table header
if type( translations ) == "table" then cont.country[rank] = translations.list('Q'..b) end
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
if cont.country[rank] == '' then
item = string.gsub(frame.args[1], "%c", ""),
local country = mw.wikibase.getEntityObject( 'Q'..b )
property = 'P4320', -- property to use for this table
cont.country[rank] = country:getLabel() or country:getLabel('en') .. ' (en)'
team_classification = false, -- it is not a team classification table, its a rider classification table
end
background = 'color' -- there is a background color for the first row
--else cont.country[rank] = mw.wikibase.label( 'Q'..b ) end
end}
return new_classification(frame, s)
else cont.country[rank] = '' end
end
 
function p.sprintsclassification(frame)
a, b = timeStartEnd(cont.teamIDs[rank], "P17", 'numeric-id', startOfSeason)
local s = {
if a == true then
header_function = headoftableII, -- translations are in function headoftableII
cont.flags[rank] = flag('Q'..b, startOfSeason)
header_1 = 12, -- translation 10 in function headoftableII is printed in the upper part of the table header
else cont.flags[rank] = '' end
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 = string.gsub(frame.args[1], "%c", ""),
if pcall(function()
property = 'P4322', -- property to use for this table
for _, v in pairs(entity.claims['P2417'][k].qualifiers['P2781']) do -- for property 'race time'
team_classification = false, -- it is not a team classification table, its a rider classification table
cont.time[rank] = tonumber(v.datavalue.value.amount)
background = 'color' -- there is a background color for the first row
end
}
end) then else cont.time[rank] = '' end
return new_classification(frame, s)
end
if pcall(function()
for _, v in pairs(entity.claims['P2417'][k].qualifiers['P2911']) do -- for property 'time gap'
cont.time_gap[rank] = tonumber(v.datavalue.value.amount)
end
end) then else cont.time_gap[rank] = '' end
if pcall(function()
for _, v in pairs(entity.claims['P2417'][k].qualifiers['P2052']) do -- for property 'speed'
cont.speed[rank] = tonumber(v.datavalue.value.amount)
end
end) then else cont.speed[rank] = '' end
end
end)
 
function p.bestyoungclassificationbypoints(frame)
for i= 1,max_rank do
local s = {
if cont.nr[i] == nil then cont.nr[i]='' end
header_function = headoftableII, -- translations are in function headoftableII
if cont.teamNames[i] == nil then cont.teamNames[i]='' end
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
item = string.gsub(frame.args[1], "%c", ""),
property = 'P4323', -- 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
}
return new_classification(frame, s)
end
 
function p.bestyoungclassification(frame)
local time_headoftable = '' -- if there is time data in the classification, print the column time
local s = {
local tableStart = '<table border="0" cellspacing="0" cellpadding="0"><th colspan="6" style="padding:2px 2px; text-align:center; background-color:#FFDF80">'
header_function = headoftableII, -- translations are in function headoftableII
local tableHeader1 = ''
header_1 = 13, -- translation 10 in function headoftableII is printed in the upper part of the table header
if WDlink_on == false then tableHeader1 = tableHeader1 .. '<span style="float:left">[[File:Wikidata-logo S.svg|12px|link=d:'.. frame.args[1].. '#P2417]]</span>' end
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
tableHeader1 = tableHeader1 .. headoftableII(wiki,8)
item = string.gsub(frame.args[1], "%c", ""),
local tableHeader2 = '<tr><th colspan="2" style="text-align:center;padding:2px 2px">'..headoftableII(wiki,3)
property = 'P4323', -- property to use for this table
if available==true then tableHeader2 = tableHeader2..'<th nowrap style="text-align:center;padding:2px 2px">'..headoftableII(wiki,2) end
team_classification = false, -- it is not a team classification table, its a rider classification table
tableHeader2 = tableHeader2..'</th><th style="text-align:center;padding:2px 2px">'..headoftableII(wiki,4)..
background = 'color' -- there is a background color for the first row
'</th><th style="text-align:center;padding:2px 2px">'..headoftableII(wiki,5)..
}
'</th><th style="text-align:center;padding:2px 2px">'..headoftableII(wiki,6).. '</th></tr>'
return new_classification(frame, s)
end
 
function p.u23classification(frame)
local tableBody = ''
local tableEnds = '</th></table>'{
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
item = string.gsub(frame.args[1], "%c", ""),
property = 'P4323', -- property to use for this table (same as best young classification)
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
}
return new_classification(frame, s)
end
 
function p.combinationclassification(frame)
local unit = ' km/h'
local s = {
if wiki == 'da' or wiki == 'fo' or wiki == 'no' then unit = ' km/t' end
header_function = headoftableII, -- translations are in function headoftableII
if wiki == 'nl' then unit = ' km/u' end
header_1 = 16, -- translation 10 in function headoftableII is printed in the upper part of the table header
if wiki == 'mk' or wiki == 'ru' then unit = ' км/ч' end
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
local i = 1
item = string.gsub(frame.args[1], "%c", ""),
while cont.nr[i] do
property = 'P4324', -- property to use for this table
tableBody = tableBody.. '<tr><td nowrap style="text-align:center;padding:2px 0.5em 2px 0.5em">'.. number('f', cont.nr[i], wiki)
team_classification = false, -- it is not a team classification table, its a rider classification table
if available==true then tableBody = tableBody..'</td><td style="text-align:left;padding:0 0.2em 0 0.2em">'.. cont.teamNames[i].. '</td>'
background = 'color' -- there is a background color for the first row
else tableBody = tableBody.. '</td><td style="text-align:left;padding:0 0.2em 0 0.2em">'.. cont.flags[i].. ' '..cont.teamNames[i].. '</td>'
}
end
return new_classification(frame, s)
if available==true then tableBody = tableBody.. '</td><td style="text-align:left;padding:0 0.2em 0 0.2em">'.. cont.flags[i].. ' '.. cont.country[i].. '</td>' end
tableBody = tableBody.. '</td><td style="text-align:right;padding:0 0.2em 0 0.2em">'.. calculate_time(wiki,cont.time[i]).. '</td>'
if i == 1 then tableBody = tableBody.. '</td><td style="text-align:right;padding:0 0.2em 0 0.2em">'.. calculate_time(wiki,cont.time_gap[i]).. '</td>'
else
if cont.time_gap[i] ~= '' then tableBody = tableBody.. '</td><td style="text-align:right;padding:0 0.2em 0 0.2em">'.. '+ '.. calculate_time(wiki,cont.time_gap[i]).. '</td>'
else tableBody = tableBody.. '</td><td></td>' end
end
if cont.speed[i] ~= '' then tableBody = tableBody.. '</td><td style="text-align:center;padding:0 0.2em 0 0.2em">'..
mw.ustring.format('%.3f', cont.speed[i]).. '<span style="font-size:80%">'.. unit.. '</span>'.. '</td></tr>'
else tableBody = tableBody.. '</td><td></td></tr>' end
i = i + 1
end
 
function p.combativeclassification(frame)
return '<table style="float:left; margin-right:0.5em; border:1px solid rgb(200,200,200)"><tr><td>'..
local s = {
tableStart.. tableHeader1.. tableHeader2.. tableBody.. tableEnd.. '</td></tr></table>'
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
item = string.gsub(frame.args[1], "%c", ""),
property = 'P4321', -- 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
}
return new_classification(frame, s)
end
 
function classificationnew_classification(itemframe, property, wikis)
local country = true
local entity = mw.wikibase.getEntityObject( item )
local g = {nr={}, riderIDs={}, riderNames={}, riderGender={}, jersey={}, jerseyIDs={}, jersey_name={}, flags={}, country={},
if wiki == 'da' then country = false end -- those wikis do not want to show the country column as standard
team={}, time={}, time_gap={}, time_date=false, no_country=true }
if wiki == 'es' then country = false end -- those wikis do not want to show the country column as standard
local startOfSeason = '' --'+2016-01-01T00:00:00Z'
local s = s
local h = {
rider={1, "", "", "", '', ""}, -- rank, rider ID, riderGender, nationality ID, flag ID, team ID
jersey={""}, -- lots of jerseyID
value={'', '', '', ''} -- points, time, time_gap, speed
}
local available_list = available_list
local entity = mw.wikibase.getEntityObject( s.item )
--[=[ It is possible to give the classification tables in the article commands to change the standard behaviour. They could look like this:
{{Cycling race/teamsclassificationbytime|Q18574623|newline=false|country=true}}
{{Cycling race/teamsclassificationbytime|Q18574623|country= false|newline=false}}
{{Cycling race/teamsclassificationbypoints|Q18574623|newline =true|country=true}}
{{Cycling race/teamsclassificationbypoints|Q18574623|newline= true}}
{{Cycling race/teamsclassificationbypoints|Q18574623|newline = false|country=false}}
{{Cycling race/teamsclassificationbytime|Q18574623|newline=true|country=true}}
One additional parameter is "newline" with the values "true" or "false". "newline" says, if there is a line brake after the table. Standard is
no line break after the tables stageclassification and teamtimetrialclassification.
The second parameter is "country" with the values "true" or "false". "country" tells the module to print the country column or not.
Most wikis have as standard to print the country columns, some wikis prefer as standard not to show the country column. A few lines above,
the command "if wiki == 'da' then country = false end" tells that daWiki do not want to see the country colums as standard. You can add your wiki
here in, if you do not want to see them as standard. With the new parameter editors are able to tell the module in the article what to do.
]=]
 
local function jersey(h)
pcall(function() startOfSeason = entity.claims["P580"][1].mainsnak.datavalue.value.time end)
local jersey
if startOfSeason == '' then
local jersey_name
local jersey_string = ' '
jerseys = {
['Q24257871'] = {file = 'Jersey yellow.svg',
name_ar = 'قميص أصفر لمتصدر الترتيب العام',
name_fr = 'maillot jaune de leader du classement général',
name_es = 'maillot amarillo de líder de la clasificación general',
name_ru = 'жёлтая майка лидера генеральной классификации'
},
['Q24645209'] = {file = 'Jersey green.svg',
name_ar = 'قميص أخضر لمتصدر ترتيب النقاط',
name_fr = 'maillot vert de leader du classement par points',
name_es = 'maillot verde de líder de la clasificación por puntos',
name_ca = 'mallot verd del líder de la classificació per punts',
name_ru = 'зелёная майка лидера очковой классификации'
},
['Q24645383'] = {file = 'Jersey white.svg',
name_ar = 'قميص أبيض لمتصدر ترتيب الشباب',
name_fr = 'maillot blanc de leader du classement du meilleur jeune',
name_es = 'maillot blanco de líder de la clasificación de los jóvenes',
name_ru = 'белая майка лидера молодёжной классификации',
name_de = 'weißes Trikot des Führenden der Nachwuchswertung'
},
}
 
if type(h) == 'table' and h[1] ~= '' then mw.log(h[1])
for i,k in ipairs(h) do
if jerseys[h[i]] ~= nil then mw.log('>')
jersey = 'File:'.. jerseys[h[i]].file
local name
name = 'name_'..wiki
jersey_name = jerseys[h[i]][name] or jerseys[h[i]]['name_en'] or jerseys[h[i]]['name_fr'] or ''
if jersey_name~='' then jersey_string = jersey_string .. '[['..jersey..'|20px|'..jersey_name..']]'
else jersey_string = jersey_string .. '[['..jersey..'|20px]]'
end
else
local entity_jersey = mw.wikibase.getEntity(h[i])
pcall(function()
jersey = 'File:'.. entity_jersey.claims['P18'][1].mainsnak.datavalue.value
jersey_name = entity_jersey:getLabel() or entity_jersey:getLabel( 'en' ) or entity_jersey:getLabel( 'fr' ) or ''
if jersey_name~='' then jersey_string = jersey_string .. '[['..jersey..'|20px|'..jersey_name..']]'
else jersey_string = jersey_string .. '[['..jersey..'|20px]]'
end
end)
end
end
return jersey_string
else return ''
end
end -- function end
local startOfSeason = '' --'+2016-01-01T00:00:00Z'
pcall(function() startOfSeason = entity.claims["P580"][1].mainsnak.datavalue.value.time end)
if startOfSeason == '' then
if pcall(function() startOfSeason = entity.claims["P585"][1].mainsnak.datavalue.value.time end) then
else
local Sitelink = entity:getSitelink(wiki .. 'wiki') or entity:getSitelink('enwiki') or entity:getSitelink('frwiki') or entity:getSitelink('dewiki') or ''
if Sitelink == '' then return '> Wikidata is missing data about the start time (P580) and end time (P582) of the season'
else startOfSeason = '+'..string.match(Sitelink, '%d%d%d%d' ) ..'-01-01T00:00:00Z'
end
end
end
 
local k, v, a, b, rank
local max_rank = 0
local nr_jersey -- number of jerseys one rider has
 
pcall(function()
for k, _ in pairs(entity.claims[property]) do -- look into all statements
for _, v in pairs(entity.claims[property][k].qualifiers['P1352']) do -- for property 'rank'
rank = tonumber(v.datavalue.value.amount) break
end
if rank > max_rank then max_rank = rank end
 
nr_jersey = 1
g.jersey[rank], g.jersey_name[rank], g.jerseyIDs[rank] = {}, {}, {}
local entity_jersey
if pcall(function()
for _, v in pairs(entity.claims[property][k].qualifiers['P2912']) do -- for property 'distinctive jersey'
g.jerseyIDs[rank][nr_jersey] = 'Q'..v.datavalue.value['numeric-id']
entity_jersey = mw.wikibase.getEntityObject(g.jerseyIDs[rank][nr_jersey])
g.jersey[rank][nr_jersey] = 'File:'.. entity_jersey.claims['P18'][1].mainsnak.datavalue.value
g.jersey_name[rank][nr_jersey] = entity_jersey:getLabel() or entity_jersey:getLabel( 'fr' )
nr_jersey = nr_jersey + 1
end
end) then else g.jersey[rank][1] = '' end
 
g.riderIDs[rank] = 'Q' .. entity.claims[property][k].mainsnak.datavalue.value['numeric-id']
g.riderNames[rank] = WPlink(g.riderIDs[rank], 'pure')
 
a, b = pcall(fooA, 'numeric-id', mw.wikibase.getEntityObject( g.riderIDs[rank] ), 'P21', 1)
if a == true then
if b == 6581097 then g.riderGender[rank] = 'm' -- men
elseif b == 6581072 then g.riderGender[rank] = 'f' -- female
else g.riderGender[rank] = '' end
else g.riderGender[rank] = '' end
 
g.nr[rank] = rank
 
a, b = timeStartEnd(g.riderIDs[rank], "P27", 'numeric-id', startOfSeason)
if a == true then
g.flags[rank] = flag('Q'..b, startOfSeason)
if available == true then
if type( translations ) == "table" then g.country[rank] = translations.list('Q'..b) end
if g.country[rank] == '' then
local country = mw.wikibase.getEntityObject( 'Q'..b )
g.country[rank] = country:getLabel() or country:getLabel('en') .. ' (en)'
end
end
end
 
g.team[rank] = national_team(wiki, g.riderIDs[rank], startOfSeason, entity, property, k)
 
if pcall(function()
for _, v in pairs(entity.claims[property][k].qualifiers['P2781']) do -- for property 'race time'
g.time[rank] = tonumber(v.datavalue.value.amount)
end
end) then else g.time[rank] = '' end
local v = ''
if pcall(function()
local plus = ''
for _, v in pairs(entity.claims[property][k].qualifiers['P2911']) do -- for property 'time gap'
local localFrame
g.time_gap[rank] = tonumber(v.datavalue.value.amount)
if string.match(frame:getParent():getTitle(), '%P+') == mw.site.namespaces.Template.name
end
end) then localFrame = frame:getParent() else g.time_gap[rank]localFrame = ''frame end
if localFrame.args[1] ~= nil then localFrame.args[1] = string.gsub(localFrame.args[1], "%c", "") end
if localFrame.args.country ~= nil then -- switch country column on or off in the article
end -- end for
if localFrame.args.country == 'true' then country = true end
end)
if localFrame.args.country == 'false' then country = false end
 
for i= 1,max_rank do
if g.nr[i] == nil then g.nr[i]='' end
if g.riderNames[i] == nil then g.riderNames[i]='' end
-- if g.jersey[i] == nil then g.jersey[i] ='' end
if g.flags[i] == nil then g.flags[i]='' end
if g.country[i] == nil then g.country[i]='' else g.no_country=false end
if g.team[i] == nil then g.team[i]='' end
if g.time[i] == nil then g.time[i] ='' end
if g.time[i] ~= '' then g.time_date = true end
if g.time_gap[i] == nil then g.time_gap[i] ='' end
end
local tableHeader2_size = table.getn(s.header_2)
return g
end
local tableStart = '<table border="0" cellspacing="0" cellpadding="0"><tr><th colspan="'.. tostring(tableHeader2_size + 1) .. '"'..
 
' style="padding:2px 2px; text-align:center; background-color:#FFDF80">'
function p.generalclassification(frame)
local WDlink_on
local tableHeader1 = '<span style="float:left">[[File:Wikidata-logo S.svg|12px|link=d:'..
local wiki = wiki
s.item.. '#'.. s.property..']]</span>'.. s.header_function (s.header_1) .. '</th></tr>'
frame.args[1] = string.gsub(frame.args[1], "%c", "")
local item = frame.args[1]
local tableHeader2 = '<tr>'
local content = classification(item, 'P2321', wiki)
for i,k in ipairs(s.header_2) do
local time_headoftable = '' -- if there is time data in the classification, print the column time
if i==1 then tableHeader2 = tableHeader2.. '<th colspan="2" style="text-align:center;padding:2px 2px;white-space:nowrap">'.. s.header_function (k) .. '</th>' end
if content.time_date == true then time_headoftable = headoftableII(wiki,4) end
if i==2 and available_list==true and country == true then tableHeader2 = tableHeader2.. '<th style="text-align:center;padding:2px 2px;white-space:nowrap">'.. s.header_function (k) .. '</th>' end
 
if i>=3 then
if wiki == "mk" or wiki == "ja" or wiki == "lv" or wiki == "ru" then WDlink_on = true else WDlink_on = false end
if i ~= tableHeader2_size then tableHeader2 = tableHeader2.. '<th style="text-align:center;padding:2px 2px;white-space:nowrap">'.. s.header_function (k).. '</th>'
 
else tableHeader2 = tableHeader2..'<th style="text-align:center;padding:2px 2px;white-space:nowrap">'.. s.header_function (k) .. '</th>'
local tableStart = '<table border="0" cellspacing="0" cellpadding="0"><th colspan="5" style="padding:2px 2px; text-align:center; background-color:#FFDF80">'
end
local tableHeader1 = ''
if WDlink_on == false then tableHeader1 = tableHeader1 .. '<span style="float:left">[[File:Wikidata-logo S.svg|12px|link=d:'.. frame.args[1].. '#P2321]]</span>' end
tableHeader1 = tableHeader1 .. headoftableII(wiki,9)
local tableHeader2 = '<tr><th colspan="2" nowrap style="text-align:center;padding:2px 2px">'..headoftableII(wiki,1)
if available==true then tableHeader2 = tableHeader2..'<th nowrap style="text-align:center">'..headoftableII(wiki,2) end
tableHeader2 = tableHeader2.. '<th nowrap style="text-align:center">'..headoftableII(wiki,3)..
'</th><th nowrap style="text-align:center">'..time_headoftable .. '</th></tr>' -- '' or 'temp', depending on available time data
local tableBody = ''
local tableEnd = '</th></table>'
 
local i = 1
local bg_color -- background color
while content.riderNames[i] do
tableBody = tableBody .. '<tr'
-- find the right background color if a rider has more then one jersey
-- see Wikidata:WikiProject Cycling/Kit to translate/Jerseys
if type(content.jersey[i]) == 'table' and content.jersey[i][1] ~= '' then
local num = 1 -- loop for more then one jersey per rider
while content.jerseyIDs[i][num] ~= nil do
if content.jerseyIDs[i][num] == "Q24257872" then bg_color="#FF8666" break end -- Jersey red.svg
if content.jerseyIDs[i][num] == "Q24257763" then bg_color="pink" -- Jersey pink.svg
if wiki == "ca" then bg_color="lightpink" end
break end
if content.jerseyIDs[i][num] == "Q24257871" then bg_color="#FFFF99" break end -- Jersey yellow.svg
if content.jerseyIDs[i][num] == "Q26696171" then bg_color="#FFFFFF" break end -- Jersey white.svg
if content.jerseyIDs[i][num] == "Q24687408" then bg_color="#99CBFF" break end -- Jersey blue.svg
if content.jerseyIDs[i][num] == "Q26945272" then bg_color="#BF80FF" break end -- Jersey violet.svg
if content.jerseyIDs[i][num] == "Q24257991" then bg_color="#FFD700" break end -- Jersey gold.svg
if content.jerseyIDs[i][num] == "Q24258056" then bg_color="#FFD030" break end -- Jersey orange.svg
if content.jerseyIDs[i][num] == "Q24258125" then bg_color="#BFFF80" break end -- Jersey green 2.svg
num = num + 1
end
end
tableHeader2 = tableHeader2.. '</tr>'
 
if i == 1 then
local tableBody = ''
tableBody = tableBody ..' style="font-weight:bold;' -- winner is formated bold
pcall(function()
if type(content.jersey[i]) == 'table' and content.jersey[i][1] ~= '' and bg_color ~= nil then -- background color of winner depending on jersey
local t_Body = {}
tableBody = tableBody ..'background-color:'..bg_color..'"'
local bg_color=""
else tableBody = tableBody ..'"' end
local nr_jersey
end
for l, m in pairs(entity.claims[s.property]) do -- look into all statements
if available==true then tableBody = tableBody ..'><td nowrap style="padding:2px 0.5em 2px 0.5em;text-align:center">'.. number(content.riderGender[i], content.nr[i], wiki)..
h.rider[1]=''
'</td><td nowrap style="padding:0 0.2em 0 0.2em">'.. content.riderNames[i]
local rank
else tableBody = tableBody ..'><td nowrap style="padding:2px 0.5em 2px 0.5em;text-align:center">'.. number(content.riderGender[i], content.nr[i], wiki)..
pcall(function()
'</td><td nowrap style="padding:0 0.2em 0 0.2em">'.. content.flags[i]..' '.. content.riderNames[i]
for _, v in pairs(m.qualifiers['P1352']) do -- for property 'rank'
end
rank = tonumber(v.datavalue.value.amount) break
end
h.rider[1] = rank
end)
local riderID = 'Q'.. m.mainsnak.datavalue.value['numeric-id']
if s.team_classification == false then
h.rider[2] = WPlink(riderID)
h.rider[6] = national_team(riderID, startOfSeason, entity, s.property, l)
end
a, b = pcall(fooA, 'numeric-id', mw.wikibase.getEntityObject( riderID ), 'P21', 1)
if a == true then
if b == 6581097 then h.rider[3] = 'm' end -- men
if b == 6581072 then h.rider[3] = 'f' end -- female
else h.rider[3] = 'n' -- for teams
end
pcall(function() -- for property 'points' P1358
for _, v in pairs(m.qualifiers['P1358']) do h.value[1] = tonumber(v.datavalue.value.amount) end
end)
pcall(function() -- for property 'race time' P2781
for _, v in pairs(m.qualifiers['P2781']) do h.value[2] = tonumber(v.datavalue.value.amount) end
end)
pcall(function() -- for property 'time gap' P2911
for _, v in pairs(m.qualifiers['P2911']) do h.value[3] = tonumber(v.datavalue.value.amount) end
plus = '+ '
end)
pcall(function() -- for property 'speed' P2052
for _, v in pairs(m.qualifiers['P2052']) do h.value[4] = tonumber(v.datavalue.value.amount) end
end)
pcall(function() -- for property 'distinctive jersey'
h.jersey= {''}
nr_jersey = 1
for _, v in pairs(m.qualifiers['P2912']) do
h.jersey[nr_jersey] = 'Q'..v.datavalue.value['numeric-id']
nr_jersey = nr_jersey + 1
end
end)
if s.team_classification == true then
h.rider[6] = transform(riderID, 't', startOfSeason)
end
if s.team_classification == false then
local a, b = timeStartEnd(riderID, "P27", 'numeric-id', startOfSeason)
if a == true then
h.rider[5] = flag('Q'..b, startOfSeason)
if available_list == true and country == true then
if type( translations.list ) == "function" then h.rider[4] = translations.list('Q'..b) end
if h.rider[4] == '' then
local country = mw.wikibase.getEntityObject( 'Q'..b )
h.rider[4] = country:getLabel() or country:getLabel('en') .. ' (en)'
end
end
end
end
if s.team_classification == true then
local a, b = pcall(fooA, 'numeric-id', mw.wikibase.getEntityObject( riderID ), 'P17', 1)
if a == true then
a, b = timeStartEnd(riderID, "P17", 'numeric-id', startOfSeason)
if a == true then
h.rider[5] = flag('Q'..b, startOfSeason)
if available_list == true and country == true then
if type( translations.list ) == "function" then h.rider[4] = translations.list('Q'..b) end
if h.rider[4] == '' then
local country = mw.wikibase.getEntityObject( 'Q'..b )
h.rider[4] = country:getLabel() or country:getLabel('en') .. ' (en)'
end
end
end
end
end
local tBody = '<tr'
-- find the right background color if a rider has more then one jersey
-- see Wikidata:WikiProject Cycling/Kit to translate/Jerseys
if h.jersey[1] ~= '' then
local num = 1 -- loop for more then one jersey per rider
while h.jersey[num] ~= nil and h.jersey[num] ~= '' do
if h.jersey[num] == "Q24257871" then bg_color="#FFFF99" break end -- Jersey yellow.svg (General)
if h.jersey[num] == "Q24257763" then bg_color="#FFC0CB" -- Jersey pink.svg
if wiki == "ca" then bg_color="lightpink" end
break end
if h.jersey[num] == "Q24257872" then bg_color="#FF8666" break end -- Jersey red.svg (General)
if h.jersey[num] == "Q24687408" then bg_color="#99CBFF" break end -- Jersey blue.svg (General)
if h.jersey[num] == "Q24258056" then bg_color="#FFD030" break end -- Jersey orange.svg (General)
if h.jersey[num] == "Q26696171" then bg_color="#FFFFFF" break end -- Jersey white.svg (General)
if h.jersey[num] == "Q24258125" then bg_color="#BFFF80" break end -- Jersey green 2.svg (General)
if h.jersey[num] == "Q24257991" then bg_color="#FFD030" break end -- Jersey gold.svg (General)
if h.jersey[num] == "Q24645208" then bg_color="#90EE90" break end -- Jersey green.svg (General)
if h.jersey[num] == "Q26945271" then bg_color="#90EE90" break end -- MaillotVolta.png (General)
if h.jersey[num] == "Q26945272" then bg_color="#BF80FF" break end -- Jersey violet.svg (General)
if h.jersey[num] == "Q29982321" then bg_color="#FFFF99" break end -- Jersey combined.svg (General)
if h.jersey[num] == "Q29594434" then bg_color="#87CEEB" break end -- MaillotCyan.PNG (General)
if h.jersey[num] == "Q30132459" then bg_color="#FFFF99" break end -- Jersey yellow-bluebar.svg (General)
if h.jersey[num] == "Q24645209" then bg_color="#90EE90" break end -- Jersey green.svg (Points)
if h.jersey[num] == "Q25831179" then bg_color="#FFFFFF" break end -- Jersey white.svg (Points)
if h.jersey[num] == "Q26919974" then bg_color="#FF8666" break end -- Jersey red.svg (Points)
if h.jersey[num] == "Q24687409" then bg_color="#99CBFF" break end -- Jersey blue.svg (Points)
if h.jersey[num] == "Q25265938" then bg_color="#BF80FF" break end -- Jersey violet.svg (Points)
if h.jersey[num] == "Q27114205" then bg_color="#C0C0C0" break end -- Jersey black.svg (Points)
if h.jersey[num] == "Q28546656" then bg_color="#FFFF99" break end -- Jersey yellow.svg (Points)
if h.jersey[num] == "Q28820618" then bg_color="#87CEEB" break end -- MaillotCyan.PNG (Points)
if h.jersey[num] == "Q29982764" then bg_color="#FFD030" break end -- Jersey orange.svg (Points)
if h.jersey[num] == "Q43276992" then bg_color="#FFC0CB" break end -- Jersey pink.svg (Points)
if h.jersey[num] == "Q47945989" then bg_color="#6495ED" break end -- Jersey dark blue.svg (Points)
if h.jersey[num] == "Q25265958" then bg_color="#FFC0CB" break end -- Jersey polkadot.svg (Mountain)
if h.jersey[num] == "Q25265959" then bg_color="#E0FFFF" break end -- Jersey blue dotted.png (Mountain)
if h.jersey[num] == "Q25265960" then bg_color="#FFC0CB" break end -- Jersey climbing Dauphine.png (Mountain)
if h.jersey[num] == "Q27670178" then bg_color="#FF8666" break end -- Jersey red.svg (Mountain)
if h.jersey[num] == "Q27670182" then bg_color="#90EE90" break end -- Jersey green.svg (Mountain)
if h.jersey[num] == "Q27670174" then bg_color="#FFD030" break end -- Jersey orange.svg (Mountain)
if h.jersey[num] == "Q24790519" then bg_color="#C0C0C0" break end -- Jersey grey.svg (Mountain)
if h.jersey[num] == "Q27670105" then bg_color="#C0C0C0" break end -- Jersey blackdots.png (Mountain)
if h.jersey[num] == "Q28604413" then bg_color="#99CBFF" break end -- Jersey blue.svg (Mountain)
if h.jersey[num] == "Q25266023" then bg_color="#F5DEB3" break end -- Jersey brown.svg (Mountain)
if h.jersey[num] == "Q27670126" then bg_color="#FF8666" break end -- Jersey granate.svg (Mountain)
if h.jersey[num] == "Q25831602" then bg_color="#FF69B4" break end -- Jersey rosa.svg (Mountain)
if h.jersey[num] == "Q29168665" then bg_color="#FFC0CB" break end -- Jersey pink.svg (Mountain)
if h.jersey[num] == "Q29823248" then bg_color="#FFFFFF" break end -- Jersey white.svg (Mountain)
if h.jersey[num] == "Q28820591" then bg_color="#F5DEB3" break end -- Jersey red green.svg (Mountain)
if h.jersey[num] == "Q36859499" then bg_color="#CCFFCC" break end -- Jersey greendots.svg (Mountain)
if h.jersey[num] == "Q33060977" then bg_color="#C0C0C0" break end -- Jersey black.svg (Mountain)
if h.jersey[num] == "Q26858731" then bg_color="#FFFFFF" break end -- Jersey white.svg (Combinated)
if h.jersey[num] == "Q28823004" then bg_color="#FFFF99" break end -- Jersey combined.svg (Combinated)
if h.jersey[num] == "Q28604421" then bg_color="#FFD030" break end -- Jersey orange.svg (Combinated)
if h.jersey[num] == "Q43098388" then bg_color="#99CBFF" break end -- Jersey blue.svg (Combinated)
if h.jersey[num] == "Q24790627" then bg_color="#FF8666" break end -- Jersey red.svg (Sprints)
if h.jersey[num] == "Q25831754" then bg_color="#99CBFF" break end -- Jersey blue.svg (Sprints)
if h.jersey[num] == "Q26806427" then bg_color="#90EE90" break end -- Jersey green.svg (Sprints)
if h.jersey[num] == "Q27478100" then bg_color="#C0C0C0" break end -- Jersey black.svg (Sprints)
if h.jersey[num] == "Q28060932" then bg_color="#BF80FF" break end -- Jersey violet.svg (Sprints)
if h.jersey[num] == "Q28483869" then bg_color="#FFFF99" break end -- Jersey yellow.svg (Sprints)
if h.jersey[num] == "Q33134180" then bg_color="#FF69B4" break end -- Jersey rosa.svg (Sprints)
if h.jersey[num] == "Q42532690" then bg_color="#E0FFFF" break end -- Jersey light blue.svg (Sprints)
if h.jersey[num] == "Q43278032" then bg_color="#FFC0CB" break end -- Jersey polkadot.svg (Sprints)
if h.jersey[num] == "Q47513277" then bg_color="#FFFFFF" break end -- Jersey white.svg (Sprints)
if h.jersey[num] == "Q24645383" then bg_color="#FFFFFF" break end -- Jersey white.svg (Best young)
if h.jersey[num] == "Q26919967" then bg_color="#90EE90" break end -- Jersey green.svg (Best young)
if h.jersey[num] == "Q26209148" then bg_color="#99CBFF" break end -- Jersey blue.svg (Best young)
if h.jersey[num] == "Q26696523" then bg_color="#FFD030" break end -- Jersey orange.svg (Best young)
if h.jersey[num] == "Q29229790" then bg_color="#BF80FF" break end -- Jersey violet.svg (Best young)
if h.jersey[num] == "Q29982765" then bg_color="#FFC0CB" break end -- Jersey pink.svg (Best young)
if h.jersey[num] == "Q33134078" then bg_color="#FF8666" break end -- Jersey red.svg (Best young)
if h.jersey[num] == "Q38929482" then bg_color="#FFFF99" break end -- Jersey yellow.svg (Best young)
if h.jersey[num] == "Q33026698" then bg_color="#FF8666" break end -- Jersey red.svg (Best young)
if h.jersey[num] == "Q26953919" then bg_color="#8FBC8F" break end -- Jersey dark green.svg (Combativity)
if h.jersey[num] == "Q29957114" then bg_color="#87CEEB" break end -- MaillotCyan.PNG (Combativity)
if h.jersey[num] == "Q25265995" then bg_color="#F5DEB3" break end -- Jersey red green.svg (Combativity)
if h.jersey[num] == "Q29594765" then bg_color="#C0C0C0" break end -- Jersey black.svg (Combativity)
if h.jersey[num] == "Q30035039" then bg_color="#FFD030" break end -- Jersey orange.svg (Combativity)
if h.jersey[num] == "Q30035038" then bg_color="#90EE90" break end -- Jersey green.svg (Combativity)
if h.jersey[num] == "Q48691401" then bg_color="#F2BC38" break end -- Jersey Goldenrod.svg (Combativity)
num = num + 1
end
end
if l == 1 and s.background == 'color' then
tBody = tBody ..' style="font-weight:bold;' -- winner is formated bold
if h.jersey[1] ~= '' and bg_color ~= nil then -- background color of winner depending on jersey
tBody = tBody ..'background-color:'..bg_color..'"'
else tBody = tBody ..'"' end
end
if l == 1 and s.background == 'strong' then
tBody = tBody ..' style="font-weight:bold;' -- winner is formated bold
end
tBody = tBody .. '><td style="text-align:center;padding:2px 0.5em 2px 0.5em;white-space:nowrap">'.. number(h.rider[3], h.rider[1], wiki).. '</td><td style="text-align:' .. textalign .. ';padding:0 0.2em 0 0.2em">'
if s.team_classification == false then
if h.rider[6]==nil then h.rider[6]='' end
if available_list==false then tBody = tBody..h.rider[5].. ' '.. h.rider[2].. jersey(h.jersey)..'</td><td>'.. h.rider[6]
else
if country == true then tBody = tBody.. h.rider[2].. jersey(h.jersey)..'</td><td>'.. h.rider[5]..' '.. h.rider[4].. '</td><td style="text-align:' .. textalign .. ';padding:0 0.2em 0 0.2em">'.. h.rider[6]
else tBody = tBody.. h.rider[5].. ' '.. h.rider[2].. jersey(h.jersey)..'</td><td style="text-align:' .. textalign .. ';padding:0 0.2em 0 0.2em">'.. h.rider[6] end
end
else
if available_list==false then tBody = tBody.. h.rider[5].. ' '.. WPlink(riderID, 'team', startOfSeason).. jersey(h.jersey)
else
if country == true then tBody = tBody.. WPlink(riderID, 'team', startOfSeason).. jersey(h.jersey).. '</td><td>'.. h.rider[5].. ' '.. h.rider[4]
else tBody = tBody.. h.rider[5].. ' '.. WPlink(riderID, 'team', startOfSeason).. jersey(h.jersey) end
end
end
tBody = tBody.. '</td>'
if s.header_2[4]==4 then -- for table stageclassification, generalclassification, adds time and time gap
if l == 1 then tBody = tBody.. '<td style="text-align:right;padding:0 0.2em 0 0.2em">'.. calculate_time(wiki, h.value[2]).. '</td>'
else tBody = tBody.. '<td style="text-align:right;padding:0 0.2em 0 0.2em">'.. plus.. calculate_time(wiki, h.value[3]).. '</td>'
end
end
if s.header_2[4] == 7 then -- for table pointsclassification, adds points
tBody = tBody.. '<td style="text-align:right;padding:0 0.2em 0 0.2em">'.. h.value[1].. '<span style="font-size:80%">'
if type(h.value[1]) == "number" then if h.value[1] > 1 then tBody = tBody..unit(7) else tBody = tBody..unit(6) end end
tBody = tBody.. '</span>' .. '</td>'
end
if s.header_2[3] == 4 then
if s.property == 'P2417' then -- for table teamtimetrialclassification, adds time
tBody = tBody.. '<td style="text-align:right;padding:0 0.2em 0 0.2em">'.. calculate_time(wiki, h.value[2]) .. '</td>'
end
end
if s.property == 'P3497' then -- for table teambytimeclassification, adds time and time gap
if type(content.jersey[i]) == 'table' and content.jersey[i][1] ~= '' then
if l == 1 then tBody = tBody.. '<td style="text-align:right;padding:0 0.2em 0 0.2em">'.. calculate_time(wiki, h.value[2]) .. '</td>'
tableBody = tableBody ..' '
else tBody = tBody.. '<td style="text-align:right;padding:0 0.2em 0 0.2em">'.. plus.. calculate_time(wiki, h.value[3]) .. '</td>'
local num = 1 -- loop for more then one jersey per rider
end
while content.jersey[i][num] ~= nil do
end
tableBody = tableBody ..'[['..content.jersey[i][num]..'|20px|'..content.jersey_name[i][num]..']]'
num = num + 1
if s.property == 'P3496' then -- for table teambypointsclassification, adds points
tBody = tBody.. '<td style="text-align:right;padding:0 0.2em 0 0.2em">'.. h.value[1].. '<span style="font-size:80%">'
if type(h.value[1]) == "number" then if h.value[1] > 1 then tBody = tBody..unit(7) else tBody = tBody..unit(6) end end
tBody = tBody.. '</span>' .. '</td>'
end
if s.header_2[4] == 5 then -- for table teamtimetrialclassification, adds time gap
tBody = tBody.. '<td style="text-align:right;padding:0 0.2em 0 0.2em">'
if l > 1 then tBody = tBody.. plus end
tBody = tBody.. calculate_time(wiki, h.value[3]) .. '</td>'
end
if s.header_2[5] == 6 then -- for table teamtimetrialclassification, adds speed
tBody = tBody.. '<td style="text-align:right;padding:0 0.2em 0 0.2em">'
if type(h.value[4]) == "number" then tBody = tBody.. mw.ustring.format('%.3f', h.value[4])..
'<span style="font-size:80%">'.. unit(5).. '</span>'
end
tBody = tBody.. '</td>'
end
tBody = tBody.. '</tr>'
if rank ~= nil then t_Body[rank] = tBody.. '</tr>' end -- sort table row into the right row
end
for _, m in pairs(t_Body) do tableBody = tableBody..m end
end)
local tableFooter=''
if s.display_ref ~=nil and s.display_ref==1 then
tableFooter ='<td class="navigation-only" colspan='..tostring(tableHeader2_size + 1)..' style="border-top: 2px #FFDF80 solid; font-size: 80%; "></td>'
tableFooter= tableFooter.."<tr><td colspan=" .. tostring(tableHeader2_size + 1) ..' style="text-align:right><small>'..race_reference(entity) ..' </small></td></tr>'
end
 
local tableEnd = '</table>'
if available==true then tableBody = tableBody.. '</td><td nowrap style="padding:0 0.2em 0 0.2em;">'.. content.flags[i].. ' '.. content.country[i]..
'</td><td style="padding:0 0.2em 0 0.2em">' .. content.team[i]
local tableStyle, tableNewline
else tableBody = tableBody.. '</td><td style="padding:0 0.2em 0 0.2em">' .. content.team[i]
if localFrame.args.newline == 'false' then -- parameter newline in WP article is 'false'
tableStyle = "float:"..floattable.."; margin-right:0.5em; border:1px solid rgb(200,200,200)"
tableNewline = ''
end
if localFrame.args.newline == 'true' then -- parameter newline in WP article is 'true'
 
tableStyle = "border:1px solid rgb(200,200,200)"
-- calculate time
tableNewline = '<br style="clear:left;">'
if content.time[i] == '' and content.time_gap[i] == '' then tableBody = tableBody .. '</td><td>' else
if i == 1 and content.time[i]~='' then tableBody = tableBody..
'</td><td style="text-align:right;padding:0 0.2em 0 0.2em">'.. calculate_time(wiki,content.time[i]).. '</td>'
elseif content.time_gap[i]~= '' then tableBody = tableBody..
'</td><td style="text-align:right;padding:0 0.2em 0 0.2em">'.. '+ '.. calculate_time(wiki,content.time_gap[i]).. '</td>' end
end
i = i + 1
end -- end while
 
tableBody = tableBody.. '</td></tr>'
 
return '<table style="border:1px solid rgb(200,200,200)"><tr><td>'..
tableStart.. tableHeader1.. tableHeader2.. tableBody.. tableEnd.. '</td></tr></table><br style="clear:left;">'
end
 
function p.stageclassification(frame)
local WDlink_on
local wiki = wiki
frame.args[1] = string.gsub(frame.args[1], "%c", "")
local item = frame.args[1]
local content = classification(item, 'P2417', wiki)
local time_headoftable = '' -- if there is time data in the classification, print the column time
if content.time_date == true then time_headoftable = headoftableII(wiki,4) end
 
if wiki == "mk" or wiki == "ja" or wiki == "lv" or wiki == "ru" then WDlink_on = true else WDlink_on = false end
 
local tableStart = '<table border="0" cellspacing="0" cellpadding="0"><th colspan="5" style="padding:2px 2px; text-align:center; background-color:#FFDF80">'
local tableHeader1 = ''
if WDlink_on == false then tableHeader1 = tableHeader1 .. '<span style="float:left">[[File:Wikidata-logo S.svg|12px|link=d:'.. frame.args[1].. '#P2321]]</span>' end
tableHeader1 = tableHeader1 .. headoftableII(wiki,8)
local tableHeader2 = '<tr><th colspan="2" nowrap style="text-align:center;padding:2px 2px">'..headoftableII(wiki,1)
if available==true then tableHeader2 = tableHeader2..'<th nowrap style="text-align:center">'..headoftableII(wiki,2) end
tableHeader2 = tableHeader2.. '<th nowrap style="text-align:center">'..headoftableII(wiki,3)..
'</th><th nowrap style="text-align:center">'..time_headoftable .. '</th></tr>' -- '' or 'temp', depending on available time data
local tableBody = ''
local tableEnd = '</th></table>'
 
local i = 1
local bg_color -- background color
while content.riderNames[i] do
tableBody = tableBody .. '<tr'
if i == 1 then tableBody = tableBody ..' style="font-weight:bold;"' end -- winner is formated bold
 
if available==true then tableBody = tableBody ..'><td nowrap style="padding:2px 0.5em 2px 0.5em;text-align:center">'.. number(content.riderGender[i], content.nr[i], wiki)..
'</td><td nowrap style="padding:0 0.2em 0 0.2em">'.. content.riderNames[i]
else tableBody = tableBody ..'><td nowrap style="padding:2px 0.5em 2px 0.5em;text-align:center">'.. number(content.riderGender[i], content.nr[i], wiki)..
'</td><td nowrap style="padding:0 0.2em 0 0.2em">'.. content.flags[i]..' '.. content.riderNames[i]
end
if localFrame.args.newline == nil then -- no second parameter, compatible to the old code
 
if s.property == 'P2417' then --stageclassification
if type(content.jersey[i]) == 'table' and content.jersey[i][1] ~= '' then
tableStyle = "float:"..floattable.."; margin-right:0.5em; border:1px solid rgb(200,200,200)"
tableBody = tableBody ..' '
tableNewline = ''
local num = 1 -- loop for more then one jersey per rider
else
while content.jersey[i][num] ~= nil do
tableStyle = "border:1px solid rgb(200,200,200)"
tableBody = tableBody ..'[['..content.jersey[i][num]..'|20px|'..content.jersey_name[i][num]..']]'
tableNewline = '<br style="clear:left;">' -- everything else
num = num + 1
end
end
 
return '<table style="'.. tableStyle.. '"><tr><td>' .. tableStart .. tableHeader1 .. tableHeader2 .. tableBody .. tableFooter..tableEnd .. '</td></tr></table>' .. tableNewline
if available==true then tableBody = tableBody.. '</td><td nowrap style="padding:0 0.2em 0 0.2em;">'.. content.flags[i].. ' '.. content.country[i]..
'</td><td style="padding:0 0.2em 0 0.2em">' .. content.team[i]
else tableBody = tableBody.. '</td><td style="padding:0 0.2em 0 0.2em">' .. content.team[i]
end
 
-- calculate time
if content.time[i] == '' and content.time_gap[i] == '' then tableBody = tableBody .. '</td><td>' else
if i == 1 and content.time[i]~='' then tableBody = tableBody..
'</td><td style="text-align:right;padding:0 0.2em 0 0.2em">'.. calculate_time(wiki,content.time[i]).. '</td>'
elseif content.time_gap[i]~= '' then tableBody = tableBody..
'</td><td style="text-align:right;padding:0 0.2em 0 0.2em">'.. '+ '.. calculate_time(wiki,content.time_gap[i]).. '</td>' end
end
i = i + 1
end -- end while
 
tableBody = tableBody.. '</td></tr>'
 
return '<table style="float:left; margin-right:0.5em; border:1px solid rgb(200,200,200)"><tr><td>'..
tableStart.. tableHeader1.. tableHeader2.. tableBody.. tableEnd.. '</td></tr></table>'
end
 
function references(entity, property, var1)
local wiki = string.match(mw.site.server, "%a+")
local ref1, ref2, ref2b, ref3, ref4 = "", " ", "", "", ""
local url, ref
local a, b
 
if wiki == 'www'onwikidata then wiki = 'fr' lang = mw.getLanguage('fr') end
 
a, b = pcall(fooB, 'value', entity, property, var1, 1, 'P854', 1) -- url
if d ~= '00' and m ~= '00' then
if wiki == "de" then ref3 = ', ' .. lang:formatDate( "j. F Y", b)
elseif wiki == "ar" then ref3 = '، ' .. lang:formatDate( "j F Y", b) .. '.'
elseif wiki == "en" then ref3 = ', ' .. lang:formatDate( "Y F, j", b) .. '.'
elseif wiki == "fr" then ref3 = ', ' .. lang:formatDate( "j F Y", b)
else ref3 = ', ' .. func_date (b, wiki, 'long') .. '.' --lang:formatDate( "j n Y", b) .. '.'
end
elseif d == '00' and m ~= '00' then
d = '01'
if wiki == "de" then ref3 = ', ' .. lang:formatDate( "F Y", year..'-'..m..'-'..d )
elseif wiki == "ar" then ref3 ='، ' .. lang:formatDate( "F Y", year..'-'..m..'-'..d )..'.'
elseif wiki == "en" then ref3 =', ' .. lang:formatDate( "Y F", year..'-'..m..'-'..d )..'.'
elseif wiki == "fr" then ref3 =', ' .. lang:formatDate( "F Y", year..'-'..m..'-'..d )
if a == true then
if wiki == "de" then ref4 = ", (abgerufen am " .. lang:formatDate( "j. F Y", b).. ')'
elseif wiki == "ar" then ref4 = " تاريخ الوصول " .. lang:formatDate( "j F Y", b) .. '.'
elseif wiki == "en" then ref4 = " Retrieved " .. lang:formatDate( "Y F, j", b) .. '.'
elseif wiki == "fr" then ref4 = " (consulté le " .. lang:formatDate( "j F Y", b) .. ')'
else ref4 = " Retrieved " .. func_date (b, wiki, 'long').. '.' --lang:formatDate( "j n Y", b) .. '.'
end
end
ref = ref2b .. '['.. ref1.. ' '.. ref2.. '] ' .. url.. ref3 .. ref4
end
return ref or ''
-- end-- end if wiki == 'www'
else return ref or ''
end
else return ''
end
end
 
local entityId = frame.args[1]
local lang = mw.language.getContentLanguage()
local wiki = string.match(mw.site.server, "%a+")
local results = false
local a1, b1, c1, a2, b2, c2
then localFrame = frame:getParent() else localFrame = frame end
 
if localFrame.args[infobox_translate(2)] then tt.nr = localFrame.args[infobox_translate(2)] end
if localFrame.args[infobox_translate(29)] then tt.picture = localFrame.args[infobox_translate(29)] end
if localFrame.args[infobox_translate(30)] then tt.caption = localFrame.args[infobox_translate(30)] end
if localFrame.args[infobox_translate(31)] then tt.map = localFrame.args[infobox_translate(31)] end
 
if entity:getLabel() ~= nil then tt.name = entity:getLabel()
else
if wiki == "ar" and entity:getLabel( 'fren' ) ~= nil then tt.name = entity:getLabel( 'fren' ).. " (fr)"
elseif entity:getLabel( 'fr' ) ~= nil then tt.name = entity:getLabel( 'fr' ).. " (fr)"
else tt.name = "Wikidata doesn´t know" end
else tt.name = "Wikidata doesn´t know" end
end
 
if a == true and tt.nr == "" then
tt.nr = b .. ". "
if wiki == "fr" or wiki == "www" then
if b == 1 then tt.nr = "1<sup>re</sup> " else tt.nr = b .."<sup>e</sup> " end end
if wiki == "nl" then tt.nr = b .."e " end
if wiki == "eo" then tt.nr = b .."-a " end
if wiki == "cs" then tt.nr = b ..". " end
if wiki == "hu" then tt.nr = b .."-ik " end
end
-- Class of a cycling race. Class is: 1.UWT, 2.UWT, 1.HC, ... add new classes, no problem
else -- if there is only one value, assume it is not a class
if a == true or c == true then t.is_a = "Q"..b end
end
if t.is_a == "Q27020041" then -- if is_a = season so try to find it from "season of"
a, b = pcall(fooA, 'numeric-id', entity, 'P3450', 1)
if a == true then t.is_a = "Q"..b end
end
 
else t.starttime = lang:formatDate( "j", b1 )
end
if wiki == "ar" then
if y ~= y2 then t.starttime = lang:formatDate( "d F Y", b1 )
elseif m ~= m2 then t.starttime = lang:formatDate( "d F", b1 )
else t.starttime = lang:formatDate( "d F", b1 )
end end
if wiki == "br" then
if y ~= y2 then t.starttime = lang:formatDate( "j", b1 ) .." a viz ".. lang:formatDate( "F Y", b1 )
t.endtime = lang:formatDate( "j F Y", b2 )
timeofrace = b2
if wiki == "ar" then
if y ~= y2 then t.endtime = lang:formatDate( "d F Y", b2 )
elseif m ~= m2 then t.endtime = lang:formatDate( "d F Y", b2 )
else t.endtime = lang:formatDate( "d، Y", b2 )
end end
if wiki == "br" then t.endtime = lang:formatDate( "j", b2 ) .." a viz ".. lang:formatDate( "F Y", b2 ) end
if wiki == "ca" or wiki == "es" then t.endtime = lang:formatDate( "j", b2 ) .." de ".. lang:formatDate( "F", b2 ) .." de ".. lang:formatDate( "Y", b2 ) end
elseif m ~= m2 then t.endtime = lang:formatDate( "F d, Y", b2 )
else t.endtime = lang:formatDate( "d, Y", b2 )
end end
if wiki == "eo" then t.endtime = lang:formatDate( "j", b2 ) .."-a de ".. lang:formatDate( "F Y", b2 ) end
if wiki == "eu" then t.endtime = lang:formatDate( "Y", b2 ) ..".eko ".. lang:formatDate( "F", b2 ) .."k ".. lang:formatDate( "j", b2 ) end
end -- if a2
 
-- This function give a format to dates when P585 (date) is used in a single day race
a1, b1, c1 = pcall(fooA, 'time', entity, 'P585', 1)
if a1 == true and t.time == "" then i = 1
a1, b1, c1 = pcall(fooA, 'time', entity, 'P585', i)
end
t.time = func_date (b1, wiki, 'long')
timeofrace = b1
end
-- This function permits to display an unity (the kilometer) for a distance, with exceptions for macedionan, russian and japanese
-- that have other symbols
a1, b1, c1 = pcall(fooA, 'amount', entity, 'P3157', 1)
if a1 == true and t.length == "" then i = 1
while a1 == true and c1 == 'deprecated' do
i = i + 1
a1, b1, c1 = pcall(fooA, 'amount', entity, 'P3157', i)
end
t.length = b1
a1, b1, _ = pcall(fooA, 'unit', entity, 'P3157', 1)
if b1 == "http://www.wikidata.org/entity/Q828224" then
t.length_unit = 'km'
if wiki == "ar" then t.length_unit = 'كم' end
if wiki == "mk" then t.length_unit = 'км' end
if wiki == "ru" then t.length_unit = 'км' end
if wiki == "ja" then t.length_unit = 'キロメートル' end
end
end
 
a1, b1, c1 = pcall(fooA, 'amount', entity, 'P2043', 1)
if a1 == true and t.length == "" then i = 1
if b1 == "http://www.wikidata.org/entity/Q828224" then
t.length_unit = 'km'
if wiki == "ar" then t.length_unit = 'كم' end
if wiki == "mk" then t.length_unit = 'км' end
if wiki == "ru" then t.length_unit = 'км' end
if b1 == "http://www.wikidata.org/entity/Q180154" then
t.speed_unit = 'km/h'
if wiki == "ar" then t.speed_unit = 'كم/س' end
if wiki == "da" or wiki == 'fo' or wiki == 'no' then t.speed_unit = 'km/t' end
if wiki == "nl" then t.speed_unit = 'km/u' end
local note, qual, id, id_team
-- By entering a value just below, the Wikipedia added will have Wikidata logos associated with cyclists in the infobox
if wiki == "www" or wiki == "mk" or wiki == "ja" or wiki == "lv" or wiki == "ru" then note = 'q' else note = 'f' end
else note = 'f'
end
-- By entering a value just below, the Wikipedia added will show the team of the winner
if pcall(foo3, entity, "P1346", 1, "P642", 1) then
end
end
-- -- pcall(function() id=v.mainsnak.datavalue.value['numeric-id'] end) -- rider ID
-- looks into race item if the winner has a P54 statement for beeng a member of a national team
pcall(function()
for _, vv in pairs(entity.claims["P1346"][k].qualifiers['P54']) do
id_team = '2t'.. ' ('.. national_team(wiki, 'Q'..id, timeofrace, entity, 'P1346', k).. ')'
end
end)
for _, vv in pairs(entity.claims["P1346"][k].qualifiers['P642']) do
qual=vv.datavalue.value['numeric-id']
if id~=nil then
 
if id~=nil and qual~=nil and v.rank~='deprecated' then
if qual == 20882667 and t.first=="" then t.first=note..id t.first_team=id_team ref.first=references(entity,"P1346",k) results=true end
if qual == 20882668 and t.second=="" then t.second=note..id t.second_team=id_team ref.second=references(entity,"P1346",k) results=true end
if qual == 20882669 and t.third=="" then t.third=note..id t.third_team=id_team ref.third=references(entity,"P1346",k) results=true end
if qual == 20883007 and t.winner_point=="" then t.winner_point=note..id t.winner_point_team=id_team ref.winner_point=references(entity,"P1346",k) results=true end
if qual == 20883212 and t.winner_mountain=="" then t.winner_mountain=note..id t.winner_mountain_team=id_team ref.winner_mountain=references(entity,"P1346",k) results=true end
if qual == 20883328 and t.winner_sprint=="" then t.winner_sprint=note..id t.winner_sprint_team=id_team ref.winner_sprint=references(entity,"P1346",k) results=true end
if qual == 20883139 and t.winner_young=="" then t.winner_young=note..id t.winner_young_team=id_team ref.winner_young=references(entity,"P1346",k) results=true end
if qual == 20893983 and t.winner_fighting=="" then t.winner_fighting=note..id t.winner_fighting_team=id_team ref.winner_fighting=references(entity,"P1346",k) results=true end
if qual == 27067359 and t.winner_metas_volantes=="" then t.winner_metas_volantes=note..id t.winner_metas_volantes_team=id_team ref.winner_metas_volantes=references(entity,"P1346",k) results=true end
if qual == 27067170 and t.winner_regularity=="" then t.winner_regularity=note..id t.winner_regularity_team=id_team ref.winner_regularity=references(entity,"P1346",k) results=true end
if qual == 20893979 and t.winner_combination=="" then t.winner_combination=note..id t.winner_combination_team=id_team ref.winner_combination=references(entity,"P1346",k) results=true end
if qual == 27907715 and t.winner_fuga_pinarello=="" then t.winner_fuga_pinarello=note..id t.winner_fuga_pinarello_team=id_team ref.winner_fuga_pinarello=references(entity,"P1346",k) results=true end
if qual == 27907747 and t.winner_azzurri_ditalia=="" then t.winner_azzurri_ditalia=note..id t.winner_azzurri_ditalia_team=id_team ref.winner_azzurri_ditalia=references(entity,"P1346",k) results=true end
if qual == 20882921 and t.winner_team == "" then t.winner_team = note .. id ref.winner_team=references(entity,"P1346",k) results = true end
a, b = pcall(fooA, 'numeric-id', mw.wikibase.getEntity( 'Q'..id ), 'P31', 1)
if qual == 27104269 and t.winner_team_points == "" then t.winner_team_points = note .. id ref.winner_team_points=references(entity,"P1346",k) results = true end
if a == true and (b == 20738667 or b == 23726798) then -- test if 'national cycling team U23' or 'national cycling team'
end
t.winner_team = '2t' .." "..national_team('Q'..id, timeofrace, entity, 'P1346', k)
end
else
t.winner_team = note .. id ref.winner_team=references(entity,"P1346",k) results = true
end
end
if qual == 27104269 and t.winner_team_points == "" then t.winner_team_points = note .. id ref.winner_team_points=references(entity,"P1346",k) results = true end
end
else
a, b = pcall(fooC, 'numeric-id', entity, 'P1346', k, 'P828', 1) -- "has cause" (P828) to be nil?
c, d = pcall(fooC, 'numeric-id', entity, 'P1346', k, 'P1013', 1) -- "criterion used"(P1013) to be nil?
if qual~=nil and a == true and b == 1229261 -- has cause:disqualification
and c == true and d == 45123627 then -- criterion used:declared deserted
if qual == 20882667 and t.first=="" then t.first=note..d results=true end
if qual == 20882668 and t.second=="" then t.second=note..d results=true end
if qual == 20882669 and t.third=="" then t.third=note..d results=true end
if qual == 20883007 and t.winner_point=="" then t.winner_point=note..d results=true end
if qual == 20883212 and t.winner_mountain=="" then t.winner_mountain=note..d results=true end
if qual == 20883328 and t.winner_sprint=="" then t.winner_sprint=note..d results=true end
if qual == 20883139 and t.winner_young=="" then t.winner_young=note..d results=true end
if qual == 20893983 and t.winner_fighting=="" then t.winner_fighting=note..d results=true end
if qual == 27067359 and t.winner_metas_volantes=="" then t.winner_metas_volantes=note..d results=true end
if qual == 27067170 and t.winner_regularity=="" then t.winner_regularity=note..d results=true end
if qual == 20893979 and t.winner_combination=="" then t.winner_combination=note..d results=true end
if qual == 27907715 and t.winner_fuga_pinarello=="" then t.winner_fuga_pinarello=note..d results=true end
if qual == 27907747 and t.winner_azzurri_ditalia=="" then t.winner_azzurri_ditalia=note..d results=true end
if qual == 20882921 and t.winner_team=="" then t.winner_team=note..d results=true end
if qual == 27104269 and t.winner_team_points=="" then t.winner_team_points=note..d results=true end
end
end
end -- for _, vv
end)
end -- for
for w=num,1,-1 do
for ww=1,w do
-- mw.log ('w=',w,' ww= ', ww)
if w ~= ww then
if list[w][1] == list[ww][1] then list[w][1] = frame:extensionTag{name='ref', args={name=entityId..ww}} break end
--look into P17 (country) to get the Qnumber of that country
a, b = pcall(fooA, 'numeric-id', mw.wikibase.getEntity( t[k] ), 'P17', 1)
if a == true and pcall(foo1, t[k]) then t[k] = flag("Q"..b, timeofrace).." "..WPlink( t[k], 'winner_teamteam', timeofrace )..ref[k] else t[k] = WPlink( t[k], 'winner_teamteam', timeofrace )..ref[k] end
end
end
--local nl ="&#10;"
-- local tooltip = infobox_bottom(2) .. nl .. mw.text.encode( property(1) .. ' (P393)' ) .. nl .. mw.text.encode( property(2) ..' (P17)')
 
local miles
local miles_h
if t.length ~= "" then
if wiki == 'en' then -- To show distance in kilometers and miles
t.length, _ = string.gsub(t.length, "[+]", "") -- delets "+" sign from t.length
miles = math.modf(10*t.length/1.609344)/10
miles = lang:formatNum(tonumber(miles)) -- formats t_g.miles in the way it is done in the local Wiki
end
t.length, _ = string.gsub(t.length, "[+]", "") -- delets "+" sign from t.length
t.length = lang:formatNum(tonumber(t.length)) -- formats t.length in the way it is done in the local Wiki
if wiki == 'fo' then t.length = string.gsub(t.length, "%.", ",") end
end
if t.speed ~= "" then
if wiki == 'en' then -- To show speed in kilometers per hour and miles per hour
miles_h = math.modf(1000*t.speed/1.609344)/1000
miles_h = lang:formatNum(tonumber(miles_h)) -- formats t_g.miles in the way it is done in the local Wiki
end
t.speed, _ = string.gsub(t.speed, "[+]", "")
t.speed = lang:formatNum(tonumber(t.speed))
if wiki == 'fo' then t.speed = string.gsub(t.speed, "%.", ",") end
end
 
if t.cost ~= "" then
t.cost, _ = string.gsub(t.cost, "[+]", "")
local j, _ = string.find(k, "]")
if i ~= nil and j ~= nil then
t.previous = string.sub(k, 1, i) .. span1 .. string.match(string.sub(k, i+1, j-1), "%d%d%d%d") .. string.sub(k, j)
if wiki == "ar" then t.previous = string.sub(k, 1, i) .. span2 .. (string.match(string.sub(k, i+1, j-1), "%d%d%d%d") or '') .. string.sub(k, j) end
else
if string.find(k, "%d%d%d%d") == nil then t.previous = '' else t.previous = string.sub(k, string.find(k, "%d%d%d%d")) end
if t.previous ~= "" then t.previous = span1 .. t.previous end
t.previous = span1 .. t.previous
if wiki == "ar" then t.previous = span2 .. t.previous end
end
end
 
k = t.next
i, _ = string.find(k, "|")
j, _ = string.find(k, "]")
if i ~= nil and j ~= nil then
t.next = string.sub(k, 1, i) .. string.match(string.sub(k, i+1, j-1), "%d%d%d%d") .. span2 .. string.sub(k,j)
if wiki == "ar" then t.next = string.sub(k, 1, i) .. (string.match(string.sub(k, i+1, j-1), "%d%d%d%d") or '') .. span1 .. string.sub(k,j) end
else
if string.find(k, "%d%d%d%d") == nil then t.next = "" else t.next = string.sub(k, string.find(k, "%d%d%d%d")) end
if t.next ~= "" then t.next = t.next .. span2 end
t.next = t.next .. span2
if wiki == "ar" then t.next = span1 .. t.next end
end
end
 
end
 
tab = "<table cellpadding='4' cellspacing='0' style='float:right"..floatinfobox.."; width:300px; border:1px solid rgb(200,200,200);"
tab = tab .. "margin:0 0 0.5em 0.5em; background-color:rgb(255, 255, 255); color:black; padding:5px; clear:left; "
tab = tab .. "text-align:left" .. textalign .. "; font-size:85%; line-height:1.6em;'>"
if wiki == "eo" then tab = "<table style='width:23em; border:1px solid rgb(200,200,200);"
tab = tab .. "margin:0 0 0.5em 0.5em; background-color:rgb(255, 255, 255); color:black; padding:5px;"
tab = tab .. "text-align:left" .. textalign .. "; font-size:85%; line-height:1.6em;' class='infobox' >"
end
tab = tab .. "<tr><td colspan='2' style='border-bottom:5px solid white; font-size:175%; background:#FFDF80; text-align:center'>"
if t.date~="" then tab = tab.."<tr><td>'''"..infobox_translate(6).."'''</td><td>" .. t.date.."</td></tr>" end
if t.dates~="" then tab = tab.."<tr><td>'''"..infobox_translate(7).."'''</td><td>" .. t.dates.."</td></tr>" end
if wiki ~= 'en' then --As default show only kilometers, but if 'en.wiki' show kilometers and miles
if t.length ~= "" then tab = tab.."<tr><td>'''"..infobox_translate(8).."'''</td><td>" .. t.length.." "..t.length_unit.."</td></tr>" end
if t.length ~= "" then tab = tab.."<tr><td>'''"..infobox_translate(8).."'''</td><td>" .. t.length.." "..t.length_unit.."</td></tr>" end
else
if t.length ~= "" then tab = tab.."<tr><td>'''"..infobox_translate(8).."'''</td><td>" .. t.length.." "..t.length_unit.." ("..miles.." mi)".."</td></tr>" end
end
if ttt.country[1] ~= nil then tab = tab.."<tr><td style= 'vertical-align:top'>'''"
if #ttt.country == 1 then tab = tab..infobox_translate(9).."'''</td><td>" else tab = tab..infobox_translate(10).."'''</td><td>" end
if t.nr_participants_start ~= "" then tab = tab.."<tr><td>'''"..infobox_translate(14).."'''</td><td>" .. t.nr_participants_start .. "</td></tr>" end
if t.nr_participants_end ~= "" then tab = tab.."<tr><td>'''"..infobox_translate(15).."'''</td><td>" .. t.nr_participants_end .. "</td></tr>" end
if wiki ~= 'en' then --As default show only kilometers/hour, but if 'en.wiki' show kilometers/hour and miles/hour
if t.speed ~= "" then tab = tab.."<tr><td>'''"..infobox_translate(16).."'''</td><td>" .. t.speed .. " "..t.speed_unit.."</td></tr>" end
if t.speed ~= "" then tab = tab.."<tr><td>'''"..infobox_translate(16).."'''</td><td>" .. t.speed .. " "..t.speed_unit.."</td></tr>" end
else
if t.speed ~= "" then tab = tab.."<tr><td>'''"..infobox_translate(16).."'''</td><td>" .. t.speed .. " "..t.speed_unit.." ("..miles_h.." mi/h)".."</td></tr>" end
end
if t.cost ~= "" then tab = tab.."<tr><td>'''"..infobox_translate(17).."'''</td><td>" .. t.cost .. " "..t.cost_unit.. "</td></tr>" end
if tttt.special_1a ~= "" then tab = tab.."<tr><td>'''"..tttt.special_1a.."'''</td><td>" .. tttt.special_1b.. "</td></tr>" end
if tt.map ~= "" then tab = tab .. "<tr><td colspan='2' style='text-align:center'>".." [[File:".. tt.map .."|center|300px]]".."</td></tr>" end
 
tabprevNextLine = tab.."<tr><td>"..t.previous.."</td><td style='text-align:right'>" .. t.next .. "</td></tr>"
if wiki == "ar" then prevNextLine = "<tr><td width='50%' style='text-align:right'>"..t.previous.."</td><td width='50%' style='text-align:left'>" .. t.next .. "</td></tr>" end
tab = tab .. prevNextLine
local s = "d:Wikidata:WikiProject Cycling/Documentation/infobox"
tab = tab .. "<tr><td colspan='2' style='text-align:right; border-top:3px solid #FFDF80; font-size:75%'>" .. "[[" .. s .. "|" .. infobox_translate(34) .. "]] [[File:Wikidata-logo S.svg|12px|link=d:".. frame.args[1] .. "]]" --infobox_bottom(1)
--tab = tab .. "<span style='float:right' title='".. tooltip .. "'>[[File:High-contrast-help-browser.svg|10px|right|link=]]</span>"
tab = tab .. "</span></td></tr>"
tab= tab.."</table>"
return tab
end
 
function national_team(wiki, riderID, startOfSeason, entity, property, k)
-- property: statement where the rider is the value
-- k: loop
local national_team, team, nationality, teamID
-- national team for U23 or older riders
if pcall(function()
local i,j, s
for _, v in pairs(entity.claims[property][k].qualifiers['P54']) do -- for property 'member of sports team'
teamID = 'Q'.. v.datavalue.value['numeric-id'] break
end
 
national_team = mw.wikibase.getEntity( teamID )
-- calculate s for national team item
a, b = pcall(fooA, 'numeric-id', national_team, 'P31', 1) -- test if country
if a == true and b == 20738667 then -- Q20738667 = national cycling team U23
if wiki == 'fr' or wiki == 'www' then s = ' espoirs' else s = ' U23' end
elseif a == true and (b == 1194951 or b == 23726798) then s = '' end
-- Q1194951 = national sports team, Q23726798 = national cycling team
 
a, b = timeStartEnd(riderID, "P27", 'numeric-id', startOfSeason)
if a == true then
local nation = mw.wikibase.getEntityObject( 'Q'..b )
nationality = nation:getLabel() or nation:getLabel('en') .. ' (en)'
if national_team:getSitelink() == nil then
team = nationality.. s
else
team = "[[".. national_team:getSitelink().. "|".. nationality.. s.. ']]'
end
national_team = mw.wikibase.getEntity( teamID )
-- calculate s for national team item
a, b = pcall(fooA, 'numeric-id', national_team, 'P31', 1) -- test if country
if a == true and b == 20738667 then -- Q20738667 = national cycling team U23
if wiki == 'fr' then s = ' espoirs' else s = ' U23' end
if wiki == 'mk' then s = ' под 23 години' end
if wiki == 'ar' then s = ' تحت 23' end
elseif a == true and (b == 1194951 or b == 23726798) then s = '' end
-- Q1194951 = national sports team, Q23726798 = national cycling team
a, b = timeStartEnd(riderID, "P27", 'numeric-id', startOfSeason)
if a == true then
local nation = mw.wikibase.getEntityObject( 'Q'..b )
nationality = nation:getLabel() or nation:getLabel('en') .. ' (en)'
if national_team:getSitelink() == nil then
team = nationality.. s
else
team = "[[".. national_team:getSitelink().. "|".. nationality.. s.. ']]'
end
end
a, b = timeStartEnd(riderID, "P17", 'numeric-id', startOfSeason)
if a == true then --team = 'abc'.. b --riderID
local nation = mw.wikibase.getEntityObject( 'Q'..b )
nationality = nation:getLabel() or nation:getLabel('en') .. ' (en)'
if national_team:getSitelink() == nil then
team = nationality.. s
else
team = "[[".. national_team:getSitelink().. "|".. nationality.. s.. ']]'
end
end
end) then
else
--standard team
pcall(function()
a, b = timeStartEnd(riderID, 'P54', 'numeric-id', startOfSeason)
if a == true then
national_team = mw.wikibase.getEntity( 'Q'..b )
-- g.team[rank] = national_team:getLabel() or g.country[rank].. s
team = WPlink('Q'..b, 'team', startOfSeason)
end
-- guest team
if teamID ~= nil then team = WPlink(teamID, 'team') end
end)
end
 
return team
end) then
else
--standard team
pcall(function()
a, b = timeStartEnd(riderID, 'P54', 'numeric-id', startOfSeason)
if a == true then
national_team = mw.wikibase.getEntity( 'Q'..b )
-- g.team[rank] = national_team:getLabel() or g.country[rank].. s
team = WPlink('Q'..b, 'team', startOfSeason)
end
-- guest team
if teamID ~= nil then team = WPlink(teamID, 'winner_team') end
end)
end
 
function func_date (date, mode)
return team
-- local date = '+2016-05-20'
end
-- local mode = 'small'
 
function func_date (date, wiki, mode)
-- local wiki = 'cs'
-- local mode = 'small'
-- local date = '+2016-05-20'
local function standard(datum)
if mode=='long' then return mw.language.getContentLanguage():formatDate("j F Y", datum) end
if mode=='small' then return mw.language.getContentLanguage():formatDate("j M", datum) end
if mode=='onlyday' then return mw.language.getContentLanguage():formatDate("j", datum) end
end
local function ar(datum)
local lang = mw.getLanguage('ar')
if mode=='long' then return mw.getLanguage('ar'):formatDate("j F Y", datum) end
if mode=='small' then return mw.getLanguage('ar'):formatDate("j F", datum) end
if mode=='onlyday' then return mw.getLanguage('ar'):formatDate("j", datum) end
end
local function br(datum)
local lang = mw.getLanguage('br')
if mode=='long' then return lang:formatDate("j", datum ) .." a viz ".. lang:formatDate("F Y", datum) end
if mode=='small' then return lang:formatDate("j", datum ) .." a viz ".. lang:formatDate("M", datum) end
if mode=='onlyday' then return lang:formatDate("j", datum ) end
end
local function ca(datum, language)
local lang = mw.getLanguage(language)
if mode=='long' then return lang:formatDate("j", datum) .." de ".. lang:formatDate("F", datum) .." de ".. lang:formatDate("Y", datum) end
if mode=='small' then return lang:formatDate("j", datum) .." de ".. lang:formatDate("M", datum) end
if mode=='onlyday' then return lang:formatDate("j", datum) end
end
local function cs(datum)
local lang = mw.getLanguage('cs')
if mode=='long' then return lang:formatDate("j. xg Y", datum) end
if mode=='small' then return lang:formatDate("j", datum) ..". xg ".. lang:formatDate("M", datum) end
if mode=='onlyday' then return lang:formatDate("j", datum) end
end
local function de(datum, language)
if mode=='long' then return mw.getLanguage(language):formatDate("j. F Y", datum) end
if mode=='small' then return mw.getLanguage(language):formatDate("j. M", datum) end
if mode=='onlyday' then return mw.getLanguage(language):formatDate("j.", datum) end
end
local function eo(datum)
local lang = mw.getLanguage('eo')
if mode=='long' then return lang:formatDate("j", datum) .."-a de ".. lang:formatDate("F Y", datum) end
if mode=='small' then return lang:formatDate("j", datum) .."-a de ".. lang:formatDate("M", datum) end
if mode=='onlyday' then return lang:formatDate("j", datum) end
end
local function en(datum)
if mode=='long' then return mw.getLanguage('en'):formatDate("F d, Y", datum) end
if mode=='small' then return mw.getLanguage('en'):formatDate("M d", datum) end
if mode=='onlyday' then return mw.getLanguage('en'):formatDate("d", datum) end
end
local function eu(datum)
local lang = mw.getLanguage('eu')
if mode=='long' then return lang:formatDate( "Y", datum) ..".eko ".. lang:formatDate("F", datum) .."k ".. lang:formatDate("j", datum) end
if mode=='small' then return lang:formatDate( "M", datum) .."k ".. lang:formatDate("j", datum) end
if mode=='onlyday' then return lang:formatDate("j", datum) end
end
local function fi(datum) -- may be different
if mode=='long' then return mw.ustring.gsub(mw.getLanguage('fi'):formatDate("j. F Y", date), "%a+", "%0ta") end
if mode=='small' then return mw.getLanguage('fi'):formatDate("j. M", date) end
if mode=='onlyday' then return mw.getLanguage('fi'):formatDate("j.", date) end
end
local function hu(datum)
local lang = mw.getLanguage('hu')
if mode=='long' then return lang:formatDate( "Y", datum) ..". ".. lang:formatDate("F", datum) ..". ".. lang:formatDate("j", datum)..". end" end
if mode=='small' then return lang:formatDate( "M", datum) ..". ".. lang:formatDate("j", datum) end
if mode=='onlyday' then return lang:formatDate("j", datum) end
end
local function ja(datum)
if mode=='long' then return mw.getLanguage('ja'):formatDate("Y年m月d日", datum) end
if mode=='small' then return mw.getLanguage('ja'):formatDate("m月d日", datum) end
if mode=='onlyday' then return mw.getLanguage('ja'):formatDate("d日", datum) end
end
local function lv(datum)
local lang = mw.getLanguage('lv')
if mode=='long' then return lang:formatDate("Y.", datum) .." gada ".. lang:formatDate("j. F", datum) end
if mode=='small' then return lang:formatDate("Yj. M", datum) end
if mode=='onlyday' then return lang:formatDate("j.", datum) end
end
local function pl(datum)
local date_pl = {"stycznia", "lutego", "marca", "kwietnia", "maja", "czerwca", "lipca", "sierpnia", "września", "października", "listopada", "grudnia"}
if mode=='long' then return lang:formatDate("j ", datum) .. date_pl[tonumber(lang:formatDate("n", datum))] .. lang:formatDate(" Y", datum) end
if mode=='small' then return lang:formatDate("j M", datum) end
if mode=='onlyday' then return lang:formatDate("j", datum) end
end
local x = {['']=standard(date), ['ar']=ar(date), ['br']=br(date), ['ca']=ca(date,'ca'), ['cs']=cs(date), ['da']=de(date,'da'), ['de']=de(date,'de'), ['en']=en(date), ['eo']=eo(date),
['es']=ca(date,'es'), ['eu']=eu(date), ['fi']=fi(date), ['fo']=de(date,'fo'), ['hu']=hu(date), ['ja']=ja(date), ['lv']=lv(date), ['no']=de(date,'no'), ['pl']=pl(date)}
 
local x = {['']=standard(date), ['br']=br(date), ['ca']=ca(date,'ca'), ['cs']=cs(date), ['da']=de(date,'da'), ['de']=de(date,'de'), ['en']=en(date), ['eo']=eo(date),
['es']=ca(date,'es'), ['eu']=eu(date), ['fi']=fi(date), ['fo']=de(date,'fo'), ['ja']=ja(date), ['lv']=lv(date), ['no']=de(date,'no'), ['pl']=pl(date)}
 
--mw.log(b1, x['no'])
return x[wiki] or x['']
end
 
function p.teamroster(frame)
if frame.args[1] ~= nil then frame.args[1] = string.gsub(frame.args[1], "%c", "") end
local squadSeason = mw.wikibase.getEntityObject( frame.args[1] )
local flags, pays = {}, {}
local riderIds, riderNames, riderBirthdays, givenname, familyname, riderTeam, time = {}, {}, {}, {}, {}, {}, {}
local riderStart, riderEnd, riderPosition, riderReason, riderRef = {}, {}, {}, {}, {}
local index, riderNames_transl, riderNames_notransl = {}, {}, {}
local labelMissing = false
local wikilang = string.match(mw.sitelanguage.server, "%a+"getContentLanguage()
local WDlink_on
local lang = mw.language.getContentLanguage()
local team, rider, startOfSeason
local WDlink_on
local team,v rider,= startOfSeason''
local v = ''
local function trans(date, month, day)
 
if date ~= '' then
local function trans(date, month, day)
local _, _, y, m, d = string.find(date, "(%d+)-(%d+)-(%d+)")
if date ~= '' then
if m == '00' then m = month end
local _, _, y, m, d = string.find(date, "(%d+)-(%d+)-(%d+)")
if md == '00' then md = monthday end
date = '+'..y..'-'..m..'-'..d..'T00:00:00Z'
if d == '00' then d = day end
return date
date = '+'..y..'-'..m..'-'..d..'T00:00:00Z'
else return date'' end
else return '' end
local function name(i, wiki, transl, names, givenname, familyname)
end
-- transform name "A B ..." into "B ... A"
local function name(i, wiki, transl, names, givenname, familyname)
local _, count = mw.ustring.gsub(names, " ", " ")
-- transform name "A B ..." into "B ... A"
local _a, countb,c,d = mw.ustring.gsub(names'', " "'', "'', ")''
local a,b,c,ddone = '', '', '', ''false
if count ~= nil then count = count + 1 else count = 1 end
local done = false
if count ~= nil then count = count + 1 else count = 1 end
if count > 1 then
 
if count >== 12 then
if names~='' then _, _, a, b = mw.ustring.find(names, "(%S+)%s+(%S+)") names=b..' '..a..":"..i end
if count == 2 then
else
if names~='' then _, _, a, b = mw.ustring.find(names, "(%S+)%s+(%S+)") names=b..' '..a..":"..i end
local name_parts_lv = {'da', 'de', 'di', 'De', 'la', 'Le', 'ten', 'van', 'Van'}
else
local name_parts_lvname_parts_mk = {'daда', 'deди', 'diде', 'DeДе', 'laла', 'LeЛе', 'tenтен', 'vanван', 'VanВан'}
local name_parts_mkname_parts_ru = {'да', 'ди', 'де', 'Де', 'ла', 'Ле', 'тен', 'ван', 'Ван'}
local name_parts_runame_parts = {'даda', 'диde', 'деdi', 'ДеDe', 'лаla', 'ЛеLe', 'тенten', 'ванvan', 'ВанVan'}
local v
local name_parts = {'da', 'de', 'di', 'De', 'la', 'Le', 'ten', 'van', 'Van'}
if count == 3 and names~='' then
local v
_, _, a, b, c = mw.ustring.find(names, "(%S+)%s+(%S+)%s+(%S+)")
if count == 3 and names~='' then
if wiki == 'mk' then
_, _, a, b, c = mw.ustring.find(names, "(%S+)%s+(%S+)%s+(%S+)")
for _,v in ipairs(name_parts_mk) do if b == v then names = b..' '..c..' '..a..":"..i done = true break end end
if wiki == 'mk' then
end
for _,v in ipairs(name_parts_mk) do if b == v then names = b..' '..c..' '..a..":"..i done = true break end end
if wiki == 'lv' then
for _,v in ipairs(name_parts_lv) do if b == v then names = b..' '..c..' '..a..":"..i done = true break end end
end
if wiki == 'ru' then
for _,v in ipairs(name_parts_ru) do if b == v then names = b..' '..c..' '..a..":"..i done = true break end end
end
if wiki ~= 'lv' and wiki ~= 'mk' and wiki ~= 'ru' then
for _,v in ipairs(name_parts) do if b == v then names = b..' '..c..' '..a..":"..i done = true break end end
end
if transl == 'notransl' then --or (wiki~='lv' and wiki~='mk' and wiki~='ru' and wiki~='ja') then
for _,v in ipairs(name_parts) do if b == v then names = b..' '..c..' '..a..":"..i done = true break end end
end
if not done and familyname==2 then names = b..' '..c..' '..a..":"..i done = true end
if not done and familyname==1 then names = c..' '..a..' '..b..":"..i done = true end
if not done and familyname==0 then names = c..' '..a..' '..b..":"..i done = true end
end
if wikicount ==> 3 and names~='lv' then
_, _, a, b, c, d = mw.ustring.find(names, "(%S+)%s+(%S+)%s+(%S+)%s+(%S+)")
for _,v in ipairs(name_parts_lv) do if b == v then names = b..' '..c..' '..a..":"..i done = true break end end
if wiki == 'mk' then
for _,v in ipairs(name_parts_mk) do if c == v then names = c..' '..d..' '..a..' '..b..":"..i done = true break end end
for _,v in ipairs(name_parts_mk) do if b == v then names = b..' '..c..' '..d..' '..a..":"..i done = true break end end
end
if wiki == 'lv' then
for _,v in ipairs(name_parts_lv) do if c == v then names = c..' '..d..' '..a..' '..b..":"..i done = true break end end
for _,v in ipairs(name_parts_lv) do if b == v then names = b..' '..c..' '..d..' '..a..":"..i done = true break end end
end
if wiki == 'ru' then
for _,v in ipairs(name_parts_ru) do if c == v then names = c..' '..d..' '..a..' '..b..":"..i done = true break end end
for _,v in ipairs(name_parts_ru) do if b == v then names = b..' '..c..' '..d..' '..a..":"..i done = true break end end
end
if wiki ~= 'lv' and wiki ~= 'mk' and wiki ~= 'ru' then
for _,v in ipairs(name_parts) do if c == v then names = c..' '..d..' '..a..' '..b..":"..i done = true break end end
for _,v in ipairs(name_parts) do if b == v then names = b..' '..c..' '..d..' '..a..":"..i done = true break end end
end
if transl == 'notransl' then --or (wiki~='lv' and wiki~='mk' and wiki~='ru' and wiki~='ja') then
for _,v in ipairs(name_parts) do if c == v then names = c..' '..d..' '..a..' '..b..":"..i done = true break end end
for _,v in ipairs(name_parts) do if b == v then names = b..' '..c..' '..d..' '..a..":"..i done = true break end end
end
if not done then names = b..' '..c..' '..d..' '..a..":"..i end
end
if wiki == 'ru' then
for _,v in ipairs(name_parts_ru) do if b == v then names = b..' '..c..' '..a..":"..i done = true break end end
end
if wiki ~= 'lv' and wiki ~= 'mk' and wiki ~= 'ru' then
for _,v in ipairs(name_parts) do if b == v then names = b..' '..c..' '..a..":"..i done = true break end end
end
if transl == 'notransl' then --or (wiki~='lv' and wiki~='mk' and wiki~='ru' and wiki~='ja') then
for _,v in ipairs(name_parts) do if b == v then names = b..' '..c..' '..a..":"..i done = true break end end
end
if not done and familyname==2 then names = b..' '..c..' '..a..":"..i done = true end
if not done and familyname==1 then names = c..' '..a..' '..b..":"..i done = true end
if not done and familyname==0 then names = c..' '..a..' '..b..":"..i done = true end
end
if count > 3 and names~='' then
_, _, a, b, c, d = mw.ustring.find(names, "(%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..":"..i done = true break end end
for _,v in ipairs(name_parts_mk) do if b == v then names = b..' '..c..' '..d..' '..a..":"..i done = true break end end
end
if wiki == 'lv' then
for _,v in ipairs(name_parts_lv) do if c == v then names = c..' '..d..' '..a..' '..b..":"..i done = true break end end
for _,v in ipairs(name_parts_lv) do if b == v then names = b..' '..c..' '..d..' '..a..":"..i done = true break end end
end
if wiki == 'ru' then
for _,v in ipairs(name_parts_ru) do if c == v then names = c..' '..d..' '..a..' '..b..":"..i done = true break end end
for _,v in ipairs(name_parts_ru) do if b == v then names = b..' '..c..' '..d..' '..a..":"..i done = true break end end
end
if wiki ~= 'lv' and wiki ~= 'mk' and wiki ~= 'ru' then
for _,v in ipairs(name_parts) do if c == v then names = c..' '..d..' '..a..' '..b..":"..i done = true break end end
for _,v in ipairs(name_parts) do if b == v then names = b..' '..c..' '..d..' '..a..":"..i done = true break end end
end
if transl == 'notransl' then --or (wiki~='lv' and wiki~='mk' and wiki~='ru' and wiki~='ja') then
for _,v in ipairs(name_parts) do if c == v then names = c..' '..d..' '..a..' '..b..":"..i done = true break end end
for _,v in ipairs(name_parts) do if b == v then names = b..' '..c..' '..d..' '..a..":"..i done = true break end end
end
if not done then names = b..' '..c..' '..d..' '..a..":"..i end
end
end
return names
end
return names
local localFrame
end
local sort
 
--[[
local localFrame
The word 'sort' is used to sort the riders after the surname. It could look like this in the Wikipedia article
local sort
{{Cycling race/teamroster|Q21769847
--[[
| sort
The word 'sort' is used to sort the riders after the surname. It could look like this in the Wikipedia article
}}
{{Cycling race/teamroster|Q21769847
A rider called 'Laurens De Vreese' is sorted after 'De Vreese Laurens'. If you want to sort after 'Vreese Laurens De'
| sort
change that in the code. In lvWiki, mkWiki and ruWiki sorting is standard, there is no need to switch sorting on in the article
}}
]]
A rider called 'Laurens De Vreese' is sorted after 'De Vreese Laurens'. If you want to sort after 'Vreese Laurens De'
if string.match(frame:getParent():getTitle(), '%P+') == mw.site.namespaces.Template.name
change that in the code. In lvWiki, mkWiki and ruWiki sorting is standard, there is no need to switch sorting on in the article
]]
if frame.args[2] ~= nil then
if string.match(frame:getParent():getTitle(), '%P+') == mw.site.namespaces.Template.name
then localFrame = frame:getParent() else localFrame = frame end
if localFrame.args[2] ~= nil then
if mw.ustring.find(mw.ustring.lower(frame.args[2]), "sort") then sort = true else sort = false end
if mw.ustring.find(mw.ustring.lower(localFrame.args[2]), "sort") then sort = true else sort = false end
else sort = false
end
if wiki == "lv" or wiki == "mk" or wiki == "ru" then sort = true end
 
pcall(function() team = squadSeason.claims["P361"][1].mainsnak.datavalue.value['numeric-id'] end)
 
-- 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
 
if pcall(function() startOfSeason = squadSeason.claims["P580"][1].mainsnak.datavalue.value.time end) then
else
local Sitelink = squadSeason:getSitelink(wiki .. 'wiki') or squadSeason:getSitelink('enwiki') or squadSeason:getSitelink('frwiki') or squadSeason:getSitelink('dewiki') or ''
if Sitelink == '' then return '> Wikidata is missing data about the start time (P580) and end time (P582) of the season'
else startOfSeason = '+'..string.match(Sitelink, '%d%d%d%d' ) ..'-01-01T00:00:00Z'
end
end
 
local i = 1
pcall(function()
while squadSeason.claims["P527"][i] do
riderIds[i] = 'Q' .. squadSeason.claims["P527"][i].mainsnak.datavalue.value['numeric-id']
riderNames[i] = WPlink(riderIds[i])
 
rider = mw.wikibase.getEntityObject(riderIds[i])
if pcall(function() riderBirthdays[i] = rider.claims["P569"][1].mainsnak.datavalue.value.time end
) then else riderBirthdays[i] = '' end
if pcall(function() local k for k, _ in pairs(rider.claims["P735"]) do givenname[i] = k end end
) then else givenname[i] = 0 end
if pcall(function() local k for k, _ in pairs(rider.claims["P734"]) do familyname[i] = k end end
) then else familyname[i] = 0 end
 
pcall(function()
while squadSeason.claims["P527"][i] do
local language
riderIds[i] = 'Q' .. squadSeason.claims["P527"][i].mainsnak.datavalue.value['numeric-id']
if wiki == "www" then language = 'en' else language = wiki end
localriderNames[i] entity=mw.wikibase.getEntity WPlink(riderIds[i])
if wiki == 'mk' or wiki == 'ru' then
rider = mw.wikibase.getEntityObject(riderIds[i])
if entity:getLabel(language) ~= nil and (mw.ustring.byte(entity:getLabel(language), 1, 1) > 127 and mw.ustring.byte(entity:getLabel(language), 3, 3) > 127)
if pcall(function() riderBirthdays[i] = rider.claims["P569"][1].mainsnak.datavalue.value.time end
then riderNames_transl[i] = entity.labels[language].value riderNames_notransl[i] = ''
) then else riderBirthdays[i] = '' end
else riderNames_notransl[i] = entity.labels['en'].value or entity.labels['fr'].value or entity.labels['de'].value riderNames_transl[i] = ''
if pcall(function() local k for k, _ in pairs(rider.claims["P735"]) do givenname[i] = k end end
) then else givenname[i] = 0 end
if pcall(function() local k for k, _ in pairs(rider.claims["P734"]) do familyname[i] = k end end
) then else familyname[i] = 0 end
pcall(function()
local language
language = wiki
local entity=mw.wikibase.getEntity(riderIds[i])
if wiki == 'mk' or wiki == 'ru' then
if entity:getLabel(language) ~= nil and (mw.ustring.byte(entity:getLabel(language), 1, 1) > 127 and mw.ustring.byte(entity:getLabel(language), 3, 3) > 127)
then riderNames_transl[i] = entity.labels[language].value riderNames_notransl[i] = ''
else riderNames_notransl[i] = entity.labels['en'].value or entity.labels['fr'].value or entity.labels['de'].value riderNames_transl[i] = ''
end
end
if wiki ~= 'mk' and wiki ~= 'ru' then
end
if entity:getLabel(language) ~= nil then riderNames_transl[i] = entity.labels[language].value riderNames_notransl[i] = ''
if wiki ~= 'mk' and wiki ~= 'ru' then
if else entity:getLabel(language)riderNames_notransl[i] ~= nilentity.labels['en'].value thenor riderNames_translentity.labels[i'fr'].value =or entity.labels[language'de'].value riderNames_notranslriderNames_transl[i] = ''
end
else riderNames_notransl[i] = entity.labels['en'].value or entity.labels['fr'].value or entity.labels['de'].value riderNames_transl[i] = ''
end
end)
if sort == true then
riderNames_transl[i] = name(i, wiki, 'transl', riderNames_transl[i], givenname[i], familyname[i])
riderNames_notransl[i] = name(i, wiki, 'notransl', riderNames_notransl[i], givenname[i], familyname[i])
else index[i] = i
end
end)
if pcall(function()
 
local date = squadSeason.claims["P527"][i].qualifiers["P580"][1].datavalue.value.time or ''
if sort == true then
riderStart[i] = func_date(trans(date,'01', '01'), 'small')
riderNames_transl[i] = name(i, wiki, 'transl', riderNames_transl[i], givenname[i], familyname[i])
end
riderNames_notransl[i] = name(i, wiki, 'notransl', riderNames_notransl[i], givenname[i], familyname[i])
) then else indexriderStart[i] = i'' end
end
if pcall(function()
 
local date = squadSeason.claims["P527"][i].qualifiers["P582"][1].datavalue.value.time
if pcall(function()
riderEnd[i] = func_date(trans(date,'12', '31'), 'small')
local date = squadSeason.claims["P527"][i].qualifiers["P580"][1].datavalue.value.time or ''
end
riderStart[i] = func_date(trans(date,'01', '01'), wiki, 'small')
) then else riderEnd[i] = '' end
end
) then else riderStart[i] = '' end
if pcall(function()
 
riderPosition[i] = 'Q' .. squadSeason.claims["P527"][i].qualifiers["P39"][1].datavalue.value['numeric-id']
if pcall(function()
local entity = mw.wikibase.getEntity( riderPosition[i] )
local date = squadSeason.claims["P527"][i].qualifiers["P582"][1].datavalue.value.time
local label = string.gsub(entity:getLabel(), "%b()", "") or entity:getLabel( 'en' )
riderEnd[i] = func_date(trans(date,'12', '31'), wiki, 'small')
end
) then else riderEnd[i] = '' end
 
if pcall(function()
riderPosition[i] = 'Q' .. squadSeason.claims["P527"][i].qualifiers["P39"][1].datavalue.value['numeric-id']
local entity = mw.wikibase.getEntity( riderPosition[i] )
local label = string.gsub(entity:getLabel(), "%b()", "") or entity:getLabel( 'en' )
--if label == null then label = entity:getLabel( 'en' ) end
riderPosition[i] = ', ' .. label end
) then else riderPosition[i] = '' end
 
riderReason[i] = ''
pcall(function() riderReason[i] = 'Q'.. squadSeason.claims["P527"][i].qualifiers["P1643"][1].datavalue.value['numeric-id'] end)
if riderReason[i] == '' then pcall(function() riderReason[i] = 'Q'.. squadSeason.claims["P527"][i].qualifiers["P1642"][1].datavalue.value['numeric-id'] end) end
if riderReason[i] == '' then pcall(function() riderReason[i] = 'Q'.. squadSeason.claims["P527"][i].qualifiers["P1534"][1].datavalue.value['numeric-id'] end) end
if riderReason[i] ~= '' then
local entity = mw.wikibase.getEntity( riderReason[i] )
local label = string.gsub(entity:getLabel(), "%b()", "") or entity:getLabel('en')
--if label == null then label = entity:getLabel( 'en' ) end
riderPosition[i] = ', ' .. label end
riderRef[i] = references(squadSeason, 'P527', i)
riderReason) then else riderPosition[i] = ', ' .. labelend
end
riderReason[i] = ''
 
pcall(function() riderReason[i] = 'Q'.. squadSeason.claims["P527"][i].qualifiers["P1643"][1].datavalue.value['numeric-id'] end)
local a, b
if riderReason[i] == '' then pcall(function() riderReason[i] = 'Q'.. squadSeason.claims["P527"][i].qualifiers["P1642"][1].datavalue.value['numeric-id'] end) end
local timeofrace
if riderReason[i] == '' then pcall(function() riderReason[i] = 'Q'.. squadSeason.claims["P527"][i].qualifiers["P1534"][1].datavalue.value['numeric-id'] end) end
local changedTime = '+0000-00-00'
if riderReason[i] ~= '' then
local changedTeam = ''
local entity, label= mw.wikibase.getEntity( riderReason[i] )
local label = string.gsub(entity:getLabel(), "%b()", "") or entity:getLabel('en')
local stagiaire
--if label == null then label = entity:getLabel( 'en' ) end
time[i]='' riderTeam[i] = ''
riderRef[i] = references(squadSeason, 'P527', i)
if pcall(function() timeofrace = squadSeason.claims["P527"][i].qualifiers["P580"][1].datavalue.value.time end)
riderReason[i] = ', ' .. label
then else timeofrace = startOfSeason end
end
if team ~= nil then a = true b = team -- if team known, don´t search for team
else a, b = timeStartEnd(riderIds[i], 'P54', 'numeric-id', timeofrace) team = b
local a, b
end
local timeofrace
if a == true and b ~= nil then
local changedTime = '+0000-00-00'
pcall(function()
local vchangedTeam = ''
local entity, label
for _, v in pairs(rider.claims["P54"]) do -- look into all P54 teams
local stagiaire
pcall(function() -- get trainee data from rider item
time[i]='' riderTeam[i] = ''
if v.mainsnak.datavalue.value['numeric-id'] == b then -- print riderStart[i], riderEnd[i], riderPosition[i], riderReason[i]
if riderReason[i] == '' then pcall(function() riderReason[i]timeofrace = 'Q'squadSeason.. vclaims["P527"][i].qualifiers["P1643P580"][1].datavalue.value['numeric-id'].time end) end
then else timeofrace = startOfSeason end
if riderReason[i] == '' then pcall(function() riderReason[i] = 'Q'.. v.qualifiers["P1642"][1].datavalue.value['numeric-id'] end) end
if team ~= nil then a = true b = team -- if team known, don´t search for team
if riderReason[i] == '' then pcall(function() riderReason[i] = 'Q'.. v.qualifiers["P1534"][1].datavalue.value['numeric-id'] end) end
else a, b = timeStartEnd(riderIds[i], 'P54', 'numeric-id', timeofrace) team = b
if string.sub(riderReason[i],1,1)=='Q' then -- only for these pcall-functions, not for those at line 970
end
local entity = mw.wikibase.getEntity( riderReason[i] )
if a == true and b ~= nil then
local label = string.gsub(entity:getLabel(), "%b()", "") or entity:getLabel('en')
pcall(function()
if pcall(function() riderRef[i] = references(squadSeason, 'P527', i) end) then else riderRef[i]='' end
local v
-- riderRef[i] = references(squadSeason, 'P527', i)
for _, v in pairs(rider.claims["P54"]) do -- look into all P54 teams
riderReason[i] = ', ' .. label
pcall(function() -- get trainee data from rider item
end
if v.mainsnak.datavalue.value['numeric-id'] == b then -- print riderStart[i], riderEnd[i], riderPosition[i], riderReason[i]
 
if riderReason[i] == '' then pcall(function() riderReason[i] = 'Q'.. v.qualifiers["P1643"][1].datavalue.value['numeric-id'] end) end
if riderReason[i] == '' then pcall(function() riderReason[i] = 'Q'.. v.qualifiers["P1642"][1].datavalue.value['numeric-id'] end) end
if riderReason[i] == '' then pcall(function() riderReason[i] = 'Q'.. v.qualifiers["P1534"][1].datavalue.value['numeric-id'] end) end
if string.sub(riderReason[i],1,1)=='Q' then -- only for these pcall-functions, not for those at line 970
local entity = mw.wikibase.getEntity( riderReason[i] )
local label = string.gsub(entity:getLabel(), "%b()", "") or entity:getLabel('en')
if pcall(function() riderRef[i] = references(squadSeason, 'P527', i) end) then else riderRef[i]='' end
-- riderRef[i] = references(squadSeason, 'P527', i)
riderReason[i] = ', ' .. label
end
local date1 = v.qualifiers["P580"][1].datavalue.value.time
date1 = trans(date1,'01','01')
local _, _, y1, m1, d1 = string.find(date1, "(%d+)-(%d+)-(%d+)")
local date2
if pcall(function() date2 = v.qualifiers["P582"][1].datavalue.value.time end) then else date2='+'..y1..'-12-31T00:00:00Z' end
date2 = trans(date2,'12','31')
local _, _, y2, m2, d2 = string.find(date2, "(%d+)-(%d+)-(%d+)")
local _, _, 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[i] = func_date(date1, 'small')
if pcall(function()
local date = v.qualifiers["P582"][1].datavalue.value.time
riderEnd[i] = func_date(date2, 'small')
end
) then else riderEnd[i] = func_date('+'..y1..'-12-31T00:00:00Z', 'small') end
if riderPosition[i] == '' then -- find the 'position' (P39) of a rider
pcall(function() riderPosition[i] ='Q' ..v.qualifiers["P39"][1].datavalue.value['numeric-id']
local entity = mw.wikibase.getEntity( riderPosition[i] )
local label = string.gsub(entity:getLabel(), "%b()", "") or entity:getLabel( 'en' )
riderPosition[i] = ', ' .. label
end)
end
end
end
end)
stagiaire = ''
pcall(function() stagiaire = v.qualifiers["P39"][1].datavalue.value['numeric-id'] end)
if v.mainsnak.datavalue.value['numeric-id'] ~= b and stagiaire == '' then -- find previous team and end time for the rider at that team
local date1 = v.qualifiers["P580"][1].datavalue.value.time
date1 = trans(date1,'01','01')
local _, _, y2, m2, d2 = string.find(date2, "(%d+)-(%d+)-(%d+)")
local _, _, y3, m3, d3 = string.find(startOfSeason, "(%d+)-(%d+)-(%d+)")
if y1 <= y3 then -- start time < season time
 
pcall(function()
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
local timeP582 = v.qualifiers["P582"][1].datavalue.value.time
-- riders who start after 1 January or end earlier then 31 December in the season
riderStart[i] timeP582 = func_datetrans(date1timeP582, wiki'12', 'small31')
if timeP582 >= changedTime then -- find maximum end time
if pcall(function()
-- Case Pierre-Roger Latour: Chambéry CF (2012 - 2014), time season at 2013
local date = v.qualifiers["P582"][1].datavalue.value.time
-- Task: changedTime should be after start time, but before startOfSeason
riderEnd[i] = func_date(date2, wiki,'small')
local _, _, y4, m4, d4 = string.find(timeP582, "(%d+)-(%d+)-(%d+)")
end
) if theny4 else> riderEnd[i]y3 then changedTime = func_date('+'..y1y3..'-12-31T00:00:00Z', wiki,'small')else changedTime = timeP582 end
changedTeam = v.mainsnak.datavalue.value['numeric-id']
 
end -- end if
if riderPosition[i] == '' then -- find the 'position' (P39) of a rider
end) -- end function
pcall(function() riderPosition[i] ='Q' ..v.qualifiers["P39"][1].datavalue.value['numeric-id']
-- print riderTeam[i], time[i]
local entity = mw.wikibase.getEntity( riderPosition[i] )
if changedTime ~= '+0000-00-00' then
local label = string.gsub(entity:getLabel(), "%b()", "") or entity:getLabel( 'en' )
riderPositionpcall(function() riderTeam[i] = WPlink( 'Q'..changedTeam , 'team', ..changedTime ) end) label
local _, _, y1, _, _ = string.find(changedTime, "(%d+)-(%d+)-(%d+)")
end)
end time[i] = ' ('..y1..')'
end
end
end)
stagiaire = ''
pcall(function() stagiaire = v.qualifiers["P39"][1].datavalue.value['numeric-id'] end)
if v.mainsnak.datavalue.value['numeric-id'] ~= b and stagiaire == '' then -- find previous team and end time for the rider at that team
local date1 = v.qualifiers["P580"][1].datavalue.value.time
date1 = trans(date1,'01','01')
local _, _, y1, m1, d1 = string.find(date1, "(%d+)-(%d+)-(%d+)")
local date2
if pcall(function() date2 = v.qualifiers["P582"][1].datavalue.value.time end) then else date2='+'..y1..'-12-31T00:00:00Z' end
date2 = trans(date2,'12','31')
local _, _, y2, m2, d2 = string.find(date2, "(%d+)-(%d+)-(%d+)")
local _, _, y3, m3, d3 = string.find(startOfSeason, "(%d+)-(%d+)-(%d+)")
if y1 <= y3 then -- start time < season time
pcall(function()
local timeP582 = v.qualifiers["P582"][1].datavalue.value.time
timeP582 = trans(timeP582,'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
local _, _, y4, m4, d4 = string.find(timeP582, "(%d+)-(%d+)-(%d+)")
if y4 > y3 then changedTime = '+'..y3..'-12-31T00:00:00Z' else changedTime = timeP582 end
changedTeam = v.mainsnak.datavalue.value['numeric-id']
end -- end if
end) -- end function
-- print riderTeam[i], time[i]
if changedTime ~= '+0000-00-00' then
pcall(function() riderTeam[i] = WPlink( 'Q'..changedTeam , 'team', changedTime ) end)
local _, _, y1, _, _ = string.find(changedTime, "(%d+)-(%d+)-(%d+)")
time[i] = ' ('..y1..')'
end
end -- end if
end -- end if for
end) -- end forfunction
end) -- end functionif
end -- end if
local a, b = timeStartEnd( riderIds[i], 'P27', 'numeric-id', startOfSeason )
 
if a then
if pcall(function()
local a, b flags[i] = timeStartEndflag(riderIds[i], "P27", 'numeric-idQ' .. b, startOfSeason )
if available_list == true and type( translations.list ) == 'function' then
flags[i] = flag('Q'..b, startOfSeason)
pays[i] = translations.list('Q'..b)
if available==true then
if pays[i] == translations.list('Q'..b) then
if local pays[i]country == mw.wikibase.getEntityObject( 'Q'..b then)
pays[i] = country:getLabel() or country:getLabel('en') .. ' (en)'
local country = mw.wikibase.getEntityObject( 'Q'..b )
end
pays[i] = country:getLabel() or country:getLabel('en') .. ' (en)'
end
else
flags[i] = ''
pays[i] = ''
end
i = i + 1
end
end)
-- sorting names after surname
if sort == true then
if language~='ja' then
table.sort(riderNames_transl, function(a,b) return a<b end)
table.sort(riderNames_notransl, function(a,b) return a<b end)
end
local ii, v1, v2, name1, name2, number
) then else flags[i] = '' end
i = 1
 
-- sorting riders with a translation
i = i + 1
for ii,name1 in ipairs(riderNames_transl) do
end
if name1 ~= '' then
end)
v1, v2 = mw.ustring.find(name1, ":")
 
number = mw.ustring.sub(name1, v2+1)
-- sorting names after surname
name2, _ = mw.ustring.gsub(name1, ":%d+", "")
if sort == true then
index[i] = tonumber(number)
if language~='ja' then
i = i + 1
table.sort(riderNames_transl, function(a,b) return a<b end)
end
table.sort(riderNames_notransl, function(a,b) return a<b end)
end
-- sorting riders without a translation
for ii,name1 in ipairs(riderNames_notransl) do
if name1 ~= '' then
v1, v2 = mw.ustring.find(name1, ":")
number = mw.ustring.sub(name1, v2+1)
name2, _ = mw.ustring.gsub(name1, ":%d+", "")
index[i] = tonumber(number)
i = i + 1
end
end
end
local ii, v1, v2, name1, name2, number
local tableBody= ''
local tableHeader = '<table border="0" cellspacing="0" cellpadding="2" class="sortable">'
..'<tr style="background-color:#FFDF80;line-height:1.8em;"><th colspan = "4" style="text-align:center;white-space:nowrap">'
if WDlink_on == false then tableHeader = tableHeader..'<span style="float:left">[[File:Wikidata-logo S.svg|12px|link=d:'.. frame.args[1].. '#P527]]</span>' end
tableHeader = tableHeader..getSquadTableColumn(7) .. '</th></tr>'
tableHeader = tableHeader..'<th style="text-align:center;padding:2px 20px 2px 2px;white-space:nowrap">'..getSquadTableColumn(1) ..
'</th><th style="text-align:center;padding:2px 20px 2px 2px;white-space:nowrap">'..getSquadTableColumn(2)
if available_list==true then tableHeader = tableHeader.. '</th><th style="text-align:center;padding:2px 20px 2px 2px;white-space:nowrap">'..getSquadTableColumn(6) end
tableHeader = tableHeader.. '</th><th style="text-align:center;padding:2px 20px 2px 2px;white-space:nowrap">'..getSquadTableColumn(3) .. '</th></tr>'
local tableFoot = '</table>'
local tableEndText = ''
local tableSize = table.getn(riderNames)
local iii = 1
i = 1
while index[i] do
-- sorting riders with a translation
tableBody = tableBody.. '<tr style="line-height:1.8em"><td style="padding:0 1em 0 0;white-space:nowrap">'
for ii,name1 in ipairs(riderNames_transl) do
if available_list==false then tableBody=tableBody.. flags[index[i]]..' '..riderNames[index[i]] else tableBody = tableBody.. riderNames[index[i]] end
if name1 ~= '' then
if WDlink_on == true then tableBody = tableBody.. ' '.. wdLink(riderIds[index[i]]) end
v1, v2 = mw.ustring.find(name1, ":")
if riderStart[index[i]]~='' or riderEnd[index[i]]~='' then
number = mw.ustring.sub(name1, v2+1)
tableBody=tableBody..'<span style="font-size:80%; color:#686868"> ('..riderStart[index[i]]..'–'..riderEnd[index[i]].. riderPosition[index[i]]
name2, _ = mw.ustring.gsub(name1, ":%d+", "")
if riderReason[index[i]] ~= tonumber(number)'' then
note = ', [[#tr_'..i..frame.args[1]..'|'..getSquadTableColumn(4)..']]'
i = i + 1
if wiki == "ar" then note = '، [[#tr_'..i..frame.args[1]..'|'..getSquadTableColumn(4)..']]' end
tableBody = tableBody .. note
end
tableBody=tableBody .. ')</span>'
elseif riderReason[index[i]]~='' then
tableBody=tableBody.. '<span style="font-size:80%; color:#686868"> ([[#tr_'..i..frame.args[1]..'|'..getSquadTableColumn(4)..']]'.. ')</span>'
end
tableBody = tableBody.. '</td><td style="text-align:right;white-space:nowrap">'
if wiki == 'lv' then
local _, _, y1, m1, d1 = string.find(startOfSeason,"(%d+)-(%d+)-0*(%d+)")
local _, _, y2, m2, d2 = string.find(riderBirthdays[index[i]],"(%d+)-(%d+)-0*(%d+)")
tableBody = tableBody.. frame:expandTemplate{ title = 'Template:Birth date and age2', args = { y1, m1, d1, y2, m2, d2 } }.. '</td>'
else
tableBody = tableBody.. func_date (riderBirthdays[index[i]], 'long')
if available_list==false then tableBody=tableBody..'</td>' else tableBody=tableBody..'</td><td>'.. flags[index[i]].. ' '..pays[i].. '</td>' end
end
tableBody = tableBody.. '<td style="padding:0 0.5em; text-align:left">'
if riderTeam[index[i]] ~= nil then tableBody = tableBody.. riderTeam[index[i]].. time[index[i]] end
tableBody = tableBody..'</td></tr>'
if riderReason[index[i]] ~= '' then
if iii == 1 then tableEndText = tableEndText.. getSquadTableColumn(5)..': '.. riderNames[index[i]].. riderReason[index[i]]
else tableEndText = tableEndText.. '<span style="color:white">'.. getSquadTableColumn(5)..': </span>'.. riderNames[index[i]].. riderReason[index[i]] end
iii = iii + 1
if riderRef[index[i]] ~= '' then tableEndText = tableEndText..
frame:extensionTag{name='ref', content=riderRef[index[i]], args = {name='tr_'..i..frame.args[1]}} end
tableEndText = tableEndText.. '<br>'
end
i = i + 1
end
-- sorting riders without a translation
--if tableEndText ~= '' then tableEndText = getSquadTableColumn(5)..': <span style="font-size:80%; color:#686868">'.. tableEndText .. '</span>' end
for ii,name1 in ipairs(riderNames_notransl) do
if name1 ~= '' then
local borderStyle = 'border:1px solid rgb(200,200,200); padding: 4px'
v1, v2 = mw.ustring.find(name1, ":")
number = mw.ustring.sub(name1, v2+1)
name2, _ = mw.ustring.gsub(name1, ":%d+", "")
index[i] = tonumber(number)
i = i + 1
end
end
end
 
local tableBody= ''
local tableHeader = '<table border="0" cellspacing="0" cellpadding="2">'
.. '<tr style="background-color:#FFDF80;line-height:1.8em;"><th nowrap style="text-align:left;">'
if WDlink_on == false then tableHeader = tableHeader .. '[[File:Wikidata-logo S.svg|12px|link=d:'.. frame.args[1].. '#P527]]&nbsp;&nbsp;&nbsp;' end
tableHeader = tableHeader..getSquadTableColumn(1)..'</th><th nowrap style="text-align:right">'..getSquadTableColumn(2)
if available==true then tableHeader = tableHeader.. '</th><th nowrap style="text-align:left;padding:0 0.5em">'..getSquadTableColumn(6) .. '&nbsp;' end
tableHeader = tableHeader.. '&nbsp;</th><th nowrap style="text-align:left;padding:0 0.5em">'..getSquadTableColumn(3) .. '&nbsp;</th></tr>'
local tableFoot = '</table>'
local tableEndText = ''
local tableSize = table.getn(riderNames)
local iii = 1
i = 1
while index[i] do
tableBody = tableBody.. '<tr style="line-height:1.8em"><td nowrap style="padding:0 1em 0 0">'
if available==false then tableBody=tableBody.. flags[index[i]]..' '..riderNames[index[i]] else tableBody = tableBody.. riderNames[index[i]] end
if WDlink_on == true then tableBody = tableBody.. ' '.. wdLink(riderIds[index[i]]) end
if riderStart[index[i]]~='' or riderEnd[index[i]]~='' then
tableBody=tableBody..'<span style="font-size:80%; color:#686868"> ('..riderStart[index[i]]..'–'..riderEnd[index[i]].. riderPosition[index[i]]
if riderReason[index[i]] ~= '' then tableBody=tableBody.. ', [[#tr_'..i..frame.args[1]..'|'..getSquadTableColumn(4)..']]' end
tableBody=tableBody .. ')</span>'
elseif riderReason[index[i]]~='' then
tableBody=tableBody.. '<span style="font-size:80%; color:#686868"> ([[#tr_'..i..frame.args[1]..'|'..getSquadTableColumn(4)..']]'.. ')</span>'
end
tableBody = tableBody.. '</td><td nowrap style="text-align:right">'
if wiki == 'lv' then
borderStyle = 'border:0'
local _, _, y1, m1, d1 = string.find(startOfSeason,"(%d+)-(%d+)-0*(%d+)")
local _, _, y2, m2, d2 = string.find(riderBirthdays[index[i]],"(%d+)-(%d+)-0*(%d+)")
tableBody = tableBody.. frame:expandTemplate{ title = 'Template:Birth date and age2', args = { y1, m1, d1, y2, m2, d2 } }.. '</td>'
else
tableBody = tableBody.. func_date (riderBirthdays[index[i]], wiki, 'long')
if available==false then tableBody=tableBody..'</td>' else tableBody=tableBody..'</td><td>'.. flags[index[i]].. ' '..pays[i].. '</td>' end
end
tableBodylocal tableStart = tableBody'<table style="' .. borderStyle .. '"><tr><td style="padding:0 0.5em; textvertical-align:lefttop;">'
local tableEnd = '</td></tr></table>'
if riderTeam[index[i]] ~= nil then tableBody = tableBody.. riderTeam[index[i]].. time[index[i]] end
tableBody = tableBody..'</td></tr>'
if labelMissing then tableEnd = tableEnd .. getMissingLabelTrackingCategory() end
if riderReason[index[i]] ~= '' then
if iii == 1 then tableEndText = tableEndText.. getSquadTableColumn(5)..': '.. riderNames[index[i]].. riderReason[index[i]]
return tableStart .. tableHeader .. tableBody .. tableFoot .. tableEnd .. tableEndText
else tableEndText = tableEndText.. '<span style="color:white">'.. getSquadTableColumn(5)..': </span>'.. riderNames[index[i]].. riderReason[index[i]] end
iii = iii + 1
if riderRef[index[i]] ~= '' then tableEndText = tableEndText..
frame:extensionTag{name='ref', content=riderRef[index[i]], args = {name='tr_'..i..frame.args[1]}} end
tableEndText = tableEndText.. '<br>'
end
i = i + 1
end
 
--if tableEndText ~= '' then tableEndText = getSquadTableColumn(5)..': <span style="font-size:80%; color:#686868">'.. tableEndText .. '</span>' end
 
local borderStyle = 'border:1px solid rgb(200,200,200); padding: 4px'
if wiki == 'lv' then
borderStyle = 'border:0'
end
local tableStart = '<table style="'.. borderStyle.. '"><tr><td style="vertical-align:top;">'
local tableEnd = '</td></tr></table>'
 
if labelMissing then tableEnd = tableEnd .. getMissingLabelTrackingCategory() end
 
return tableStart.. tableHeader.. tableBody.. tableFoot.. tableEnd.. tableEndText
end
 
function timeStartEnd(Qid, property, mode, timeofrace)
-- mode = 'numeric-id', property = 'P54', Qid = 'Q123'
local entity = mw.wikibase.getEntity(Qid)
local a, b = pcall(fooA, mode, entity, property, 1)
local starttime, endtime
local available_lang_priority = available_lang_priority
 
if a == true then
if a == true then
local timeStartEnd = {}
local numtimeStartEnd = 1{}
local vnum = 1
local v
for _, v in pairs(entity.claims[property]) do
for _, v in pairs(entity.claims[property]) do
if pcall(function () local test = v.mainsnak.datavalue.value[mode] end) then -- test if not 'unnown value'
if pcall(function () local test = v.mainsnak.datavalue.value[mode] end) then -- test if not 'unnown value'
if pcall(function () starttime = v.qualifiers["P580"][1].datavalue.value.time end) then
starttime = v.qualifiers["P580"][1].datavalue.value.time
local _,_,year,m,d = string.find(starttime,"(%d+)-(%d+)-(%d+)")
if m == '00' and d == '00' then starttime = '+'..year..'-01-01T00:00:00Z' end
end
if pcall(function () endtime = v.qualifiers["P582"][1].datavalue.value.time end) then
endtime = v.qualifiers["P582"][1].datavalue.value.time
local _,_,year,m,d = string.find(endtime,"(%d+)-(%d+)-(%d+)")
if m == '00' and d == '00' then endtime = '+'..year..'-12-31T00:00:00Z' end
if m == '01' and d == '01' then endtime = '+'..year..'-12-31T00:00:00Z' end
end
if v.qualifiers then
if (not v.qualifiers["P580"] or starttime <= timeofrace)
and
(not v.qualifiers["P582"] or endtime >= timeofrace)
then
if available_lang_priority == true and property == "P1448" then
timeStartEnd[num] = v.mainsnak.datavalue.value[mode]
num local =test num += 1false
pcall(function () if type( v.qualifiers["P1448"])=='table' then test=true end end)
end
if test == false then
else
timeStartEnd[num] = v.mainsnak.datavalue.value[mode]
else
num = num + 1
local lang_module, lang_WD
end
local language= ''
end
local zaehler
end
for i,j in ipairs(translations.lang_priority) do
return a, timeStartEnd[1]
lang_module = j
else return false, '' end
for number in pairs(v.qualifiers["P1448"]) do
lang_WD = v.qualifiers["P1448"][number].datavalue.value.language
if lang_WD == lang_module then zaehler = number break end
end -- for number in pairs
if lang_WD == lang_module then language = lang_WD break end
end -- for i,j
if language~='' then -- a WD translation matching translations.lang_priority exist
local t = v.qualifiers["P1448"][zaehler].datavalue.value.text
timeStartEnd[num] = t
else timeStartEnd[num] = v.mainsnak.datavalue.value[mode]-- no matching between lang module and "official name" qualifier
end -- if language~=''
end -- test if official name qualifier exist
else timeStartEnd[num] = v.mainsnak.datavalue.value[mode]
end -- if property == "P1448"
num = num + 1
end
else
timeStartEnd[num] = v.mainsnak.datavalue.value[mode]
num = num + 1
end
end
end
return a, timeStartEnd[1]
else return false, '' end
end
 
function black_list(wiki, Label)
-- 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 } end
if wiki=='en' then black_list={ ["Tiago da Silva"]=true, ["Jan Maas"]=true, ["Alexander Meier"]=true, ["James McLaughlin"]=true, ["Andrea Nencini"]=true,
["Johannes Weber"]=true } end
if 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 } end
return black_list[Label]
end
 
function WPlink(Qnumber, ...)
local link=''
local entity = mw.wikibase.getEntity( Qnumber )
local Sitelink = entity:getSitelink() -- link to WParticle
local Sitelink2 = Sitelink
local Label = entity:getLabel() or ''
local Label_fr = entity:getLabel( 'fr' ) or ''
local a, b
local Sitelink_claas = mw.wikibase.getEntity( 'Q22348500' ):getSitelink()
local a,official_name b= ""
local official_name = ""
if arg[1] == nil then
local wiki = string.match(mw.site.server, "%a+")
if pcall(foo1, Qnumber) then
 
if arg[1]Sitelink =~= nil then
if wiki=="en" then --delete string ", ..." from e.g. "Unley, South Australia"
if pcall(foo1, Qnumber) then
if Sitelink ~= nil then
local i, _ = mw.ustring.find(Sitelink, ",")
if wiki=="en" then --delete string ", ..." from e.g. "Unley, South Australia"
if Sitelinki ~= nil then Sitelink2 = mw.ustring.sub(Sitelink, 1, i-1) end
end
local i, _ = mw.ustring.find(Sitelink, ",")
if i ~= nil then Sitelink2 = mw.ustring.sub(Sitelink, 1, i-1) end
end
link = "[[" .. Sitelink .. "|" .. mw.text.trim(mw.ustring.gsub(Sitelink2, "%b()", "")..' ') .. "]]"
end
if wiki == "de" then -- ru riders get label as alias, to shorten the name
link = "[[" .. Sitelink .. "|" .. mw.text.trim(mw.ustring.gsub(Sitelink2, "%b()", "")..' ') .. "]]"
local a, b = pcall(fooA, 'numeric-id', entity, 'P27', 1)
if wiki == "de" then -- ru riders get label as alias, to shorten the name
if a == true and (b==159 or b==184 or b==212 or b==232) then link = "[[" .. Sitelink .. "|" .. Label .. "]]" end
local a, b = pcall(fooA, 'numeric-id', entity, 'P27', 1)
end
if a == true and (b==159 or b==184 or b==212 or b==232) then link = "[[" .. Sitelink .. "|" .. Label .. "]]" end
elseif Label ~= '' then
end
elseif if Labelwiki ~== 'ar' then
if wiki ~= 'www' then
if black_list(wiki, Label) == true then
link = Label -- function black_list: articles that are printed as text, not wikilinks
else -- detect if there is a different local article with the same name
local title = mw.title.new(Label)
if title.exists then link = Label else link = "[["and title.. Label.. "]]"exists end
then link = Label
else link = mw.getCurrentFrame():expandTemplate{ title = 'Ill-WD2', args = {id=Qnumber,target='en',label=Label} }--"[[" .. Label.. "]]"
end
else
if black_list(wiki, Label) == true then
link = Label -- function black_list: articles that are printed as text, not wikilinks
else -- detect if there is a different local article with the same name
local title = mw.title.new(Label)
if title and title.exists then link = Label else link = "[[" .. Label.. "]]" end
end
end
else link = Label end
else linkreturn ="unknown LabelID endin function WPlink" end
if link == '' then
else return "unknown ID in function WPlink" end
link = entity:getLabel('fr') or entity:getLabel('en') or entity:getLabel('de') or ''
if link == '' then
if wiki == "ar" then link = entity:getLabel() or entity:getLabel('fren') or entity:getLabel('enfr') or entity:getLabel('de') or '' end
if link ~= '' then link = mw.ustring.gsub(link, "%b()", "")
else link = "(label missing)" end
end
end -- if arg[1] == nil
if arg[1] == 'winner_team' then -- Qnumber of a team
if arg[1] == 'team' then -- add '(team of the winner)'
a, b = pcall(fooA, 'text', entity, 'P1448', 2) -- test if more then two official names
if a == true then
a, b = timeStartEnd(Qnumber, 'P1448', 'text', arg[2]) --officialName(entity)
local a1, b1 = pcall(fooA, 'numeric-id', entity, 'P361', 1)
if a1== true then
local a2, b2 = timeStartEnd('Q'..b1, 'P1448', 'text', arg[2])
if a2== true then a = a2 b = b2 end
entity = mw.wikibase.getEntity( 'Q'..b1 )
Sitelink2 = entity:getSitelink() -- link to WParticle
end
if a == true then official_name = b end
else
if available_lang_priority == false then
a, b = pcall(fooA, 'text', entity, 'P1448', 1)
a, b = pcall(fooA, 'text', entity, 'P1448', 2) -- test if more then two official names
if a == true then official_name = b end
if a == true then
end
a, b = timeStartEnd(Qnumber, 'P1448', 'text', arg[2]) --officialName(entity)
if pcall(foo1, Qnumber) then
if Sitelinka ~== niltrue andthen official_name == b and official_name ~= nil then link = "[[".. Sitelink.. "|".. official_name.. "]]" end
else
else -- if there is no saison article, then print team article (if available)
a, b = pcall(fooA, 'numeric-idtext', entity, 'P361P1448', 1)
if a == true then official_name = b end
end
local entity = mw.wikibase.getEntity( 'Q'.. b ) -- Qnumber of team
local Sitelink = entity:getSitelink() -- link to WParticle
if Sitelink ~= nil and official_name ~= nil and official_name ~='' then link = "[[".. Sitelink.. "|".. official_name.. "]]"
elseif Sitelink ~= nil then
if wiki=="en" then --delete string ", ..." from e.g. "Unley, South Australia"
if Sitelink~=nil then
local i, _ = mw.ustring.find(Sitelink, ",")
if i ~= nil then Sitelink2 = mw.ustring.sub(Sitelink, 1, i-1) end
end
else Sitelink2 = Sitelink -- Otherwise it stays "nil" and causes serious trouble
end
link = "[[".. Sitelink.. "|".. mw.text.trim(mw.ustring.gsub(Sitelink2,"%b()","").. ' ').. "]]"
else link = official_name end
else link = Sitelink end
end
else return "unknown ID in function WPlink" end
if linkSitelink =~= nil then
if official_name == nil then
link = entity:getLabel()
link = "[[".. Sitelink.. "|".. mw.text.trim(mw.ustring.gsub(Sitelink,"%b()","").. ' ') .. "]]"
if link == nil then link = "(label missing)" end
else
end
if wiki=="en" then --delete string ", ..." from e.g. "Unley, South Australia"
end -- end arg[1]
local i, _ = mw.ustring.find(Sitelink, ",")
if arg[1] == 'team' then -- add '(team of the winner)'
if i ~= nil then Sitelink = mw.ustring.sub(Sitelink, 1, i-1) end
a, b = timeStartEnd(Qnumber, 'P1448', 'text', arg[2]) --officialName(entity)
end
if a == true then official_name = b end
link = link .. '[['.. Sitelink.. "|".. official_name.. ']]'
if wiki=="en" then --delete string ", ..." from e.g. "Unley, South Australia"
if Sitelink~=nil then
local i, _ = mw.ustring.find(Sitelink, ",")
if i ~= nil then Sitelink = mw.ustring.sub(Sitelink, 1, i-1) end
end
end
if link == '' and Sitelink2 ~= nil then -- code goes from season item to team item
if official_name == nil or official_name == '' then
link = "[[".. Sitelink2.. "|".. mw.text.trim(mw.ustring.gsub(Sitelink2,"%b()","").. ' ') .. "]]"
else
if wiki=="en" then --delete string ", ..." from e.g. "Unley, South Australia"
local i, _ = mw.ustring.find(Sitelink2, ",")
if i ~= nil then Sitelink2 = mw.ustring.sub(Sitelink2, 1, i-1) end
end
link = link .. '[['.. Sitelink2.."|".. official_name.. ']]'
end
end
if Sitelink == nil and Sitelink2 == nil then
if official_name ~='' then link = official_name else link = entity:getLabel() end
if link == nil then link = "(label missing)" end
end
if Sitelink ~= nil and official_name ~= nil and official_name ~='' then link = "[[" .. Sitelink .. "|" .. official_name .. "]]" end
if-- mw.log('Sitelink ==', nilSitelink, and official_name ~'Sitelink2=', nil andSitelink2, 'official_name ~='', then link = official_name) end
end -- end arg[1]
if arg[1] == 'pure' then
if pcall(foo1, Qnumber) then
if wiki == "en" or wiki=="www" then --delete string ", ..." from e.g. "Unley, South Australia"
if Sitelink~=nil then
local i, _ = mw.ustring.find(Sitelink, ",")
if i ~= nil then Sitelink2 = mw.ustring.sub(Sitelink, 1, i-1) end
end
end
if Sitelink ~= nil then link = "[[" .. Sitelink .. "|" .. mw.text.trim(mw.ustring.gsub(Sitelink2, "%b()", "")..' ') .. "]]"
elseif wiki == 'ar' then
else link = mw.ustring.gsub(Label, "^(%a)", function (x) return mw.ustring.upper(x) end)
local title = mw.title.new(Label)
end
if title and title.exists
then link = Label
else link = mw.getCurrentFrame():expandTemplate{ title = 'Ill-WD2', args = {id=Qnumber,target='en',label=Label} }--"[[" .. Label.. "]]"
end
else link = mw.ustring.gsub(Label, "^(%a)", function (x) return mw.ustring.upper(x) end)
end
end
end
if arg[1] == 'race' then -- for infobox "Competitions"
end
local a, b = pcall(fooA, 'numeric-id', entity, 'P31', 1)
if arg[1] == 'race' then -- for infobox "Competitions"
if a == true and b == 1137352 then
local a, b = pcall(fooA, 'numeric-id', entity, 'P31', 1)
local entity_race = mw.wikibase.getEntity( 'Q' .. b )
if a == true and b == 1137352 then
local entity_raceLabel_race = mw.wikibase.getEntityentity_race:getLabel() or 'Q'..b )
local Label_raceSitelink_race = entity_race:getLabelgetSitelink() or ''
if Label_race ~= '' and Sitelink ~= nil then link = '[[' .. Sitelink .. '|' .. Label_race .. ']]'
local Sitelink_race = entity_race:getSitelink() or ''
if Label_race ~= '' and elseif Sitelink ~= nil then link = '[[' .. Sitelink ..'|'..Label_race.. ']]'
elseif else Sitelinkif Sitelink_race ~= nil '' then link = "'[["' .. SitelinkSitelink_race ..'|' .. mw.text.trim(mw.ustring.gsub(Sitelink_race, "%b()", "") .. ' ') .. ']]"'
else link = Label_race or Label end
else if Sitelink_race ~= '' then link = '[['..Sitelink_race.."|".. mw.text.trim(mw.ustring.gsub(Sitelink_race,"%b()","").. ' ').. "]]"
end
else link = Label_race or Label end
if onwikidata == true then link = '[['..entity:getSitelink( 'frwiki')..'|'..entity_race:getLabel('fr')..']]' end
else if Sitelink ~= nil then link = "[[".. Sitelink.. "]]" else link = Label end
end
if wiki == 'www' then link = '[['..entity:getSitelink( 'frwiki')..'|'..entity_race:getLabel('fr')..']]' end
 
else if Sitelink ~= nil then link = "[[".. Sitelink.. "]]" else link = Label end
end
if arg[1] == "Q22348500" then -- add weblink from item "Q22348500" if available
end
local Sitelink_claas = mw.wikibase.getEntity( 'Q22348500' ):getSitelink()
if arg[1] == "Q22348500" then -- add weblink from item "Q22348500" if available
if pcall(foo1, Qnumber) then --Sitelink_claas
if Sitelink == nil then
if Sitelink_claas ~= nil then link = "[[" .. Sitelink_claas .. "|" .. Label .. "]]"
elseif entity:getLabel( 'frar' )~=nil then link = entity:getLabel( 'frar' )
elseif entity:getLabel( 'enfr' )~=nil then link = entity:getLabel( 'enfr' )
elseif entity:getLabel( 'deen' )~=nil then link = entity:getLabel( 'deen' )
elseif entity:getLabel( 'de' )~=nil then link = entity:getLabel( 'de' )
else link = Label
else link = Label
end
end
end
end
end
return link
end
return link
end
 
local frame = mw.getCurrentFrame()
local n = frame:expandTemplate {title="sxangxu sxablonon2", args = {["sxablono"] = "Cycling race/infobox"}}
return n
end
 
function fooA (mode,entity,property,var)
local snak
if mode=="value" then snak=entity.claims[property][var].mainsnak.datavalue.value
else snak=entity.claims[property][var].mainsnak.datavalue.value[mode]
end
return snak, entity.claims[property][var].rank
end
 
function fooB (mode, entity_var, property, var1, var2, ref, var3)
local snak
if mode == 'value' then snak = entity_var.claims[property][var1].references[var2].snaks[ref][var3].datavalue.value
else snak = entity_var.claims[property][var1].references[var2].snaks[ref][var3].datavalue.value[mode]
end
return snak
end
 
function fooC (mode, entity_var, property, var1, quali, var2)
local snak
if mode == 'value' then snak = entity_var.claims[property][var1].references[var2].snaks[ref][var3].datavalue.value
else snak = entity_var.claims[property][var1].qualifiers[quali][var2].datavalue.value[mode]
end
return snak
end
 
function foo1 (arg)
local entity = mw.wikibase.getEntity( arg )
end
 
function foo2 (entity_var, property, var)
local snak = entity_var.claims[property][var].mainsnak.datavalue.value.amount
end
 
function foo3 (entity_var, property, var1, quali, var2)
local snak = entity_var.claims[property][var1].qualifiers[quali][var2].datavalue.value.amount
end
 
function winner (wiki, t, winner_id)
local number = t.number
local wiki = wiki
local winner_id = winner_id
local tt = {}
for num=1,number do table.insert(tt, "") end
local WDlink_on
local winner
 
-- WDlink_on is used to decide if a Wikidata flag will be shown
if wiki == "mk" or wiki == "ja" or wiki == "lv" or wiki == "ru" then WDlink_on = true else WDlink_on = false end
for num=1,number do
local entity_race = mw.wikibase.getEntityObject(t.race[num][1])
if pcall(fooA, 'numeric-id', entity_race, 'P1346', 1) == true then --if exist "winner" (P1346)
for k, v1 in pairs(entity_race.claims['P1346']) do
if pcall(fooCfooA, 'numeric-idvalue', entity_race, 'P1346', k, 'P642', 1) == true and v1.qualifiers.P642[1].datavalue.value['numericthen --id'] ==Check winner_idif then"winner" (P1346) is not void due some "of" (P642)
if pcall(fooC, 'numeric-id', entity_race, 'P1346', k, 'P642', 1) == true
local time_var, a, b
local and winner = "Q"..v1.mainsnakqualifiers.P642[1].datavalue.value['numeric-id'] == winner_id then
local time_var, a, b
winner = "Q"..v1.mainsnak.datavalue.value['numeric-id']
-- get date of the race, e.g. "+2016-01-01T00:00:00Z"
-- P585 (point in time for a single day race) or P580 (start time for a stage race)
a, b = pcall(fooA, 'time', entity_race, 'P585', 1)
if a == true then time_var = b
else
a, b = pcall(fooA, 'time', entity_race, 'P580', 1)
if a == true then time_var = b end
end
 
-- get nationality of the winner, nationality could have changed, therefore look for qualifiers p580 and p582
-- get date of the race, e.g. "+2016-01-01T00:00:00Z"
a, b = pcall(fooA, 'numeric-id', mw.wikibase.getEntity( winner ), 'P27', 1) -- standard: only one nationality
-- P585 (point in time for a single day race) or P580 (start time for a stage race)
if a == true then
a, b = pcall(fooA, 'time', entity_race, 'P585', 1)
if a tt[num] == trueflag("Q"..b, thentime_var) .. " " .. WPlinkrider(winner, time_var) =.. b" "
if WDlink_on == true then tt[num] = tt[num].. wdLink(winner) end
else
else if WDlink_on == true then tt[num] = " " .. wdLink(winner) else tt[num] = "" end
a, b = pcall(fooA, 'time', entity_race, 'P580', 1)
if a == true then time_var = b end
end
 
-- getif nationalityperson ofhas themore winner,than one nationality could have changed, therefore look for qualifiers p580calculate andtt[num] p582again
a, b = pcall(fooA, 'numeric-id', mw.wikibase.getEntity( winner ), 'P27', 12) -- standard: only one nationality
if a == true then
local _, bb = timeStartEnd(winner, "P27", 'numeric-id', time_var)
tt[num] = flag("Q"..b, time_var) .. " " .. WPlink(winner) .. " "
if WDlink_on == true then tt[num] = tt[num]flag('Q'..bb, wdLinktime_var) .. " " .. WPlinkrider(winner, time_var) end.. " "
else if WDlink_on == true then tt[num] = " " tt[num].. wdLink(winner) else tt[num] = "" end
end
end -- if v1.
 
-- If "winner (P1346)"" is nil, check if still "of" has "numeric-id" and if "has cause" (P828)" for "disqualification"
-- if person has more than one nationality calculate tt[num] again
else
a, b = pcall(fooA, 'numeric-id', mw.wikibase.getEntity( winner ), 'P27', 2)
if pcall(fooC, 'numeric-id', entity_race, 'P1346', k, 'P642', 1) == true -- if exist "of" (P642)
if a == true then
and v1.qualifiers.P642[1].datavalue.value['numeric-id'] == winner_id -- if "of" is a winner_id (winner, second or third)
local _, bb = timeStartEnd(winner, "P27", 'numeric-id', time_var)
and pcall(fooC, 'numeric-id', entity_race, 'P1346', k, 'P828', 1) == true -- if exist "has cause" (P828)
tt[num] = flag('Q'..bb, time_var) .. " " .. WPlink(winner) .. " "
and v1.qualifiers.P828[1].datavalue.value['numeric-id'] == 1229261 then -- if cause is "discualification" (Q1229261)
if WDlink_on == true then tt[num] = tt[num].. wdLink(winner) end
if pcall(fooC, 'numeric-id', entity_race, 'P1346', k, 'P1013', 1) == true then -- if exist "criterion used" (P1013)
end
local criterion = v1.qualifiers.P1013[1].datavalue.value['numeric-id'] -- if criterion is "declared desert" (Q45123627)
end -- if v1.
if criterion == 45123627 then -- if criterion is "declared desert" (Q45123627), add others if you want
tt[num] = WPlink("Q"..criterion)
end
end
end
end
end -- for k, v1
end -- if
end -- for num=
return tt
end
 
local entity = mw.wikibase.getEntity( frame.args[1] )
local WDlink_on
local wiki = string.match(mw.site.server, "%a+")
local WPcontent = {}
 
-- WDlink_on is used to decide if a Wikidata flag will be shown
if wiki == "mk" or wiki == "ja" or wiki == "lv" or wiki == "ru" then WDlink_on = true else WDlink_on = false end
 
local num = 0
if pcall(fooA, 'numeric-id', entity, 'P527', 1) == true then
for k, v1 in pairs(entity.claims['P527']) do
local year, race, entity_race, a, b
race = 'Q'..v1.mainsnak.datavalue.value['numeric-id'] -- Qnumbers of the parts of a tour
entity_race = mw.wikibase.getEntityObject(race)
 
-- P585(point in time for a single day race) or P580(start time for a stage race)
a, b = pcall(fooA, 'time', entity_race, 'P585', 1)
if a == true then year = b
else
a, b = pcall(fooA, 'time', entity_race, 'P580', 1)
if a == true then year = b end
end
if year ~= nil then _, _, year, _, _ = string.find(year, "(%d+)-(%d+)-(%d+)") end
table.insert(t.race, { race, year} )
table.sort(t.race, function(a,b) return a[2] < b[2] end) -- t.race is sorted after year
num = num + 1
end
 
if year ~= nil then _, _, year, _, _ = string.find(year, "(%d+)-(%d+)-(%d+)") end
table.insert(t.race, { race, year} )
table.sort(t.race, function(a,b) return a[2] < b[2] end) -- t.race is sorted after year
num = num + 1
end
end -- for k, v1
t.number = num
 
for num=1, t.number do -- build year column with link to wikipedia article and to wikidata item
local sitelink = mw.wikibase.sitelink( t.race[num][1] )
if sitelink == nil then sitelink = t.race[num][2] else sitelink = "[[" .. sitelink .. "|" .. t.race[num][2] .. "]]" end
local table_first = "<table cellpadding='4' cellspacing='0' style='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:left" .. textalign .. "; vertical-align:top; font-size:85%; line-height:1.6em;'>"
local table_proto = "<tr style='background:#FFDF80; text-align:center'><th>"
if WDlink_on == false then table_proto = table_proto .. '<span style="float:left">[[File:Wikidata-logo S.svg|12px|link=d:'.. frame.args[1].. '#P527]]</span>' end
table_proto = table_proto.. headoftableIV(wiki,1).. "</th><th>".. headoftableIV(wiki,2).. "</th><th>".. headoftableIV(wiki,3).. "</th><th>".. headoftableIV(wiki,4).. "</th></tr>"
local table_center, table_last = "", "</table>"
 
local level = false
local a, b, num, var
local wiki = string.match(mw.site.server, "%a+")
local entity0 = mw.wikibase.getEntityObject( frame.args[1] )
local WDlink_on
start location and end location are the same. The file data for the icon looks this way: [[File:Stage rest day.svg|any text]]
]=]
if localFrame.args[2] ~= nil then
-- local WProw, WPcourse, WPwinner = mw.ustring.lower(headoftable(1)), mw.ustring.lower(headoftable(3)), mw.ustring.lower(headoftable(5))
local WProw, WPnew_row, WPcourse, WPtext, WPdate, WPwinner, WPicon, WPdistance = 'row', 'afterrow', 'location', 'text', 'date', 'winner', 'icon', 'distance'
for num,var in pairs(localFrame.args) do
if num > 1 and mw.ustring.find(mw.ustring.lower(localFrame.args[num]), WProw) then
_, _, key1, key2, val = mw.ustring.find(localFrame.args[num], "([^:]+)%s*:?%s*([^:]*)%s*:%s*(%C+)")
_, _, key01, key11, key12 = mw.ustring.find(key1, "(%a+)%s*(%a+)%s*(%d+)")
key12 = tonumber(key12) key11 = mw.ustring.lower(key01..key11)
key2 = mw.ustring.lower(mw.text.trim(key2))
_, _, key21, key22 = mw.ustring.find(key2, "(%a+)%s*(%a*)")
key21 = mw.ustring.lower(key21) key22 = mw.ustring.lower(key22)
 
if type(WPcontent[key12]) ~= 'table' then WPcontent[key12] = {} end
if key11 == WProw and key21 == WPcourse then WPcontent[key12][key22] = val end
if key11 == WPnew_row and key2 == WPdate then
WPcontent[key12]['date'] = val
WPcontent[key12]['text'] = WPcontent[key12]['text'] or ''
WPcontent[key12]['icon (new row)'] = WPcontent[key12]['icon (new row)'] or ''
end
if key11 == WPnew_row and key2 == WPtext then
WPcontent[key12]['text'] = val
WPcontent[key12]['date'] = WPcontent[key12]['date'] or ''
WPcontent[key12]['icon (new row)'] = WPcontent[key12]['icon (new row)'] or ''
end
if key11 == WPnew_row and key2 == WPicon then
val = mw.ustring.gsub(val, "|", "|border|right|20px|", 1)
WPcontent[key12]['icon (new row)'] = val
WPcontent[key12]['date'] = WPcontent[key12]['date'] or ''
WPcontent[key12]['text'] = WPcontent[key12]['text'] or ''
end
if key11 == WProw and key21 == WPwinner and key22 == 'a' then WPcontent[key12]['stage winner'] = val end
if key11 == WProw and key21 == WPwinner and key22 == 'b' then WPcontent[key12]['general winner'] = val end
if key11 == WProw and key21 == WPicon then
val = mw.ustring.gsub(val, "|", "|border|right|20px|", 1) WPcontent[key12]['icon'] = val end
if key11 == WProw and key21 == WPdistance then WPcontent[key12]['distance'] = val end
end
if key11 == WProw and key21 == WPwinner and key22 == 'a' then WPcontent[key12]['stage winner'] = val end
if key11 == WProw and key21 == WPwinner and key22 == 'b' then WPcontent[key12]['general winner'] = val end
if key11 == WProw and key21 == WPicon then
val = mw.ustring.gsub(val, "|", "|border|right|20px|", 1) WPcontent[key12]['icon'] = val end
if key11 == WProw and key21 == WPdistance then WPcontent[key12]['distance'] = val end
end
end
end
-- if there is one 'P527' then level = true
a, b = pcall(fooA, 'numeric-id', entity0, 'P527', 1)
 
-- WDlink_on is used to decide if a Wikidata flag will be shown
if wiki == "mk" or wiki == "ja" or wiki == "lv" or wiki == "ru" then WDlink_on = true else WDlink_on = false end
 
var = #entity0.claims["P527"]
if a == true then point_of_time[num] = b else point_of_time[num] = " " end
a, b = pcall(fooA, 'numeric-id', entity[num], 'P1427', 1)
if a == true then sitelinks1[num] = WPlink( 'Q'..b, 'pure' ) else sitelinks1[num] = " " end
a, b = pcall(fooA, 'numeric-id', entity[num], 'P1444', 1)
if a == true then sitelinks2[num] = WPlink( 'Q'..b, 'pure' ) else sitelinks2[num] = " " end
a, b = pcall(fooA, 'amount', entity[num], 'P2043P3157', 1)
if a == true then length[num] = b else length[num] = " " end
else
a, b = pcall(fooA, 'amount', entity[num], 'P2043', 1)
if a == true then length[num] = b else length[num] = " " end
end
 
flag1[num] = ' '
if a == true then
flag1[num] = flag('Q'..b, point_of_time[num])
sitelinks3[num] = WPlink( number1[num], 'winner_teamteam', point_of_time[num] )
end
end
if a == true then
flag2[num] = flag( 'Q'..b, point_of_time[num])
sitelinks4[num] = WPlink( number2[num], 'winner_teamteam' )
end
end
table_first = "<table border='0' cellpadding='4' cellspacing='0' style='border:1px solid rgb(200,200,200); color:black; "
table_first = table_first .. "margin:0 0 0.5em 0; background-color:rgb(255, 255, 255); padding:5px; clear:left; "
table_first = table_first .. "text-align:left" .. textalign .. "; font-size:85%; line-height:1.6em;'>"
table_proto = "<tr style='background:#FFDF80; text-align:center;'><th style='white-space:nowrap'>"
if WDlink_on == false then table_proto = table_proto .. "[[File:Wikidata-logo S.svg|12px|link=d:".. localFrame.args[1].. "#P527]]" end
table_proto = table_proto.. headoftable(1) .."</th><th>" .. headoftable(2) .."</th><th>".. headoftable(3)..
if day == "1" and (wiki == "fr") then day = "1<sup>er</sup>" end
if wiki == "lv" then stageNr = series_ordinal[num] end
local month = func_month(tonumber(m[num]))
local date = day ..' ' .. month
if wiki == "br" then date = day.. " a viz ".. month end
if wiki == "ca" or wiki == "es" then date = day .. " de ".. month end
if wiki == "en" then date = month.. " ".. day end
 
local miles
if pcall(function()
if wiki == 'en' then --If 'en.wiki' express distance in kilometers and miles
length[num] = mw.language.getContentLanguage():formatNum(tonumber(length[num]))
if pcall(function()
end
) miles then else= math.modf(10*length[num] = " " end/1.609344)/10
miles = mw.language.getContentLanguage():formatNum(tonumber(miles))
end
) then else miles = " " end
if pcall(function()
length[num] = mw.language.getContentLanguage():formatNum(tonumber(length[num]))
end
) then else length[num] = " " end
if length[num] ~= " " then length[num] = length[num].." ("..miles..")" end
else
if pcall(function()
length[num] = mw.language.getContentLanguage():formatNum(tonumber(length[num]))
end
) then else length[num] = " " end
end
 
if type(WPcontent[num]) == 'table' and WPcontent[num]['a'] ~= nil then sitelinks1[num] = WPcontent[num]['a'] end
table_center = table_center.. sitelinks2[num].."</td><td style='padding-top:10px'>".. stage[num].. "</td><td style='text-align:center'>".. length[num].. "</td>"
if type(WPcontent[num]) == 'table' and WPcontent[num]['stage winner'] ~= nil then
table_center = table_center.. "<td style='text-align:center" .. textalign .. "'>".. flag1[num].. ' '.. sitelinks3[num].. number1[num] .. "</td>"
else table_center = table_center.. "<td>".. flag1[num].. ' '.. sitelinks3[num].. number1[num] .. "</td>" end
if type(WPcontent[num]) == 'table' and WPcontent[num]['general winner'] ~= nil then
table_center = table_center.. "<td style='text-align:center" .. textalign .. "'>".. flag2[num].. ' '.. sitelinks4[num].. number2[num].. "</td></tr>"
else table_center = table_center.. "<td>".. flag2[num].. ' '.. sitelinks4[num].. number2[num].. "</td></tr>" end
 
if type(WPcontent[num]) == 'table' and (WPcontent[num]['date'] ~= nil or WPcontent[num]['text'] ~= nil or WPcontent[num]['icon (new row)'] ~= nil)
then table_center = table_center.. "<tr><td></td>"
if WPcontent[num]['icon (new row)'] == '' then table_center = table_center.."<td nowrap style='text-align:right; padding:3px 0px 10px 0px;white-space:nowrap'>".. WPcontent[num]['date']
else table_center = table_center.."<td style='text-align:right; padding-right:0px'>".. WPcontent[num]['date'] end
if WPcontent[num]['icon (new row)'] == '' then table_center = table_center.."</td><td style='text-align:left" .. textalign .. "; padding:3px 4px 10px'>"..WPcontent[num]['text']
else table_center = table_center.."</td><td style='text-align:left" .. textalign .. "'>"..WPcontent[num]['text'] end
table_center = table_center.."</td><td style='padding-top:10px'>".. WPcontent[num]['icon (new row)'].. "</td><td colspan='3' ></td></tr>"
end
 
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"]="Prolog", ["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" }
 
if l10nDef[wiki] ~= nil then return l10nDef[wiki] else return l10nDef["en"] end -- if no translation, show en translation
local wiki=wiki -- global wiki to local wiki
 
if wiki=='www' then return l10nDef["fr"]
else
if l10nDef[wiki] ~= nil then return l10nDef[wiki] else return l10nDef["en"] end -- if no translation, show en translation
end
end
 
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" }
 
local wiki=wiki -- global wiki to local wiki
local word1, word2
if wiki=='www' then word2=l10nDef["fr"] else word2=l10nDef[wiki] end
if word2 == nil then word2=l10nDef["en"] end -- if no translation, show en translation
local word = word2
 
-- fr: {{1re}} étape, {{2e}} étape
if wiki=="www" or 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,
function func_month(x)
local l10nDef = { }
l10nDef["ar"] = {"يناير", "فبراير", "مارس", "أبريل", "مايو", "يونيو", "يوليو", "أغسطس", "سبتمبر", "أكتوبر", "نوفمبر", "ديسمبر"}
l10nDef["fr"] = {"janv.", "févr.", "mars", "avr.", "mai", "juin", "juil.", "août", "sept.", "oct.", "nov.", "déc."}
l10nDef["en"] = {"January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"}
l10nDef["de"] = {"Jan.", "Feb.", "März", "Apr.", "Mai", "Juni", "Juli", "Aug.", "Sept.", "Okt.", "Nov.", "Dez."}
l10nDef["eo"] = {"janu.", "febr.", "marto", "apr.", "majo", "jun.", "jul.", "auxg.", "sept.", "okt.", "nov.", "dec."}
l10nDef["es"] = {"enero", "feb.febrero", "marzo", "abr.abril", "mayo", "jun.junio", "jul.julio", "agosto", "sept.septiembre", "oct.octubre", "nov.noviembre", "dic.diciembre"}
l10nDef["et"] = {"jaan.", "veebr.", "märts", "apr.", "mai", "juuni", "juuli", "aug.", "sept.", "okt.", "nov.", "dets."}
l10nDef["eu"] = {"urtarrila", "otsaila", "martxoa", "apirila", "maiatza", "ekaina", "uztaila", "abuztua", "iraila", "urria", "azaroa", "abendua"}
l10nDef["pt"] = {"jan", "fev", "mar", "abr", "mai", "jun", "jul", "ago", "set", "out", "nov", "dez"}
l10nDef["ro"] = {"Ian.", "Feb.", "Mar.", "Apr.", "Mai", "Iun.", "Iul.", "Aug.", "Sep.", "Oct.", "Nov.", "Dec."}
l10nDef["ru"] = {"Январяянваря", "Февраляфевраля", "Мартамарта", "Апреляапреля", "Маямая", "Июняиюня", "Июляиюля", "Августаавгуста", "Сентябрясентября", "Октябряоктября", "Ноябряноября", "Декабрядекабря"}
l10nDef["sh"] = {"sijec.", "velj.", "ozuj.", "trav.", "svib.", "lip.", "srp.", "kol.", "ruj.", "list.", "stud.", "pros."}
l10nDef["sk"] = {"jan.", "feb.", "mar.", "apr.", "máj", "jún.", "júl.", "aug.", "sept.", "okt.", "nov.", "dec."}
l10nDef["zh"] = {"1月", "2月", "3月", "4月", "5月", "6月", "7月", "8月", "9月", "10月", "11月", "12月"}
 
local wiki,l10n =mw.site.server l10nDef[wiki]
if wiki=='//www.wikidata.org'not l10n then returnl10n = l10nDef["fren"][tonumber(x)] end -- default
return l10n[x]
else return l10nDef[string.sub(wiki,string.find(wiki,"%a+"))][tonumber(x)] end
end
 
function headoftable(x) -- En-tête du tableau listant les étapes
local l10nDef={ }
l10nDef["ar"]={"المرحلة", "التاريخ", "الدورة", "المسافة (كم)", "الفائز بالمرحلة", "القائد العام"}
l10nDef["fr"]={"Étape", "Date", "Villes étapes", "Distance (km)", "Vainqueur d'étape", "Leader du classement général"}
l10nDef["en"]={"Stage", "Date", "Course", "Distance (- km (mi)", "Stage winner", "Overall leader"}
l10nDef["br"]={"Tennad", "Deiziad", "Kêr loc'hañ ha kêr degouezhout", "Hed (km)", "Trec'hour", "E penn ar renkamant hollek"}
l10nDef["ca"]={"Etapa", "Data", "Ciutats d'etapa", "Distància (km)", "Vencedor de l'etapa", "Líder de la general"}
l10nDef["sk"]={"Etapa", "Dátum", "Trasa", "Vzdialenosť (km)", "Víťaz", "Priebežný líder"}
l10nDef["sv"]={"Etapp", "Datum", "Start – mål", "Distans (km)", "Skede vinnare", "Övergripande ledare"}
l10nDef["als"]=l10nDef["fr"]
 
local wiki,l10n=mw.site.server
if wiki=='//www.wikidata.org' then l10n=l10nDef["fr"]
else l10n=l10nDef[string.sub(wiki,string.find(wiki,"%a+"))] end
 
local l10n = l10nDef[wiki]
if not l10n then l10n = l10nDef["en"] end -- default
return l10n[x]
end
 
function headoftableII(wiki,x) -- En-têtes des tableaux générant les classements
local l10nDef = { }
l10nDef["ar"] = {"العداء", "البلد", "الفريق", "الوقت", "إزاحة الوقت", "السرعة", "النقاط", "تصنيف الفرق ضد الساعة", "التصنيف العام", "تصنيف النقاط", "تصنيف الجبال", "تصنيف أفضل عداء", "تصنيف أفضل شاب", "تصنيف الفرق حسب الوقت", "ترتيب الفرق حسب النقاط", "تصنيف المجموعة", "تصنيف أفضل مقاتل", "التصنيف تحت 23"}
l10nDef["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"}
l10nDef["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"}
l10nDef["en"] = {"Rider", "Country", "Team", "Time", "Time Gap", "Speed", "Points", "Stage classification", "General classification", "Points classification", "Mountains classification", "Sprints classification", "Best young classification", "Teams classifications"}
l10nDef["bren"] = {"RederRider", "BroCountry", "SkipailhTeam", "AmzerTime", "Time Gap", "Speed", "PoentoùPoints", "RenkadurStage anclassification", "General tennadclassification", "RenkadurPoints hollekclassification", "RenkadurMountains a-boentoùclassification", "RenkadurSprints arclassification", menez"Best young classification", "RenkadurTeams arclassification", sprintoù"Points classification for teams", "RenkadurCombination arclassification", yaouank"Combative gwellañclassification", "RenkadurU23 a-skipailhclassification"}
l10nDef["cabr"] = {"CorredorReder", "PaísBro", "EquipSkipailh", "TempsAmzer", "Time Gap", "VelocitatSpeed", "PuntsPoentoù", "ClassificacióRenkadur dean l'etapatennad", "ClassificacióRenkadur generalhollek", "ClassificacióRenkadur per puntsa-boentoù", "ClassificacióRenkadur dear lamenez", "Renkadur ar muntanyasprintoù", "ClassificacióRenkadur delsar esprintsyaouank gwellañ", "ClassificacióRenkadur dela-skipailh", millor"Renkadur jovea-skipailh", "ClassificacióCombination perclassification", "Combative classification", "U23 equipsclassification"}
l10nDef["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"}
l10nDef["da"] = {"Rytter", "Land", "Hold", "Tid", "Tidsforskel", "Gns. fart", "Point", "Etaperesultat", "Samlede stilling", "Pointkonkurrence", "Bjergkonkurrence", "Sprintkonkurrence", "Ungdomskonkurrence", "Holdkonkurrence"}
l10nDef["deda"] = {"FahrerRytter", "Land", "TeamHold", "ZeitTid", "ZeitabstandTidsforskel", "GeschwGns. fart", "PunktePoint", "EtappenergebnisEtaperesultat", "GesamtwertungSamlede stilling", "PunktewertungPointkonkurrence", "BergwertungBjergkonkurrence", "SprintwertungSprintkonkurrence", "NachwuchswertungUngdomskonkurrence", "Holdkonkurrence", "Holdkonkurrence efter point", "Kombinationskonkurrence", "Mest angrebsivrige rytter", "MannschaftswertungU23-konkurrence"}
l10nDef["eode"] = {"KurantoFahrer", "LandoLand", "TeamoTeam", "TempoZeit", "Time GapZeitabstand", "RapidoGeschw.", "PoentojPunkte", "EtapaEtappenergebnis", klasifiko"Gesamtwertung", "Gxenerala klasifikoPunktewertung", "KlasifikoBergwertung", laux"Sprintwertung", poentoj"Nachwuchswertung", "KlasifikoMannschaftswertung", por la montaro"Mannschaftswertung", "KlasifikoCombination por la sprintojclassification", "KlasifikoCombative de la plej bona junoclassification", "Klasifiko poU23 teamoclassification"}
l10nDef["eseo"] = {"CiclistaKuranto", "PaísLando", "EquipoTeamo", "TiempoTempo", "IntervaloTime de tiempoGap", "Velocidad mediaRapido", "PuntosPoentoj", "ClasificaciónEtapa deklasifiko", la"Gxenerala etapaklasifiko", "ClasificaciónKlasifiko generallaux poentoj", "ClasificaciónKlasifiko por puntosla montaro", "ClasificaciónKlasifiko depor la montañasprintoj", "ClasificaciónKlasifiko de losla plej bona sprintsjuno", "ClasificaciónKlasifiko delpo mejorteamo", joven"Klasifiko po teamo", "ClasificaciónCombination porclassification", "Combative classification", "U23 equiposclassification"}
l10nDef["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"}
l10nDef["eu"] = {"Txirrindularia", "Herrialdea", "Taldea", "Denbora", "Time Gap", "Speed", "Puntua", "Etapako sailkapena", "Sailkapen orokorra", "Puntukako sailkapena", "Mendiko sailkapena", "Esprinetako sailkapena", "Gazte onenaren sailkapena", "Taldekako sailkapena"}
l10nDef["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"}
l10nDef["fi"] = {"Pyöräilijä", "Maa", "Joukkue", "Aika", "Aikaero", "Nopeus", "Pisteet", "Etapin tulokset", "Kokonaistilanne", "Pistekilpailu", "Vuoristokilpailu", "Sprinttikilpailu", "Nuorten kilpailu", "Joukkuekilpailu"}
l10nDef["fofi"] = {"SúkklariPyöräilijä", "LandMaa", "LiðJoukkue", "TíðAika", "TimeAikaero", Gap"Nopeus", "FerðPisteet", "StigEtapin tulokset", "TeinaplaseringKokonaistilanne", "SamlaðPistekilpailu", plasering"Vuoristokilpailu", "StigkappinginSprinttikilpailu", "FjallakappinginNuorten kilpailu", "SpurtkappinginJoukkuekilpailu", "UngdómskappinginJoukkuekilpailu", "LiðkappinginCombination classification", "Combative classification", "U23 classification"}
l10nDef["hufo"] = {"VersenyzőSúkklari", "OrszágLand", "ÉquipeLið", "IdőTíð", "IdőkülönbségTime Gap", "ÁtlagsebességFerð", "PontStig", "SzakaszTeinaplasering", "Samlað versenyplasering", "ÖsszetettStigkappingin", verseny"Fjallakappingin", "PontversenySpurtkappingin", "HegyiUngdómskappingin", pontverseny"Liðkappingin", "GyorsulversenyLiðkappingin", "FiatalokKombinatiónsheiðurkappingin", versenye"Combative classification", "CsapatversenyU23 classification"}
l10nDef["lbhu"] = {"CoureurVersenyző", "LandOrszág", "EquipeÉquipe", "ZäitIdő", "TimeIdőkülönbség", Gap"Átlagsebesség", "VitessePont", "PunktenSzakasz verseny", "EtappeklassementÖsszetett verseny", "GeneralklassementPontverseny", "KlassementHegyi nopontverseny", Punkten"Gyorsulverseny", "BiergpräisFiatalok versenye", "SprintklassementCsapatverseny", "BeschteCsapatverseny", Jonken"Combination classification", "EquippeklassementCombative classification", "U23 classification"}
l10nDef["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"}
l10nDef["mk"] = {"Возач", "Земја", "Екипа", "Време", "Разлика", "Брзина", "Бодови", "Етапен резултат", "Генерален пласман", "Бодовен пласман", "Планински пласман", "Спринтерски пласман", "Пласман за млад возач", "Екипен пласман"}
l10nDef["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"}
l10nDef["no"] = {"Rytter", "Land", "Lag", "Tid", "Tidsforskjell", "Fart", "Poeng", "Etappeplassering", "Sammenlagtplassering", "Poengkonkurranse", "Klatrekonkurranse", "Sprintkonkurranse", "Ungdomskonkurranse", "Lagkonkurranse"}
l10nDef["mk"] = {"Возач", "Земја", "Екипа", "Време", "Разлика", "Брзина", "Бодови", "Етапен резултат", "Генерален пласман", "Бодовен пласман", "Планински пласман", "Спринтерски пласман", "Пласман за млад возач", "Екипен пласман", "Екипен пласман", "Combination classification", "Combative classification", "U23 classification"}
l10nDef["nl"] = {"Renner", "Land", "Ploeg", "Tijd", "Tijdsverschil", "Snelheid", "Punten", "Etappeklassement", "Algemeen Klassement", "Puntenklassement", "Bergklassement", "Sprintklassement", "Jongerenklassement", "Ploegenklassement"}
l10nDef["no"] = {"Rytter", "Land", "Lag", "Tid", "Tidsforskjell", "Fart", "Poeng", "Etappeplassering", "Sammenlagtplassering", "Poengkonkurranse", "Klatrekonkurranse", "Spurtkonkurranse", "Ungdomskonkurranse", "Lagkonkurranse", "Lagkonkurranse (poeng)", "Kombinasjonkonkurranse", "U23 classification", "Combative classification", "U23 classification"}
l10nDef["pt"] = {"Ciclista", "País", "Equipe", "Tempo", "Intervalo de tempo", "Rapidez", "Pontos", "Classificação por etapas", "Classificação geral", "Classificação por pontos", "Classificação de montanha", "Classificação por velocidade", "Classificação de juventude", "Classificação coletiva"}
l10nDef["ronl"] = {"CiclistRenner", "ȚarăLand", "EchipăPloeg", "TimpTijd", "TimeTijdsverschil", Gap"Snelheid", "VitezăPunten", "PuncteEtappeklassement", "ClasamentulAlgemeen etapeiKlassement", "Clasament generalPuntenklassement", "ClasamentBergklassement", pe puncte"Sprintklassement", "ClasamentJongerenklassement", cățărători"Ploegenklassement", "ClasamentPloegenklassement", sprinteri"Combinatieklassement", "Clasamentul celui maiCombative bun tânărclassification", "Clasament peU23 echipeclassification"}
l10nDef["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"}
l10nDef["ru"] = {"Гонщик", "Страна", "Команда", "Время", "Отставание", "Скорость", "Очки", "Результаты этапа", "Генеральная классификация", "Очковая классификация", "Горная классификация", "Спринтерская классификация", "Молодёжная классификация", "Командная классификация"}
l10nDef["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"}
l10nDef["www"] = l10nDef["fr"]
l10nDef["ru"] = {"Гонщик", "Страна", "Команда", "Время", "Отставание", "Скорость", "Очки", "Результаты этапа", "Генеральная классификация", "Очковая классификация", "Горная классификация", "Спринтерская классификация", "Молодёжная классификация", "Командная классификация по времени", "Командная классификация по очкам", "Комбинированная классификация", "Бойцовская калссификация", "Классификация U23"}
local l10n = l10nDef[wiki]
if not l10n then l10n = l10nDef["en"] end -- default
return l10n[x]
end
 
function headoftableIVheadoftableIII(wiki,x) -- En-tête du tableau dulistant palmarèsles d'uneéquipes courseparticipantes cycliste(P1923)
local l10nDef = { }
l10nDef["ar"] = {"اسم الفريق", "البلد", "الرمز", "فريق عالمي", "فرق عالمية", "فريق برو", "فرق برو", "فريق قاري محترف", "فرق قارية محترفة", "فريق قاري", "فرق قارية", "فريق وطني", "فرق وطنية", "فريق إقليمي ونادي", "فرق إقليمية وأندية", "فريق دراجات محترف", "فرق دراجات محترفة", "فريق هواة دراجات", "فرق هواة دراجات", "مجموعة رياضية أولى", "مجموعات رياضية أولى", "مجموعة رياضية ثانية", "مجموعات رياضية ثانية", "مجموعة رياضية ثالثة", "مجموعات رياضية ثالثة", "فريق مختلط", "فرق مختلطة", "فريق إناث محترف", "فرق إناث محترفة", "فريق هواة دراجات إناث", "فرق هواة دراجات إناث"}
l10nDef["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"}
l10nDef["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", "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"}
l10nDef["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"}
l10nDef["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 club", "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 merc'hed", "Skipailhoù merc'hed", "Women's amateur cycling team", "Women's amateur cycling teams"}
l10nDef["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", "Women's amateur cycling team", "Women's amateur cycling teams"}
l10nDef["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"}
l10nDef["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"}
l10nDef["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"}
l10nDef["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", "Women's amateur cycling team", "Women's amateur cycling teams"}
l10nDef["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"}
l10nDef["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"}
l10nDef["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"}
l10nDef["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"}
l10nDef["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"}
l10nDef["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"}
l10nDef["nl"] = {"Teamnaam", "Land", "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", "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", "Women's amateur cycling team", "Women's amateur cycling teams"}
l10nDef["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", "Sportsgruppe I", "Sportsgruppe I", "Sportsgruppe II", "Sportsgruppe II", "Sportsgruppe III", "Sportsgruppe III", "Mix-lag", "Mix-lag", "Profflag", "Profflag", "Amatørlag", "Amatørlag"}
l10nDef["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", "Women's amateur cycling team", "Women's amateur cycling teams"}
l10nDef["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"}
l10nDef["ru"] = {"Команда", "Страна", "Код", "[[UCI WorldTeam|WorldTeam]]", "[[UCI WorldTeam|WorldTeams]]", "[[UCI ProTeam|ProTeam]]", "[[UCI ProTeams|ProTeams]]", "[[UCI Professional Continental Team|Профессиональная континентальная команда]]", "[[UCI Professional Continental Team|Профессиональные континентальные команды]]", "[[UCI Continental Team|Континентальная команда]]", "[[UCI Continental Team|Континентальные команды]]", "Национальная команда", "Национальные команды", "Региональная команда или клуб", "Региональные команды и клубы", "Профессиональная велокоманда", "Профессиональные велокоманды", "Любительская велокоманда", "Любительские велокоманды", "Groupe sportif I", "Groupes sportifs I", "Groupe sportif II", "Groupes sportifs II", "Groupe sportif III", "Groupes sportifs III", "Смешанная велокоманда", "Смешанные велокоманды", "[[UCI Women’s Team|Женская профессиональная команда]]", "[[UCI Women’s Team|Женские профессиональные команды]]", "Женская любительская велокоманда", "Женские любительские велокоманды"}
 
local l10n = l10nDef[wiki]
if not l10n then l10n = l10nDef["en"] end -- default
return l10n[x]
end
 
function headoftableIV(x) -- En-tête du tableau du palmarès d'une course cycliste
local l10nDef = { }
l10nDef["ar"] = {"السنة", "الفائز", "الثاني", "الثالث"}
l10nDef["fr"] = {"Année", "Vainqueur", "Deuxième", "Troisième"}
l10nDef["en"] = {"Year", "Winner", "Second", "Third"}
l10nDef["sr"] = {"Година", "Победник", "Други", "Трећи"}
l10nDef["sv"] = {"År", "Vinnare", "Andra", "Tredje"}
 
l10nDef["www"] = l10nDef["fr"]
return l10nDef[wiki][x]
end
-- l10nDef[""] = {plain = "", hilly="", inter='', mount='', time_prologue='', time_team='', time_indiv='', uphill='', rest=''}
local l10nDef = { }
l10nDef["ar"] = {plain = "مرحلة مستوية", hilly="مرحلة التلال", inter='مرحلة متوسطة', mount='مرحلة جبلية', time_prologue='مرحلة سباق ضد الساعة', time_team='مرحلة سباق الفرق ضد الساعة', time_indiv='مرحلة سباق فردي ضد الساعة', uphill='مرحلة تسلق الجبل ضد الساعة', rest='يوم راحة'}
l10nDef["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'}
l10nDef["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'}
l10nDef["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ä'}
l10nDef["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'}
l10nDef["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=''}
l10nDef["ja"] = {plain = "平坦ステージ", hilly="丘陵ステージ", inter='中間ステージ', mount='山岳ステージ', time_prologue='タイムトライアルステージ', time_team='チームタイムトライアルステージ', time_indiv='個人タイムトライアルステージ', uphill='アップヒルタイムトライアルステージ', rest='休養日'}
l10nDef["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'}
l10nDef["pt"] = {plain = "etapa plana", hilly="", inter='média montanha', mount='alta montanha', time_prologue='prólogo', time_team='contrarrelógio por equipes', time_indiv='contrarrelógio individual', uphill='', rest=''}
l10nDef["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'}
l10nDef["ru"] = {plain = "равнинный", hilly="холмистый", inter='горныйсреднегорный', mount='высокогорныйгорный', time_prologue='пролог', time_team='командная разделка', time_indiv='индивидуальная разделка', uphill='горная разделка', rest='день отдыха'}
l10nDef["sv"] = {plain = "Flack etapp", hilly="", inter='Kuperat', mount='Bergsetapp', time_prologue='Prolog', time_team='Lagtempoetapp', time_indiv='Tempoetapp', uphill='', rest='Vilodag'}
 
local wiki,l10n =mw.site.server l10nDef[wiki]
if wiki=='//www.wikidata.org'not l10n then l10n = l10nDef["fren"] end -- default
else l10n=l10nDef[string.sub(wiki,string.find(wiki,"%a+"))] end
 
if x=='plain stage' then return "[[File:Plainstage.svg|border|right|20px|"..l10n.plain.."]]" end
local num = 1
if pcall(fooA, 'numeric-id', entity, 'P41', 1) then
local v
for _, v in pairs(flags) do
if v.qualifiers then
if (not v.qualifiers["P580"] or v.qualifiers["P580"][1].datavalue.value.time <= date)
and (not v.qualifiers["P582"] or v.qualifiers["P582"][1].datavalue.value.time >= date)
then possible_flag[num]=v.mainsnak.datavalue.value num=num+1 end
else possible_flag[num]=v.mainsnak.datavalue.value num=num+1 end
end
local file="[[File:"..possible_flag[1].."|border|20px"
if possible_flag[1]~=nil then
local a2,b2=pcall(fooA,'value',entity,'P984',1) -- P984 (country code by the International Olympic Committee)
file="[[File:"..possible_flag[1].."|border|20px"
if a2==true then file=file.."|"..b2.."]]" else file=file.."]]" end
else
flag_table[x] = file
file="[[File:".."failed".."|border|20px"
return file
end
local a2,b2=pcall(fooA,'value',entity,'P984',1) -- P984 (country code by the International Olympic Committee)
if a2 == true then file=file.."|"..b2.."]]" else file=file.."]]" end
flag_table[x] = file
return file
end
end