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

54.237 octets eliminats ,  fa 1 any
update
(Update)
(update)
local p = {}
local wiki, onwikidata
wiki = string.match(mw.site.server, "%a+")
if wiki == "www" then
local contentLanguage = mw.getContentLanguage()
local wikilang = contentLanguage:getCode()
local wikibase = mw.wikibase
local localframe -- Value may be given by functions which use frame functions like getReference
 
-- == Structure of the code ==
-- Classes declared as global --
-- I) Constant
-- II) Basic functions (fooA)
-- III) Functions less basic called from other functions
-----A) Time functions
-----B) Link functions
-----C) Functions for the output, like table
-----D) Jersey, flag functions
-----E) Other (winner)
-- IV) Translation
-- V) Main functions
----- A) Function race reference
----- B) Calendar
----- C) Victory
----- D) Stage infobox
----- E) List of teams
----- F) Classifications
----- G) Infobox
----- H) Team roster
----- I) Function list of winners (palmarès)
----- J) List of stages
--Tipps: search "--==" to navigate between the sections
 
--== I) Classes declared as global ==
-- Class of a cycling race. Class is: 1.UWT, 2.UWT, 1.HC, ... add new classes, no problem
local class = { "Q22231106", "Q22231107", "Q22231108", "Q22231109", "Q22231110", "Q22231111", "Q22231112",
"Q22231113", "Q22231114", "Q22231115", "Q22231116", "Q22231117", "Q22231118", "Q22231119", "Q23015458", "Q23005601", "Q23005603" }
"Q23005601", "Q23005603" }
class_2x = {"Q22231107", "Q23005603", "Q22231115", "Q22231109", "Q22231112", "Q22231113", "Q22231117"} --multi stage races
local classes = {
class_sort={["Q22231106"]='01', ["Q22231107"]='01', ["Q23005601"]='01', ["Q23005603"]='01', ["Q22231115"]='01', -- 1.UWT, 2.UWT, 1.WWT, 2.WWT, 2.Ncup
Q22231106 = true, Q22231107 = true, Q22231108 = true, Q22231109 = true, Q22231110 = true, Q22231111 = true,
Q22231112 = true, Q22231113 = true, Q22231114 = true, Q22231115 = true, Q22231116 = true, Q22231117 = true,
Q22231118 = true, Q22231119 = true, Q23015458 = true, Q23005601 = true, Q23005603 = true
}
 
local class_2x = {"Q22231107", "Q23005603", "Q22231115", "Q22231109", "Q22231112", "Q22231113", "Q22231117"} --multi stage races
local class_without2x = { "Q22231106", "Q22231108", "Q22231110", "Q22231111", "Q22231114", "Q22231116",
"Q22231118", "Q22231119", "Q23015458", "Q23005601", "Q23005603" }
local class_champ = { "Q22231118", "Q22231119", "Q23015458"}
 
local 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' }
local stages = {'Q18131152', 'Q20646667', 'Q20646670', 'Q20680270', 'Q20646668', 'Q20679712', 'Q2348250', 'Q2266066', 'Q485321'}
-- UCI Europe Tour,..., UCI ProTour, UCI World Calendar, UCI WorldTour, UCI Women’s WorldTour, UCI Women's Road World Rankings
local UCI_Circuits = {'Q1194340', 'Q1063423', 'Q1063430', 'Q268357', 'Q1039648', 'Q1329578', 'Q12270097', 'Q635366', 'Q21075974', 'Q1693153'}
 
local available, translations = pcall(require, "Module:Cycling race/lang")
 
local available_list = available and type(translations.list) == "function"
 
local available_lang_priority = available == true and type(translations.lang_priority) == "table"
 
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"
floatinfobox = "left"
end
 
function race_reference_translate(wiki, x)
--== II) basic functions
--[[ Get any value for a property which is not deprecated ]]
local function firstValue(QID, PID, field)
local ss = wikibase.getAllStatements(QID, PID)
for _, s in pairs(ss) do
if s.rank ~= 'deprecated' and s.mainsnak.snaktype == 'value' then
return field and s.mainsnak.datavalue.value[field] or s.mainsnak.datavalue.value
end
end
end
 
--[[ Go from season of a team to the team ]]
local function getParentID(teamID)
return firstValue(teamID, 'P361', 'id') -- P361 is 'part of'
or firstValue(teamID, 'P5138', 'id') -- P5138 is 'season of club or team'
end
 
--[[ Get a label in any of the languages in the fallback list of language codes ]]
local function getLabelFallback(itemID, fallback)
local label
for _, lang in ipairs(fallback) do
label = mw.wikibase.getLabelByLang(itemID, lang)
if label then break end
end
return label
end
 
--[[ Get a sitelink from the local wiki or from the fallback list of language codes ]]
local function getSitelinkFallback(itemID, fallback)
local link = mw.wikibase.getSitelink(itemID)
if link then return link end
for _, lang in ipairs(fallback) do
link = mw.wikibase.getSitelink(itemID, lang .. 'wiki')
if link then return link end
end
return nil
end
 
local function make_IllWD2_link(q, label)
link = mw.getCurrentFrame():expandTemplate{ title = 'Ill-WD2', args = {id= q ,target='en',label = label } }
return link
end
 
--[[ Iterator to get all statements for an entity and property which are not deprecated and have a value]]
local function nextStatement(state, i)
local s
repeat
i = i + 1
local s = state[i]
if s and s.rank ~= 'deprecated' and s.mainsnak.snaktype == 'value' then
return i, s
end
until s == nil
end
local function statements(QID, PID)
return nextStatement, wikibase.getAllStatements(QID, PID), 0
end
 
--[[ Iterator to get all qualifier values for a property for a statement]]
local function nextQualifier(state, i)
local q
repeat
i = i + 1
local q = state[i]
if q and q.snaktype == 'value' then
return i, q.datavalue
end
until q == nil
end
local function qualifiers(statement, PID)
return nextQualifier, statement.qualifiers and statement.qualifiers[PID] or {}, 0
end
 
function qualifieramount(element, property)
local result
for _, q in qualifiers(element, property) do
result = tonumber(q.value.amount)
end
return result
end
--== III) Functions less basic called from other functions ==
--=== A) Time functions ===
--[[ Get a Wikidata statement for an entity and property valid at the given timevalue ]]
local function getStatementForTime(ID, property, time)
for _, s in statements(ID, property) do
local start, startPrecision, END, endPrecision
local q = s.qualifiers
if q then
if q.P580 and q.P580[1] and q.P580[1].snaktype == 'value' then -- P580 is start time
start = q.P580[1].datavalue.value.time
startPrecision = q.P580[1].datavalue.value.precision
if startPrecision == 9 then -- precision is years
start = string.sub(start, 1, 5) -- Cut of everything after year
elseif startPrecision == 10 then -- precision is months
start = string.sub(start, 1, 8) -- Cut of everything after month
end
end
if q.P582 and q.P582[1] and q.P582[1].snaktype == 'value' then -- P582 is end time
END = q.P582[1].datavalue.value.time
endPrecision = q.P582[1].datavalue.value.precision
end
end
if not start or start <= time then
if not END then
return s
end
if endPrecision == 9 then -- precision 9 is 'years'
END = string.sub(END, 1, 6) .. '13' -- Set month to 13
elseif endPrecision == 10 then -- precision 10 is 'months'
END = string.sub(END, 1, 9) .. '32' -- Set day to 32
end
if END > time then
return s
end
end
end
end
 
--[[ Get start time of race as a timevalue ('+2016-01-01T00:00:00Z') or nil ]]
local function getTimeOfRace (raceID)
local timeOfRace
local p580 = mw.wikibase.getBestStatements(raceID, "P580") -- P580 is start time
if p580[1] and p580[1].mainsnak.snaktype == 'value' then
timeOfRace = p580[1].mainsnak.datavalue.value.time
else
local p585 = mw.wikibase.getBestStatements(raceID, "P585") -- P585 is point in time
if p585[1] and p585[1].mainsnak.snaktype == 'value' then
timeOfRace = p585[1].mainsnak.datavalue.value.time
else
local link = getSitelinkFallback(raceID, {'en', 'fr', 'de'})
if link then
local year = string.match(link, '%d%d%d%d')
if year then
timeOfRace = year .. '-01-01T00:00:00Z'
end
end
end
end
return timeOfRace, '> Wikidata is missing data about start time (P580) or point in time (P582)'
end
 
local function getStartEndTime(sTime, eTime, mode)
-- Note: Add the formats to "formats" and use func_date
local wiki = wiki
local lang = contentLanguage
local starttime, endtime
--local format = formats[wiki] or formats['']
if mode==nil then mode='long' end
-- Timevalues is like "+2015-07-04T00:00:00Z"
local _, _, y, m, d = string.find(sTime, "(%d+)-(%d+)-(%d+)")
local _, _, y2, m2, d2 = string.find(eTime, "(%d+)-(%d+)-(%d+)")
if y ~= y2 then
if mode=='long' then
starttime = lang:formatDate( "j F Y", sTime )
else
starttime = lang:formatDate( "j M Y", sTime )
end
elseif m ~= m2 then
if mode=='long' then
starttime = lang:formatDate( "j F", sTime )
else
starttime = lang:formatDate( "j M", sTime )
end
else starttime = lang:formatDate( "j", sTime )
end
 
if wiki == "ar" then
if y ~= y2 then starttime = lang:formatDate( "d F Y", sTime )
elseif m ~= m2 then starttime = lang:formatDate( "d F", sTime )
else starttime = lang:formatDate( "d ", sTime ) end
elseif wiki == "br" then
if y ~= y2 then starttime = lang:formatDate( "j", sTime ) .." a viz ".. lang:formatDate( "F Y", sTime )
elseif m ~= m2 then starttime = lang:formatDate( "j", sTime ) .." a viz ".. lang:formatDate( "F", sTime )
else starttime = lang:formatDate( "j", sTime ) .." "
end
elseif wiki == "ca" or wiki == "es" or wiki == "ast" then
if y ~= y2 then
starttime = lang:formatDate( "j", sTime ) .." de ".. lang:formatDate( "F", sTime ) .." de ".. lang:formatDate( "Y", sTime )
elseif m ~= m2 then
starttime = lang:formatDate( "j", sTime ) .." de ".. lang:formatDate( "F", sTime )
else starttime = lang:formatDate( "j", sTime ) .." "
end
elseif wiki == "cs" then
if y ~= y2 then starttime = lang:formatDate( "j. xg Y", sTime )
elseif m ~= m2 then starttime = lang:formatDate( "j. xg", sTime )
else starttime = lang:formatDate( "j", sTime )
end
elseif wiki == "de" or wiki == "da" or wiki == "fo" or wiki == "no" then
if y ~= y2 then starttime = lang:formatDate( "j. F Y", sTime )
elseif m ~= m2 then starttime = lang:formatDate( "j. F", sTime )
else starttime = lang:formatDate( "j.", sTime )
end
elseif wiki == "fi" then
if y ~= y2 then starttime = lang:formatDate( 'j. F"ta" Y', sTime )
elseif m ~= m2 then starttime = lang:formatDate( 'j. F"ta"', sTime )
else starttime = lang:formatDate( "j.", sTime )
end
elseif wiki == "en" then
if y ~= y2 then starttime = lang:formatDate( "F d, Y", sTime )
elseif m ~= m2 then starttime = lang:formatDate( "F d", sTime )
else starttime = lang:formatDate( "F d", sTime )
end
elseif wiki == "eo" then
if y ~= y2 then starttime = lang:formatDate( "j", sTime ) .."-a de ".. lang:formatDate( "F Y", sTime )
elseif m ~= m2 then starttime = lang:formatDate( "j", sTime ) .."-a de ".. lang:formatDate( "F", sTime )
else starttime = lang:formatDate( "j", sTime ) .."-a "
end
elseif wiki == "eu" then
if y ~= y2 then starttime = lang:formatDate( "Y", sTime ) ..".eko ".. lang:formatDate( "F", sTime ) .."k ".. lang:formatDate( "j", sTime )
elseif m ~= m2 then starttime = lang:formatDate( "F", sTime ) .."k ".. lang:formatDate( "j", sTime )
else starttime = lang:formatDate( "F", sTime ) .."k ".. lang:formatDate( "j", sTime )
end
elseif wiki == "hu" then
if y ~= y2 then starttime = lang:formatDate( "Y", sTime ) ..". ".. lang:formatDate( "F j", sTime ) .."."
elseif m ~= m2 then starttime = lang:formatDate( "F j", sTime ) .."."
else starttime = lang:formatDate( "F j", sTime ) .."."
end
elseif wiki == "ja" then
if y ~= y2 then starttime = lang:formatDate( "Y年m月d日", sTime )
elseif m ~= m2 then starttime = lang:formatDate( "Y年m月d日", sTime )
else starttime = lang:formatDate( "Y年m月d日", sTime )
end
elseif wiki == "lv" then
if y ~= y2 then starttime = lang:formatDate( "Y. \\g\\a\\d\\a j. F", sTime )
elseif m ~= m2 then starttime = lang:formatDate( "Y. \\g\\a\\d\\a j. F", sTime )
else starttime = lang:formatDate( "Y. \\g\\a\\d\\a j.", sTime )
end
elseif wiki == "pl" then
local date_pl = {"stycznia", "lutego", "marca", "kwietnia", "maja", "czerwca", "lipca", "sierpnia", "września", "października", "listopada", "grudnia"}
if y ~= y2 then starttime = lang:formatDate( "j ", sTime ) .. date_pl[tonumber(lang:formatDate( "n", sTime ))] .. lang:formatDate( " Y", sTime )
elseif m ~= m2 then starttime = lang:formatDate( "j ", sTime ) .. date_pl[tonumber(lang:formatDate( "n", sTime ))]
else starttime = lang:formatDate( "j", sTime )
end
end
if mode=='long' or y ~= y2 then
endtime = lang:formatDate("j F Y", eTime)
else
endtime = lang:formatDate("j M", eTime)
end
if wiki == "ar" then
if mode=='long' or y ~= y2 then endtime = lang:formatDate( "d F Y", eTime )
elseif m ~= m2 then endtime = lang:formatDate( "d F Y", eTime )
else endtime = lang:formatDate( "d F Y", eTime )
end
elseif wiki == "br" then endtime = lang:formatDate( "j", eTime ) .." a viz ".. lang:formatDate( "F Y", eTime )
elseif wiki == "ca" or wiki == "es" or wiki == "ast" then
if mode=='long' or y ~= y2 then
endtime = lang:formatDate( "j", eTime ) .." de "..
lang:formatDate( "F", eTime ) .." de ".. lang:formatDate( "Y", eTime )
else
endtime = lang:formatDate( "j", eTime ) .." de "..
lang:formatDate( "F", eTime )
end
elseif wiki == "cs" then endtime = lang:formatDate( "j. xg Y", eTime )
elseif wiki == "de" or wiki == "da" or wiki == "fi" or wiki == "fo" or wiki == "no" then
if mode=='long' or y ~= y2 then
endtime = lang:formatDate( "j. F Y", eTime )
else
endtime = lang:formatDate( "j. M", eTime )
end
elseif wiki == "en" then
if y ~= y2 then endtime = lang:formatDate( "F d, Y", eTime )
elseif m ~= m2 then endtime = lang:formatDate( "F d, Y", eTime )
else endtime = lang:formatDate( "d, Y", eTime ) --suspect way to write it
end
elseif wiki == "eo" then endtime = lang:formatDate( "j", eTime ) .."-a de ".. lang:formatDate( "F Y", eTime )
elseif wiki == "eu" then endtime = lang:formatDate( "Y", eTime ) ..".eko ".. lang:formatDate( "F", eTime ) .."k "..
lang:formatDate( "j", eTime )
elseif wiki == "fi" then endtime = lang:formatDate('j F"ta" Y', eTime)
elseif wiki == "hu" then endtime = lang:formatDate( "Y", eTime ) ..". ".. lang:formatDate( "F j", eTime ) .."."
elseif wiki == "ja" then
if y ~= y2 then endtime = lang:formatDate( "Y年m月d日", eTime )
elseif m ~= m2 then endtime = lang:formatDate( "m月d日", eTime )
else endtime = lang:formatDate( "d日", eTime )
end
elseif wiki == "lv" then
if mode=='long' or y ~= y2 then endtime = lang:formatDate( "Y. \\g\\a\\d\\a j. F", eTime )
elseif m ~= m2 then endtime = lang:formatDate( "j. F", eTime )
else endtime = lang:formatDate( "j. F", eTime )
end
elseif wiki == "pl" then
local date_pl = {"stycznia", "lutego", "marca", "kwietnia", "maja", "czerwca", "lipca", "sierpnia",
"września", "października", "listopada", "grudnia"}
endtime = lang:formatDate( "j ", eTime ) .. date_pl[tonumber(lang:formatDate( "n", eTime ))] ..
lang:formatDate( " Y", eTime )
end
return starttime, endtime
end
 
local formats = {
[''] = { long = 'j F Y', small = 'j M', onlyday = 'j' },
ar = { long = 'j F Y', small = 'j F', onlyday = 'j' },
br = { long = 'j "a viz" F Y', small = 'j "a viz" M', onlyday = 'j' },
ca = { long = 'j "de" F "de" Y', small = 'j "de" M', onlyday = 'j' },
cs = { long = 'j. xg Y', small = 'j. M', onlyday = 'j' },
da = { long = 'j. F Y', small = 'j. M', onlyday = 'j.' }, -- copy of de
de = { long = 'j. F Y', small = 'j. M', onlyday = 'j.' },
eo = { long = 'j"-a de" F Y', small = 'j"-a de" M', onlyday = 'j' },
en = { long = 'F d, Y', small = 'M d', onlyday = 'd' },
es = { long = 'j "de" F "de" Y', small = 'j "de" M', onlyday = 'j' }, -- copy of ca
eu = { long = 'Y".eko" F"k" j', small = 'M"k" j', onlyday = 'j' },
fi = { long = 'j. F"ta" Y', small = 'j. M', onlyday = 'j.' },
fo = { long = 'j. F Y', small = 'j. M', onlyday = 'j.' }, -- copy of de
he = { long = 'j xg Y', small = 'j F', onlyday = 'j' },
hu = { long = 'Y. F j.', small = 'M. j', onlyday = 'j' },
ja = { long = 'Y年m月d日', small = 'm月d日', onlyday = 'd日' },
lv = { long = 'Y. "gada" j. F', small = 'j. M', onlyday = 'j.' },
hu = { long = 'j xg Y', small = 'j M', onlyday = 'j' },
no = { long = 'j. F Y', small = 'j. M', onlyday = 'j.' }, -- copy of de
}
function func_date (date, mode)
-- local date = '+2016-05-20'
-- local mode = 'small'
local contentLanguage = contentLanguage
local format = formats[wiki] or formats['']
return contentLanguage:formatDate(format[mode], date)
end
 
--[[ get the year for a race as a string, or an empty string]]
local function getYear(raceID)
local year = firstValue(raceID, 'P580', 'time') or -- P580 is 'start time'
firstValue(raceID, 'P585', 'time') -- P585 is 'point in time'
if year then
return string.sub(year, 2, 5)
end
return ''
end
 
--=== B) Link functions ===
local function getOfficialName(teamID, timeOfRace)
local p1448 = getStatementForTime(teamID, 'P1448', timeOfRace) -- P1448 is official name
if p1448 then
if available_lang_priority and p1448.qualifiers and p1448.qualifiers.P1448 then
local q = p1448.qualifiers.P1448
local wantedLanguages = {}
local best = 999
local name
for i, lang in ipairs(translations.lang_priority) do
wantedLanguages[lang] = i
end
for _, l in pairs(q) do
if l.snaktype == 'value' then
local lang = l.datavalue.value.language
if wantedLanguages[lang] and wantedLanguages[lang] < best then
best = wantedLanguages[lang]
name = l.datavalue.value.text
end
end
end
if name then return name, true end
end
return p1448.mainsnak.datavalue.value.text, false
end
return wikibase.getLabel(teamID) -- No official name, try label
end
 
local function getRiderLink(riderID, startOfSeason) --startOfSeason optional
local sitelink = wikibase.getSitelink(riderID)
local label, officialname
if startOfSeason~= nil then
local wikislavic={"mk","ru"}
local wikiisslavic=false
for a, b in pairs(wikislavic) do
if wiki==b then wikiisslavic=true break end
end
local p1448 = getStatementForTime(riderID, 'P1448', startOfSeason)
if p1448 then
local languageisslavic=false
local language=p1448.mainsnak.datavalue.value.language
for a, b in pairs(wikislavic) do
if language==b then languageisslavic=true break end
end
if (languageisslavic==true and wikislavic==true) or languageisslavic==false then
officialname = p1448.mainsnak.datavalue.value.text
end
end
end
if sitelink and officialname then --if there is an official name, then use it
return "[[" .. sitelink .. "|" ..officialname.."]]"
else
if officialname then return officialname end
if sitelink then
if wiki == "de" then
-- Russian riders get label as alias, to shorten the name
local label = wikibase.getLabelByLang(riderID, wiki)
if label then
local p27 = wikibase.getBestStatements(riderID, 'P27') -- P27 is country of citizenship
if p27[1] and p27[1].mainsnak.snaktype == 'value' then
local c = p27[1].mainsnak.datavalue.value['numeric-id']
if c==159 or c==184 or c==212 or c==232 then -- Q159, Q184, Q212, Q232 is Russia, Belarus, Ukraine, Kazakhstan
return "[[" .. sitelink .. "|" .. label .. "]]"
end
end
end
end
return "[[" .. sitelink .. "|" .. mw.text.trim(mw.ustring.gsub(sitelink, "%b()", "")) .. "]]"
end
-- No WP article. Display label, and make it a red link if no other article uses the title
local link
local label = wikibase.getLabelByLang(riderID, wiki)
if label then
if wiki == 'ar' then
link = make_IllWD2_link(riderID)
else
if black_list(wiki, label) then
link = label
else
local title = mw.title.new(label)
if title and title.exists then
link = label
else
link = "[[" .. label.. "]]"
end
end
end
return link
end
-- No label in the local language. Try other languages, but don't link.
link = getLabelFallback(riderID, {'en', 'de'})
if link then
link = mw.ustring.gsub(link, "%b()", "")
else
link = "(label missing)"
end
if wiki == 'ar' then
link = make_IllWD2_link(riderID)--getLabelFallback(riderID, {'en', 'fr', 'de'})
else
link = getLabelFallback(riderID, {'en', 'de'})
end
return link
end
end
 
--[[ Get the name of a country ]]
local function getCountryName(countryID)
local name = ''
if available_list then
name = translations.list(countryID)
end
if name == '' then
local label, lang = wikibase.getLabelWithLang(countryID)
--[[ Uses standard language fallback. Should not return nil, nil, as all countries have English labels. ]]
if lang == wikilang then
name = label
elseif lang then
name = label .. ' (' .. lang .. ')'
end
end
return name
end
 
--[[ Get sitelink with no wiki no formating ]]
local function getRawTeamLink(teamID)
local sitelink
local parentID = getParentID(teamID)
if parentID then -- try parent team first
sitelink = mw.wikibase.getSitelink(parentID)
end
if not sitelink then
sitelink = mw.wikibase.getSitelink(teamID)
end
return sitelink
end
 
--[[ Get sitelink, categoryID and maybe country for a team.
Returns sitelink, team category ID, countryID (only countryID if country arg is true ]]
local function getTeamLinkCat(teamID, timeOfRace, country)
local name, sitelink, parentID
-- Find team category
local catID = firstValue(teamID, 'P31', 'id') -- P31 is 'instance of'
-- Find country if needed
local countryID
if country or catID == 'Q23726798' or catID == 'Q20738667' then
countryID = firstValue(teamID, 'P17', 'id') -- P17 is country
end
if countryID and (catID == 'Q23726798' or catID == 'Q20738667') then
-- It is a national cycling team
name = getCountryName(countryID)
if catID == 'Q20738667' then -- national cycling team U23
local s
if wiki == 'fr' then s = ' espoirs'
elseif wiki == 'mk' then s = ' под 23 години'
elseif wiki == 'ar' then s = ' تحت 23'
elseif wiki == 'es' then s = ' sub-23'
else s = ' U23'
end
name = name .. s
end
sitelink = getRawTeamLink(teamID)
else
-- It is not a national cycling team
local isLocal
parentID = getParentID(teamID)
if parentID then -- try parent team first
sitelink = wikibase.getSitelink(parentID)
name, isLocal = getOfficialName(parentID, timeOfRace)
end
if not sitelink then
sitelink = wikibase.getSitelink(teamID)
end
 
if not name or (not isLocal and available_lang_priority) then
local partName, partIsLocal = getOfficialName(teamID, timeOfRace)
if partName and (not name or partIsLocal) then
name = partName
end
end
end
if sitelink then
if name then
sitelink = '[[' .. sitelink .. '|' .. name .. ']]'
else
sitelink = '[[' .. sitelink .. ']]'
end
else
if name then
sitelink = name
else
sitelink = (ParentID and wikibase.getLabel(ParentID)) or
wikibase.getLabel(TeamID) or 'No name'
end
end
return sitelink, catID, countryID
end
 
local function getTeamCodeCat(teamID, timeOfRace)
-- Find team category
local codeUCI
local p1998 =getStatementForTime(teamID, 'P1998', timeOfRace)
if p1998 then
codeUCI = p1998.mainsnak.datavalue.value
else
local parentID = getParentID(teamID)
if parentID then
p1998 =getStatementForTime(parentID, 'P1998', timeOfRace)
if p1998 then
codeUCI = p1998.mainsnak.datavalue.value
end
end
end
return codeUCI
end
 
local function getReference(statement, outputLocal)
local function formatRefDate(date, precision)
if precision == 9 then -- Precision is year
return string.sub(date, 2, 5)
elseif precision == 10 then -- Precision is month
return contentLanguage:formatDate("F Y", string.sub(date, 2, 8))
elseif precision >= 11 then -- Precision is day (or less)
return func_date (date, 'long')
end
end
 
local ref = statement.references
if not ref or not ref[1] then
return nil
end
local text
ref = ref[1].snaks
if ref.P854 and ref.P854[1] and ref.P854[1].snaktype == 'value' then -- P854 is 'reference URL'
local refURL = ref.P854[1].datavalue.value
local refTitle = ''
local refDate = ''
local refRetrieved = ''
local refLang = ''
if ref.P1476 and ref.P1476[1] and ref.P1476[1].snaktype == 'value' then -- P1476 is 'title URL'
refTitle = ref.P1476[1].datavalue.value.text
local lang = ref.P1476[1].datavalue.value.language
if lang ~= wikilang then
refLang = '(' .. lang .. ')'
end
end
if ref.P577 and ref.P577[1] and ref.P577[1].snaktype == 'value' then -- P577 is 'publication date'
local value = ref.P577[1].datavalue.value
refDate = formatRefDate(value.time, value.precision)
if (wiki == 'ar') then refDate = '، ' .. refDate
else refDate = ', ' .. refDate
end
end
if ref.P813 and ref.P813[1] and ref.P813[1].snaktype == 'value' then -- P813 is 'retrieved'
local value = ref.P813[1].datavalue.value
refRetrieved = formatRefDate(value.time, value.precision)
if wiki == "de" then
refRetrieved = ", (abgerufen am " .. refRetrieved .. ')'
elseif wiki == "ar" then
refRetrieved = " تاريخ الوصول " .. refRetrieved .. '.'
elseif wiki == "fr" then
refRetrieved = " (consulté le " .. refRetrieved .. ')'
else
refRetrieved = " Retrieved " .. refRetrieved .. '.'
end
end
local domain = mw.ustring.match(refURL, '//([^/]+)')
if string.sub(domain, 1, 4) == 'www.' then
domain = string.sub(domain, 5)
end
local refText
if wiki == "fr" then
-- fr: "(en) « Lloyd Mondory ... EPO », sur velonews.competitor.com (consulté le 30 april 2016), 30 octobre 2015."
local sur = ', sur <span style="font-style:italic;"> ' .. domain .. '</span>'
refText = refLang .. ' « ['.. refURL .. ' '.. refTitle .. '] »' .. sur .. refRetrieved .. refDate .. '.'
elseif wiki == "de" then
local In = ' In: <span style="font-style:italic;">' .. domain .. '</span>'
refText = '<span style="font-style:italic;">['.. refURL.. ' '.. refTitle.. '.]</span> ' ..
In .. refDate .. refRetrieved ..'.'
else
local at = ', <span style="font-style:italic;"> ' .. domain .. '</span>'
refText = refLang .. ' [' .. refURL .. ' ' .. refTitle .. ']' .. at .. refDate .. '.' .. refRetrieved
end
if outputLocal==1 then
return refText
else
return localframe:extensionTag('ref', refText, {name=refText})
end
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
 
local function getImage(QID)
local wikilang = wikilang
local p18 = wikibase.getBestStatements(QID, 'P18') -- P18 is 'image'
local first
for _, image in pairs(p18) do
if image.mainsnak.snaktype == 'value' then
if not first then
first = image.mainsnak.datavalue.value
end
local q = image.qualifiers
if q then
for _, caption in pairs(q.P2096) do -- P2096 is 'caption'
if caption.snaktype == 'value' and caption.datavalue.value.language == wikilang then
return image.mainsnak.datavalue.value, caption.datavalue.value.text
end
end
end
end
end
return first
end
 
--[[ Get link for race or competition]]
local function raceLink(QID)
local sitelink = wikibase.getSitelink(QID)
local instanceOf = firstValue(QID, 'P31', 'id') -- P31 is 'instance of'
if instanceOf == 'Q1137352' then -- Q1137352 is 'French Road Cycling Cup'
local label2 = wikibase.getLabel(instanceOf)
if sitelink then
if label2 then return '[[' .. sitelink .. '|' .. label2 .. ']]' end
return '[[' .. sitelink .. ']]'
end
local sitelink2 = wikibase.getSitelink(instanceOf)
if sitelink2 then return '[[' .. sitelink2 ..'|' .. mw.ustring.gsub(sitelink2, " %b()", "") .. ']]' end
if label2 then return label2 end
end
if sitelink then return "[[".. sitelink.. "]]" end
return wikibase.getLabel(QID) or ''
end
 
local function getPlaceLink(placeID)
local link
local sitelink = wikibase.getSitelink(placeID)
if sitelink then
if wiki == 'en' then
-- For English, delete string ", ..." from e.g. "Unley, South Australia"
return '[[' .. sitelink .. '|' .. string.gsub(sitelink, ',.*', '') .. ']]'
end
-- For others, delete " (...)" form e.g. "Unley (South Australia)"
return '[[' .. sitelink .. '|' .. mw.ustring.gsub(sitelink, ' %b()', '') .. ']]'
end
local label = wikibase.getLabel(placeID) or ''
if wiki == 'ar' then
return make_IllWD2_link( placeID,label)
-- '[[' .. label.. ']]'
end
return contentLanguage:ucfirst(label)
end
 
local function classLink(class)
local link = wikibase.getSitelink('Q22348500') -- Q22348500 is 'cycling race class'
local label = getLabelFallback(class, {wikilang, 'en', 'fr', 'de'})
if label and link then
link = '[[' .. link .. '|' .. label .. ']]'
elseif link then
link = '[[' .. link .. ']]'
elseif label then
link = label
else
link=''
end
if wiki == "ar" then-- right now Q22348500 has no link in "ar"
link = make_IllWD2_link(class , "")
end
return link
end
--[[ Get local content to a infoboxe from template args ]]
local function getLocalContent(contents, args)
 
for _, content in pairs(contents) do
local name = content.name
local nameNoShy = mw.ustring.gsub(name, '&#173;', '') -- filter soft hyphen out
local name_plural = content.name_plural
local name_pluralNoShy = name_plural and mw.ustring.gsub(name_plural, '&#173;', '') -- filter soft hyphen out
if args[nameNoShy] and args[nameNoShy] ~= '' then
if content.special then
local _, _, newname, value = mw.ustring.find(args[nameNoShy], '([^:]+):(.*)')
if value and mw.text.trim(value) ~= '' then
content.name = mw.text.trim(newname)
content.content = mw.text.trim(value)
end
else
content.content = mw.text.trim(args[nameNoShy])
end
elseif args[name_pluralNoShy] and args[name_pluralNoShy] ~= '' then
content.name = content.name_plural
content.content = mw.text.trim(args[name_pluralNoShy])
end
end
end
 
local function getTeam(riderID, timeOfRace, q)
-- q: qualifiers of statement in race entity where the rider is the value
local teamID, link
if q and q.P54 and q.P54[1].snaktype == 'value' then -- P54 is member of sports team
teamID = q.P54[1].datavalue.value.id
link = getTeamLinkCat(teamID, timeOfRace)
else
p54 = getStatementForTime(riderID, 'P54', timeOfRace)
if p54 then
teamID = p54.mainsnak.datavalue.value.id
link = getTeamLinkCat(teamID, timeOfRace)
end
end
return link
end
 
local function getTeamCode(riderID, timeOfRace, q)
-- q: qualifiers of statement in race entity where the rider is the value
local teamID, code
if q and q.P54 and q.P54[1].snaktype == 'value' then -- P54 is member of sports team
teamID = q.P54[1].datavalue.value.id
code = getTeamCodeCat(teamID, timeOfRace)
else
p54 = getStatementForTime(riderID, 'P54', timeOfRace)
if p54 then
teamID = p54.mainsnak.datavalue.value.id
code= getTeamCodeCat(teamID, timeOfRace)
end
end
return code
end
 
--[[ Make a table row for infoboxes with links to previous and next ]]
local function getPreviousNextLine(raceID)
local previousID = firstValue(raceID, 'P155', 'id') -- P155 is 'follows'
local nextID = firstValue(raceID, 'P156', 'id') -- P156 is 'followed by'
if not previousID and not nextID then
return ''
end
local previousText, nextText = '', ''
if previousID then
local year = getYear(previousID)
local link = wikibase.getSitelink(previousID)
if link then
previousText = '<span style="color:#3366CC">[[' .. link .. '|&#x25C0; ' .. year .. ']]</span>'
else
previousText = '<span style="color:#3366CC">&#x25C0;</span> ' .. year
end
end
if nextID then
local year = getYear(nextID)
local link = wikibase.getSitelink(nextID)
if link then
nextText = '<span style="color:#3366CC">[[' .. link .. '|' .. year .. ' &#x25B6;]]</span>'
else
nextText = year .. ' <span style="color:#3366CC">&#x25B6;</span>'
end
end
local direction = contentLanguage:getDir()
return "<tr><td style='text-align:" .. ((direction == 'ltr') and 'left' or 'right') ..
"'>" .. previousText .. "</td><td style='text-align:" .. ((direction == 'ltr') and 'right' or 'left') ..
"'>" .. nextText .. "</td></tr>"
end
 
function wdLink (id)
return "[[File:Wikidata-logo S.svg|12px|link=d:" .. id .. "]]"
end
 
function WPlinkpure(Qnumber)
local link=''
local Sitelink = wikibase.getSitelink(Qnumber) -- link to WParticle
local Sitelink2 = Sitelink
local Label = getLabelFallback(Qnumber, {wikilang, 'en', 'fr', 'de'}) or ''
 
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
end
if Sitelink ~= nil then link = "[[" .. Sitelink .. "|" .. mw.text.trim(mw.ustring.gsub(Sitelink2, "%b()", "")..' ') .. "]]"
elseif wiki == 'ar' then
link = make_IllWD2_link(Qnumber , Label)
else link = mw.ustring.gsub(Label, "^(%a)", function (x) return mw.ustring.upper(x) end)
end
return link
end
 
--=== C) Function for the output ===
function tableA(s, tableBody)
local s = s
local tableBody = tableBody
local available_list = available_list
 
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 tableB(s, tableBody)
local s = s
local tableBody = tableBody
local available_list = available_list
 
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 cellpadding="4" cellspacing="0" style="width:100%;" style="border: 1px solid rgb(200,200,200); color: black; margin: 0 0 0.5em 0; background-color: rgb(255, 255, 255); padding: 5px; float: left; clear: left; ; text-align: left; vertical-align: top; font-size: 85%; line-height: 1.8em;>'
local tableStart =tableStart..'<tr><th style="background-color:#FFDF80;" align="center" colspan="3">'
local tableHeader1 = '<span style="float:left">[[File:Wikidata-logo S.svg|12px|link=d:'.. s.item.. '#'.. s.property..']]'.. error_message .. '</span>' ..
Startlist_translate(1) .. '</th></tr><tr>'
 
local tableEnd = '</table>'
 
return '<table style="border:1px solid rgb(200,200,200)"><tr><td>' .. tableStart .. tableHeader1 .. tableBody .. tableEnd .. '</td></tr></table>'
end
 
--=== D) Jersey, flag functions ===
function flag (countryID, date)
 
local trackingCategory = ''
--[[ If you uncomment the line under this comment, all pages with look-up misses in
the flag table will be placed in a tracking category. You can use this to find more flags
to add to the table. ]]
-- trackingCategory = '[[Category:Missing flag in Module:Cycling race]]'
local flags = {
Q16 = {'CAN', {'Flag of Canada.svg', '+1965-02-15'}},
Q17 = {'JPN', {'Flag of Japan.svg', '+1999-08-13'}},
Q20 = {'NOR', {'Flag of Norway.svg', '+1821-07-13'}},
Q27 = {'IRL', {'Flag of Ireland.svg', '+1937-12-29'}},
Q28 = {'HUN', {'Flag of Hungary.svg', '+1957-05-23'}},
Q29 = {'ESP', {'Flag of Spain.svg', '+1981-12-06'},
{'Flag of Spain (1977–1981).svg', '+1977-01-21', '+1981-12-06'},
{'Flag of Spain (1945–1977).svg', '+1945-10-11', '+1977-01-21'},
{'Flag of Spain (1938–1945).svg', '+1939', '+1945-10-11'},
{'Flag of the Second Spanish Republic.svg', '+1931-04-14', '+1939'},
{'Flag of Spain (1785–1873, 1875–1931).svg', '+1874', '+1931-04-13'}},
Q30 = {'USA', {'Flag of the United States.svg', '+1960-07-04'}},
Q31 = {'BEL', {'Flag of Belgium (civil).svg'}},
Q32 = {'LUX', {'Flag of Luxembourg.svg'}},
Q33 = {'FIN', {'Flag of Finland.svg', '+1918-05-29'}},
Q34 = {'SWE', {'Flag of Sweden.svg'}},
Q35 = {'DEN', {'Flag of Denmark.svg'}},
Q36 = {'POL', {'Flag of Poland.svg'}},
Q37 = {'LTU', {'Flag of Lithuania.svg', '+2004-09-01'},
{'Flag of Lithuania (1988-2004).svg', '+1990-03-11', '+2004-09-01'}},
Q38 = {'ITA', {'Flag of Italy.svg', '+1946-06-19'},
{'Flag of Italy (1861–1946).svg', '+1861', '+1946-06-19'}},
Q39 = {'SUI', {'Flag of Switzerland.svg', '+1889-12-12'}},
Q40 = {'AUT', {'Flag of Austria.svg', '+1945-05-01'}},
Q41 = {'GRE', {'Flag of Greece.svg', '+1978'}},
Q43 = {'TUR', {'Flag of Turkey.svg'}},
Q45 = {'POR', {'Flag of Portugal.svg', '+1911-06-30'}},
Q55 = {'NED', {'Flag of the Netherlands.svg', '+1806'}},
Q77 = {'URU', {'Flag of Uruguay.svg'}},
Q96 = {'MEX', {'Flag of Mexico.svg', '+1968-09-16'},
{'Flag of Mexico (1934-1968).svg', '+1934', '+1968-09-16'}},
Q114 = {'KEN', {'Flag of Kenya.svg'}},
Q115 = {'ETH', {'Flag of Ethiopia.svg', '+1996-10-31'}},
Q142 = {'FRA', {'Flag of France.svg', '+1794-05-20'}},
Q145 = {'GBR', {'Flag of the United Kingdom.svg'}},
Q148 = {'CHN', {"Flag of the People's Republic of China.svg", '+1985'}},
Q155 = {'BRA', {'Flag of Brazil.svg', '+1992-05-11'},
{'Flag of Brazil (1968–1992).svg', '+1968-05-28', '+1992-05-11'}},
Q159 = {'RUS', {'Flag of Russia.svg', '+1993-12-11'},
{'Flag of Russia (1991–1993).svg', '+1991-08-22', '+1993-12-11'},
{'Flag of the Russian Soviet Federative Socialist Republic.svg', '+1954', '+1991-08-22'},
{'Flag of the Russian Soviet Federative Socialist Republic (1937–1954).svg', '+1937', '+1954'}},
Q183 = {'GER', {'Flag of Germany.svg', '+1949-05-23'},
{'Flag of the German Reich (1935–1945).svg', '+1935-09-15', '+1945-05-23'},
{'Flag of the German Reich (1933–1935).svg', '+1933-03-12', '+1935-09-15'},
{'Flag of Germany (3-2 aspect ratio).svg', '+1919-04-11', '+1933-03-12'},
{'Flag of the German Empire.svg', '+1871-04-16', '+1919-04-11'}},
Q184 = {'BLR', {'Flag of Belarus.svg', '+2012-05-11'},
{'Flag of Belarus (1995–2012).svg', '+1995-06-07', '+2012-05-11'}},
Q191 = {'EST', {'Flag of Estonia.svg'}},
Q211 = {'LAT', {'Flag of Latvia.svg'}},
Q212 = {'UKR', {'Flag of Ukraine.svg', '+1992-01-28'}},
Q213 = {'CZE', {'Flag of the Czech Republic.svg', '+1920-03-30'}},
Q214 = {'SVK', {'Flag of Slovakia.svg'}},
Q215 = {'SLO', {'Flag of Slovenia.svg'}},
Q217 = {'MDA', {'Flag of Moldova.svg'}},
Q218 = {'ROU', {'Flag of Romania.svg', '+1989-12-27'},
{'Flag of Romania (1965-1989).svg', '+1989-12-27', '+1965'},
{'Flag of Romania (1952-1965).svg', '+1952', '+1965'},
{'Flag of Romania (1948-1952).svg', '+1948-01-08', '+1952'},
{'Flag of Romania.svg', '12. april 1867-04-12', '+1948-01-08'}},
Q219 = {'BUL', {'Flag of Bulgaria.svg', '+1990-11-22'},
{'Flag of Bulgaria (1971 – 1990).svg', '+1971-05-18', '+1990-11-22'}},
Q222 = {'ALB', {'Flag of Albania.svg', '+1992'}},
Q224 = {'CRO', {'Flag of Croatia.svg', '+1990-12-21'},
{'Flag of Croatia (white chequy).svg', '+1990-06-27', '+1990-12-21'}},
Q227 = {'AZE', {'Flag of Azerbaijan.svg'}},
Q228 = {'AND', {'Flag of Andorra.svg'}},
Q229 = {'CYP', {'Flag of Cyprus.svg', '+2006-08-20'},
{'Flag of Cyprus (1960-2006).svg', '+1960-08-16', '+2006-08-20'}},
Q232 = {'KAZ', {'Flag of Kazakhstan.svg'}},
Q238 = {'SMR', {'Flag of San Marino.svg'}},
Q241 = {'CUB', {'Flag of Cuba.svg'}},
Q252 = {'INA', {'Flag of Indonesia.svg'}},
Q258 = {'RSA', {'Flag of South Africa.svg', '+1994-04-27'},
{'Flag of South Africa (1928–1994).svg', '+1928-05-31', '+1994-04-27'}},
Q262 = {'ALG', {'Flag of Algeria.svg'}},
Q265 = {'UZB', {'Flag of Uzbekistan.svg'}},
Q298 = {'CHI', {'Flag of Chile.svg'}},
Q334 = {'SGP', {'Flag of Singapore.svg'}},
Q347 = {'LIE', {'Flag of Liechtenstein.svg'}},
Q398 = {'BRN', {'Flag of Bahrain.svg', '+2002-02-14'}},
Q403 = {'SRB', {'Flag of Serbia.svg', '+2004-08-18'},
{'Flag of Serbia (1992–2004).svg', '+1992-04-27', '+2004-08-17'}},
Q408 = {'AUS', {'Flag of Australia.svg'}},
Q414 = {'ARG', {'Flag of Argentina.svg'}},
Q664 = {'NZL', {'Flag of New Zealand.svg'}},
Q711 = {'MGL', {'Flag of Mongolia.svg'}},
Q717 = {'VEN', {'Flag of Venezuela.svg', '+2006'}},
Q736 = {'ECU', {'Flag of Ecuador.svg'}},
Q739 = {'COL', {'Flag of Colombia.svg'}},
Q750 = {'BOL', {'Flag of Bolivia.svg', '+1851-10-31'}},
Q786 = {'DOM', {'Flag of the Dominican Republic.svg'}},
Q794 = {'IRI', {'Flag of Iran.svg', '+1980-07-29'},
{'Flag of Iran (1964–1980).svg', '+1964', '+1980-07-29'}},
Q800 = {'CRC', {'Flag of Costa Rica (state).svg', '+1906-11-27'}},
Q801 = {'ISR', {'Flag of Israel.svg'}},
Q817 = {'KUW', {'Flag of Kuwait.svg', '+1961-09-07'}},
Q833 = {'MAS', {'Flag of Malaysia.svg', '+1963-09-16'}},
Q842 = {'OMA', {'Flag of Oman.svg', '+1995'}},
Q846 = {'QAT', {'Flag of Qatar.svg'}},
Q865 = {'TPE', {'Flag of the Republic of China.svg', '+1928-12-17'}},
Q869 = {'THA', {'Flag of Thailand.svg'}},
Q878 = {'UAE', {'Flag of the United Arab Emirates.svg'}},
Q884 = {'KOR', {'Flag of South Korea.svg', '+1997-10'}},
Q928 = {'PHI', {'Flag of the Philippines.svg', '+1998'}},
Q948 = {'TUN', {'Flag of Tunisia.svg', '+1999-07-03'}},
Q965 = {'BUR', {'Flag of Burkina Faso.svg'}},
Q986 = {'ERI', {'Flag of Eritrea.svg'}},
Q1000 = {'GAB', {'Flag of Gabon.svg', '+1960-08-09'}},
Q1008 = {'CIV', {"Flag of Côte d'Ivoire.svg"}},
Q1009 = {'CMR', {'Flag of Cameroon.svg'}},
Q1028 = {'MAR', {'Flag of Morocco.svg'}},
Q1036 = {'UGA', {'Flag of Uganda.svg', '+1962-10-09'}},
Q1037 = {'RWA', {'Flag of Rwanda.svg', '+2001-10-25'},
{'Flag of Rwanda (1962–2001).svg', '+1962', '+2001-10-25'}},
Q9676 = {'IMN', {'Flag of the Isle of Man.svg'}},
Q15180 = {'URS', {'Flag of the Soviet Union.svg', '+1980-08-15', '+1991-12-25'},
{'Flag of the Soviet Union (1955–1980).svg', '+1955-08-19', '+1980-08-14'}},
Q16957 = {'GDR', {'Flag of East Germany.svg', '+1959-10-01'},
{'Flag of Germany.svg', '+1949-10-07', '+1959-10-01'}}, --German Democratic Republic
Q8646 = {'HKG', {'Flag of Hong Kong.svg'}},
Q29999 = {'NED', {'Flag of the Netherlands.svg', '+1690'}}, --Kingdom of the Netherlands
Q33946 = {'TCH', {'Flag of the Czech Republic.svg', '+1920'}}, -- Czechoslovakia (1918–1992)
Q36704 = {'YUG', {'Flag of Yugoslavia (1992–2003).svg', '+1992-04-27', '+2003-02-04'}, --Yugoslavia
{'Flag of Yugoslavia (1943–1992).svg', '+1946', '+1992-04-27'}},
Q83286 = {'YUG', {'Flag of Yugoslavia (1943–1992).svg'}}, --Socialist Federal Republic of Yugoslavia
Q172579 = {'ITA', {'Flag of Italy (1861–1946).svg'}}, --Kingdom of Italy (1861-1946)
Q713750 = {'FRG', {'Flag of Germany.svg'}}, --West Germany
Q13474305 = {'ESP', {'Flag of Spain (1945–1977).svg', '+1945-10-11', '+1977-01-21'}, -- Francoist Spain (1935-1976)
{'Flag of Spain (1938–1945).svg', '+1939', '+1945-10-11'},
{'Flag of the Second Spanish Republic.svg', '+1931-04-14', '+1939'}},
}
local entry = flags[countryID]
local IOC
local file
if entry then
for i, v in ipairs(entry) do
if i == 1 then
IOC = v
else
if not date then
file = v[1]
break
else
local from = v[2]
local to = v[3]
if (not from or from <= date) and (not to or to > date) then
file = v[1]
break
end
end
end
end
end
local flagpxSize = '20px'
if countryID == 'Q39' then flagpxSize = '16px'end -- Small size for an square flag as Switzerland
if file then
return '[[File:' .. file .. '|border|' .. flagpxSize ..'|' .. IOC .. ']]'
elseif not date then
local p41 = mw.wikibase.getBestStatements(countryID, "P41") -- P41 is flag image
if p41[1] and p41[1].mainsnak.snaktype == 'value' then
return '[[File:' .. p41[1].mainsnak.datavalue.value .. '|border|' .. flagpxSize ..'|(Wikidata:' .. countryID .. ')]]' .. trackingCategory
end
else
-- Search flag for specific date
local p41 = getStatementForTime(countryID, "P41", date) -- P41 is flag image
if p41 then
return '[[File:' .. p41.mainsnak.datavalue.value .. '|border|' .. flagpxSize ..'|(Wikidata:' .. countryID .. ')]]' .. trackingCategory
end
end
return trackingCategory
end
 
function jersey_infobox(wiki, winner_classification, item, timeofrace)
local jersey, jersey_name = '', ''
local jerseyWPID = ''
local starttime, endtime = '', '+2500'
local a1, b1
 
-- 1. Item of race, e.g. Tour de France = 'Q33881'
-- 2. type of winner, names are the ones in variable t_s
-- 3. and 4. start and end time. '+2500' means year 2500. Always beginning with a '+'
-- 5. item of the jersey
-- 6. item of the Wikipedia article of that jersey
 
local data={{'Q33881', 'montagne', '+1975', '+2500', 'Q25265958', 'Q927157'}, -- Tour de France
{'Q33881', 'leader', '+1919', '+2500', 'Q24257871', 'Q738903'},
{'Q33881', 'points', '+1953', '+1967', 'Q24645209', 'Q175399'}, -- Jersey green.svg
{'Q33881', 'points', '+1968', '+1968', 'Q26919974', 'Q175399'}, -- Jersey red.svg
{'Q33881', 'points', '+1969', '+2500', 'Q24645209', 'Q175399'}, -- Jersey green.svg
{'Q33881', 'jeune', '+1975', '+2500', 'Q24645383', 'Q2254180'}, -- Jersey white.svg
{'Q33881', 'winner_fighting', '+2003', '+2500', 'Q27644113', 'Q2094179'}, -- Jersey red number.svg
{'Q33881', 'winner_fighting2', '+2003', '+2500', 'Q27644113', 'Q2094179'}, -- Jersey red number.svg
{'Q33881', 'equipe', '+2006', '+2500', 'Q27644112', 'Q1436680'}, -- Jersey yellow number.svg
 
{'Q33861', 'leader', '+1931', '+2500', 'Q24257763', 'Q1164275'}, -- Giro d'Italia, Jersey pink.svg
{'Q33861', 'points', '+1967', '+1968', 'Q26919974', 'Q641083'}, -- Jersey red.svg
{'Q33861', 'points', '+1969', '+2009', 'Q26945272', 'Q641083'}, -- Jersey violet.svg
{'Q33861', 'points', '+2010', '+2016', '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
{'Q33861', 'jeune', '+1976', '+2500', 'Q24645383', 'Q641662'}, -- Jersey white.svg
 
{'Q33937', 'leader', '+1935', '+1936', 'Q24258056', 'Q3278226'}, -- Vuelta a España, Jersey orange.svg
{'Q33937', 'leader', '+1941', '+1941', 'Q26696171', 'Q640430'}, -- Jersey white.svg
{'Q33937', 'leader', '+1942', '+1942', 'Q24258056', 'Q3278226'}, -- Jersey orange.svg
{'Q33937', 'leader', '+1945', '+1945', 'Q24257872', 'Q2534046'}, -- Jersey red.svg
{'Q33937', 'leader', '+1946', '+1950', 'Q26696171', 'Q640430'}, -- Jersey white.svg
{'Q33937', 'leader', '+1955', '+1976', 'Q24257871', 'Q738903'}, -- Jersey yellow.svg
{'Q33937', 'leader', '+1977', '+1977', 'Q24258056', 'Q3278226'}, -- Jersey orange.svg
{'Q33937', 'leader', '+1978', '+1998', 'Q24257871', 'Q738903'}, -- Jersey yellow.svg
{'Q33937', 'leader', '+1999', '+2009', 'Q24257991', 'Q27665179'}, -- Jersey gold.svg
{'Q33937', 'leader', '+2010', '+2500', 'Q24257872', 'Q2534046'}, -- Jersey red.svg
{'Q33937', 'points', '+1945', '+1986', 'Q24687409', 'Q2746711'}, -- Jersey blue.svg
{'Q33937', 'points', '+1987', '+1989', 'Q24645209', 'Q11638007'}, -- Jersey green.svg
{'Q33937', 'points', '+1990', '+2009', 'Q24687409', 'Q2746711'}, -- Jersey blue.svg
{'Q33937', 'points', '+2010', '+2500', 'Q24645209', 'Q11638007'}, -- Jersey green.svg
{'Q33937', 'montagne', '+1935', '+1985', 'Q27670182', 'Q11638007'}, -- Jersey green.svg
{'Q33937', 'montagne', '+1986', '+1986', 'Q27670174', 'Q3278226'}, -- Jersey orange.svg
{'Q33937', 'montagne', '+1987', '+1987', 'Q27670178', 'Q2534046'}, -- Jersey red.svg
{'Q33937', 'montagne', '+1988', '+1989', 'Q27670105', 'Q27670115'}, -- Jersey blackdots.png
{'Q33937', 'montagne', '+1990', '+2005', 'Q27670182', 'Q11638007'}, -- Jersey green.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', '+2017', 'Q24645209', 'Q30020298'}, -- Jersey green.svg
{'Q2091354', 'points', '+2018', '+2500', 'Q28820618', 'Q30020298'}, -- MaillotCyan.PNG
{'Q2091354', 'montagne', '+2011', '+2015', 'Q25265958', 'Q30020298'}, -- Jersey polkadot.svg
{'Q2091354', 'montagne', '+2016', '+2017', 'Q27670174', 'Q30020298'}, -- Jersey orange.svg
{'Q2091354', 'montagne', '+2018', '+2500', 'Q25265958', 'Q30020298'}, -- Jersey polkadot.svg
{'Q2091354', 'jeune', '+2011', '+2500', 'Q24645383', 'Q30020298'}, -- Jersey white.svg
{'Q2091354', 'winner_fighting', '+2017', '+2017', 'Q29957114', 'Q30020298'}, -- MaillotCyan.PNG
{'Q128713', 'leader', '+2013', '+2017', 'Q24257871', 'Q30020299'}, -- Tour des Fjords, Jersey yellow.svg
{'Q128713', 'leader', '+2018', '+2500', 'Q29594434', 'Q30020299'}, -- MaillotCyan.PNG
{'Q128713', 'points', '+2013', '+2014', 'Q24645209', 'Q30020299'}, -- Jersey green.svg
{'Q128713', 'points', '+2015', '+2017', 'Q24687409', 'Q30020299'}, -- Jersey blue.svg
{'Q128713', 'points', '+2018', '+2500', 'Q25265938', 'Q30020299'}, -- Jersey violet.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', '+2017', 'Q30035039', 'Q30020299'}, -- Jersey orange.svg
{'Q128961', 'leader', '+2013', '+2500', 'Q24687408', 'Q30020300'}, -- Arctic Race of Norway, Jersey blue.svg
{'Q128961', 'points', '+2013', '+2500', 'Q24645209', 'Q30020300'}, -- Jersey green.svg
{'Q128961', 'montagne', '+2013', '+2014', 'Q27670178', 'Q30020300'}, -- Jersey red.svg
{'Q128961', 'montagne', '+2015', '+2500', 'Q27670174', 'Q30020300'}, -- Jersey orange.svg
{'Q128961', 'jeune', '+2013', '+2500', 'Q24645383', 'Q30020300'}, -- Jersey white.svg
{'Q128961', 'winner_fighting', '+2014', '+2500', 'Q27644113', 'Q30020300'}, -- Jersey red number.svg
{'Q17619325', 'leader', '+2014', '+2014', 'Q24257871', 'Q30020302'}, -- Ladies Tour of Norway, Jersey yellow.svg
{'Q17619325', 'leader', '+2015', '+2016', 'Q26945272', 'Q30020302'}, -- Jersey violet.svg
{'Q17619325', 'leader', '+2017', '+2500', 'Q24257871', 'Q30020302'}, -- Jersey yellow.svg
{'Q17619325', 'points', '+2014', '+2500', 'Q24645209', 'Q30020302'}, -- Jersey green.svg
{'Q17619325', 'montagne', '+2014', '+2500', 'Q25265958', 'Q30020302'}, -- Jersey polkadot.svg
{'Q17619325', 'jeune', '+2014', '+2500', 'Q24645383', 'Q30020302'}, -- Jersey white.svg
{'Q17619325', 'winner_fighting', '+2016', '+2500', 'Q30035039', 'Q30020302'}} -- Jersey orange.svg
 
--timeofrace = '+1968-07-01T00:00:00Z'
timeofrace = string.sub(timeofrace, string.find(timeofrace, "+%d%d%d%d"))
for k, v in pairs(item) do
for key, value in pairs(data) do
if v == value[1] then
if winner_classification == value[2] then
if (timeofrace >= value[3]) and (timeofrace <= value[4]) then
jersey = value[5]
jerseyWPID = value[6]
end
end
end
end
end
 
if jersey~='' then --and (timeofrace > starttime) and (timeofrace < endtime) then
local entity_jersey = mw.wikibase.getEntity(jersey)
jersey = entity_jersey.claims['P18'][1].mainsnak.datavalue.value
jersey_name = entity_jersey:getLabel(wikilang) or ''
if jerseyWPID~= '' then
local entity = mw.wikibase.getEntity( jerseyWPID )
local Sitelink = entity:getSitelink(wiki..'wiki') -- link to WParticle
if Sitelink~= nil then jerseyWPID = wiki..':'..Sitelink else jerseyWPID = '' end
end
return jersey, jersey_name, jerseyWPID
else return '', '', ''
end
end
 
local function jersey(h)
local jersey_string = ' '
local 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
for _, v in ipairs(h) do
local jersey_name
if jerseys[v] then
jersey_string = jersey_string .. '[[File:' .. jerseys[v].file .. '|20px'
jersey_name = jerseys[v]['name_' .. wiki] or mw.wikibase.getLabel(v) or jerseys[v]['name_fr']
if jersey_name then
jersey_string = jersey_string .. '|' .. jersey_name
end
jersey_string = jersey_string .. ']]'
else
p18 = mw.wikibase.getBestStatements(v, 'P18')
if p18[1] and p18[1].mainsnak.snaktype == 'value' then
jersey_string = jersey_string .. '[[File:' .. p18[1].mainsnak.datavalue.value .. '|20px'
jersey_name = getLabelFallback(v, {wikilang, 'en', 'fr'})
if jersey_name then
jersey_string = jersey_string .. '|' .. jersey_name
end
jersey_string = jersey_string .. ']]'
end
end
end
end
return jersey_string
end -- function end
 
--=== E) Other (winner, getkm) ===
function subwinner(riderId, timeofrace, q)
local isHuman= false
local outputtable={}
local riderTeam, riderLink
if riderId ~= nil then
local p31 = wikibase.getBestStatements(riderId, 'P31') -- P31 is 'instance of'
for _, iOf in pairs (p31) do
if iOf.mainsnak.snaktype == 'value' and iOf.mainsnak.datavalue.value['numeric-id'] == 5 then
-- Q5 is 'human'
isHuman = true
break
end
end
if isHuman then
riderLink = getRiderLink(riderId, timeofrace)
local p27 = getStatementForTime(riderId, 'P27', timeofrace) --P27 is country of citizenship
if p27 then
countryID = p27.mainsnak.datavalue.value.id
end
if countryID then
riderLink = flag(countryID, timeofrace) .. ' ' .. riderLink
end
riderTeam = getTeam(riderId, timeofrace, q) or ''
else
riderLink, _, countryID = getTeamLinkCat(riderId, timeofrace, true)
if countryID then
riderLink = flag(countryID, timeofrace) .. ' ' .. riderLink
end
end
end
outputtable[1]=riderLink
outputtable[2]=riderTeam
return outputtable
end
 
function winner(raceID, winners, timeOfRace, countryflag, WDlink_on, team, ref)
local p1346 = wikibase.getAllStatements(raceID, 'P1346') -- P1346 is 'winner'
for _, winner in pairs(p1346) do
local wID = winner.mainsnak.snaktype == 'value' and winner.mainsnak.datavalue.value.id
local wOf, wCause, wCriterion, riderLink
local q = winner.qualifiers
if q then
if q.P642 and q.P642[1].snaktype == 'value' then
for _, q642 in pairs(q.P642) do
wOf = q642.datavalue.value.id -- P642 is 'of'
if not wOf then
-- Try P1346 (winner) instead
-- Assume Q20882667 ('overall winner general classification') if neither are found
wOf = q.P1346 and q.P1346[1].snaktype == 'value' and q.P1346[1].datavalue.value.id or 'Q20882667'
end
wCause = q.P828 and q.P828[1].snaktype == 'value' and q.P828[1].datavalue.value.id
-- P828 is 'has cause'
wCriterion = q.P1013 and q.P1013[1].snaktype == 'value' and q.P1013[1].datavalue.value.id
-- P1013 is 'criterion used'
if winners[wOf] then
if wID then
-- The winner can be a rider or a team, so check if it is a human.
local isHuman
local p31 = wikibase.getBestStatements(wID, 'P31') -- P31 is 'instance of'
for _, iOf in pairs (p31) do
if iOf.mainsnak.snaktype == 'value' and iOf.mainsnak.datavalue.value['numeric-id'] == 5 then
-- Q5 is 'human'
isHuman = true
break
end
end
local reference = ref and getReference(winner)
local _, countryID
if isHuman then
riderLink = getRiderLink(wID, timeOfRace)
if reference then
riderLink = riderLink .. reference
end
if team then
riderTeam = getTeam(wID, timeOfRace, q)
if riderTeam then
riderLink = riderLink .. ' (' .. riderTeam .. ')'
end
end
else
riderLink, _, countryID = getTeamLinkCat(wID, timeOfRace, countryflag)
if reference then
riderLink = riderLink .. reference
end
end
if countryflag then
if not countryID then
local p27 = getStatementForTime(wID, 'P27', timeOfRace) --P27 is country of citizenship
if p27 then
countryID = p27.mainsnak.datavalue.value.id
end
end
if countryID then
riderLink = flag(countryID, timeOfRace) .. ' ' .. riderLink
end
end
if WDlink_on then
riderLink = riderLink .. ' ' .. wdLink(wID)
end
else
riderLink = wCriterion and contentLanguage:ucfirst(wikibase.getLabel(wCriterion) or '') or ''
if wCause then
local cause = wikibase.getLabel(wCause)
if cause then
riderLink = riderLink .. ' (' .. cause .. ')'
end
end
end
if winners[wOf] == '' then
winners[wOf] = riderLink
else
winners[wOf] = winners[wOf] .. '<br/>' .. riderLink
end
end
end
end
end
end
end
 
--------- Definition sub-functions for calendar and victory ------
local function fn_date(entityID, functionName) --to move as a general function
local tempdate, dateOfRace, sortkey, sortkeyDate
local outputtable={}
local sTime = firstValue(entityID, 'P580', 'time') -- P580 is 'start time'
local eTime = firstValue(entityID, 'P582', 'time') -- P582 is 'end time'
if sTime and eTime then
local startTime, endTime = getStartEndTime(sTime, eTime, 'small')
local _, _, y, m, d = string.find(sTime, "(%d+)-(%d+)-(%d+)")
if functionName==nil then --calendar
tempdate = startTime .. ' – ' .. endTime --mettre year en option!
sortkeyDate =sTime
else --victory, general classification
tempdate =endTime
sortkeyDate =eTime
end
dateOfRace = eTime
else
-- This function give a format to dates when P585 (date) is used in a single day race
local pTime = firstValue(entityID, 'P585', 'time') -- P585 is 'point in time'
if pTime then
tempdate = func_date (pTime, 'small')
dateOfRace = pTime
sortkeyDate = pTime
end
end
local _, _, y, m, d = string.find(sortkeyDate, "(%d+)-(%d+)-(%d+)")
if y~= nil and m~= nil and d~=nil then
sortkey = y..m..d
elseif y~= nil and m~= nil then
sortkey = y..m
elseif y~= nil then
sortkey = y
else sortkey = '0000'
end
 
outputtable[1]=dateOfRace
outputtable[2]='<td data-sort-value="'..sortkey.. '" style="text-align:right;padding:0 0.5em">'..tempdate.. '</td>'
outputtable[3]=sortkey
return outputtable
end
 
local function fn_country(entityID, dateOfRace,countryflagonly, ParentID)
-- This function gives countries where the race take place
-- ParentID taken from fn_race, optional
local country, countryname, outputtable= {}, {}, {}
local countryID
for _, p17 in statements(entityID, 'P17') do -- P17 is 'country' --we have to select the right one
countryID = p17.mainsnak.datavalue.value.id
countryname[#countryname + 1] = getCountryName(countryID)
if countryflagonly==true or not countryname[#countryname] then
country[#country + 1]=flag(countryID, dateOfRace)
else
country[#country + 1]=flag(countryID, dateOfRace).." "..countryname[#countryname]
end
end
--no country in entity, look by parent
if countryID == nil and ParentID ~= nil then
for _, p17 in statements(ParentID, 'P17') do -- P17 is 'country' --we have to select the right one
countryID = p17.mainsnak.datavalue.value.id
countryname[#countryname + 1] = getCountryName(countryID)
if countryflagonly==true or not countryname[#countryname] then
country[#country + 1]=flag(countryID, dateOfRace)
else
country[#country + 1]=flag(countryID, dateOfRace).." "..countryname[#countryname]
end
end
end
if countryname[1] then
outputtable[2]=countryname[1]
beginofstr='<td style="text-align:' .. textalign .. ';padding:0 0.5em data-sort-value="'..countryname[1].. '>'
if country[1] then
outputtable[1]=beginofstr..country[1]..'</td>'
else
outputtable[1]=beginofstr..'</td>'
end
else
outputtable[2]=''
outputtable[1]='<td></td>'
end
return outputtable
end
 
local function commastage(stageID,racelabel) --how to write "stage, "
local outputtable={}
local stagenumber=''
local substage = ''
local stagenumberonly, stageletter
outputtable[1]=''
outputtable[2]=''
local temp=firstValue(stageID, 'P1545')
if temp then stagenumber = temp end
--local p1545 = wikibase.getBestStatements(stageID, 'P1545') --name for championship
--if p1545[1] and p1545[1].mainsnak.snaktype == 'value' then stagenumber = p1545[1].mainsnak.datavalue.value end
if stagenumber=='0' then
stagenumber= victories_translate(wiki,9)
else
if stagenumber==nil then
stagenumber= victories_translate(wiki,8)
else
--look for substage
local i,j = string.find(stagenumber, "%a+") --if letter in the stage number
if i ~= nil then --we have to do something
local k,l = string.find(stagenumber, "%d+") --select the number in the stage number
stagenumberonly = string.sub(stagenumber, k, l)--cut the string in 2
stageletter = string.sub(stagenumber, i, j)
stagenumber=stagenumberonly
if stageletter ~= nil then substage=stageletter end
end
if wiki == 'ar' then
stagenumber= victories_translate(wiki,8)..' '..number('f', stagenumber, wiki)
else
stagenumber= number('f', stagenumber, wiki)..substage..' '..victories_translate(wiki,8)
end
end
end
 
local comma = ", "
if wiki == 'ar' then comma = " ، " end
if wiki == 'fr' then
local correpondance={
{name="^Trois", article= " des "},
{name="^Quatre", article= " des "},
{name="^Boucles", article= " des "},
{name="^Triptyque", article= " du "},
{name="^Tour", article= " du "},
{name="^Grand Prix", article= " du "},
{name="^Circuit", article= " du "},
{name="^Mémorial", article= " du "},
{name="^Trophée", article= " du "},
{name="^Ronde", article= " de la "},
{name="^Semaine", article= " de la "},
{name="^Classica", article= " de la "},
{name="^Flèche", article= " de la "},
{name="^Course", article= " de la "},
{name="^Classique", article= " de la "},
{name="Race", article= " de la "},
{name="^Étoile", article= " de l'"},
{name="^La", article= " de "}
}
for ii, v in ipairs(correpondance) do
local i, _ = mw.ustring.find(racelabel, correpondance[ii].name)
if i ~= nil then comma = correpondance[ii].article end
end
end
if wiki == 'fr' or wiki == "lb" or wiki=="ca" or wiki=="es" or wiki=="ast" then
outputtable[1]=stagenumber..comma
elseif wiki=="de" or wiki=="da" or wiki=="fo" or wiki=="no" or wiki=="ru" or wiki=="en" or wiki=="ar" then
outputtable[2]=comma..stagenumber
end
return outputtable
end
 
local function getmainraceLink(entityID,entity_type,stageID, functionName) --the link to the edition but with a general name
local instanceOf, label, Sitelink, isclass, prefix, postfix
Sitelink=wikibase.getSitelink(entityID)
prefix=''; postfix=''
for _, p31 in statements(entityID, 'P31') do
instanceOf = p31.mainsnak.datavalue.value.id
isclass=0
for i=1,#class do--we don't want the class, but the main race
if instanceOf == class[i] then isclass=1 end
end
if isclass==0 then
for _, p2561 in statements(instanceOf, 'P2561') do --name for championship
local lang_WD = p2561.mainsnak.datavalue.value.language
if wiki == lang_WD then label = p2561.mainsnak.datavalue.value.text end
end
--if label==nil then
--if label==nil then --should be with a "today"
-- local p1448 = wikibase.getBestStatements(instanceOf, 'P1448') --official name
-- if p1448[1] and p1448[1].mainsnak.snaktype == 'value' then label = "blibli" end --p1448[1].mainsnak.datavalue.value.text end
--end
if label==nil then
label=wikibase.label(instanceOf)
if not label then
label = getLabelFallback(entityID, {'en', 'fr', 'de'}) or ''
end
end
if Sitelink==nil then --only if no link to the race direct
Sitelink=wikibase.getSitelink(instanceOf)
end
if Sitelink==nil and entity_type=='champ' then --only for champ
local temp=firstValue(instanceOf, 'P361','id')
if temp then Sitelink= wikibase.getSitelink(temp) end
end
end
end
--affect the label
if label==nil then
label=wikibase.label(entityID)
if not label then
label = getLabelFallback(entityID, {'en', 'fr', 'de'}) or ''
end
end
--look for link to the race if nothing
--if different languages have to be added, a language table can be created
if entity_type=='2' then
if functionName~=nil then --calendar=nil
if wiki == 'fr' then prefix= victories_translate(wiki,1)..', ' --general classification
elseif wiki == 'ar' then postfix ='، '..victories_translate(wiki,1)
else postfix = ', '..victories_translate(wiki,1)
end
end
elseif entity_type=='stage' then
--how to write "stage, " is concentrated in one function
local commatable=commastage(stageID, label)
prefix= commatable[1]
postfix=commatable[2]
end
 
if Sitelink == nil then
return prefix..label..postfix
else
return prefix..'[['..Sitelink..'|'..label..']]'..postfix
end
end
 
local function fn_getclassinfo(entityID,displayed_class) --get the class of the race
local display=false
local outputtable={}
local entity_type, class_text, sortkey_class
if displayed_class==nil then
display=true
else
for i=1,#displayed_class do
if entityID ==displayed_class[i] then display=true break end
end
end
--is it a championship?
for i=1,#class_champ do
if entityID == class_champ[i] then
entity_type = 'champ'
class_text = mw.wikibase.label(class_champ[i])
sortkey_class = class_sort[class_champ[i]]
end
end
if entity_type==nil then
for i=1,#class_2x do -- #class = number of elements in class
if entityID == class_2x[i] then
entity_type = '2'
class_text = mw.wikibase.label(class_2x[i])
sortkey_class = class_sort[class_2x[i]]
end
end
if entity_type==nil then
for i=1,#class_without2x do
if entityID == class_without2x[i] then
entity_type = '1'
class_text = mw.wikibase.label(class_without2x[i])
sortkey_class = class_sort[class_without2x[i]]
end
end
end
if entity_type==nil then entity_type = 'nada' end--to allow display of race without class...
end
if display==false then
else
outputtable[1]=entity_type
outputtable[2]=class_text
outputtable[3]=sortkey_class
outputtable[4]=entityID --save the class
end
return outputtable
end
 
local function fn_race(entityID,displayed_class,displayclass, functionName)--return link to the race and class
--first function read from victory main
local Sitelink,instanceOf,circuitID,parentCircuitID, displayedCircuitID, Circuitlink
local Classlink, entity_type, classID, class_text
local inputtable, outputtable={}, {}
local display=false
local stageID=entityID
 
for _, p31 in statements(entityID, 'P31') do
instanceOf = p31.mainsnak.datavalue.value.id
for i=1,#stages do --is it a stage?
if instanceOf == stages[i] then
entity_type = 'stage' --then the class is one stage above!
local ParentID=getParentID(entityID)
entityID=ParentID
outputtable[3]=ParentID --as we read it here, no need to read it afterwards
display=true
for _, p31bis in statements(ParentID, 'P31') do
instanceOfbis = p31bis.mainsnak.datavalue.value.id
inputtable=fn_getclassinfo(instanceOfbis,displayed_class)
if inputtable[1]==nil or inputtable[1]=='nada' then
else
class_text =inputtable[2]
sortkey_class=inputtable[3]
classID=inputtable[4]
end
end
end
end
if entity_type==nil then --bypass if stage
inputtable=fn_getclassinfo(instanceOf,displayed_class)
if inputtable[1]==nil then
elseif inputtable[1]=='nada' then --no display="inputtable[1]==nil" inputtable[1]=='nada'--> display but empty
display=true
else
display=true
entity_type=inputtable[1]
class_text =inputtable[2]
sortkey_class=inputtable[3]
classID=inputtable[4]
end
end
end
--Now we have the class and know the type of race it is
--Get the circuit, if we display it only
if class_text ~=nil then Classlink = class_text else Classlink ='' sortkey_class='' end
 
if display then
if entity_type == 'stage' then
Sitelink=getmainraceLink(entityID,entity_type,stageID, functionName)
else
Sitelink=getmainraceLink(entityID,entity_type,nil, functionName)
end
outputtable[1]='<td style="text-align:'.. textalign ..';padding:0 2.3em">'..Sitelink.. '</td>'
if displayclass == true then
if classID=='Q23005601' or classID=='Q23005603' then --1WWT 2WWT clear
displayedCircuitID = 'Q21075974'
elseif classID=='Q22231106' or classID=='Q22231107' then --1UWT 2UWT clear
displayedCircuitID = 'Q635366'
else --we have to look in the item
for _, p361 in statements(entityID, 'P361') do
circuitID = p361.mainsnak.datavalue.value.id
for _, p31 in statements(circuitID, 'P31') do --is it a UCI circuit?
parentCircuitID = p31.mainsnak.datavalue.value.id
for i=1,#UCI_Circuits do
if parentCircuitID == UCI_Circuits[i] then --Yes it is
displayedCircuitID=circuitID
break
end
end
end
end
end
if displayedCircuitID~=nil then
Circuitlink = wikibase.getSitelink(displayedCircuitID) --we display the circuit of the year
if Circuitlink ~= nil then Classlink = '[['..Circuitlink..'|'..class_text..']]' end
end
-- class
outputtable[2]='<td data-sort-value="'..sortkey_class.. '" style="text-align:center;padding:0 0.5em">'..Classlink.. '</td>'
end
end
return outputtable
end
 
local function fn_rider(entityID,dateOfRace,displayteam,only_winner)
local winRows = ''
local win, winners = {},{}
if only_winner == 1 then
winners= {Q20882667 = '', Q20882747=''} -- first, general or stage
elseif only_winner == 0 then
winners= { Q20882667 = '', Q20882668 = '',Q20882669 = ''} -- Q20882668 is 'second overall'
else --3
winners= { Q47640757='' } -- World Tour -- name not used here
end
winner(entityID, winners, dateOfRace, true, WDlink_on, displayteam, true)
if only_winner==0 then
winRows = winRows .. '<td style="text-align:'.. textalign ..';padding:0 0.5em">'..winners.Q20882667.. '</td>'
winRows = winRows .. '<td style="text-align:'.. textalign ..';padding:0 0.5em">'..winners.Q20882668.. '</td>'
winRows = winRows .. '<td style="text-align:'.. textalign ..';padding:0 0.5em">'..winners.Q20882669.. '</td>'
return winRows
else
local tempwinner
if only_winner == 1 then
if winners.Q20882667~=nil and winners.Q20882667~='' then
tempwinner=winners.Q20882667
else
tempwinner=winners.Q20882747
end
else
tempwinner=winners.Q47640757
end
return winRows .. '<td style="text-align:'.. textalign ..';padding:0 0.5em">'..tempwinner.. '</td>'
end
end
 
local function getKm(wiki)
local km
if wiki == "ar" then km = 'كم'
elseif wiki == "mk" then km = 'км'
elseif wiki == "ru" then km = 'км'
elseif wiki == "ja" then km = 'キロメートル'
else km = 'km' end
return km
end
local function getDistance(raceID, addUnit)
local p = mw.wikibase.getBestStatements(raceID, 'P3157') -- P3157 is 'event distance'
if not p[1] then
p = mw.wikibase.getBestStatements(raceID, 'P2043') -- P2043 is 'length'
end
local km, unit
local text
local wiki = wiki
local lang = contentLanguage
if p[1] and p[1].mainsnak.snaktype == 'value' then
km = tonumber(p[1].mainsnak.datavalue.value.amount)
unit = p[1].mainsnak.datavalue.value.unit
if unit == 'http://www.wikidata.org/entity/Q828224' then -- Q828224 is 'kilometre'
-- The unit should always be km. Skip if it isn't.
text = lang:formatNum(km)
if wiki == 'fo' then
text = string.gsub(text, "%.", ",")
end
if addUnit then
text = text .. ' ' .. getKm(wiki)
end
if wiki == 'en' then
-- Show miles also
local miles = math.modf(10*km/1.609344)/10
text = text .. ' (' .. lang:formatNum(miles)
if addUnit then
text = text .. ' mi'
end
text = text .. ')'
end
end
end
return text
end
 
local function getKmh(wiki)
local kmh
if wiki == "ar" then kmh = 'كم/س'
elseif wiki == "da" then kmh = 'km/t'
elseif wiki == "fo" then kmh = 'km/t'
elseif wiki == "nl" then kmh = 'km/u'
elseif wiki == "no" then kmh = 'km/t'
elseif wiki == "mk" then kmh = 'км/ч'
elseif wiki == "ru" then kmh = 'км/ч'
elseif wiki == "ja" then kmh = 'キロメートル毎時'
else kmh = 'km/h' end
return kmh
end
 
local function getSpeed(raceID, addUnit)
local p = mw.wikibase.getBestStatements(raceID, 'P2052') -- P2052 is 'speed'
local kmh, unit
local text
local wiki = wiki
local lang = contentLanguage
if p[1] and p[1].mainsnak.snaktype == 'value' then
kmh = tonumber(p[1].mainsnak.datavalue.value.amount)
unit = p[1].mainsnak.datavalue.value.unit
if unit == 'http://www.wikidata.org/entity/Q180154' then -- Q180154 is 'kilometre per hour'
-- The unit should always be km/h. Skip if it isn't.
text = lang:formatNum(kmh)
if wiki == 'fo' then
text = string.gsub(text, "%.", ",")
end
if addUnit then
text = text .. ' ' .. getKmh(wiki)
end
if wiki == 'en' then
-- Show miles per hour also
local mih = math.modf(1000*kmh/1.609344)/1000
text = text .. ' (' .. lang:formatNum(mih)
if addUnit then
text = text .. ' mi/h'
end
text = text .. ')'
end
end
end
return text
end
 
function getgendercode(riderID, default)
local p21 = mw.wikibase.getBestStatements(riderID, 'P21') -- P21 is gender
if p21[1] and p21[1].mainsnak.snaktype == 'value' then
local g = p21[1].mainsnak.datavalue.value.id
if g == 'Q6581097' then gender = 'm' -- Male
elseif g == 'Q6581072' then gender = 'f' -- Female
end
else
gender = default -- For teams, n or f
end
return gender
end
 
function number(gender, b, wiki)
local str
if b=="" then return "" end
if wiki=="ar" then
str = b
elseif wiki == "ca" then
if b==1 then str = b.."r"
elseif b==2 then str = b.."n"
elseif b==3 then str = b.."r"
elseif b==4 then str = b.."t"
else str = b.."è"
end
elseif wiki=="en" then
if b==1 then
str="1<sup>st</sup>"
elseif b==2 then
str="2<sup>nd</sup>"
elseif b==3 then
str="3<sup>rd</sup>"
else
str=b.."<sup>th</sup>"
end
elseif wiki=="es" then
if gender == 'm' or gender == 'n' then str = b..".º"
elseif gender == 'f' then str = b..".ª"
else str = b.."."
end
elseif wiki=="fr" 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
elseif wiki=="nl" then str=b.."e"
elseif wiki=="ru" then str=b.."-й"
elseif wiki=="eo" then str=b.."-a"
elseif wiki=="ast" then
if gender == 'm' or gender == 'n' then str = b.."ᵘ"
elseif gender == 'f' then str = b..".ª"
else str = b.."."
end
else str = b .. ". "
end
return str
end
 
function calculate_time(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 func_error_message(wiki,x)
local l10nDef = {
["en"] = {'Property <1> is missing in item "<2>" (<3>)'},
["ar"] = {'الخاصية <1> غير موجودة في العنصر "<2>" (<3>)'},
}
local l10n = l10nDef[wiki]
if not l10n then l10n = l10nDef["en"] end -- default
return l10n[x]
end
 
function changetemplate () -- for eoWiki
local frame = mw.getCurrentFrame()
local n = frame:expandTemplate {title="sxangxu sxablonon2", args = {["sxablono"] = "Cycling race/infobox"}}
return n
end
 
function getMissingLabelTrackingCategory()
local l10nDef = {
["//cs.wikipedia.org"] = '[[Kategorie:Údržba:Doplnit štítek na Wikidatech]]',
["//lv.wikipedia.org"] = '[[Category:Vikidatos trūkst nosaukuma latviešu valodā]]',
["//he.wikipedia.org"] = '[[קטגוריה:ויקינתונים:ערכים חסרי תווית בעברית: קבוצת אופניים]]',
}
local l10n = l10nDef[mw.site.server]
if not l10n then
l10n = ''
end
return l10n
end
 
--== IV) Translation ==
function Startlist_translate(x)
local l10nDef = {
["ar"] = {"المشاركين", "م", "عداء","موضع","مدير الرياضة:","AB","HD","NP","DQ","طريق","chrono","et" , "بدون فريق"},
["fr"] = {"Liste des participants", "Num", "Coureur","Pos","Directeur sportif :","AB","HD","NP","DQ","route","chrono","et", "no team"},
["en"] = {"Startlist", "#", "Rider","Rank","Directeur sportif:","DNF","HD","NP","DQ","road","ITT","and", "no team"},
["es"] = {"Lista de Participantes", "Dorsal", "Ciclista","Posición","Director deportivo:","DNF","HD","NP","DQ","ruta","CRI","y", "sin equipo"},
["de"] = {"Startliste", "Nr.", "Renner","Platz","Sportlicher Leiter:","DNF","HD","NP","DQ","Straße","Zeitfahrt","und", "no team"},
["da"] = {"Startliste", "Nr.", "Rytter","Placering","Sportsdirektør:","DNF","HD","NP","DQ","landevej","enkeltstart","og", "intet hold"},
["lv"] = {"Starta saraksts", "#", "Braucējs","Rangs","Sporta direktors:","DNF","HD","NP","DQ","šoseja","ITT","un", "nav komandas"},
}
local l10n = l10nDef[wiki]
if not l10n then l10n = l10nDef["en"] end -- default
return l10n[x]
end
 
local function race_reference_translate(wiki, x)
local l10nDef = {
["ar"] = {"مصدر: ", "مصادر: "},
["he"] = {"מקור : ", "מקורות : "},
["ast"] = {"Fonte: ","Fontes: "},
["lv"] = {"Avots: ", "Avoti: "},
}
local l10n = l10nDef[wiki] or l10nDef["en"] -- default
return l10n[x]
end
 
function calendar_translate(wiki, x, title)
local l10nDef = {
["ar"] = { "تقويم الاتحاد الدولي للدراجات", "التاريخ", "#", "السباق", "البلد", "الصنف", "الفائز", "الثاني", "الثالث", "متصدر الترتيب العام", "طواف العالم للدراجات للنساء", "", "طواف العالم للدراجات" , "طواف أوروبا للدراجات" , "طواف آسيا للدراجات" , "طواف أمريكا للدراجات" , "طواف أفريقيا للدراجات" , "طواف أوقيانوسيا للدراجات", "بطولات وطنية", "سباق الطريق", "سباق فردي ضد الساعة" },
["fr"] = {"Calendrier UCI", "Date", "n°","Course", "Pays", "Classe", "Vainqueur", "Deuxième", "Troisième", "Leader du classement général","UCI Women's World Tour","","UCI World Tour","UCI Europe Tour","UCI Asia Tour","UCI America Tour","UCI Africa Tour","UCI Oceania Tour","Championnats nationaux","Course en ligne","Contre-la-montre"},
["en"] = {"UCI Calendar", "Date", "#","Race", "Country", "Class", "Winner", "Second", "Third", "Overall leader","UCI Women's World Tour","","UCI World Tour","UCI Europe Tour","UCI Asia Tour","UCI America Tour","UCI Africa Tour","UCI Oceania Tour","National championship","Road race","Individual time trial"},
["de"] = {"UCI Kalender", "Datum", "Nr.","Rennen", "Staat", "Klasse", "Sieger", "Zweiter", "Dritter", "Gesamt&shy;führender","UCI Women's World Tour","","UCI World Tour","UCI Europe Tour","UCI Asia Tour","UCI America Tour","UCI Africa Tour","UCI Oceania Tour","Nationale Straßen-Radsportmeister","Straßenrennen","Einzelzeitfahren"},
["da"] = {"","Dato", "#","Løb", "Land", "Klasse", "Vinder","Toer", "Treer", "Førende rytter","UCI Women's World Tour","","UCI World Tour","UCI Europe Tour","UCI Asia Tour","UCI America Tour","UCI Africa Tour","UCI Oceania Tour","Nationalt mesterskab","Landevej","Enkeltstart"},
["es"] = {"Calendario UCI", "Fecha", "#","Carrera", "País", "Clase", "Ganador","Segundo", "Tercero", "Líder","UCI Women's World Tour","","UCI World Tour","UCI Europe Tour","UCI Asia Tour","UCI America Tour","UCI Africa Tour","UCI Oceania Tour","Campeonato nacional","Carrera de ruta","Contrarreloj individual"},
["ja"] = {"", "開催日", "#","レース", "国", "国", "勝者","準優勝", "3位", "全体リーダー","UCI Women's World Tour","","UCI World Tour","UCI Europe Tour","UCI Asia Tour","UCI America Tour","UCI Africa Tour","UCI Oceania Tour","National championship","Road race","Individual time trial"},
["lv"] = {"", "Datums", "#","Sacensības", "Valsts", "Kategorija", "Uzvarētājs","Otrais", "Trešais", "Kopvērtējuma līderis","UCI Women's World Tour","","UCI World Tour","UCI Europe Tour","UCI Asia Tour","UCI America Tour","UCI Africa Tour","UCI Oceania Tour","National championship","Road race","Individual time trial"},
["mk"] = {"", "Датум","#", "Трка", "Земја", "Класа", "Победник", "Второпласиран", "Третопласиран", "Cевкупен лидер","UCI Women's World Tour","","UCI World Tour","UCI Europe Tour","UCI Asia Tour","UCI America Tour","UCI Africa Tour","UCI Oceania Tour","National championship","Road race","Individual time trial"},
["no"] = {"", "Dato", "#","Ritt", "Land", "Klasse", "Vinner", "Andreplass", "Tredjeplass", "Sammenlagt&shy;leder","UCI Women's World Tour","","UCI World Tour","UCI Europe Tour","UCI Asia Tour","UCI America Tour","UCI Africa Tour","UCI Oceania Tour","Nasjonalt mesterskap","Landevei","Tempo"},
["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"},
["he"] = {"UCI Calendar", "תאריך", "#","מרוץ", "מדינה", "Class", "מנצח", "שני", "שלישי", "Overall leader","UCI Women's World Tour","","UCI World Tour","UCI Europe Tour","UCI Asia Tour","UCI America Tour","UCI Africa Tour","UCI Oceania Tour","אלוף לאומי","Road race","Individual time trial"},
["ast"] = {"Calendariu UCI", "Data", "#","Carrera", "País", "Clas", "Ganador","Segundu", "Terceru", "Líder","UCI WorldTour Femenín 2018","","UCI WorldTour","UCI Europe Tour","UCI Asia Tour","UCI America Tour","UCI Africa Tour","UCI Oceania Tour","Campeonatu nacional","Carrera de ruta","Contrarreló individual"},
}
local l10n = l10nDef[wiki]
if not l10n then l10n = l10nDef["en"] end -- default
if x==1000 then --code
return title
else
return l10n[x]
end
end
 
function victories_translate(wiki, x)
local l10nDef = {
["ar"] = {"التصنيف العام", "سجل الفوز", "التاريخ", "السباق", "البلد", "الصنف", "الفائز","مرحلة","المقدمة"},
["fr"] = {"Classement général", "Victoires", "Date", "Course", "Pays", "Classe", "Vainqueur","étape","Prologue"},
["en"] = {"General classification", "Victories", "Date", "Race", "Country", "Class", "Winner","stage","Prologue"},
["de"] = {"Gesamtwertung", "Siege", "Datum", "Rennen", "Staat", "Klasse", "Sieger","Etappe","Prolog"},
["da"] = {"Samlede stilling", "Sejre", "Dato", "Løb", "Land", "Klasse", "Vinder","etape","Prolog"},
["es"] = {"Clasificación general", "Victorias", "Fecha", "Carrera", "País", "Clase", "Ganador","etapa","Prólogo"},
["ja"] = {"General classification", "Victories", "開催日", "レース", "国", "国", "勝者","ステージ","プロローグ"},
["lv"] = {"Kopvērtējums", "Uzvaras", "Datums", "Sacensības", "Valsts", "Kategorija", "Uzvarētājs","Posms","Prologs"},
["mk"] = {"General classification", "Victories", "Датум", "Трка", "Земја", "Класа", "Победник","Етапа","Пролог"},
["no"] = {"Sammenlagt", "Seire", "Dato", "Ritt", "Land", "Klasse", "Vinner","etappe","Prolog"},
["ru"] = {"Генеральная классификация", "Победы", "Дата", "Гонка", "Страна", "Класс", "Победитель","Этап","Пролог"},
["ast"] = {"Clasificación xeneral", "Victories", "Data", "Carrera", "País", "Clas", "Ganador","etapa","Prólogu"},
["br"]={"General classification", "Victories", "Date", "Race", "Country", "Class", "Winner","Tennad","Prolog"},
["ca"]={"General classification", "Victories", "Date", "Race", "Country", "Class", "Winner","etapa","Pròleg"},
["cs"]={"General classification", "Victories", "Date", "Race", "Country", "Class", "Winner","etapa","Prolog"},
["eo"]={"General classification", "Victories", "Date", "Race", "Country", "Class", "Winner","Etapo","Prologo"},
["eu"]={"General classification", "Victories", "Date", "Race", "Country", "Class", "Winner","Etapa","Aitzinetapa"},
["fi"]={"General classification", "Victories", "Date", "Race", "Country", "Class", "Winner","Etappi","Prologi"},
["fo"]={"General classification", "Victories", "Date", "Race", "Country", "Class", "Winner","teinur","Forteinur"},
["he"] = {"סיווג כללי", "נצחונות", "תאריך", "מרוץ", "מדינה", "מחלקה", "מנצח","שלב","פרולוג"},
["la"]={"General classification", "Victories", "Date", "Race", "Country", "Class", "Winner","Statio","Incipit prologus"},
["it"]={"General classification", "Victories", "Date", "Race", "Country", "Class", "Winner","Tappa","Prologo"},
["hu"]={"General classification", "Victories", "Date", "Race", "Country", "Class", "Winner","Szakasz","Prolog"},
["lb"]={"General classification", "Victories", "Date", "Race", "Country", "Class", "Winner","etapp","Prolog"},
["nl"]={"General classification", "Victories", "Date", "Race", "Country", "Class", "Winner","Etappe","Proloog"},
["pl"]={"General classification", "Victories", "Date", "Race", "Country", "Class", "Winner","Etap","Prologu"},
["pt"]={"General classification", "Victories", "Date", "Race", "Country", "Class", "Winner","Etapa","Prólogo"},
["ro"]={"General classification", "Victories", "Date", "Race", "Country", "Class", "Winner","Etapa","Prolog"},
["sk"]={"General classification", "Victories", "Date", "Race", "Country", "Class", "Winner","Etapa","Prológ"},
["sv"]={"General classification", "Victories", "Date", "Race", "Country", "Class", "Winner","Etapp","Prolog"},
}
local l10n = l10nDef[wiki]
if not l10n then l10n = l10nDef["en"] end -- default
return l10n[x]
end
 
function stageinfobox_translate(x)
--[[ This function permits to translate fields of the infobox for stages. Take the line below, give a Wikipedia
(ex : mk), and translate all fields. By default, English values are taken.]]
local l10nDef = {
["fr"] = {"Généralités", "Course", "Type", "Date", "Dates", "Distance", "Pays", "Pays",
"Lieu de départ", "Lieu d'arrivée", "Partants",
"Arrivants", "Vitesse moyenne", "Coût", "Résultats de l’étape", "Vainqueur", "Deuxième", "Troisième", "Combatif",
"Classement général à l’issue de l’étape", "Leader", "Deuxième", "Troisième",
"Classements annexes à l’issue de l’étape", "Points", "Montagne", "Sprints", "Jeune", "Super- combatif",
"Combiné", "Étapes volantes", "Régularité",
"Équipe", "Équipe aux points",
"Image", "Légende", "Carte", "Vue en coupe", "Documentation", "Cima Coppi", "Cima Pantani", "Azzurri d'Italia", "Fuga"},
["ar"] = {"تفاصيل السباق", "سباق", "نوع", "تاريخ", "تاريخ", "مسافة", "بلد", "بلدان", "نقطة البداية", "نقطة النهاية", "الدراجين في البداية",
"الدراجين في النهاية", "متوسط السرعة", "الكلفة", "نتائج المرحلة", "الفائز", "الثاني", "الثالث", "متمرس",
"التصنيف العام بعد المرحلة", "القائد", "الثاني", "الثالث",
"التصنيفات الثانوية بعد المرحلة", "النقاط", "الجبل", "سباقات السرعة", "شاب", "تصنيف القتال", "ممتزجة", "سباقات السرعة", "الانتظام",
"فريق", "فريق حسب النقاط", "صورة", "أسطورة", "بطاقة", "عرض الاقسام", "توثيق",
"سيما كوبي", "سيما بانتاني", "أزوري دي إيطاليا", "فوجا بيناريلو"},
["en"] = {"Race details", "Race", "Type", "Date", "Dates", "Distance", "Country", "Countries",
"Journey origin", "Lieu d'arrivée", "Starting riders",
"Arriving riders", "Average speed", "Cost", "Stage results", "Winner", "Second", "Third", "Combative",
"General classification after stage", "Leader", "Second", "Third",
"Secondary classifications after stage", "Points", "Mountain", "Sprints", "Young", "Combativity",
"Combinated", "Intermediate sprints", "Regularity",
"Team", "Team by points",
"Image", "Legend", "Card", "Sectional view", "Documentation", "Cima Coppi", "Cima Pantani",
"Azzurri d'Italia", "Breakaway"},
["ja"] = {"レース詳細", "レース", "種類", "日付", "日付", "距離", "国", "国", "スタート", "ゴール", "スタート選手",
"ゴール選手", "平均速度", "Cost", "ステージ結果", "優勝", "2位", "3位", "Combative",
"ステージ後クラス", "1位", "2位", "3位",
"ステージ後副次的クラス", "ポイント賞", "山岳賞", "スプリント賞", "新人賞", "敢闘賞", "コンビネーション賞", "Metas volantes", "Regularity",
"チーム", "ポイント順位",
"画像", "凡例", "カード", "断面図", "ドキュメンテーション", "Cima Coppi", "Cima Pantani", "Azzurri d'Italia", "Breakaway"},
["ca"] = {"Detalls de la cursa", "Cursa", "Tipus", "Data", "Dates", "Distància", "País", "Països", "Origen de la cursa", "Lloc d’arribada", "Corredors sortits",
"Corredors arrivats", "Velocitat mitjana", "Duració", "Resultats de l’etapa", "Guanyador", "Segon", "Tercer", "Combatiu",
"Classificació general després de l'etapa", "Líder", "Segon", "Tercer",
"Classificacions secundàries després de l'etapa ", "Punts", "Muntanya", "Esprints ", "Jove", "Combativitat", "Combinada", "Metes volants", "Regularitat",
"Equip", "Equip per punts",
"Image", "Legend", "Card", "Sectional view", "Documentation", "Cima Coppi", "Cima Pantani", "Azzurri d'Italia", "Fuga"},
["da"] = {"Etapedetaljer", "Rute", "Type", "Dato", "Datoer", "Distance", "Land", "Lande", "Startby", "Målby", "Startende ryttere",
"Fuldførende ryttere", "Gennemsnitlig fart", "Omkostninger", "Etaperesultat", "Vinder", "Toer", "Treer", "Mest angrebsivrige",
"Samlede stilling efter etapen", "Førende rytter", "Toer", "Treer",
"Klassementerne efter etapen", "Point", "Bjerg", "Sprint", "Ungdom", "Mest angrebsivrige", "Kombination", "Indlagt spurt", "Regularitet",
"Hold", "Hold efter point",
"Billede", "Billedtekst", "Kort", "Profil", "Dokumentation", "Cima Coppi", "Cima Pantani", "Azzurri d'Italia", "Breakaway"},
["es"] = {"Detalles de la carrera", "Carrera", "Tipo", "Fecha", "Fechas", "Distancia", "País", "Países", "Lugar de inicio", "Lugar de llegada", "Ciclistas participantes",
"Ciclistas finalizados", "Velocidad media", "Duración", "Resultados de la etapa", "Ganador", "Segundo", "Tercero", "Combativo",
"Clasificación general después de la etapa", "Líder", "Segundo", "Tercero",
"Clasificaciones secundarias después de la etapa", "Puntos", "Montaña", "Esprint", "Joven", "Combatividad", "Combinada", "Metas volantes", "Regularidad",
"Equipo", "Equipo por puntos",
"Imagen", "Leyenda", "Card", "Sectional view", "Documentation", "Cima Coppi", "Cima Pantani", "Azzurri d'Italia", "Fuga"},
["fo"] = {"Smálutir um kapping", "Kapping", "Slag", "Dagur", "Dagar", "Fjarstøða", "Land", "Lond", "Byrjunarbýur", "Málbýur", "Byrjandi súkklarar",
"Fullførandi súkklarar", "Miðalferð", "Kostnaður", "Teinaúrslit", "Vinnari", "Annað pláss", "Triðja pláss", "Álopsheiður",
"Høvuðskappingin eftir teinin", "Førandi súkklari", "Tveyari", "Tríari",
"Aðrar kappingar eftir teinin", "Stig", "Fjøll", "Spurtar", "Ungdóms", "Álopsheiður", "Kombinatiónsheiður", "Metas volantes", "Regularitetur",
"Lið", "Lið eftir stigum",
"Mynd", "Myndatekstur", "Kort", "Brotpartur", "Skjalfesting", "Cima Coppi", "Cima Pantani", "Azzurri d'Italia", "Breakaway"},
["he"] = {"פרטי מרוץ", "מרוץ", "סוג", "תאריך", "תאריכים", "מרחק", "מדינה", "מדינות",
"התחלת המסלול", "Lieu d'arrivée", "רוכבים מתחילים",
"רוכבים מסיימים", "מהירות ממוצעת", "Cost", "Stage results", "מנצח", "מקום שני", "מקום שלישי", "Combative",
"General classification after stage", "מוביל", "שני", "שלישי",
"Secondary classifications after stage", "נקודות", "הר", "Sprints", "Young", "Combativity",
"Combinated", "Intermediate sprints", "Regularity",
"קבוצה", "קבוצה על פי ניקוד",
"תמונה", "כיתוב", "Card", "Sectional view", "Documentation", "Cima Coppi", "Cima Pantani",
"Azzurri d'Italia", "Breakaway"},
["lb"] = {"Allgemenges", "Course", "Typ", "Datum", "Datumer", "Distanz", "Land", "Land", "Depart", "Arrivée", "Um Start",
"Ukomm", "Vitess-moyenne", "Käschten", "Résultater vun der Etapp", "Gewënner", "Zweeten", "Drëtten", "Combativ",
"Generalklassement no der Etapp", "Éischten", "Zweeten", "Drëtten",
"Aner Klassementer no der Etapp", "Punkten", "Bierg", "Sprint", "Bescht Jonken", "Super- combativ", "Combiné", "Fligend Etappen", "Regelméissegkeet",
"Equipe", "Equipe no Punkten",
"Fichier", "Legend", "Kaart", "Profil", "Dokumentatioun", "Cima Coppi", "Cima Pantani", "Azzurri d'Italia", "Breakaway"},
["no"] = {"Etappedetaljer", "Etappe", "Type", "Dato", "Datoer", "Distanse", "Land", "Land", "Startsted", "Målsted", "Startende ryttere",
"Fullførende ryttere", "Snittfart", "Omkostninger", "Etapperesultat", "Vinner", "Andre", "Tredje", "Offensiv",
"Sammenlagtstilling etter etappen", "Sammenlagtleder", "Andre", "Tredje",
"Klassifisering etter etappen", "Poeng", "Klatring", "Spurt", "Ungdom", "Offensiv", "Kombinasjon", "Innlagte spurter", "Regularitet",
"Lag", "Lag (poeng)",
"Bilde", "Bildetekst", "Kart", "Profil", "Dokumentasjon", "Cima Coppi", "Cima Pantani", "Azzurri d'Italia", "Brudd"},
["pt"] = {"Detalhes da corrida", "Corrida", "Tipo", "Data", "Datas", "Distância", "País", "Países", "Origem da viagem", "Local de chegada", "Partida dos ciclistas",
"Chegada dos ciclistas", "Velocidade média", "Custo", "Resultados da etapa", "Vencedor", "Segundo", "Terceiro", "Combativo",
"Classificação geral após a etapa", "Líder", "Segundo", "Terceiro",
"Classificação secundária após a etapa", "Pontos", "Montanha", "Corridas de velocidade", "Jovem", "Combatividade", "Combinados", "Metas volantes", "Regularidade",
"Equipe", "Equipe por pontos",
"Imagem", "Legenda", "Ficha", "Vista secional", "Documentação", "Cima Coppi", "Cima Pantani", "Azzurri d'Italia", "Fuga"},
["nl"] = {"Race details", "Wedstrijd", "Soort", "Datum", "Datums", "Afstand", "Land", "Landen", "Start van de etappe", "Aankomstplaats", "Coureurs aan de start",
"Coureurs bij de finish", "Gemiddelde snelheid", "Kosten", "Etappeuitslag", "Winnaar", "Tweede", "Derde", "Combative",
"Algemeen klassement na de etappe", "Leider", "Tweede", "Derde",
"Bijkomende uitslagen na de wedstrijd", "Punten", "Berg", "Sprints", "Jongeren", "Combativity", "Combinatie", "Metas volantes", "Regularity",
"Team", "Team by points",
"Afbeelding", "Legend", "Card", "Sectional view", "Documentation", "Cima Coppi", "Cima Pantani", "Azzurri d'Italia", "Breakaway"},
["ru"] = {"Детали гонки", "Гонка", "Тип", "Дата", "Даты", "Дистанция", "Страна", "Страны", "Место старта", "Место финиша", "Стартовало гонщиков",
"Финишировало гонщиков", "Средняя скорость", "Затраты", "Результаты этапа", "Победитель", "Второй", "Третий", "Боец",
"Генеральная классификация после этапа", "Лидер", "Второй", "Третий",
"Классификации после этапа", "Очки", "Горная", "Спринтерская", "Молодёжная", "Бойцовская", "Комбинированная", "Промежуточные финиши", "Регулярность",
"Командная по времени", "Командная по очкам",
"Изображение", "Описание", "Карта", "Сектора", "Документация", "Cima Coppi", "Cima Pantani", "Azzurri d'Italia", "Breakaway"},
["ast"] = {"Detalles de la carrera", "Carrera", "Tipu", "Data", "Dates", "Distancia", "País", "Países", "Llugar d'entamu",
"Llugar de llegada", "Ciclistes participantes", "Ciclistes acabaos", "Velocidá media", "Duración", "Resultaos de la etapa",
"Ganador", "Segundu", "Terceru", "Combativu", "Clasificación xeneral depués de la etapa", "Líder", "Segundu", "Terceru",
"Clasificaciones secundaries depués de la etapa", "Puntos", "Monte", "Esprint", "Mozu", "Combatividá", "Combinada", "Metes volantes",
"Regularidá", "Equipu", "Equipu per puntos", "Imaxe", "Lleenda", "Card", "Sectional view", "Documentación", "Cume Coppi",
"Cume Pantani", "Azzurri d'Italia", "Fuga"}
}
local l10n = l10nDef[wiki]
if not l10n then l10n = l10nDef["en"] end -- default
return l10n[x]
end
 
function getSquadTableColumn(x)
local l10nDef = { -- note (in the table), note (below the table)
["ar"] = {"المتسابق", "تاريخ الولادة", "الفريق السابق", "ملاحظة", "ملاحظة", "البلد", "قائمة الفريق"},
["fr"] = {"Cycliste", "Date de naissance", "Équipe précédente", "note", "note", "Pays", "Effectif"},
["en"] = {"Rider", "Date of birth", "Previous team", "note", "note", "Country", "Team roster"},
["br"] = {"Reder", "Deiziad genel", "Previous team", "note", "note", "Bro", "Team roster"},
["ca"] = {"Ciclista", "Data de naixement", "Equip previ", "Nota", "Nota", "Pais", "Team roster"},
["cs"] = {"Cyklista", "Datum narození", "Previous team", "note", "note", "Stát", "Team roster"},
["da"] = {"Rytter", "Fødselsdag", "Seneste hold", "note", "note", "Land", "Trup"},
["de"] = {"Name", "Geburtsdatum", "Vorheriges Team", "Anm.", "Anmerkung", "Land", "Team roster"},
["eo"] = {"Antaŭnomo Nomo", "Naskiĝtago", "Previous team", "note", "note", "Lando", "Team roster"},
["es"] = {"Corredor", "Fecha de nacimiento", "Equipo previo", "Nota", "Nota", "Pais", "Integrantes del Equipo"},
["eu"] = {"Izena", "Jaiotze-data", "Aurreko taldea", "Oharra", "Oharra", "Herrialdea", "Team roster"},
["fi"] = {"Ajaja", "Syntymäaika", "Edellinen joukkue", "huomio", "huomio", "Maa", "Team roster"},
["fo"] = {"Súkklari", "Føðingardagur", "Undanfarna lið", "note", "note", "Land", "Team roster"},
["he"] = {"רוכב", "תאריך לידה", "קבוצה קודמת", "הערה", "הערה", "מדינה", "סגל הקבוצה"},
["hu"] = {"Név", "Születésnap", "Előző csapat", "jegyzet", "jegyzet", "Ország", "Team roster"},
["it"] = {"Ciclista", "Data di nascita", "Previous team", "Nota", "Nota", "Paese", "Team roster"},
["ja"] = {"選手名", "生年月日", "前所属", "脚注", "脚注", "国", "Team roster"},
["lb"] = {"Coureur", "Gebuertsdatum", "Equipe virdrun", "Nott", "Nott", "Staat", "Team roster"},
["lv"] = {"Braucējs", "Dzimšanas datums", "Iepriekšējā komanda", "piezīme", "piezīme", "Valsts", "Komandas sastāvs"},
["mk"] = {"Велосипедист", "Датум на раѓање", "Претходна екипа", "Фуснота", "Фуснота", "Држава", "Team roster"},
["nl"] = {"Naam", "Geboortedatum", "Vorige ploeg", "noot", "noot", "Nationaliteit", "Renners"},
["no"] = {"Rytter", "Fødselsdato", "Tidligere lag", "note", "note", "Land", "Ryttere"},
["pl"] = {"Imię i nazwisko", "Data urodzenia", "Poprzednia grupa", "Przypis", "Przypis", "Państwo", "Team roster"},
["pt"] = {"Ciclista", "Data de nascimento", "Equipe anterior", "Nota", "Nota", "Pais", "Integrantes da equipe"},
["ro"] = {"Ciclist", "Data nașterii", "Previous team", "note", "note", "Țară", "Team roster"},
["ru"] = {"Гонщик", "Дата рождения", "Предыдущая команда", "Примечание", "Примечание", "Страна", "Состав"},
["sv"] = {"Namn", "Födelsedatum", "Previous team", "not", "not", "Land", "Team roster"},
["zh"] = {"車手", "出生日期", "Previous team", "脚注", "脚注", "国家", "Team roster"},
["ast"] = {"Corredor", "Data de nacencia", "Equipu previu", "Nota", "Nota", "País", "Integrantes del Equipu"},
}
local l10n = l10nDef[wiki]
if not l10n then l10n = l10nDef["en"] end -- default
return l10n[x]
end
 
function infobox_translate(x)
-- This function permits to translate fields of the infobox, take the line below, give a Wikipedia (ex : mk), and translate all fields. By default, English values are taken.
-- l10nDef["//??.wikipedia.org"] = {"RACE DETAILS", "COURSE", "COMPETITION", "COMPETITIONS", "STAGES", "DATE", "DATES", "DISTANCE", "COUNTRY", "COUNTRIES",
-- "JOURNEY ORIGIN", "JOURNEY DESTINATION", "TEAMS", "STARTING RIDERS", "ARRIVING RIDERS", "AVERAGE SPEED", "COST", "PALMARES", "WINNER", "SECOND", "THIRD",
-- "POINTS", "MOUNTAINS", "SPRINTS", "YOUTH", "COMBATIVITY", "COMBINATION", "TEAM", "Picture", "Caption", "Map", "Special 1", "Special 2", "Documentation",
-- "METAS VOLANTES", "REGULARIDAD", "TEAM POINTS"}
local l10nDef = {
["ar"] = {"تفاصيل السباق", "سلسلة", "منافسة", "مسابقات", "مراحل", "التاريخ", "التواريخ", "المسافات", "البلد", "البلدان",
"نقطة البداية", "نقطة النهاية", "الفرق", "عدد المتسابقين في البداية", "عدد المتسابقين في النهاية", "متوسط السرعة", "الكلفة", "المنصة", "الفائز", "الثاني",
"الثالث", "حسب النقاط", "تسلق الجبل", "سباقات السرعة", "أفضل شاب", "تصنيف القتال", "مجموعة", "الفريق", "صورة", "تعليق", "خريطة", "مميز 1", "مميز 2", "توثيق", "سباقات السرعة", "انتظام", "نقاط الفريق", "فوجا بيناريلو", "أزوري دي إيطاليا","Rookie"},
["fr"] = {"Généralités", "Course", "Compétition", "Compétitions", "Étapes", "Date", "Dates", "Distance", "Pays", "Pays",
"Lieu de départ", "Lieu d'arrivée", "Équipes", "Partants", "Arrivants", "Vitesse moyenne", "Coût", "Résultats", "Vainqueur", "Deuxième", "Troisième",
"Classement par points", "Meilleur grimpeur", "Meilleur sprinteur", "Meilleur jeune", "Super-combatif", "Meilleur au combiné", "Meilleure équipe",
"Image", "Légende", "Carte", "Special 1", "Special 2", "Documentation", "Étapes volantes", "Régularité", "Meilleure équipe aux points",
"Fuga", "Azzurri d'Italia", "Néophyte"},
["en"] = {"Race details", "Course", "Competition", "Competitions", "Stages", "Date", "Dates", "Distance", "Country", "Countries",
"Journey origin", "Journey destination", "Teams", "Starting riders", "Arriving riders", "Average speed", "Cost", "Palmares", "Winner", "Second",
"Third", "Points", "Mountains", "Sprints", "Youth", "Combativity", "Combination", "Team", "Picture", "Caption", "Map", "Special 1", "Special 2",
"Documentation", "Intermediate sprints", "Regularidad", "Team points", "Breakaway", "Azzurri d'Italia", "Rookie"},
["ja"] = {"レース詳細", "コース", "競技", "競技", "ステージ", "日付", "日付", "距離", "距離", "国",
"スタート", "ゴール", "チーム", "参加人数", "完走人数", "平均速度", "Cost", "結果", "優勝", "準優勝",
"3位", "ポイント賞", "山岳賞", "スプリント賞", "新人賞", "敢闘賞", "チーム総合時間賞", "チーム", "画像", "キャプション", "地図", "Special 1", "Special 2",
"ドキュメンテーション", "Metas volantes", "Regularidad", "チームポイント", "Breakaway", "Azzurri d'Italia", "Rookie"},
["br"] = {"Hollegezhioù", "Redadeg", "Kevezadeg", "Kevezadegoù", "Tennadoù", "Deiziad", "Deiziadoù", "Hed", "Bro", "Broioù",
"Lec'h loc'hañ", "Lec'h degouezhout", "Skipailhoù", "Loc'herien", "Erruerien", "Tizh keitat", "Koust", "Disoc'hoù", "Gounezer", "Eil", "Trede",
"Renkadur a-boentoù", "Kraper gwellañ", "Sprinter gwellañ", "Yaouank gwellañ", "Stourmer meur", "Gwellañ el liesrenkadur", "Skipailh gwellañ",
"Picture", "Caption", "Map", "Special 1", "Special 2", "Documentation", "Metas volantes", "Regularidad", "Team points", "Breakaway", "Azzurri d'Italia", "Rookie"},
["ca"] = {"Detalls de la cursa", "Cursa", "Competició", "Competicions", "Etapes", "Data", "Dates", "Distància", "País", "Països",
"Sortida", "Arribada", "Equips", "Inscrits", "Finalitzen", "Velocitat mitjana", "Cost", "Palmarès", "Vencedor", "Segon", "Tercer", "Punts", "Muntanya",
"Esprints", "Joves", "Combativitat", "Combinada", "Equip", "Picture", "Caption", "Map", "Special 1", "Special 2", "Documentació", "Metas volantes",
"Regularidad", "Team points", "Fuga", "Azzurri d'Italia", "Rookie"},
["cs"] = {"Přehled", "Závod", "Soutěž", "Soutěže", "Počet etap", "Datum", "Datum", "Celková délka", "Země", "Země", "Start", "Cíl",
"Týmy", "Běžci", "Příjezdy", "Rychlostní průměr", "Náklady", "Konečné pořadí", "Celkový vítěz", "2. místo", "3. místo", "Vítěz bodovací soutěže",
"Nejlepší vrchař", "Nejlepší sprinter", "Nejlepší mladý jezdec", "Nejaktivnější jezdec", "Nejlepší kombinovaná", "Nejlepší družstvo", "Picture",
"Caption", "Map", "Special 1", "Special 2", "Dokumentace", "Metas volantes", "Regularidad", "Team points", "Breakaway", "Azzurri d'Italia", "Rookie"},
["da"] = {"Løbsdetaljer", "Rute", "Konkurrence", "Konkurrencer", "Etaper", "Dato", "Datoer", "Distance", "Land", "Lande",
"Startby", "Målby", "Hold", "Startende ryttere", "Fuldførende ryttere", "Gennemsnitlig fart", "Pris", "Resultater", "Vinder", "Toer", "Treer",
"Pointtrøje", "Bjergtrøje", "Sprinttrøje", "Ungdomstrøje", "Mest angrebsivrige", "Kombinationstrøje", "Holdkonkurrence", "Billede", "Billedtekst",
"Kort", "Special 1", "Special 2", "Dokumentation", "Indlagt spurt", "Regularitet", "Holdkonkurrence efter point", "Breakaway", "Azzurri d'Italia", "Rookie"},
["de"] = {"Allgemeines", "Ausgabe", "Rennserie", " Wettbewerb", "Etappen", "Datum", "Datum", "Gesamtlänge", "Austragungsland",
"Austragungsländer", "Start", "Ziel", "Teams", "Fahrer am Start", "Fahrer im Ziel", "Durchschnitts&#173;geschwindigkeit", "Kosten", "Ergebnis",
"Sieger", "Zweiter", "Dritter", "Punktewertung", "Bergwertung", "Sprintwertung", "Nachwuchswertung", "Kämpferischster Fahrer", "Kombinationswertung",
"Teamwertung", "Bild", "Beschriftung", "Karte", "Special 1", "Special 2", "Dokumentation", "Metas volantes", "Regularidad", "Teamwertung (Punkte)",
"Breakaway", "Azzurri d'Italia", "Rookie"},
["eo"] = {"Gxeneralajxo", "Bicikla konkurso", "Konkuro", "Konkuroj", "Etapoj", "Dato", "Datoj", "Longo", "Lando", "Landoj",
"Komencloko", "Alvenloko", "Teamoj", "Startantoj", "Alvenantoj", "Averagxa rapido", "Kosto", "Rezultoj", "Venkinto", "Dua pozicio", "Tria pozicio",
"Klasifiko laux poentoj", "Plej bona grimpanto", "Plej bona sprinto", "Plej bona juno", "Superbatalema", "Plej bona por kombino", "Plej bona teamo",
"Picture", "Caption", "Map", "Special 1", "Special 2", "Dokumentado", "Metas volantes", "Regularidad", "Team points", "Breakaway", "Azzurri d'Italia", "Rookie"},
["es"] = {"Detalles", "Carrera", "Competición", "Competiciones", "Etapas", "Fecha", "Fechas", "Distancia total", "País", "Países",
"Lugar de inicio", "Lugar de llegada", "Equipos", "Ciclistas participantes", "Ciclistas finalizados", "Velocidad media", "Costo", "Clasificación final",
"Ganador", "Segundo", "Tercero", "Puntos", "Montaña", "Metas volantes", "Jóvenes", "Combatividad", "Combinada", "Equipo", "Imagen", "Leyenda", "Mapa",
"Especial 1", "Especial 2", "Documentación", "Metas volantes", "Regularidad", "Team points", "Fuga", "Azzurri d'Italia", "Novatos"},
["eu"] = {"Lasterketaren xehetasunak", "Ibilbidea", "Lehiaketa", "Lehiaketak", "Etapak", "Data", "Datak", "Distantzia",
"Herrialdea", "Herrialdeak", "Jardunaldiko abiapuntua", "Jardunaldiko helmuga", "Taldeak", "Abiatutako txirrindulariak", "Iritsitako txirrindulariak",
"Batez besteko abiadura", "Kostua", "Azken sailkapena", "Irabazlea", "Bigarrena", "Hirugarrena", "Puntuak", "Mendiak", "Esprintak", "Gazteak",
"Saiatuena", "Konbinatua", "Taldeak", "Picture", "Caption", "Map", "Special 1", "Special 2", "Dokumentazioa", "Metas volantes", "Regularidad",
"Team points", "Breakaway", "Azzurri d'Italia", "Rookie"},
["fi"] = {"Kilpailun tiedot", "Nimi", "Kilpailu", "Kilpailut", "Etapit", "Päivä", "Päivät", "Matka", "Maa", "Maat",
"Lähtöpaikka", "Saapumispaikka", "Joukkueet", "Osallistuneet pyöräilijät", "Maaliin saapuneet pyöräilijät", "Keskinopeus", "Kustannukset", "Lopputilanne",
"Voittaja", "Toinen", "Kolmas", "Pistekilpailu", "Mäkikirikilpailu", "Sprintit", "Nuoret", "Yritteliäin", "Yhdistelmä", "Joukkue", "Kuva", "Kuvateksti",
"Kartta", "Special 1", "Special 2", "Ohjesivu", "Metas volantes", "Regularidad", "Team points", "Breakaway", "Azzurri d'Italia", "Rookie"},
["fo"] = {"Smálutir", "Leið", "Kapping", "Kappingar", "Teinar", "Dagfesting", "Dagfestingar", "Strekki", "Land", "Lond", "Byrjunarbýur",
"Málbýur", "Lið", "Byrjandi súkklarar", "Fullførandi súkklarar", "Miðalferð", "Kostnaður", "Palmares", "Vinnari", "Nr. 2", "Nr. 3", "Stig", "Fjøll",
"Spurtar", "Ungdómur", "Mest álopssinnaður", "Kombinatión", "Lið", "Picture", "Caption", "Map", "Special 1", "Special 2", "Dokumentation", "Metas volantes",
"Regularidad", "Team points", "Breakaway", "Azzurri d'Italia", "Rookie"},
["he"] = {"פרטי מרוץ", "Course", "תחרות", "תחרויות", "Stages", "תאריך", "תאריכים", "מרחק", "מדינה", "מדינות",
"התחלת מסלול", "סוף מסלול", "קבוצות", "Starting riders", "Arriving riders", "Average speed", "Cost", "Palmares", "מנצח", "שני",
"שלישי", "ניקוד", "הרים", "ספרינטים", "Youth", "Combativity", "Combination", "קבוצה", "תמונה", "Caption", "Map", "Special 1", "Special 2",
"תיעוד", "Intermediate sprints", "Regularidad", "Team points", "Breakaway", "Azzurri d'Italia", "Rookie"},
["lb"] = {"Detailer", "Course", "Kompetitioun", "Kompetitiounen", "Etappen", "Datum", "Datumer", "Distanz", "Land", "Länner",
"Depart", "Arrivée", "Equippen", "Um Depart", "Ukomm", "Vitess-Moyenne", "Käschten", "Palmarès", "Gewënner", "Zweeten", "Drëtten", "Beschte Sprinter",
"Biergpräis", "Sprinter", "Beschte Jonken", "Kombativitéit", "Kombinatioun", "Equipe", "Picture", "Caption", "Map", "Special 1", "Special 2",
"Dokumentatioun", "Étapes volantes", "Regularidad", "Team points", "Breakaway", "Azzurri d'Italia", "Rookie"},
["lv"] = {"Sacensību informācija", "Sacensības", "Kategorija", "Sacensības", "Posmi", "Datums", "Datumi", "Distance", "Valsts",
"Valstis", "Starts", "Finišs", "Komandas", "Braucēji startā", "Braucēji finišā", "Vidējais ātrums", "Izmaksas", "Rezultāti", "Uzvarētājs", "Otrais",
"Trešais", "Punkti", "Kalnu karalis", "Sprints", "Jaunais braucējs", "Cīnītājs", "Kombinācija", "Komanda", "Atēls", "Paraksts", "Karte", "Papildinformācija 1",
"Papildinformācija 2", "Dokumentācija", "Metas volantes", "Regularidad", "Team points", "Breakaway", "Azzurri d'Italia", "Rookie"},
["mk"] = {"Детали за трката", "Издание", "Натпреварување", "Натпреварувања", "Етапи", "Датум", "Датуми", "Растојание",
"Држава", "Држави", "Поаѓалиште", "Одредиште", "Екипи", "Возачи на почеток", "Возачи на крај", "Просечна брзина", "Трошоци", "Добитници на наградите",
"Победник", "Второпласиран", "Третопласиран", "Бодовен", "Планински", "Спринтерски", "Младински", "Борбеност", "Комбиниран", "Екипен", "слика", "опис",
"местоположбена карта", "Special 1", "Special 2", "Документација", "Metas volantes", "Regularidad", "Team points", "Breakaway", "Azzurri d'Italia", "Rookie"},
["nl"] = {"Wedstrijddetails", "Koers", "Wedstrijd", "Wedstrijden", "Etappes", "Datum", "Datums", "Afstand", "Land", "Landen",
"Startplaats", "Finishplaats", "Teams", "Aantal coureurs aan de start", "Aantal coureurs bij de aankomst", "Gemiddelde snelheid", "Kosten", "Palmares",
"Winnaar", "Tweede", "Derde", "Punten", "Bergen", "Sprints", "Jeugd", "Aanvalslust", "Combinatie", "Team", "Picture", "Caption", "Map", "Special 1",
"Special 2", "Documentatie", "Metas volantes", "Regularidad", "Teampunten", "Breakaway", "Azzurri d'Italia", "Rookie"},
["no"] = {"Detaljer", "Ritt", "Konkurranse", "Konkurranser", "Etapper", "Dato", "Datoer", "Distanse", "Land", "Land", "Startsted",
"Målsted", "Lag", "Startende ryttere", "Fullførende ryttere", "Gjennomsnittsfart", "Kostnad", "Resultater", "Vinner", "2. plass", "3. plass", "Poeng",
"Klatring", "Spurt", "Ungdom", "Mest offensive", "Kombinasjon", "Lagkonkurranse", "Bilde", "Bildetekst", "Kart", "Spesial 1", "Spesial 2", "Dokumentasjon",
"Innlagte spurter", "Regularitet", "Lagkonkurranse (poeng)", "Brudd", "Azzurri d'Italia", "Rookie"},
["pl"] = {"Wyrażenia ogólne", "Wyścig", "Konkurencja", "Konkursy", "Etapów", "Data", "Daty", "Dystans", "Państwo", "Państwy",
"Odejście", "Przyjazd", "Zespoły", "Zgłoszenia", "Ukończyło wyścig", "Średnia prędkość", "Koszt", "Podium", "Pierwsze miejsce", "Drugie miejsce",
"Trzecie miejsce", "Punktowa", "Górska", "Sprinterska", "Młodzieżowa", "Najaktywniejszych", "Kombinowana", "Drużynowa", "Picture", "Caption", "Map",
"Special 1", "Special 2", "Dokumentacja", "Metas volantes", "Regularidad", "Team points", "Breakaway", "Azzurri d'Italia", "Rookie"},
["pt"] = {"Detalhes", "Corrida", "Válida para", "Válida para", "Etapas", "Data", "Data", "Distância", "País", "Países",
"Partida", "Chegada", "Nº de equipes", "Ciclistas que iniciaram", "Ciclistas que finalizaram", "Velocidade média", "Custo", "Classificação final",
"Vencedor", "Segundo", "Terceiro", "Prêmio por pontos", "Prêmio de montanha", "Sprints", "Juventude", "Disputa", "Combinação", "Equipes", "Imagem",
"Legenda", "Mapa", "Special 1", "Special 2", "Documentação", "Metas volantes", "Regularidad", "Team points", "Breakaway", "Azzurri d'Italia", "Rookie"},
["ro"] = {"Detalii cursă", "Cursă", "Competiție", "Competiții", "Etape", "Dată", "Date", "Distanță", "Țară", "Țări", "Start",
"Sosire", "Echipe", "Cicliști la start", "Cicliști la sosire", "Viteză medie", "Cost", "Palmares", "Câștigător", "Al doilea", "Al treilea", "Clasament pe puncte",
"Cel mai bun cățărător", "Cel mai bun sprinter", "Cel mai bun tânăr", "Combativitate", "Combinat", "Echipă", "Picture", "Caption", "Map", "Special 1",
"Special 2", "Documentație", "Metas volantes", "Regularidad", "Team points", "Breakaway", "Azzurri d'Italia", "Rookie"},
["ru"] = {"Детали гонки", "Маршрут", "Соревнование", "Соревнования", "Этапы", "Дата", "Даты", "Дистанция", "Страна", "Страны",
"Место старта", "Место финиша", "Команды", "Стартовало гонщиков", "Финишировало гонщиков", "Средняя скорость", "Призовые", "Призёры", "Победитель",
"Второй", "Третий", "Очковая", "Горная", "Спринтерская", "Молодёжная", "Бойцовская", "Комбинированная", "Командная по времени", "Вид", "Описание", "Карта", "Сектор 1",
"Сектор 2", "Документация", "Промежуточные финиши", "Регулярность", "Командная по очкам", "Breakaway", "Azzurri d'Italia", "Rookie"},
["sv"] = {"Race details", "Course", "Competition", "Competitions", "Stages", "Date", "Dates", "Distance", "Country", "Countries",
"Journey origin", "Journey destination", "Teams", "Starting riders", "Arriving riders", "Average speed", "Cost", "Palmares", "Winner", "Second",
"Third", "Points", "Mountains", "Sprints", "Youth", "Combativity", "Combination", "Team", "Picture", "Caption", "Map", "Special 1", "Special 2",
"Documentation", "Metas volantes", "Regularidad", "Team points", "Breakaway", "Azzurri d'Italia", "Rookie"},
["ast"] = {"Detalles", "Carrera", "Competición", "Competiciones", "Etapes", "Data", "Dates", "Distancia total", "País", "Países",
"Llugar d'entamu", "Llugar de llegada", "Equipos", "Ciclistes participantes", "Ciclistes acabaos", "Velocidá media", "Costu", "Clasificación final", "Ganador", "Segundu",
"Terceru", "Puntos", "Monte", "Metes volantes", "Mozos", "Combatividá", "Combinada", "Equipu", "Imaxe", "Lleenda", "Mapa", "Especial 1", "Especial 2",
"Documentación", "Metes volantes", "Regularidá", "Team points", "Fuga", "Azzurri d'Italia", "Rookie"}
}
local l10n = l10nDef[wiki]
end
 
function unit(x)
local l10nDef = {
["ar"] = {"", " س ", " دقيقة ", " ث", ' كم/س', " نقطة", " نقطة"},
["fr"] = {"en", " h ", " min ", " s", ' km/h', " pt", " pts"},
["br"] = {"", "e ", "' ", '"', ' km/h', " pt", " pts"},
["da"] = {"", "t ", "' ", '"', ' km/t', " point", " point"},
["de"] = {"", " h ", " min ", " s", ' km/h', " P.", " P."},
["en"] = {"", "h ", "' ", '"', ' km/h', " pt", " pts"},
["es"] = {"", " h ", " min ", " s", ' km/h', " pt&nbsp;&nbsp;", " pts"},
["eu"] = {"", " h ", " min ", " s", ' km/h', " pt", " pt"},
["fo"] = {"", "t ", "' ", '"', ' km/t', " pt", " pts"},
["fi"] = {"", ".", ".", "", ' km/h', " pt", " pts"},
["he"] = {"", "h ", "' ", '"', ' קמ"ש', " נק\'", " נקודות"},
["hu"] = {"", " óra ", ":", "", ' km/h', " pt", " pts"},
["it"] = {"", "h", "'", '"', ' km/h', " pt", " pts"},
["ja"] = {"", "時間", "分", '秒', 'km/h', "ポイント", "ポイント"},
["lb"] = {"", " h ", " min ", " s", ' km/h', " pt", " pts"},
["mk"] = {"", "ч ", "' ", "", ' км/ч', " pt", " pts"},
["nl"] = {"", "u", "'", '"', ' km/u', " pt", " pts"},
["no"] = {"", "t ", "' ", '"', ' km/t', " poeng", " poeng"},
["pt"] = {"", "h", "m", "s", ' km/h', " pt", " pts"},
["ru"] = {"", "ч ", "' ", "", ' км/ч', " очко", " очков"},
["ast"] = {"", " h ", " min ", " s", ' km/h', " pt ", " pts"}
}
local l10n = l10nDef[wiki]
if not l10n then l10n = l10nDef["en"] end -- default for lv,cs,en,ca,ro,pt,pl,sv
return l10n[x]
end
 
function func_month(x)
local l10nDef = {
["ar"] = {"يناير", "فبراير", "مارس", "أبريل", "مايو", "يونيو", "يوليو", "أغسطس", "سبتمبر", "أكتوبر", "نوفمبر", "ديسمبر"},
["fr"] = {"janv.", "févr.", "mars", "avr.", "mai", "juin", "juil.", "août", "sept.", "oct.", "nov.", "déc."},
["en"] = {"January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"},
["be"] = {"studz.", "liut.", "sak.", "kras.", "mai.", "cherv.", "lip.", "zhniven'", "veras", "kastr.", "list.", "snezh."},
["bg"] = {"ian.", "fevr.", "mart", "april", "mai", "iuni", "iuli", "avg.", "sept.", "okt.", "noem.", "dek."},
["br"] = {"Genver", "C'hwevrer", "Meurzh", "Ebrel", "Mae", "Mezheven", "Gouere", "Eost", "Gwengolo", "Here", "Du", "Kerzu"},
["ca"] = {"gener", "febrer", "març", "abril", "maig", "juny", "juliol", "agost", "setembre", "octubre", "novembre", "desembre"},
["cs"] = {"led.", "ún.", "bře.", "dub.", "kvě.", "čvn.", "čvc.", "srp.", "září.", "říj.", "list.", "pros."},
["da"] = {"jan.", "febr.", "marts", "april", "maj", "juni", "juli", "aug.", "sept.", "okt.", "nov.", "dec."},
["de"] = {"Jan.", "Feb.", "März", "Apr.", "Mai", "Juni", "Juli", "Aug.", "Sept.", "Okt.", "Nov.", "Dez."},
["eo"] = {"janu.", "febr.", "marto", "apr.", "majo", "jun.", "jul.", "auxg.", "sept.", "okt.", "nov.", "dec."},
["es"] = {"enero", "febrero", "marzo", "abril", "mayo", "junio", "julio", "agosto", "septiembre", "octubre", "noviembre", "diciembre"},
["et"] = {"jaan.", "veebr.", "märts", "apr.", "mai", "juuni", "juuli", "aug.", "sept.", "okt.", "nov.", "dets."},
["eu"] = {"urtarrila", "otsaila", "martxoa", "apirila", "maiatza", "ekaina", "uztaila", "abuztua", "iraila", "urria", "azaroa", "abendua"},
["fi"] = {"tammikuuta", "helmikuuta", "maaliskuuta", "huhtikuuta", "toukokuuta", "kesäkuuta", "heinäkuuta", "elokuuta", "syyskuuta", "lokakuuta", "marraskuuta", "joulukuuta"},
["fo"] = {"januar", "februar", "mars", "apríl", "mai", "juni", "juli", "august", "september", "oktober", "november", "desember"},
["he"] = {"ינואר", "פברואר", "מרץ", "אפריל", "מאי", "יוני", "יולי", "אוגוסט", "ספטמבר", "אוקטובר", "נובמבר", "דצמבר"},
["hu"] = {"január", "február", "március", "április", "május", "június", "július", "augusztus", "szeptember", "október", "november", "december"},
["id"] = {"Djan.", "Peb.", "Mrt.", "Apr.", "Mai", "Djuni", "Djuli", "Ag.", "Sept.", "Okt.", "Nop.", "Des."},
["it"] = {"genn.", "febbr.", "mar.", "apr.", "magg.", "giugno", "luglio", "ag.", "sett.", "ott.", "nov.", "dic."},
["ja"] = {"1月", "2月", "3月", "4月", "5月", "6月", "7月", "8月", "9月", "10月", "11月", "12月"},
["la"] = {"Ian.", "Febr.", "Mart.", "Apr.", "Mai.", "Iun.", "Iul.", "Aug.", "Sept.", "Oct.", "Nov.", "Dec."},
["lb"] = {"Januar", "Februar", "Mäerz", "Abrëll", "Mee", "Juni", "Juli", "August", "September", "Oktober", "November", "Dezember"},
["lt"] = {"saus.", "vas.", "kovas", "bal.", "geg.", "birz", "liepa", "rugp.", "rugs.", "spalis", "lapkr.", "gr."},
["lv"] = {"janvāris", "februāris", "marts", "aprīlis", "maijs", "jūnijs", "jūlijs", "augusts", "septembris", "oktobris", "novembris", "decembris"},
["mk"] = {"јануари", "февруари", "март", "април", "мај", "јуни", "јули", "август", "септември", "октомври", "ноември", "декември"},
["ms"] = {"Jan.", "Feb.", "Mac", "Apr.", "Mei", "Jun", "Julai", "Og", "Sept.", "Okt.", "Nov.", "Dis."},
["no"] = {"jan.", "feb.", "mar.", "apr.", "mai", "jun.", "jul.", "aug.", "sep.", "okt.", "nov.", "des."},
["nl"] = {"jan.", "feb.", "maart", "apr.", "mei", "juni", "juli", "aug.", "sept.", "okt.", "nov.", "dec."},
["pl"] = {"stycznia", "lutego", "marca", "kwietnia", "maja", "czerwca", "lipca", "sierpnia", "września", "października", "listopada", "grudnia"},
["pt"] = {"jan", "fev", "mar", "abr", "mai", "jun", "jul", "ago", "set", "out", "nov", "dez"},
["ro"] = {"Ian.", "Feb.", "Mar.", "Apr.", "Mai", "Iun.", "Iul.", "Aug.", "Sep.", "Oct.", "Nov.", "Dec."},
["ru"] = {"января", "февраля", "марта", "апреля", "мая", "июня", "июля", "августа", "сентября", "октября", "ноября", "декабря"},
["sh"] = {"sijec.", "velj.", "ozuj.", "trav.", "svib.", "lip.", "srp.", "kol.", "ruj.", "list.", "stud.", "pros."},
["sk"] = {"jan.", "feb.", "mar.", "apr.", "máj", "jún.", "júl.", "aug.", "sept.", "okt.", "nov.", "dec."},
["sl"] = {"jan.", "feb.", "mar.", "apr.", "maj", "jun.", "jul.", "avg.", "sept.", "okt.", "nov.", "dec."},
["sv"] = {"jan.", "febr.", "mars", "april", "maj", "juni", "juli", "aug.", "sept.", "okt.", "nov.", "dec."},
["zh"] = {"1月", "2月", "3月", "4月", "5月", "6月", "7月", "8月", "9月", "10月", "11月", "12月"},
["ast"] = {"xineru", "febreru", "marzu", "abril", "mayu", "xunu", "xunetu", "agostu", "setiembre", "ochobre", "payares", "avientu"},
}
local l10n = l10nDef[wiki]
if not l10n then l10n = l10nDef["en"] end -- default
return l10n[x]
end
 
function headoftable(x) -- En-tête du tableau listant les étapes
local l10nDef={
["ar"] = {"المرحلة", "التاريخ", "الدورة", "المسافة (كم)", "الفائز بالمرحلة", "القائد العام"},
["fr"] = {"Étape", "Date", "Villes étapes", "Distance (km)", "Vainqueur d'étape", "Leader du classement général"},
["en"] = {"Stage", "Date", "Course", "Distance - km (mi)", "Stage winner", "Overall leader"},
["br"] = {"Tennad", "Deiziad", "Kêr loc'hañ ha kêr degouezhout", "Hed (km)", "Trec'hour", "E penn ar renkamant hollek"},
["ca"] = {"Etapa", "Data", "Ciutats d'etapa", "Distància (km)", "Vencedor de l'etapa", "Líder de la general"},
["cs"] = {"Etapa", "Datum", "Trasa", "Vzdálenost (km)", "Vítěz", "Průběžný lídr"},
["da"] = {"Etape", "Dato", "Start – Mål", "Afstand (km)", "Etapevinder", "Førende rytter"},
["de"] = {"Etappe", "Datum", "Etappenorte", "Länge (km)", "Etappen&shy;sieger", "Gesamt&shy;führender"},
["eo"] = {"Etapo", "Dato", "Etapa urbo", "Longo (km)", "Venkinto de la etapo", "Estro de la gxeneralo klasado"},
["es"] = {"Etapa", "Fecha", "Recorrido", "Distancia (km)", "Ganador", "Líder"},
["eu"] = {"Etapa", "Data", "Ibilbidea", "Distantzia (km)", "Irabazlea", "Liderra"},
["fi"] = {"Etappi", "Päivä", "Reitti", "Pituus (km)", "Voittaja", "Kokonaiskilpailun johtaja"},
["fo"] = {"Teinur", "Dagur", "Byrjan – Mál", "Vegalongd (km)", "Teina&shy;vinnari", "Gula troyggjan"},
["hu"] = {"Szakasz", "Időpont", "Végpontok", "Hossz (km)", "Szakasz&shy;győztes", "Általános vezető"},
["it"] = {"Tappa", "Data", "Percorso", "Distanza (km)", "Vincitore di tappa", "Leader cl. generale"},
["ja"] = {"ステージ", "開催日", "コース", "距離 (km)", "ステージ勝者", "全体リーダー"},
["la"] = {"Statio", "Dies", "Iter", "Distantia (km)", "Victor", "Altiore princeps"},
["lb"] = {"Etapp", "Datum", "Etappestied", "Längt (km)", "Gewënner", "General&shy;klassement"},
["lv"] = {"Posms", "Datums", "Maršruts", "Posma garums (km)", "Uzvarētājs", "Kopvērtējuma līderis"},
["mk"] = {"Етапа", "Датум", "Тек", "Растојание (км)", "Победник", "Cевкупен лидер"},
["nl"] = {"Etappe", "Datum", "Start – Finish", "Afstand (km)", "Winnaar", "Klassements&shy;leider"},
["no"] = {"Etappe", "Dato", "Start – Målgang", "Distanse (km)", "Etappe&shy;vinner", "Sammenlagt&shy;leder"},
["pl"] = {"Etap", "Data", "Start – Meta", "Dystans (km)", "Zwycięzca etapu", "Lider"},
["pt"] = {"Etapa", "Data", "Percurso", "Distância (km)", "Vencedor", "Líder geral"},
["ro"] = {"Etapa", "Dată", "Start – Sosire", "Distanță (km)", "Câștigător", "Liderul global"},
["ru"] = {"Этап", "Дата", "Маршрут", "Длина (км)", "Победитель", "Лидер генеральной классификации"},
["sk"] = {"Etapa", "Dátum", "Trasa", "Vzdialenosť (km)", "Víťaz", "Priebežný líder"},
["sv"] = {"Etapp", "Datum", "Start – mål", "Distans (km)", "Skede vinnare", "Övergripande ledare"},
["ast"] = {"Etapa", "Data", "Percorríu", "Distancia (km)", "Ganador", "Líder"},
}
local l10n = l10nDef[wiki]
if not l10n then l10n = l10nDef["en"] end -- default
return l10n[x]
end
 
function headoftableII(x) -- En-têtes des tableaux générant les classements
local l10nDef = {
["ar"] = {"العداء", "البلد", "الفريق", "الوقت", "إزاحة الوقت", "السرعة", "النقاط", "تصنيف الفرق ضد الساعة", "التصنيف العام", "تصنيف النقاط", "تصنيف الجبال", "تصنيف أفضل عداء", "تصنيف أفضل شاب", "تصنيف الفرق حسب الوقت", "ترتيب الفرق حسب النقاط", "تصنيف المجموعة", "تصنيف أفضل مقاتل", "التصنيف تحت 23","UCI Ranking"},
["fr"] = {"Coureur", "Pays", "Équipe", "Temps", "Écart de temps", "Vitesse moy.", "Points", "Classement de l'étape", "Classement général", "Classement par points", "Classement de la montagne", "Classement des sprints", "Classement du meilleur jeune", "Classement par équipes", "Classement par équipes aux points", "Classement du combiné", "Classement de la combativité", "Classement du meilleur jeune", "Classement UCI"},
["en"] = {"Rider", "Country", "Team", "Time", "Time Gap", "Speed", "Points", "Stage classification", "General classification", "Points classification", "Mountains classification", "Sprints classification", "Best young classification", "Teams classification", "Points classification for teams", "Combination classification", "Combative classification", "U23 classification", "UCI Ranking"},
["br"] = {"Reder", "Bro", "Skipailh", "Amzer", "Time Gap", "Speed", "Poentoù", "Renkadur an tennad", "Renkadur hollek", "Renkadur a-boentoù", "Renkadur ar menez", "Renkadur ar sprintoù", "Renkadur ar yaouank gwellañ", "Renkadur a-skipailh", "Renkadur a-skipailh", "Combination classification", "Combative classification", "U23 classification", "UCI classification"},
["ca"] = {"Corredor", "País", "Equip", "Temps", "Time Gap", "Velocitat", "Punts", "Classificació de l'etapa", "Classificació general", "Classificació per punts", "Classificació de la muntanya", "Classificació dels esprints", "Classificació del millor jove", "Classificació per equips", "Classificació per equips", "Classificació de la combinada", "Classificació de la combativitat", "Classificació sub-23","Classificació UCI"},
["da"] = {"Rytter", "Land", "Hold", "Tid", "Tidsforskel", "Gns. fart", "Point", "Etaperesultat", "Samlede stilling", "Pointkonkurrence", "Bjergkonkurrence", "Sprintkonkurrence", "Ungdomskonkurrence", "Holdkonkurrence", "Holdkonkurrence efter point", "Kombinationskonkurrence", "Mest angrebsivrige rytter", "U23-konkurrence","UCI Ranking"},
["de"] = {"Fahrer", "Land", "Team", "Zeit", "Zeitabstand", "Geschw.", "Punkte", "Etappenergebnis", "Gesamtwertung", "Punktewertung", "Bergwertung", "Sprintwertung", "Nachwuchswertung", "Mannschaftswertung", "Mannschaftswertung", "Combination classification", "Combative classification", "U23 classification","UCI classification"},
["eo"] = {"Kuranto", "Lando", "Teamo", "Tempo", "Time Gap", "Rapido", "Poentoj", "Etapa klasifiko", "Gxenerala klasifiko", "Klasifiko laux poentoj", "Klasifiko por la montaro", "Klasifiko por la sprintoj", "Klasifiko de la plej bona juno", "Klasifiko po teamo", "Klasifiko po teamo", "Combination classification", "Combative classification", "U23 classification","UCI classification"},
["es"] = {"Ciclista", "País", "Equipo", "Tiempo", "Intervalo de tiempo", "Velocidad media", "Puntos", "Clasificación de la etapa", "Clasificación general", "Clasificación por puntos", "Clasificación de la montaña", "Clasificación de las metas volantes", "Clasificación del mejor joven", "Clasificación por equipos", "Clasificación por equipos", "Clasificación de la combinada", "Clasificación de la combatividad", "Clasificación sub-23", "Clasificación UCI"},
["eu"] = {"Txirrindularia", "Herrialdea", "Taldea", "Denbora", "Time Gap", "Speed", "Puntua", "Etapako sailkapena", "Sailkapen orokorra", "Puntukako sailkapena", "Mendiko sailkapena", "Esprinetako sailkapena", "Gazte onenaren sailkapena", "Taldekako sailkapena", "Taldekako sailkapena", "Combination classification", "Combative classification", "U23 classification","UCI Ranking"},
["fi"] = {"Pyöräilijä", "Maa", "Joukkue", "Aika", "Aikaero", "Nopeus", "Pisteet", "Etapin tulokset", "Kokonaistilanne", "Pistekilpailu", "Vuoristokilpailu", "Sprinttikilpailu", "Nuorten kilpailu", "Joukkuekilpailu", "Joukkuekilpailu", "Combination classification", "Combative classification", "U23 classification","UCI Ranking"},
["fo"] = {"Súkklari", "Land", "Lið", "Tíð", "Time Gap", "Ferð", "Stig", "Teinaplasering", "Samlað plasering", "Stigkappingin", "Fjallakappingin", "Spurtkappingin", "Ungdómskappingin", "Liðkappingin", "Liðkappingin", "Kombinatiónsheiðurkappingin", "Combative classification", "U23 classification","UCI Ranking"},
["hu"] = {"Versenyző", "Ország", "Équipe", "Idő", "Időkülönbség", "Átlagsebesség", "Pont", "Szakasz verseny", "Összetett verseny", "Pontverseny", "Hegyi pontverseny", "Gyorsulverseny", "Fiatalok versenye", "Csapatverseny", "Csapatverseny", "Combination classification", "Combative classification", "U23 classification","UCI Ranking"},
["lb"] = {"Coureur", "Land", "Equipe", "Zäit", "Time Gap", "Vitesse", "Punkten", "Etappeklassement", "Generalklassement", "Klassement no Punkten", "Biergpräis", "Sprintklassement", "Beschte Jonken", "Equippeklassement", "Equippeklassement", "Combinéklassement", "Combative classification", "U23 classification","UCI Ranking"},
["lv"] = {"Braucējs", "Valsts", "Komanda", "Laiks", "laika atstarpe", "Ātrums", "Punkti", "Posma rezultāti", "Kopvērtējums", "Punktu klasifikācija", "Kalnu klasifikācija", "Sprinta klasifikācija", "Jauno braucēju klasifikācija", "Komandu klasifikācija", "Komandu klasifikācija", "Kombinācijas klasifikācija", "Cīnītāja klasifikācija", "U23 klasifikācija","UCI klasifikācija"},
["mk"] = {"Возач", "Земја", "Екипа", "Време", "Разлика", "Брзина", "Бодови", "Етапен резултат", "Генерален пласман", "Бодовен пласман", "Планински пласман", "Спринтерски пласман", "Пласман за млад возач", "Екипен пласман", "Екипен пласман", "Combination classification", "Combative classification", "U23 classification","UCI Ranking"},
["no"] = {"Rytter", "Land", "Lag", "Tid", "Tidsforskjell", "Fart", "Poeng", "Etappeplassering", "Sammenlagtplassering", "Poengkonkurranse", "Klatrekonkurranse", "Spurtkonkurranse", "Ungdomskonkurranse", "Lagkonkurranse", "Lagkonkurranse (poeng)", "Kombinasjonkonkurranse", "Mest offensive rytter", "U23-konkurranse","UCI Ranking"},
["nl"] = {"Renner", "Land", "Ploeg", "Tijd", "Tijdsverschil", "Snelheid", "Punten", "Etappeklassement", "Algemeen Klassement", "Puntenklassement", "Bergklassement", "Sprintklassement", "Jongerenklassement", "Ploegenklassement", "Ploegenklassement", "Combinatieklassement", "Combative classification", "U23 classification","UCI Ranking"},
["pt"] = {"Ciclista", "País", "Equipe", "Tempo", "Intervalo de tempo", "Rapidez", "Pontos", "Classificação por etapas", "Classificação geral", "Classificação por pontos", "Classificação da montanha", "Classificação por velocidade", "Classificação dos jovens", "Classificação por equipes", "Classificação por equipes", "Classificação de combinados", "Classificação da combatividade", "Classificação U23","Classificação UCI"},
["ro"] = {"Ciclist", "Țară", "Echipă", "Timp", "Time Gap", "Viteză", "Puncte", "Clasamentul etapei", "Clasament general", "Clasament pe puncte", "Clasament cățărători", "Clasament sprinteri", "Clasamentul celui mai bun tânăr", "Clasament pe echipe", "Clasament pe echipe", "Combination classification", "Combative classification", "U23 classification","UCI Ranking"},
["ru"] = {"Гонщик", "Страна", "Команда", "Время", "Отставание", "Скорость", "Очки", "Результаты этапа", "Генеральная классификация", "Очковая классификация", "Горная классификация", "Спринтерская классификация", "Молодёжная классификация", "Командная классификация по времени", "Командная классификация по очкам", "Комбинированная классификация", "Бойцовская калссификация", "Классификация U23","Классификация UCI"},
["ast"] = {"Ciclista", "País", "Equipu", "Tiempu", "Intervalu de tiempu", "Velocidá media", "Puntos", "Clasificación de la etapa", "Clasificación xeneral", "Clasificación per puntos", "Clasificación de monte", "Clasificación de les metes volantes", "Clasificación del meyor mozu", "Clasificación per equipos", "Clasificación per equipos", "Clasificación de la combinada", "Clasificación de la combatividá", "Clasificación sub-23","Clasificación UCI"},
}
local l10n = l10nDef[wiki]
if not l10n then l10n = l10nDef["en"] end -- default
return l10n[x]
end
 
function headoftableIII(x) -- En-tête du tableau listant les équipes participantes (P1923)
local l10nDef = {
["ar"] = {"اسم الفريق", "البلد", "الرمز", "فريق عالمي", "فرق عالمية", "فريق برو", "فرق برو", "فريق قاري محترف", "فرق قارية محترفة", "فريق قاري", "فرق قارية", "فريق وطني", "فرق وطنية", "فريق إقليمي ونادي", "فرق إقليمية وأندية", "فريق دراجات محترف", "فرق دراجات محترفة", "فريق هواة دراجات", "فرق هواة دراجات", "مجموعة رياضية أولى", "مجموعات رياضية أولى", "مجموعة رياضية ثانية", "مجموعات رياضية ثانية", "مجموعة رياضية ثالثة", "مجموعات رياضية ثالثة", "فريق مختلط", "فرق مختلطة", "فريق إناث محترف", "فرق إناث محترفة", "فريق هواة دراجات إناث", "فرق هواة دراجات إناث"},
["fr"] = {"Nom de l'équipe", "Pays", "Code", "WorldTeam", "WorldTeams", "ProTeam", "ProTeams", "Équipe continentale professionnelle", "Équipes continentales professionnelles", "Équipe continentale", "Équipes continentales", "Équipe nationale", "Équipes nationales", "Équipe régionale et de club", "Équipes régionales et de clubs", "Équipe cycliste professionnelle", "Équipes cyclistes professionnelles", "Équipe cycliste amateur", "Équipes cyclistes amateurs", "Groupe sportif I", "Groupes sportifs I", "Groupe sportif II", "Groupes sportifs II", "Groupe sportif III", "Groupes sportifs III", "Équipe mixte", "Équipes mixtes", "Équipe féminine professionnelle", "Équipes féminines professionnelles", "Équipe cycliste amateur féminine", "Équipe cycliste amateur féminines"},
["en"] = {"Team name", "Country", "Code", "WorldTeam", "WorldTeams", "ProTeam", "ProTeams", "Professional continental team", "Professional continental teams", "Continental team", "Continental teams", "National team", "National teams", "Regional and club team", "Regional and club teams", "Professional cycling team", "Professional cycling teams", "Amateur cycling team", "Amateur cycling teams", "Trade Team I", "Trade Teams I", "Trade Team II", "Trade Teams II", "Trade Team III", "Trade Teams III", "Mixed team", "Mixed teams", "Professional woman team", "Professional women teams", "Women's amateur cycling team", "Women's amateur cycling teams"},
["ja"] = {"チーム名", "国", "コード", "ワールドチーム", "ワールドチーム", "プロチーム", "プロチーム", "プロフェッショナルコンチネンタルチーム", "プロフェッショナルコンチネンタルチーム", "コンチネンタルチーム", "コンチネンタルチーム", "ナショナルチーム", "ナショナルチーム", "地域・クラブチーム", "地域・クラブチーム", "プロ自転車チーム", "プロ自転車チーム", "アマ自転車チーム", "アマ自転車チーム", "Groupe sportif I", "Groupes sportifs I", "Groupe sportif II", "Groupes sportifs II", "Groupe sportif III", "Groupes sportifs III", "Mixt team", "Mixt teams", "プロ女子チーム", "プロ女子チーム", "Women's amateur cycling team", "Women's amateur cycling teams"},
["br"] = {"Anv skipailh", "Bro", "Kod", "WorldTeam", "WorldTeams", "ProTeam", "ProTeams", "Skipailh kevandir a-vicher", "Skipailhoù kevandir a-vicher", "Skipailh kevandir", "Skipailhoù kevandir", "Skipailh bro", "Skipailhoù bro", "Skipailh rannvro ha klub", "Skipailhoù rannvro ha 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"},
["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"},
["da"] = {"Holdnavn", "Land", "Kode", "WorldTeam", "WorldTeams", "ProTeam", "ProTeams", "Professionelt kontinentalhold", "Professionelle kontinentalhold", "Kontinentalhold", "Kontinentalhold", "Landshold", "Landshold", "Regional- og klubhold", "Regional- og klubhold", "Prohold", "Prohold", "Amatørhold", "Amatørhold", "Sportsgruppe I", "Sportsgruppe I", "Sportsgruppe II", "Sportsgruppe II", "Sportsgruppe III", "Sportsgruppe III", "Mix-hold", "Mix-hold", "Kvindehold", "Kvindehold", "Amatørkvindehold", "Amatørkvindehold"},
["de"] = {"Team", "Land", "Code", "WorldTeam", "WorldTeams", "ProTeam", "ProTeams", "Professional Continental Team", "Professional Continental Teams", "Continental Team", "Continental Teams", "Nationalmannschaft", "Nationalmannschaften", "Regionale Teams und Vereine", "Regionale Teams und Vereine", "Profi-Radsportteam", "Profi-Radsportteams", "Amateurmannschaft", "Amateurmannschaften", "Groupe Sortif I", "Groupes Sportifs I", "Groupe Sportif II", "Groupes Sportifs II", "Groupe Sportif III", "Groupes Sportifs III", "Mixed Team", "Mixed Teams", "UCI Women's Team", "UCI Women's Teams", "Sonstiges Frauenteam", "Sonstige Frauenteams"},
["eo"] = {"Nomo de la teamo", "Lando", "Kodo", "Monda teamo", "Mondaj teamoj", "ProTeamo", "ProTeamoj", "Profesiista kontinenta teamo", "Profesiistaj kontinentaj teamoj", "Kontinenta teamo", "Kontinentaj teamoj", "Nacia teamo", "Naciaj teamoj", "Regiona aux kluba teamo", "Regionaj aux klubaj teamoj", "Profesiista bicikla teamo", "Profesiistaj biciklaj teamoj", "Amatora bicikla teamo", "Amatoraj biciklaj teamoj", "Sporta grupo 1", "Sportaj grupoj 1", "Sporta grupo 2", "Sportaj grupoj 2", "Sporta grupo 3", "Sportaj grupoj 3", "Miksa teamo", "Miksaj teamoj", "Ina teamo", "Inaj teamoj", "Women's amateur cycling team", "Women's amateur cycling teams"},
["es"] = {"Nombre del equipo", "País", "Código", "WorldTeam", "WorldTeams", "ProTeam", "ProTeams", "Equipo continental profesional", "Equipos continentales profesionales", "Equipo continental", "Equipos continentales", "Equipo nacional", "Equipos nacionales", "Equipo regional y de club", "Equipos regionales y de clubes", "Equipo ciclista profesional", "Equipos ciclistas profesionales", "Equipo ciclista aficionado", "Equipos ciclistas aficionados", "Grupo deportivo I", "Grupos deportivos I", "Grupo deportivo II", "Grupos deportivos II", "Grupo deportivo III", "Grupos deportivos III", "Equipo mixto", "Equipos mixtos", "Equipo femenino", "Equipos femeninos", "Equipo femenino de ciclismo amateur", "Equipos femeninos de ciclismo amateur"},
["eu"] = {"Taldearen izena", "Herrialdea", "Kodea", "Munduko taldea", "Munduko taldeak", "Pro taldea", "Pro taldeak", "Kontinenteko talde profesionala", "Kontinenteko talde profesionala", "Kontinenteko taldea", "Kontinenteko taldeak", "Estatuko taldea", "Estatuko taldeak", "Eskualdeko eta klubeko taldea", "Eskualdeko eta klubeko taldeak", "Txirrindulari talde profesionala", "Txirrindulari talde profesionalak", "Txirrindulari talde amateurra", "Txirrindulari talde amateurrak", "I. mailako kirol taldea", "I. mailako kirol taldeak", "II. mailako kirol taldea", "II. mailako kirol taldeak", "III. mailako kirol taldea", "III. mailako kirol taldeak", "Talde mistoa", "Talde mistoak", "Emakume taldea", "Emakume taldeak", "Women's amateur cycling team", "Women's amateur cycling teams"},
["fi"] = {"Joukkueen nimi", "Maa", "Koodi", "WorldTeam", "WorldTeams", "ProTeam", "ProTeams", "Professional continental -joukkue", "Professional continental -joukkueet", "Continental-joukkue", "Continental-joukkueet", "Maajoukkue", "Maajoukkueet", "Alue- ja seurajoukkue", "Alue- ja seurajoukkueet", "Ammattilaispyöräilytalli", "Ammattilaispyöräilytallit", "Amatööripyöräilytalli", "Amatööripyöräilytallit", "Groupe sportif I", "Groupes sportifs I", "Groupe sportif II", "Groupes sportifs II", "Groupe sportif III", "Groupes sportifs III", "Mixt team", "Mixt teams", "Naisten ammattilaisjoukkue", "Naisten ammattilaisjoukkueet", "Women's amateur cycling team", "Women's amateur cycling teams"},
["fo"] = {"Liðnavn", "Land", "Kota", "WorldTeam", "WorldTeams", "ProTeam", "ProTeams", "Professionelt kontinentallið", "Professionel kontinentallið", "Kontinentallið", "Kontinental lið", "Landslið", "Landslið", "Regional- og klublið", "Regional- og felagslið", "Prolið", "Prolið", "Amatørlið", "Amatørlið", "Ítróttarbólkur I", "Ítróttarbólkur I", "Ítróttarbólkur II", "Ítróttarbólkur II", "Ítróttarbólkur III", "Ítróttarbólkur III", "Blandaðlið", "Blandaðlið", "Kvinulið", "Kvinnulið", "Women's amateur cycling team", "Women's amateur cycling teams"},
["he"] = {"שם קבוצה", "מדינה", "קוד", "WorldTeam", "קבוצות [[UCI World Tour|World Tour]]", "קבוצת פרו", "קבוצות פרו", "קבוצת קונטיננטל-פרו", "קבוצות קונטיננטל-פרו", "קבוצת קונטיננטל", "קבוצות קונטיננטל", "קבוצה לאומית", "קבוצות לאומיות", "Regional and club team", "Regional and club teams", "קבוצת רכיבה מקצועית", "קבוצות רכיבה מקצועיות", "Amateur cycling team", "Amateur cycling teams", "Groupe sportif I", "Groupes sportifs I", "Groupe sportif II", "Groupes sportifs II", "Groupe sportif III", "Groupes sportifs III", "Mixt team", "Mixt teams", "Professional woman team", "Professional women teams", "Women's amateur cycling team", "Women's amateur cycling teams"},
["lb"] = {"Equippennumm", "Land", "Code", "WorldTeam", "WorldTeams", "ProTeam", "ProTeams", "Professionell Kontinentalequipe", "Professionell Kontinentalequippen", "Kontinentalequipe", "Kontinentalequippen", "Nationalequipe", "Nationalequippen", "Regional- a Klubequipe", "Regional- a Klubequippen", "Professionell Vëlosequipe", "Professionell Vëlosequippen", "Amateursequipe", "Amateursequippen", "Sportsgrupp I", "Sportsgruppen I", "Sportsgrupp II", "Sportsgruppen II", "Sportsgrupp III", "Sportsgruppen III", "Gemëscht Equipe", "Gemëscht Equippen", "Dammenequipe", "Dammenequippen", "Women's amateur cycling team", "Women's amateur cycling teams"},
["lv"] = {"Komandas nosaukums", "Valsts", "Kods", "WorldTeam", "WorldTeam komandas", "ProTeam", "ProTeam komandas", "Profesionālā kontinentālā komanda", "Profesionālās kontinentālās komandas", "Kontinentālā komanda", "Kontinentālās komandas", "Nacionālā izlase", "Nacionālās izlases", "Reģionālā vai klubu komanda", "Reģionālās vai klubu komandas", "Profesionāla riteņbraukšanas komanda", "Profesionālas riteņbraukšanas komandas", "Amatieru riteņbraukšanas komanda", "Amatieru riteņbraukšanas komandas", "1. sporta grupa", "1. sporta grupa", "2. sporta grupa", "3. sporta grupa", "3. sporta grupa", "3. sporta grupa", "Jauktā komanda", "Jauktās komandas", "Profesionāla sieviešu komanda", "Profesionālas sieviešu komandas", "Amatieru sieviešu komanda", "Amatieru sieviešu komandas"},
["mk"] = {"Име на екипата", "Земја", "Код", "Екипа од Светската турнеја UCI", "Екипи од Светската турнеја UCI", "ProTeam", "ProTeams", "Професионална континентална екипа", "Професионални континентални екипи", "Континентална екипа", "Континентални екипи", "Национална екипа", "Национални екипи", "Регионална екипа и клуб", "Регионални екипи и клубови", "Професионална велосипедска екипа", "Професионални велосипедски екипи", "Аматерска велосипедска екипа", "Аматерски велосипедски екипи", "Groupe sportif I", "Groupes sportifs I", "Groupe sportif II", "Groupes sportifs II", "Groupe sportif III", "Groupes sportifs III", "Мешана екипа", "Мешани екипи", "Професионална женска екипа", "Професионални женски екипи", "Women's amateur cycling team", "Women's amateur cycling teams"},
["nl"] = {"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"},
["no"] = {"Lagnavn", "Land", "Kode", "WorldTour-lag", "WorldTour-lag", "ProTour-lag", "ProTour-lag", "Profesjonelt kontinentallag", "Profesjonelle kontinentallag", "Kontinentallag", "Kontinentallag", "Landslag", "Landslag", "Regional- og klubblag", "Regional- og klubblag", "Profflag", "Profflag", "Amatørlag", "Amatørlag", "Trade Team I", "Trade Teams I", "Trade Team II", "Trade Teams II", "Trade Team III", "Trade Teams III", "Mix-lag", "Mix-lag", "Profflag", "Profflag", "Amatørlag", "Amatørlag"},
["pt"] = {"Nome da equipe", "País", "Código", "Equipe WorldTeam", "Equipes WorldTeam", "Equipe ProTeam", "Equipes ProTeam", "Equipe profissional Continental", "Equipes profissionais Continentais", "Equipe Continental", "Equipes Continentais", "Equipe nacional", "Equipes nacionais", "Equipe regional e clube", "Equipes regionais e clubes", "Equipe profissional de ciclismo", "Equipes profissionais de ciclismo", "Equipe amadora de ciclismo", "Equipes amadoras de ciclismo", "Grupo esportivo I", "Grupos esportivos I", "Grupo esportivo II", "Grupos esportivos II", "Grupo esportivo III", "Grupos esportivos III", "Equipe mista", "Equipes mistas", "Equipe feminina profissional", "Equipes femininas profissionais", "Women's amateur cycling team", "Women's amateur cycling teams"},
["ro"] = {"Numele echipei", "Țară", "Cod", "WorldTeam", "WorldTeams", "ProTeam", "ProTeams", "Echipă continentală profesionistă", "Echipe continentale profesioniste", "Echipă continentală", "Echipe continentale", "Echipă națională", "Echipe naționale", "Echipă regională și de club", "Echipe regionale și de club", "Echipă ciclistă profesionistă", "Echipe cicliste profesioniste", "Echipă ciclistă de amatori", "Echipe cicliste de amatori", "Grup sportiv I", "Grupuri sportive I", "Grup sportiv II", "Grupuri sportive II", "Grup sportiv III", "Grupuri sportive III", "Echipă mixtă", "Echipe mixte", "Echipă feminină", "Echipe feminine", "Women's amateur cycling team", "Women's amateur cycling teams"},
["ru"] = {"Команда", "Страна", "Код", "[[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|Женские профессиональные команды]]", "Женская любительская велокоманда", "Женские любительские велокоманды"},
["ast"] = {"Nome del equipu", "País", "Códigu", "WorldTeam", "WorldTeams", "ProTeam", "ProTeams", "Equipu continental profesional", "Equipos continentales profesionales", "Equipu continental", "Equipos continentales", "Equipu nacional", "Equipos nacionales", "Equipu rexonal y de club", "Equipos rexonales y de clubes", "Equipu ciclista profesional", "Equipos ciclistes profesionales", "Equipu ciclista aficionáu", "Equipos ciclistes aficionaos", "Grupu deportivu I", "Grupos deportivos I", "Grupu deportivu II", "Grupos deportivos II", "Grupu deportivu III", "Grupos deportivos III", "Equipu mestu", "Equipos mestos", "Equipu femenín", "Equipos femeninos", "Equipu femenín de ciclismu amateur", "Equipos femeninos de ciclismu amateur"},
}
local l10n = l10nDef[wiki]
if not l10n then l10n = l10nDef["en"] end -- default
return l10n[x]
end
 
function headoftableIV(x) -- En-tête du tableau du palmarès d'une course cycliste
local l10nDef = {
["ar"] = {"السنة", "الفائز", "الثاني", "الثالث"},
["fr"] = {"Année", "Vainqueur", "Deuxième", "Troisième"},
["en"] = {"Year", "Winner", "Second", "Third"},
["br"] = {"Bloavezh", "1añ", "2l", "3de"},
["ca"] = {"Any", "Vencedor", "Segon", "Tercer"},
["cs"] = {"Ročník", "Vítěz", "Druhý", "Třetí"},
["da"] = {"År", "Vinder", "Toer", "Treer"},
["de"] = {"Jahr", "Sieger", "Zweiter", "Dritter"},
["eo"] = {"Jaro", "Venkinto", "Dua pozicio", "Tria pozicio"},
["es"] = {"Año", "Ganador", "Segundo", "Tercero"},
["eu"] = {"Urtea", "Irabazlea", "Bigarrena", "Hirugarrena"},
["fi"] = {"Vuosi", "Voittaja", "Toinen", "Kolmas"},
["fo"] = {"Ár", "Vinnari", "Nr. 2", "Nr. 3"},
["hu"] = {"Év", "Versenyző", "Második", "Harmadik"},
["it"] = {"Anno", "Vincitore", "Secondo", "Terzo"},
["ja"] = {"年", "優勝", "準優勝", "3位"},
["lb"] = {"Joer", "Gewënner", "Zweeten", "Drëtten"},
["lv"] = {"Gads", "Uzvarētājs", "Otrais", "Trešais"},
["mk"] = {"Година", "Победник", "Второпласиран", "Третопласиран"},
["nl"] = {"Jaar", "Winnaar", "Tweede", "Derde"},
["no"] = {"År", "Vinner", "Andreplass", "Tredjeplass"},
["pl"] = {"Rok", "Pierwsze", "Drugie", "Trzecie"},
["pt"] = {"Ano", "Vencedor", "Segundo", "Terceiro"},
["ro"] = {"An", "Câștigător", "Locul doi", "Locul trei"},
["ru"] = {"Год", "Победитель", "Второй", "Третий"},
["sr"] = {"Година", "Победник", "Други", "Трећи"},
["sv"] = {"År", "Vinnare", "Andra", "Tredje"},
["ast"] = {"Añu", "Ganador", "Segundu", "Terceru"},
}
return l10nDef[wiki][x]
end
 
function typeofstage(x, typ)
-- plain, hilly, inter, ... must be "" or "any text"
-- l10nDef[""] = {plain = "", hilly="", inter='', mount='', time_prologue='', time_team='', time_indiv='', uphill='', rest=''}
local l10nDef = {
["ar"] = {plain = "مرحلة مستوية", hilly="مرحلة التلال", inter='مرحلة متوسطة', mount='مرحلة جبلية', time_prologue='مرحلة سباق ضد الساعة', time_team='مرحلة سباق الفرق ضد الساعة', time_indiv='مرحلة سباق فردي ضد الساعة', uphill='مرحلة تسلق الجبل ضد الساعة', rest='يوم راحة'},
["fr"] = {plain = "étape de plaine", hilly="étape vallonnée", inter='étape de moyenne montagne', mount='étape de montagne', time_prologue='prologue', time_team='contre-la-montre par équipes', time_indiv='contre-la-montre individuel', uphill='contre-la-montre en côte', rest='étape de repos'},
["en"] = {plain = "plain stage", hilly="hilly stage", inter='intermediate stage', mount='mountain stage', time_prologue='time trial stage', time_team='team time trial stage', time_indiv='individual time trial stage', uphill='uphill time trial stage', rest='rest day'},
["br"] = {plain = "tennad plaen", hilly="tennad digompez", inter='tennad damveneziek', mount='tennad meneziek', time_prologue='', time_team='ABEU a-skipailhoù', time_indiv='ABEU', uphill='', rest='devezh diskuizh'},
["ca"] = {plain = "etapa plana", hilly="etapa accidentada", inter='etapa de mitja muntanya', mount='etapa de muntanya', time_prologue='pròleg', time_team='contrarellotge per equips', time_indiv='contrarellotge individual', uphill='', rest='etapa de descans'},
["cs"] = {plain = "rovinatá etapa", hilly="", inter='kopcovitá etapa', mount='horská etapa', time_prologue='prolog', time_team='týmová časovka', time_indiv='individuální časovka', uphill='', rest=''},
["da"] = {plain = "flad etape", hilly="kuperet etape", inter='middel bjergetape', mount='bjergetape', time_prologue='prolog', time_team='holdtidskørsel', time_indiv='enkeltstart', uphill='bjergenkeltstart', rest='hviledag'},
["de"] = {plain = "Flachetappe", hilly="Hügelige Etappe", inter='Mittelschwere Etappe', mount='Hochgebirgsetappe', time_prologue='Prolog', time_team='Teamzeitfahren', time_indiv='Einzelzeitfahren', uphill='Bergzeitfahren', rest='Ruhetag'},
["eo"] = {plain = "ebena etapo", hilly="malebena etapo", inter='mezgranda montaro etapo', mount='montara etapo', time_prologue='prologo', time_team='teama kontraux-la-kronometro', time_indiv='individua kontraux-la-kronometro', uphill='malebena kontraux-la-kronometro', rest='ripoza etapo'},
["es"] = {plain = "etapa llana", hilly="etapa escarpada", inter='etapa de media montaña', mount='etapa de montaña', time_prologue='prólogo', time_team='contrarreloj por equipos', time_indiv='contrarreloj individual', uphill='cronoescalada', rest='jornada de descanso'},
["eu"] = {plain = "etapa laua", hilly="etapa gorabeheratsua", inter='bitarteko etapa', mount='mendiko etapa', time_prologue='aitzinetapa', time_team='taldekako erlojupekoa', time_indiv='banakako erlojupekoa', uphill='erlojupeko igoera', rest='atseden eguna'},
["fi"] = {plain = "Tasamaaetappi", hilly="Mäkietappi", inter='Keskivaikea vuorietappi', mount='Vuorietappi', time_prologue='', time_team='Joukkueaika-ajo', time_indiv='Henkilökohtainen aika-ajo', uphill='mäkiaika-ajo', rest='välipäivä'},
["fo"] = {plain = "Slætt", hilly="Slætt við brúgvasteinum", inter='Óslætt', mount='Fjallateinur', time_prologue='Forteinur', time_team='Liðsúkkling', time_indiv='Einkultstartur', uphill='', rest='Hvílidagur'},
["hu"] = {plain = "sík szakasz", hilly="dombos szakasz", inter='közepes hegyi szakasz', mount='hegyi szakasz', time_prologue='prolog', time_team='csapat időfutam', time_indiv='egyéni időfutam', uphill='hegyi időfutam', rest=''},
["ja"] = {plain = "平坦ステージ", hilly="丘陵ステージ", inter='中間ステージ', mount='山岳ステージ', time_prologue='タイムトライアルステージ', time_team='チームタイムトライアルステージ', time_indiv='個人タイムトライアルステージ', uphill='アップヒルタイムトライアルステージ', rest='休養日'},
["lb"] = {plain = "Flaach Etapp", hilly="Hiwweleg Etapp", inter='Mëttelschwéier Etapp', mount='Biergetapp', time_prologue='Prolog', time_team='Contre-la-montre (Equipe)', time_indiv='Contre-la-montre (Eenzel)', uphill='Biergcourse', rest='Roudag'},
["lv"] = {plain = "līdzenuma posms", hilly="paugurains posms", inter='vidēju kalnu posms', mount='kalnu posms', time_prologue='individuālais brauciens', time_team='komandu brauciens', time_indiv='individuālais brauciens', uphill='individuālais brauciens kalnā', rest='atpūtas diena'},
["mk"] = {plain = "рамна етапа", hilly="ридеста етапа", inter='среднопланинска етапа', mount='планинска етапа', time_prologue='пролог', time_team='екипен хронометар', time_indiv='индивидуален хронометар', uphill='', rest='ден за одмор'},
["nl"] = {plain = "vlakke rit", hilly="heuvelrit", inter='heuvelrit', mount='bergrit', time_prologue='proloog', time_team='ploegentijdrit', time_indiv='individuele tijdrit', uphill='klimtijdrit', rest='rustdag'},
["no"] = {plain = "flat etappe", hilly="kupert etappe", inter='middels klatreetappe', mount='klatreetappe', time_prologue='prolog', time_team='lagtempo', time_indiv='temporitt', uphill='klatretempoetappe', rest='hviledag'},
["pl"] = {plain = "płaski", hilly="", inter='pagórkowaty', mount='górski', time_prologue='prologu', time_team='jazda drużynowa na czas', time_indiv='jazda indywidualna na czas', uphill='', rest=''},
["pt"] = {plain = "etapa plana", hilly="", inter='média montanha', mount='alta montanha', time_prologue='prólogo', time_team='contrarrelógio por equipes', time_indiv='contrarrelógio individual', uphill='', rest=''},
["ro"] = {plain = "etapă de plat", hilly="etapă valonată", inter='etapă intermediară', mount='etapă de munte', time_prologue='prolog', time_team='contratimp pe echipe', time_indiv='contratimp individual', uphill='', rest='zi de repaus'},
["ru"] = {plain = "равнинный", hilly="холмистый", inter='среднегорный', mount='горный', time_prologue='пролог', time_team='командная разделка', time_indiv='индивидуальная разделка', uphill='горная разделка', rest='день отдыха'},
["sv"] = {plain = "Flack etapp", hilly="", inter='Kuperat', mount='Bergsetapp', time_prologue='Prolog', time_team='Lagtempoetapp', time_indiv='Tempoetapp', uphill='', rest='Vilodag'},
["ast"] = {plain = "etapa llana", hilly="etapa escarpada", inter='etapa de mediu monte', mount='etapa de monte', time_prologue='prólogu', time_team='contrarreló per equipos', time_indiv='contrarreloj individual', uphill='cronoescalada', rest='xornada de descansu'},
}
local l10n = l10nDef[wiki]
if not l10n then l10n = l10nDef["en"] end -- default
 
if x=='plain stage' then return "[[File:Plainstage.svg|border|right|20px|"..l10n.plain.."]]" end
if x=='hilly stage' then return "[[File:Hillystage.svg|border|right|20px|"..l10n.hilly.."]]" end
if x=='intermediate stage' then return "[[File:Mediummountainstage.svg|right|border|20px|"..l10n.inter.."]]" end
if x=='mountain stage' then return "[[File:Mountainstage.svg|border|right|20px|"..l10n.mount.."]]" end
if x=='uphill time trial stage' then return "[[File:Mountain Time Trial Stage.svg|border|right|20px|"..l10n.uphill.."]]" end
if x=='rest day' then return "[[File:Stage rest day.svg|border|right|20px|"..l10n.rest.."]]" end
if x=='time trial stage' then
if typ==2348250 then return "[[File:Team Time Trial Stage.svg|right|20px|"..l10n.time_team.."]]" end
if typ==2266066 then return "[[File:Time Trial.svg|right|20px|"..l10n.time_indiv.."]]" end
if typ==485321 then return "[[File:Time Trial.svg|right|20px|"..l10n.time_prologue.."]]" end
end
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", ["ast"]="Prólogu"}
 
if l10nDef[wiki] ~= nil then return l10nDef[wiki] else return l10nDef["en"] end -- if no translation, show en translation
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", ["ast"]="etapa" }
 
local word1, word2
word2=l10nDef[wiki]
if word2 == nil then word2=l10nDef["en"] end -- if no translation, show en translation
local word = word2
 
if wiki=="ar" then return word2 .. " " .. ( a or "" ) , "#" .. word2 .. " " .. ( a or "" ) end
 
-- fr: {{1re}} étape, {{2e}} étape
if wiki=="fr" or wiki=="lb" then
if b == "" then -- series_ordinal without character
if a == "1" then word1 = "1<sup>re</sup> "..word else word1 = a.."<sup>e</sup> "..word end -- table text = {{1re}} étape, {{2ae}} étape,
if a == "1" then word2 = "#1re "..word else word2 = "#"..a.."e "..word end --text of section header = #1re étape, #2e étape
return word1, word2
end
if b ~= "" then -- series_ordinal with character: instead of eg "1a re" it is "1re a"
if a == "1" then word1 = "1<sup>re</sup> "..b.." "..word else word1 = a.."<sup>e</sup> "..b.." "..word end -- table text = {{1re}} étape, {{2ae}} étape,
if a == "1" then word2 = "#1re "..b.." "..word else word2 = "#"..a.."e"..b.." "..word end --text of section header = #1re étape, #2e étape
return word1, word2
end
end
if wiki=="de" or wiki=="da" or wiki=="fo" or wiki=="no" then return a..". "..b.." "..word, "#"..a..". "..b.." "..word end
if wiki=="ca" then return a.."a "..b.." "..word, "#"..a..". "..b.." "..word end
if wiki=="es" then return a..".<sup>a</sup> "..b.." "..word, "#"..a..". "..b.." "..word end
if wiki=="ast" then return a.."ª "..b.." "..word, "#"..a..". "..b.." "..word end
-- default
word1 = x -- table text = 1, 2a, 3
word2 = "#"..word.." ".. x -- text of section header = #Etappe 2a, #Stage 4
return word1, word2
end
 
--== V) Main functions
--=== A) Function race reference ===
local function race_reference(raceID)
-- Allow to display the reference below the classifications --
end
 
--=== B) Calendar ===
function Calendar_translate(wiki, x, title)
local l10nDef = {
["ar"] = { "تقويم الاتحاد الدولي للدراجات", "التاريخ", "#", "السباق", "البلد", "الصنف", "الفائز", "الثاني", "الثالث", "متصدر الترتيب العام", "طواف العالم للدراجات للنساء", "", "طواف العالم للدراجات" , "طواف أوروبا للدراجات" , "طواف آسيا للدراجات" , "طواف أمريكا للدراجات" , "طواف أفريقيا للدراجات" , "طواف أوقيانوسيا للدراجات", "بطولات وطنية", "سباق الطريق", "سباق فردي ضد الساعة" },
["fr"] = {"Calendrier UCI", "Date", "n°","Course", "Pays", "Classe", "Vainqueur", "Deuxième", "Troisième", "Leader du classement général","UCI Women's World Tour","","UCI World Tour","UCI Europe Tour","UCI Asia Tour","UCI America Tour","UCI Africa Tour","UCI Oceania Tour","Championnats nationaux","Course en ligne","Contre-la-montre"},
["en"] = {"UCI Calendar", "Date", "#","Race", "Country", "Class", "Winner", "Second", "Third", "Overall leader","UCI Women's World Tour","","UCI World Tour","UCI Europe Tour","UCI Asia Tour","UCI America Tour","UCI Africa Tour","UCI Oceania Tour","National championship","Road race","Individual time trial"},
["de"] = {"UCI Kalender", "Datum", "Nr.","Rennen", "Staat", "Klasse", "Sieger", "Zweiter", "Dritter", "Gesamt&shy;führender","UCI Women's World Tour","","UCI World Tour","UCI Europe Tour","UCI Asia Tour","UCI America Tour","UCI Africa Tour","UCI Oceania Tour","Nationale Straßen-Radsportmeister","Straßenrennen","Einzelzeitfahren"},
["da"] = {"","Dato", "#","Løb", "Land", "Klasse", "Vinder","Toer", "Treer", "Førende rytter","UCI Women's World Tour","","UCI World Tour","UCI Europe Tour","UCI Asia Tour","UCI America Tour","UCI Africa Tour","UCI Oceania Tour","Nationalt mesterskab","Landevej","Enkeltstart"},
["es"] = {"Calendario UCI", "Fecha", "#","Carrera", "País", "Clase", "Ganador","Segundo", "Tercero", "Líder","UCI Women's World Tour","","UCI World Tour","UCI Europe Tour","UCI Asia Tour","UCI America Tour","UCI Africa Tour","UCI Oceania Tour","Campeonato nacional","Carrera de ruta","Contrarreloj individual"},
["ja"] = {"", "開催日", "#","レース", "国", "国", "勝者","準優勝", "3位", "全体リーダー","UCI Women's World Tour","","UCI World Tour","UCI Europe Tour","UCI Asia Tour","UCI America Tour","UCI Africa Tour","UCI Oceania Tour","National championship","Road race","Individual time trial"},
["lv"] = {"", "Datums", "#","Sacensības", "Valsts", "Kategorija", "Uzvarētājs","Otrais", "Trešais", "Kopvērtējuma līderis","UCI Women's World Tour","","UCI World Tour","UCI Europe Tour","UCI Asia Tour","UCI America Tour","UCI Africa Tour","UCI Oceania Tour","National championship","Road race","Individual time trial"},
["mk"] = {"", "Датум","#", "Трка", "Земја", "Класа", "Победник", "Второпласиран", "Третопласиран", "Cевкупен лидер","UCI Women's World Tour","","UCI World Tour","UCI Europe Tour","UCI Asia Tour","UCI America Tour","UCI Africa Tour","UCI Oceania Tour","National championship","Road race","Individual time trial"},
["no"] = {"", "Dato", "#","Ritt", "Land", "Klasse", "Vinner", "Andreplass", "Tredjeplass", "Sammenlagt&shy;leder","UCI Women's World Tour","","UCI World Tour","UCI Europe Tour","UCI Asia Tour","UCI America Tour","UCI Africa Tour","UCI Oceania Tour","Nasjonalt mesterskap","Landevei","Tempo"},
["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"},
["he"] = {"UCI Calendar", "תאריך", "#","מרוץ", "מדינה", "Class", "מנצח", "שני", "שלישי", "Overall leader","UCI Women's World Tour","","UCI World Tour","UCI Europe Tour","UCI Asia Tour","UCI America Tour","UCI Africa Tour","UCI Oceania Tour","אלוף לאומי","Road race","Individual time trial"},
["ast"] = {"Calendariu UCI", "Data", "#","Carrera", "País", "Clas", "Ganador","Segundu", "Terceru", "Líder","UCI WorldTour Femenín 2018","","UCI WorldTour","UCI Europe Tour","UCI Asia Tour","UCI America Tour","UCI Africa Tour","UCI Oceania Tour","Campeonatu nacional","Carrera de ruta","Contrarreló individual"},
}
local l10n = l10nDef[wiki]
if not l10n then l10n = l10nDef["en"] end -- default
if x==1000 then --code
return title
else
return l10n[x]
end
end
 
function p.calendarcustom(frame)
----- function to display calendar óf any competition -----
----- based on victories function -----
----- author: psemdel -----
local countryflagonlytemp, numberingtemp, displayclasstemp,onlywinnertemp, displayteamtemp, displayleadertemp
local headertemp, data_typetemp={}, {}
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
calendarID= string.gsub(frame.args[1], "%c", "")
end
--date
headertemp[ll]=2
data_typetemp[ll] = ''
ll=ll+1
 
numberingtemp=false
if frame.args[2] ~= nil then
if frame.args[2] ~= nil and 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
countryflagonlytemp=true
if frame.args[3] ~= nil and tonumber(frame.args[3]) ==1 then countryflagonlytemp =false end
-- country --
headertemp[ll]=5
data_typetemp[ll] = ''
ll=ll+1
 
displayclasstemp =false
if frame.args[4] ~= nil then
if frame.args[4] ~= nil and 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 =false0
headertemp[ll]=7 --winner
data_typetemp[ll] = ''
ll=ll+1
headertemp[ll]=8 --second
data_typetemp[ll] = ''
ll=ll+1
headertemp[ll]=9 --third
data_typetemp[ll] = ''
ll=ll+1
else
onlywinnertemp =true1
headertemp[ll]=7
data_typetemp[ll] = ''
end
else
onlywinnertemp=true1
headertemp[ll]=7
data_typetemp[ll] = ''
ll=ll+1
end
 
displayleadertemp =false
if frame.args[6] ~= nil then
if frame.args[6] ~= nil and 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
 
displayteamtemp =false
if frame.args[7] ~= nil then
if frame.args[7] ~= nil and tonumber(frame.args[7]) ==1 then displayteamtemp =true end
local titletemp=wikibase.getLabel(calendarID)
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_translatecalendar_translate, -- translations are in function victories_translateCalendar_translate
header_1 = 1000, -- translation 1 in function victories_translateCalendar_translate is printed in the upper part of the table header
header_2 = headertemp,-- translations 2, 3, 4, 5, 6 in function victories_translateCalendar_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,
displayclass=displayclasstemp,
leadercolumn=displayleadertemp,
frame=frame
 
}
return tableA(s, calendar_main(s))
----- author: Mr. Ibrahem -----
local calendarID = ""
if wiki == "ar" then frame = frame:getParent() end
frame = frame:getParent()
end
UCI = {}
UCI["WT"] = { -- Q635366
['20182019'] = 'Q42317185Q56966729',['20172018'] = 'Q21857932Q42317185',['20162017'] = 'Q20970765Q21857932',
['20152016'] = 'Q18192726Q20970765',['20142015'] = 'Q14979277Q18192726',['20132014'] = 'Q1031504Q14979277',
['2013'] = 'Q1031504',['2012'] = 'Q849059', ['2011'] = 'Q849092'
}
UCI["europe"] = { -- Q1194340
['20182019'] = 'Q44497477Q57267776',['20172018'] = 'Q27915850Q44497477',['20162017'] = 'Q21029681Q27915850',
['20152016'] = 'Q18342122Q21029681',['20142015'] = 'Q15041668Q18342122',['20132014'] = 'Q1280387Q15041668',
['20122013'] = 'Q961709Q1280387',['2010–112012'] = 'Q751208Q961709',['2009–102010–11'] = 'Q212197Q751208',
['2008–092009–10'] = 'Q1811548Q212197',['2007–082008–09'] = 'Q1788011Q1811548',['2006–072007–08'] = 'Q1780660Q1788011',
['2006–07'] = 'Q1780660',['2005–06'] = 'Q1455600',['2005'] = 'Q1431816'
}
UCI["asia"] = { -- Q1063423
['20182019'] = 'Q42204070Q57267783',['20172018'] = 'Q27679728Q42204070',['20162017'] = 'Q21622227Q27679728',
['20152016'] = 'Q18341318Q21622227',['2013–142015'] = 'Q15041671Q18341318',['2012–132013–14'] = 'Q1606048Q15041671',
['2011–122012–13'] = 'Q2117797Q1606048',['2010–112011–12'] = 'Q633349Q2117797',['2009–102010–11'] = 'Q630798Q633349',
['2008–092009–10'] = 'Q565160Q630798',['2007–082008–09'] = 'Q1506934Q565160',['2006–072007–08'] = 'Q966011Q1506934',
['2006–07'] = 'Q966011',['2005–06'] = 'Q459817',['2005'] = 'Q469479',
}
UCI["america"] = { -- Q1063430
['20182019'] = 'Q42199340Q57267780',['20172018'] = 'Q27704415Q42199340',['20162017'] = 'Q21621040',['2015'] = 'Q18413668Q27704415',
['2013–142016'] = 'Q15041669Q21621040',['2012–132015'] = 'Q129177Q18413668',['2011–122013–14'] = 'Q1239608',['2010–11'] = 'Q1849269Q15041669',
['2009–102012–13'] = 'Q1303982Q129177',['2008–092011–12'] = 'Q1536927Q1239608',['2007–082010–11'] = 'Q31716',['2006–07'] = 'Q31714Q1849269',
['2005–062009–10'] = 'Q1429246Q1303982',['20052008–09'] = 'Q1431880Q1536927',['2007–08'] = 'Q31716',
['2006–07'] = 'Q31714',['2005–06'] = 'Q1429246',['2005'] = 'Q1431880',
}
UCI["africa"] = { -- Q268357
['20182019'] = 'Q42202027Q57267785', ['20172018'] = 'Q27679848Q42202027', ['20162017'] = 'Q21622217Q27679848',
['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',
}
UCI["oceania"] = { -- Q1039648
['20182019'] = 'Q42205000Q57267787', ['20172018'] = 'Q27887426Q42205000', ['20162017'] = 'Q21559636Q27887426',
['20152016'] = 'Q18413671Q21559636', ['20142015'] = 'Q15246814Q18413671', ['20132014'] = 'Q129134Q15246814',
['2011–122013'] = 'Q1591132Q129134', ['20112011–12'] = 'Q2298207Q1591132', ['2009–102011'] = 'Q665283Q2298207',
['2008–092009–10'] = 'Q964517Q665283', ['2007–082008–09'] = 'Q1788621Q964517', ['2006–072007–08'] = 'Q1473640Q1788621',
['2006–07'] = 'Q1473640',['2005–06'] = 'Q1429165', ['2005'] = 'Q937636',
}
 
UCI["WWT"] = {
['20182019'] = 'Q41787783Q57277246', ['20172018'] = 'Q27431192Q41787783', ['20162017'] = 'Q21034783Q27431192',
['2016'] = 'Q21034783',
}
 
UCI["women"] = {
['20182019'] = 'Q47005682Q57267790', ['20172018'] = 'Q27765666Q47005682', ['20162017'] = 'Q22696468Q27765666',
['20152016'] = 'Q18348936Q22696468', ['20142015'] = 'Q15831496Q18348936', ['20132014'] = 'Q6425932Q15831496',
['20122013'] = 'Q2466796Q6425932', ['20112012'] = 'Q2466792Q2466796', ['20102011'] = 'Q2933831Q2466792',
['20092010'] = 'Q2933830Q2933831', ['20082009'] = 'Q2933828Q2933830', ['20072008'] = 'Q3650627Q2933828',
['2007'] = 'Q3650627', ['2006'] = 'Q16154659',
}
 
data_sort_type_code1={'', 'unsortable', '', '', '','',''}
data_sort_type_code2={'', 'unsortable', '', '', '','',''}
only_winner_code1 = false0
only_winner_code2 = true1
numbering_code1= true
numbering_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", "")
header_1_number = header_1_tab[key]
display_code=display_code_tab[key]
end
if wiki == "ar" and frame.args["code"] and frame.args["code"] ~= "" then
display_code = 1
end
end
 
local s = {
header_function = Calendar_translatecalendar_translate, -- translations are in function victories_translateCalendar_translate
header_1 = header_1_number, -- translation 12 in function victories_translate is emptyt
header_2 = header_2temp,--
 
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,
displayteam=displayteamtemp,
displayclass=displayclasstemp,
leadercolumn=leadercolumntemp,
frame=frame
}
return tableA(s, calendar_main(s))
end
 
function calendar_main(s)--Display the UCI women calendar of one year, function similar to listofwinners
localframe=s.frame
local calendarID=s.item
local hsortkey_class, = {}sortkey
local country = s.country
local countryflagonly= s.countryflagonly
local sortkey, sortkey_class
local tBody = ''
local tableBody, sortindex = {}, {}
local a1timeofrace, b1, c1displayed_class
if displayed_class==nil then displayed_class=class else displayed_class=s.displayed_class end
local timeofrace
local displayed_class
local displayteam
local numbering
 
local temp=firstValue(calendarID, s.property)
if displayed_class==nil then
if temp then else s.error_message = 2 return '' end
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 )
 
----- Begin of the main part of the code
pcall(function() test = entity.claims[s.property][1].mainsnak.snaktype end)
if calendarID ~= nil then
if test == 'somevalue' or test == 'novalue' then s.error_message = 2 return '' end
local kk=0
local fn_racetable,fn_datetable, fn_countrytable ={}, {},{}
 
for _, p527 in statements(calendarID, 'P527') do
if pcall(function() test = entity.claims[s.property][1].mainsnak.datavalue.value['numeric-id'] end)
RaceID = p527.mainsnak.datavalue.value.id
then else s.error_message = 1 return ''
---- Create a row ----
end
fn_racetable=fn_race(RaceID,displayed_class,s.displayclass)
 
if fn_racetable[1]~=nil then --otherwise the class is not display
for _, value in pairs(s.no_country) do -- get data if country should be printed in this wiki
tBody = '<tr style= "line-height: 1.8em; padding: 5px;">'
if value == wiki then country = false end
fn_datetable=fn_date(RaceID)
end
dateOfRace=fn_datetable[1]
 
tBody = tBody..fn_datetable[2]
--------- Definition local functions ------
sortkey=fn_datetable[3]
function fn_date(h,entity_race) --write all the end of the race
kk=kk+1 --only if displayed
local i
if s.numbering==true then
sortkey=''
tBody = tBody..'<td style="text-align:center;padding:0 0.5em">'..tostring(kk).. '</td>'
--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
if s.country == true then
local _, _, y, m, d = string.find(e1, "(%d+)%p(%d+)%p(%d+)")
fn_countrytable=fn_country(RaceID,dateOfRace,s.countryflagonly,fn_racetable[3]) --fn_racetable[1] is parentID
h['endmonth']=m
tBody = tBody..fn_countrytable[1]
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
tBody = tBody..fn_racetable[1]
break
if fn_racetable[2] then tBody = tBody..fn_racetable[2] end
end
tBody = tBody..fn_rider(RaceID,dateOfRace,s.displayteam,s.only_winner)
end
if s.leadercolumn==true then
for _,property in ipairs({"P580","P585"}) do
tBody = tBody..fn_rider(RaceID,dateOfRace,s.displayteam,3)
-- 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
tBody = tBody.. '</tr>'
local _, _, y, m, d = string.find(b1, "(%d+)%p(%d+)%p(%d+)")
---- Add the row to the table
h['beginmonth']=m
local number = table.getn(tableBody)
if m ~= '00' and d =='00'
--Insertion sort
then
if number == 0 then
sortkey = y..m..'32' h['time'] = mw.language.getContentLanguage():formatDate("M", '+'..y.."-"..m.."-31")
table.insert(sortindex, sortkey)
if wiki == "ar" then sortkey = y..m..'32' h['time'] = mw.language.getContentLanguage():formatDate("F", '+'..y.."-"..m.."-31") end
table.insert(tableBody, tBody)
elseif m == '00' and d =='00' then sortkey = y..'12'..'32' h['time'] = ''
elseelseif sortkey >= y..m..dsortindex[number] then
table.insert(sortindex, sortkey)
if h['endtime']=='' then --if no end date then show the month
table.insert(tableBody, tBody)
h['time'] = func_date (b1, 'small')
else --otherwise only day
local done=0
if h['beginmonth']==h['endmonth'] then
for i=number,2,-1 do
h['time'] = func_date (b1, 'onlyday')--d
if sortkey >= sortindex[i] then
else
table.insert(sortindex, i+1, sortkey)
h['time'] = func_date (b1, 'small')
table.insert(tableBody, i+1, tBody)
done=1
break
end
end
if done==0 then --case that the new one is the first
end
table.insert(sortindex, 1, sortkey)
timeofrace = b1
table.insert(tableBody, 1, tBody)
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
return table.concat (tableBody)
 
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
 
--[[ Get a label in any of the languages in the fallback list of language codes ]]
local function getLabelFallback(itemID, fallback)
local label
for _, lang in ipairs(fallback) do
label = mw.wikibase.getLabelByLang(itemID, lang)
if label then break end
end
return label
end
 
--[[ Get a sitelink from the local wiki or from the fallback list of language codes ]]
local function getSitelinkFallback(itemID, fallback)
local link = mw.wikibase.getSitelink(itemID)
if link then return link end
for _, lang in ipairs(fallback) do
link = mw.wikibase.getSitelink(itemID, lang .. 'wiki')
if link then return link end
end
return nil
end
 
--[[ Get start time of race as a timevalue ('+2016-01-01T00:00:00Z') or nil ]]
local function getTimeOfRace (raceID)
local timeOfRace
local p580 = mw.wikibase.getBestStatements(raceID, "P580") -- P580 is start time
if p580[1] and p580[1].mainsnak.snaktype == 'value' then
timeOfRace = p580[1].mainsnak.datavalue.value.time
else
local p585 = mw.wikibase.getBestStatements(raceID, "P585") -- P585 is point in time
if p585[1] and p585[1].mainsnak.snaktype == 'value' then
timeOfRace = p585[1].mainsnak.datavalue.value.time
else
local link = getSitelinkFallback(raceID, {'en', 'fr', 'de'})
if link then
local year = string.match(link, '%d%d%d%d')
if year then
timeOfRace = year .. '-01-01T00:00:00Z'
end
end
end
end
return timeOfRace, '> Wikidata is missing data about start time (P580) or point in time (P582)'
end
 
UCI = {}
UCI["women"] = {
['2018'] = 'Q47088675Q43920899', ['2017'] = 'Q28005879', ['2016'] = 'Q22021840',
['2015'] = 'Q19296998', ['2014'] = 'Q15621925', ['2013'] = 'Q3339162',
['2012'] = 'Q1333003', ['2011'] = 'Q1143844', ['2010'] = 'Q1568490',
 
local s = {
header_function = Calendar_translatecalendar_translate, -- translations are in function victories_translateCalendar_translate
header_1 = 19, --
header_1 = 19, -- translation 1 in function victories_translate is printed in the upper part of the table header
header_2 = {5, 20, 21},
 
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,
item = calendarID,
property = 'P527',
year = year,
mode=modetemp,
no_country = {},
error_message = 0,
displayteam=true,
frame=frame
}
return tableA(s, nationalchampionships_main(s))
end
 
function nationalchampionships_main(s)--Display the UCIlist womenof calendarnational ofchampions for one year, function similar to listofwinners
localframe=s.frame
local calendarID=s.item
local hsortkey_class, =tRoadrace, {}tITT
local sortkey, sortkey_class
local tBody = ''
local tableBody, sortindex = {}, {}
local a1, b1, c1
local temp=firstValue(calendarID, s.property)
local timeofrace
if temp then else s.error_message = 2 return '' end
local displayteam
local country=true --otherwise makes no sence
 
if calendarID ~= nil then
displayteam=s.displayteam
local championshipID, RaceIDRoadrace, sortkey
----- Test if everything is fine -----
local fn_datetable, fn_countrytable ={}, {}
_, _, s.item = string.find(s.item, "(%w+)")
local entity = mw.wikibase.getEntityObject(s.item )
 
for _, p527 in statements(calendarID, 'P527') do
pcall(function() test = entity.claims[s.property][1].mainsnak.snaktype end)
championshipID = p527.mainsnak.datavalue.value.id
if test == 'somevalue' or test == 'novalue' then s.error_message = 2 return '' end
tRoadrace=''
 
tITT=''
if pcall(function() test = entity.claims[s.property][1].mainsnak.datavalue.value['numeric-id'] end)
for _, p527bis in statements(championshipID, 'P527') do
then else s.error_message = 1 return ''
RaceID = p527bis.mainsnak.datavalue.value.id
end
Racelabel= mw.wikibase.getLabelByLang(RaceID,"fr")
 
if Racelabel~=nil then
for _, value in pairs(s.no_country) do -- get data if country should be printed in this wiki
Racelabelmod=mw.ustring.gsub( Racelabel, '-', 'x' )
if value == wiki then country = false end
testMenRoadrace=string.find( Racelabel, 'Course en ligne masculine aux' )
end
testMenITT=string.find( Racelabelmod, 'Contrexlaxmontre masculin aux' )
 
testWomenRoadrace=string.find( Racelabel, 'Course en ligne féminine aux' )
--------- Definition local functions ------
testWomenITT=string.find( Racelabelmod, 'Contrexlaxmontre féminin aux' )
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
--fn_datetable[3] ~= nil then year =fn_datetable[3] end--otherwise keep the old one
end
if s.mode=="women" then
end
if testWomenRoadrace ~= nil then tRoadrace=fn_rider(RaceID,s.year,s.displayteam,1) end
--no stage in UCI calendar
if testWomenITT ~= nil then tITT=fn_rider(RaceID,s.year,s.displayteam,1) end
end
else--men
if testMenRoadrace ~= nil then tRoadrace=fn_rider(RaceID,year,s.displayteam,1) end
if testMenITT ~= nil then tITT=fn_rider(RaceID,s.year,s.displayteam,1)end
end
fn_countrytable=fn_country(RaceID,dateOfRace,s.countryflagonly)
sortkey=mw.ustring.gsub(fn_countrytable[2],'É','E') --case États Unis
 
end
local function fn_country(h)
tBody = '<tr style= "line-height: 1.8em; padding: 5px;">'
local str
if available_listfn_countrytable[1]==true and country == truenil then
tBody='<td></td>'..tRoadrace..tITT --
fn2_country()
else
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>'
tBody=fn_countrytable[1]..tRoadrace..tITT
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 tBody = '<td>'..''tBody.. '</tdtr>'
end
return str
end
 
---- Add the row to the table
local function fn_rider(h,entity_race,displayteam)
local qualnumber = table.getn(tableBody)
--Insertion sort
local winner= ''
if number == 0 then
local winner_flag=''
table.insert(sortindex, sortkey)
local propertyID=20882667
table.insert(tableBody, tBody)
 
elseif sortkey >= sortindex[number] then
a, b = pcall(fooC, 'numeric-id', entity_race, 'P1346', 1, 'P642', 1)
table.insert(sortindex, sortkey)
if a == true then
table.insert(tableBody, tBody)
winner = '' winner_flag = ''
else
for k, v in ipairs(entity_race.claims["P1346"]) do
local done=0
for kk, vv in ipairs(v.qualifiers['P642']) do
for i=number,2,-1 do
if vv.datavalue.value['numeric-id'] == propertyID then -- overall winner general classification
if sortkey >= sortindex[i] then
winner = 'Q'.. v.mainsnak.datavalue.value['numeric-id']
table.insert(sortindex, i+1, sortkey)
table.insert(tableBody, i+1, tBody)
done=1
break
end
end
if done==0 then --case that the new one is the first
end
table.insert(sortindex, 1, sortkey)
--no need for winner flag, it is clear
table.insert(tableBody, 1, tBody)
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
end--this championship
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
 
--=== C) Victory ===
 
function victories_translate(wiki, x)
local l10nDef = {
["ar"] = {"التصنيف العام", "سجل الفوز", "التاريخ", "السباق", "البلد", "الصنف", "الفائز"},
["fr"] = {"Classement général", "Victoires", "Date", "Course", "Pays", "Classe", "Vainqueur"},
["en"] = {"General classification", "Victories", "Date", "Race", "Country", "Class", "Winner"},
["de"] = {"Gesamtwertung", "Siege", "Datum", "Rennen", "Staat", "Klasse", "Sieger"},
["da"] = {"Samlede stilling", "Sejre", "Dato", "Løb", "Land", "Klasse", "Vinder"},
["es"] = {"Clasificación general", "Victorias", "Fecha", "Carrera", "País", "Clase", "Ganador"},
["ja"] = {"General classification", "Victories", "開催日", "レース", "国", "国", "勝者"},
["lv"] = {"Kopvērtējums", "Uzvaras", "Datums", "Sacensības", "Valsts", "Kategorija", "Uzvarētājs"},
["mk"] = {"General classification", "Victories", "Датум", "Трка", "Земја", "Класа", "Победник"},
["no"] = {"Sammenlagt", "Seire", "Dato", "Ritt", "Land", "Klasse", "Vinner"},
["ru"] = {"Генеральная классификация", "Победы", "Дата", "Гонка", "Страна", "Класс", "Победитель"},
["ast"] = {"Clasificación xeneral", "Victories", "Data", "Carrera", "País", "Clas", "Ganador"}
}
local l10n = l10nDef[wiki]
if not l10n then l10n = l10nDef["en"] end -- default
return l10n[x]
end
 
function func_error_message(wiki,x)
local l10nDef = {
["en"] = {'Property <1> is missing in item "<2>" (<3>)'},
["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 = {
data_type = {'date', 'race', 'country', 'class', 'rider'},
country_column = 3,
countryflagonly=false,
flag_column = 2,
data_sort_type = {'', 'unsortable', '', '', ''}, -- see https://meta.wikimedia.org/wiki/Help:Sorting
property = 'P2522',
no_country = {},
error_message = 0,
frame=frame
}
return tableA(s, victory_main(s, Qnumber))
 
function victory_main(s, Qnumber)
localframe=s.frame
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 )
 
local temp=firstValue(s.item, s.property,'id')
pcall(function() test = entity.claims[s.property][1].mainsnak.snaktype end)
if testtemp ==then 'somevalue' or test == 'novalue' thenelse 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
local sortkey, sortkey_class
local tBody = ''
local tableBody, sortindex, fn_countrytable, fn_datetable, fn_racetable = {}, {}, {}, {}, {}
local a1, b1, c1
local timeofrace
 
for l_, mp2522 in pairsstatements(entity.claims[s.property]item, 'P2522') do -- look into all statements
RaceID = p2522.mainsnak.datavalue.value.id
h['time'] = '' h['countryID'] = '' h['countryName'] = ''
h['raceID'] = 'Q'.. m.mainsnak.datavalue.value['numeric-id']
tBody = '<tr style= "line-height: 1.8em; padding: 5px;">' -- start the table row
h['item1ID'] = h['raceID'] h['item2ID'] = '' h['item3ID'] = ''
fn_datetable=fn_date(RaceID, 'victory')
local entity_race = mw.wikibase.getEntityObject( h['raceID'] )
dateOfRace=fn_datetable[1]
 
sortkey=fn_datetable[2]
local function fn2_country()
fn_racetable=fn_race(RaceID,nil ,true, 'victory')--displayed_class=nil
local raceID
if fn_racetable[1]~= nil then --otherwise class not to be displayed
local a, b = timeStartEnd(h['raceID'], "P17", 'numeric-id', timeofrace)
tBody = tBody..fn_datetable[2]
if a == true then
tBody = tBody..fn_racetable[1]
h['countryID'] = 'Q'..b
if available_list == true and country == true then
fn_countrytable=fn_country(RaceID,dateOfRace,s.countryflagonly,fn_racetable[3]) --fn_racetable[3] is parentID
if type( translations.list ) == "function" then h['countryName'] = translations.list('Q'..b) h['countryID'] = 'Q'..b end
tBody = tBody..fn_countrytable[1]
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
tBody = tBody..fn_racetable[2]
end
tBody = tBody..fn_rider(RaceID,dateOfRace,false,1)
 
tBody = tBody.. '</tr>' -- end the table row
local function fn_date(h)
local p = entity_race:getBestStatements('P582') --P582 is end time
local number = table.getn(tableBody)
if not p[1] then
--Insertion sort
p = entity_race:getBestStatements('P585') -- P582 is time in time
if number == 0 then
end
table.insert(sortindex, sortkey)
if not p[1] then
table.insert(tableBody, tBody)
p = entity_race:getBestStatements('P580') -- P582 is start time
elseif sortkey >= sortindex[number] then
end
table.insert(sortindex, sortkey)
if not p[1] then
table.insert(tableBody, tBody)
sortkey = '9999'
else
local done=0
timeofrace = p[1].mainsnak.datavalue.value.time
for i=number,2,-1 do
local _, _, y, m, d = string.find(timeofrace, "(%d+)%p(%d+)%p(%d+)")
if dsortkey ~>= '00'sortindex[i] then
table.insert(sortindex, i+1, sortkey)
sortkey = y..m..d
table.insert(tableBody, i+1, tBody)
h.time = func_date(timeofrace, 'small')
done=1
elseif m ~= '00' then
sortkey = y..m..'32'
if wiki == "ar" then
h.time = mw.language.getContentLanguage():formatDate('F', '+'..y..'-'..m..'-01')
else
h.time = mw.language.getContentLanguage():formatDate('M', '+'..y..'-'..m..'-01')
end
else
sortkey = y..'12-32'
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", ["ast"]="etapa"}
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" or wiki=="ru" 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
elseif wiki=="ast" 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" ,["ast"]="Prólogu"}
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" or wiki=="ru" 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
if done==0 then --case that the new one is the first
end
table.insert(sortindex, 1, sortkey)
end
table.insert(tableBody, 1, tBody)
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
 
--== D) Stage infobox
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 = {
["fr"] = {"Généralités", "Course", "Type", "Date", "Dates", "Distance", "Pays", "Pays", "Lieu de départ", "Lieu d'arrivée", "Partants",
"Arrivants", "Vitesse moyenne", "Coût", "Résultats de l’étape", "Vainqueur", "Deuxième", "Troisième", "Combatif",
"Classement général à l’issue de l’étape", "Leader", "Deuxième", "Troisième",
"Classements annexes à l’issue de l’étape", "Points", "Montagne", "Sprints", "Jeune", "Super- combatif", "Combiné", "Étapes volantes", "Régularité",
"Équipe", "Équipe aux points",
"Image", "Légende", "Carte", "Vue en coupe", "Documentation", "Cima Coppi", "Cima Pantani", "Azzurri d'Italia", "Fuga"},
["ar"] = {"تفاصيل السباق", "سباق", "نوع", "تاريخ", "تاريخ", "مسافة", "بلد", "بلدان", "نقطة البداية", "نقطة النهاية", "الدراجين في البداية",
"الدراجين في النهاية", "متوسط السرعة", "الكلفة", "نتائج المرحلة", "الفائز", "الثاني", "الثالث", "متمرس",
"التصنيف العام بعد المرحلة", "القائد", "الثاني", "الثالث",
"التصنيفات الثانوية بعد المرحلة", "النقاط", "الجبل", "سباقات السرعة", "شاب", "تصنيف القتال", "ممتزجة", "سباقات السرعة", "الانتظام",
"فريق", "فريق حسب النقاط", "صورة", "أسطورة", "بطاقة", "عرض الاقسام", "توثيق",
"سيما كوبي", "سيما بانتاني", "أزوري دي إيطاليا", "فوجا بيناريلو"},
["en"] = {"Race details", "Race", "Type", "Date", "Dates", "Distance", "Country", "Countries", "Journey origin", "Lieu d'arrivée", "Starting riders",
"Arriving riders", "Average speed", "Cost", "Stage results", "Winner", "Second", "Third", "Combative",
"General classification after stage", "Leader", "Second", "Third",
"Secondary classifications after stage", "Points", "Mountain", "Sprints", "Young", "Combativity", "Combinated", "Intermediate sprints", "Regularity",
"Team", "Team by points",
"Image", "Legend", "Card", "Sectional view", "Documentation", "Cima Coppi", "Cima Pantani", "Azzurri d'Italia", "Breakaway"},
["ja"] = {"レース詳細", "レース", "種類", "日付", "日付", "距離", "国", "国", "スタート", "ゴール", "スタート選手",
"ゴール選手", "平均速度", "Cost", "ステージ結果", "優勝", "2位", "3位", "Combative",
"ステージ後クラス", "1位", "2位", "3位",
"ステージ後副次的クラス", "ポイント賞", "山岳賞", "スプリント賞", "新人賞", "敢闘賞", "コンビネーション賞", "Metas volantes", "Regularity",
"チーム", "ポイント順位",
"画像", "凡例", "カード", "断面図", "ドキュメンテーション", "Cima Coppi", "Cima Pantani", "Azzurri d'Italia", "Breakaway"},
["ca"] = {"Detalls de la cursa", "Cursa", "Tipus", "Data", "Dates", "Distància", "País", "Països", "Origen de la cursa", "Lloc d’arribada", "Corredors sortits",
"Corredors arrivats", "Velocitat mitjana", "Duració", "Resultats de l’etapa", "Guanyador", "Segon", "Tercer", "Combatiu",
"Classificació general després de l'etapa", "Líder", "Segon", "Tercer",
"Classificacions secundàries després de l'etapa ", "Punts", "Muntanya", "Esprints ", "Jove", "Combativitat", "Combinada", "Metes volants", "Regularitat",
"Equip", "Equip per punts",
"Image", "Legend", "Card", "Sectional view", "Documentation", "Cima Coppi", "Cima Pantani", "Azzurri d'Italia", "Fuga"},
["da"] = {"Etapedetaljer", "Rute", "Type", "Dato", "Datoer", "Distance", "Land", "Lande", "Startby", "Målby", "Startende ryttere",
"Fuldførende ryttere", "Gennemsnitlig fart", "Omkostninger", "Etaperesultat", "Vinder", "Toer", "Treer", "Mest angrebsivrige",
"Samlede stilling efter etapen", "Førende rytter", "Toer", "Treer",
"Klassementerne efter etapen", "Point", "Bjerg", "Sprint", "Ungdom", "Mest angrebsivrige", "Kombination", "Indlagt spurt", "Regularitet",
"Hold", "Hold efter point",
"Billede", "Billedtekst", "Kort", "Profil", "Dokumentation", "Cima Coppi", "Cima Pantani", "Azzurri d'Italia", "Breakaway"},
["es"] = {"Detalles de la carrera", "Carrera", "Tipo", "Fecha", "Fechas", "Distancia", "País", "Países", "Lugar de inicio", "Lugar de llegada", "Ciclistas participantes",
"Ciclistas finalizados", "Velocidad media", "Duración", "Resultados de la etapa", "Ganador", "Segundo", "Tercero", "Combativo",
"Clasificación general después de la etapa", "Líder", "Segundo", "Tercero",
"Clasificaciones secundarias despúes de la etapa", "Puntos", "Montaña", "Esprint", "Joven", "Combatividad", "Combinada", "Metas volantes", "Regularidad",
"Equipo", "Equipo por puntos",
"Imagen", "Leyenda", "Card", "Sectional view", "Documentation", "Cima Coppi", "Cima Pantani", "Azzurri d'Italia", "Fuga"},
["fo"] = {"Smálutir um kapping", "Kapping", "Slag", "Dagur", "Dagar", "Fjarstøða", "Land", "Lond", "Byrjunarbýur", "Málbýur", "Byrjandi súkklarar",
"Fullførandi súkklarar", "Miðalferð", "Kostnaður", "Teinaúrslit", "Vinnari", "Annað pláss", "Triðja pláss", "Álopsheiður",
"Høvuðskappingin eftir teinin", "Førandi súkklari", "Tveyari", "Tríari",
"Aðrar kappingar eftir teinin", "Stig", "Fjøll", "Spurtar", "Ungdóms", "Álopsheiður", "Kombinatiónsheiður", "Metas volantes", "Regularitetur",
"Lið", "Lið eftir stigum",
"Mynd", "Myndatekstur", "Kort", "Brotpartur", "Skjalfesting", "Cima Coppi", "Cima Pantani", "Azzurri d'Italia", "Breakaway"},
["lb"] = {"Allgemenges", "Course", "Typ", "Datum", "Datumer", "Distanz", "Land", "Land", "Depart", "Arrivée", "Um Start",
"Ukomm", "Vitess-moyenne", "Käschten", "Résultater vun der Etapp", "Gewënner", "Zweeten", "Drëtten", "Combativ",
"Generalklassement no der Etapp", "Éischten", "Zweeten", "Drëtten",
"Aner Klassementer no der Etapp", "Punkten", "Bierg", "Sprint", "Bescht Jonken", "Super- combativ", "Combiné", "Fligend Etappen", "Regelméissegkeet",
"Equipe", "Equipe no Punkten",
"Fichier", "Legend", "Kaart", "Profil", "Dokumentatioun", "Cima Coppi", "Cima Pantani", "Azzurri d'Italia", "Breakaway"},
["no"] = {"Etappedetaljer", "Etappe", "Type", "Dato", "Datoer", "Distanse", "Land", "Land", "Startsted", "Målsted", "Startende ryttere",
"Fullførende ryttere", "Snittfart", "Omkostninger", "Etapperesultat", "Vinner", "Andre", "Tredje", "Offensiv",
"Sammenlagtstilling etter etappen", "Sammenlagtleder", "Andre", "Tredje",
"Klassifisering etter etappen", "Poeng", "Klatring", "Spurt", "Ungdom", "Offensiv", "Kombinasjon", "Innlagte spurter", "Regularitet",
"Lag", "Lag (poeng)",
"Bilde", "Bildetekst", "Kart", "Profil", "Dokumentasjon", "Cima Coppi", "Cima Pantani", "Azzurri d'Italia", "Brudd"},
["pt"] = {"Detalhes da corrida", "Corrida", "Tipo", "Data", "Datas", "Distância", "País", "Países", "Origem da viagem", "Local de chegada", "Partida dos ciclistas",
"Chegada dos ciclistas", "Velocidade média", "Custo", "Resultados da etapa", "Vencedor", "Segundo", "Terceiro", "Combativo",
"Classificação geral após a etapa", "Líder", "Segundo", "Terceiro",
"Classificação secundária após a etapa", "Pontos", "Montanha", "Corridas de velocidade", "Jovem", "Combatividade", "Combinados", "Metas volantes", "Regularidade",
"Equipe", "Equipe por pontos",
"Imagem", "Legenda", "Ficha", "Vista secional", "Documentação", "Cima Coppi", "Cima Pantani", "Azzurri d'Italia", "Fuga"},
["nl"] = {"Race details", "Wedstrijd", "Soort", "Datum", "Datums", "Afstand", "Land", "Landen", "Start van de etappe", "Aankomstplaats", "Coureurs aan de start",
"Coureurs bij de finish", "Gemiddelde snelheid", "Kosten", "Etappeuitslag", "Winnaar", "Tweede", "Derde", "Combative",
"Algemeen klassement na de etappe", "Leider", "Tweede", "Derde",
"Bijkomende uitslagen na de wedstrijd", "Punten", "Berg", "Sprints", "Jongeren", "Combativity", "Combinatie", "Metas volantes", "Regularity",
"Team", "Team by points",
"Afbeelding", "Legend", "Card", "Sectional view", "Documentation", "Cima Coppi", "Cima Pantani", "Azzurri d'Italia", "Breakaway"},
["ru"] = {"Детали гонки", "Гонка", "Тип", "Дата", "Даты", "Дистанция", "Страна", "Страны", "Место старта", "Место финиша", "Стартовало гонщиков",
"Финишировало гонщиков", "Средняя скорость", "Затраты", "Результаты этапа", "Победитель", "Второй", "Третий", "Боец",
"Генеральная классификация после этапа", "Лидер", "Второй", "Третий",
"Классификации после этапа", "Очки", "Горная", "Спринтерская", "Молодёжная", "Бойцовская", "Комбинированная", "Промежуточные финиши", "Регулярность",
"Командная по времени", "Командная по очкам",
"Изображение", "Описание", "Карта", "Сектора", "Документация", "Cima Coppi", "Cima Pantani", "Azzurri d'Italia", "Breakaway"},
["ast"] = {"Detalles de la carrera", "Carrera", "Tipu", "Data", "Dates", "Distancia", "País", "Países", "Llugar d'entamu",
"Llugar de llegada", "Ciclistes participantes", "Ciclistes acabaos", "Velocidá media", "Duración", "Resultaos de la etapa",
"Ganador", "Segundu", "Terceru", "Combativu", "Clasificación xeneral depués de la etapa", "Líder", "Segundu", "Terceru",
"Clasificaciones secundaries depués de la etapa", "Puntos", "Monte", "Esprint", "Mozu", "Combatividá", "Combinada", "Metes volantes",
"Regularidá", "Equipu", "Equipu per puntos", "Imaxe", "Lleenda", "Card", "Sectional view", "Documentación", "Cume Coppi",
"Cume Pantani", "Azzurri d'Italia", "Fuga"}
}
local l10n = l10nDef[wiki]
if not l10n then l10n = l10nDef["en"] end -- default
return l10n[x]
end
 
function jersey(wiki, winner_classification, item, timeofrace)
local jersey, jersey_name = '', ''
local jerseyWPID = ''
local starttime, endtime = '', '+2500'
local a1, b1
 
-- 1. Item of race, e.g. Tour de France = 'Q33881'
-- 2. type of winner, names are the ones in variable t_s
-- 3. and 4. start and end time. '+2500' means year 2500. Always beginning with a '+'
-- 5. item of the jersey
-- 6. item of the Wikipedia article of that jersey
 
local data={{'Q33881', 'montagne', '+1975', '+2500', 'Q25265958', 'Q927157'}, -- Tour de France
{'Q33881', 'leader', '+1919', '+2500', 'Q24257871', 'Q738903'},
{'Q33881', 'points', '+1953', '+1967', 'Q24645209', 'Q175399'}, -- Jersey green.svg
{'Q33881', 'points', '+1968', '+1968', 'Q26919974', 'Q175399'}, -- Jersey red.svg
{'Q33881', 'points', '+1969', '+2500', 'Q24645209', 'Q175399'}, -- Jersey green.svg
{'Q33881', 'jeune', '+1975', '+2500', 'Q24645383', 'Q2254180'}, -- Jersey white.svg
{'Q33881', 'winner_fighting', '+2003', '+2500', 'Q27644113', 'Q2094179'}, -- Jersey red number.svg
{'Q33881', 'winner_fighting2', '+2003', '+2500', 'Q27644113', 'Q2094179'}, -- Jersey red number.svg
{'Q33881', 'equipe', '+2006', '+2500', 'Q27644112', 'Q1436680'}, -- Jersey yellow number.svg
 
{'Q33861', 'leader', '+1931', '+2500', 'Q24257763', 'Q1164275'}, -- Giro d'Italia, Jersey pink.svg
{'Q33861', 'points', '+1967', '+1968', 'Q26919974', 'Q641083'}, -- Jersey red.svg
{'Q33861', 'points', '+1969', '+2009', 'Q26945272', 'Q641083'}, -- Jersey violet.svg
{'Q33861', 'points', '+2010', '+2016', '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
{'Q33861', 'jeune', '+1976', '+2500', 'Q24645383', 'Q641662'}, -- Jersey white.svg
 
{'Q33937', 'leader', '+1935', '+1936', 'Q24258056', 'Q3278226'}, -- Vuelta a España, Jersey orange.svg
{'Q33937', 'leader', '+1941', '+1941', 'Q26696171', 'Q640430'}, -- Jersey white.svg
{'Q33937', 'leader', '+1942', '+1942', 'Q24258056', 'Q3278226'}, -- Jersey orange.svg
{'Q33937', 'leader', '+1945', '+1945', 'Q24257872', 'Q2534046'}, -- Jersey red.svg
{'Q33937', 'leader', '+1946', '+1950', 'Q26696171', 'Q640430'}, -- Jersey white.svg
{'Q33937', 'leader', '+1955', '+1976', 'Q24257871', 'Q738903'}, -- Jersey yellow.svg
{'Q33937', 'leader', '+1977', '+1977', 'Q24258056', 'Q3278226'}, -- Jersey orange.svg
{'Q33937', 'leader', '+1978', '+1998', 'Q24257871', 'Q738903'}, -- Jersey yellow.svg
{'Q33937', 'leader', '+1999', '+2009', 'Q24257991', 'Q27665179'}, -- Jersey gold.svg
{'Q33937', 'leader', '+2010', '+2500', 'Q24257872', 'Q2534046'}, -- Jersey red.svg
{'Q33937', 'points', '+1945', '+1986', 'Q24687409', 'Q2746711'}, -- Jersey blue.svg
{'Q33937', 'points', '+1987', '+1989', 'Q24645209', 'Q11638007'}, -- Jersey green.svg
{'Q33937', 'points', '+1990', '+2009', 'Q24687409', 'Q2746711'}, -- Jersey blue.svg
{'Q33937', 'points', '+2010', '+2500', 'Q24645209', 'Q11638007'}, -- Jersey green.svg
{'Q33937', 'montagne', '+1935', '+1985', 'Q27670182', 'Q11638007'}, -- Jersey green.svg
{'Q33937', 'montagne', '+1986', '+1986', 'Q27670174', 'Q3278226'}, -- Jersey orange.svg
{'Q33937', 'montagne', '+1987', '+1987', 'Q27670178', 'Q2534046'}, -- Jersey red.svg
{'Q33937', 'montagne', '+1988', '+1989', 'Q27670105', 'Q27670115'}, -- Jersey blackdots.png
{'Q33937', 'montagne', '+1990', '+2005', 'Q27670182', 'Q11638007'}, -- Jersey green.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', '+2017', 'Q24645209', 'Q30020298'}, -- Jersey green.svg
{'Q2091354', 'points', '+2018', '+2500', 'Q28820618', 'Q30020298'}, -- MaillotCyan.PNG
{'Q2091354', 'montagne', '+2011', '+2015', 'Q25265958', 'Q30020298'}, -- Jersey polkadot.svg
{'Q2091354', 'montagne', '+2016', '+2017', 'Q27670174', 'Q30020298'}, -- Jersey orange.svg
{'Q2091354', 'montagne', '+2018', '+2500', 'Q25265958', 'Q30020298'}, -- Jersey polkadot.svg
{'Q2091354', 'jeune', '+2011', '+2500', 'Q24645383', 'Q30020298'}, -- Jersey white.svg
{'Q2091354', 'winner_fighting', '+2017', '+2017', 'Q29957114', 'Q30020298'}, -- MaillotCyan.PNG
{'Q128713', 'leader', '+2013', '+2017', 'Q24257871', 'Q30020299'}, -- Tour des Fjords, Jersey yellow.svg
{'Q128713', 'leader', '+2018', '+2500', 'Q29594434', 'Q30020299'}, -- MaillotCyan.PNG
{'Q128713', 'points', '+2013', '+2014', 'Q24645209', 'Q30020299'}, -- Jersey green.svg
{'Q128713', 'points', '+2015', '+2017', 'Q24687409', 'Q30020299'}, -- Jersey blue.svg
{'Q128713', 'points', '+2018', '+2500', 'Q25265938', 'Q30020299'}, -- Jersey violet.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', '+2017', 'Q30035039', 'Q30020299'}, -- Jersey orange.svg
{'Q128961', 'leader', '+2013', '+2500', 'Q24687408', 'Q30020300'}, -- Arctic Race of Norway, Jersey blue.svg
{'Q128961', 'points', '+2013', '+2500', 'Q24645209', 'Q30020300'}, -- Jersey green.svg
{'Q128961', 'montagne', '+2013', '+2014', 'Q27670178', 'Q30020300'}, -- Jersey red.svg
{'Q128961', 'montagne', '+2015', '+2500', 'Q27670174', 'Q30020300'}, -- Jersey orange.svg
{'Q128961', 'jeune', '+2013', '+2500', 'Q24645383', 'Q30020300'}, -- Jersey white.svg
{'Q128961', 'winner_fighting', '+2014', '+2500', 'Q27644113', 'Q30020300'}, -- Jersey red number.svg
{'Q17619325', 'leader', '+2014', '+2014', 'Q24257871', 'Q30020302'}, -- Ladies Tour of Norway, Jersey yellow.svg
{'Q17619325', 'leader', '+2015', '+2016', 'Q26945272', 'Q30020302'}, -- Jersey violet.svg
{'Q17619325', 'leader', '+2017', '+2500', 'Q24257871', 'Q30020302'}, -- Jersey yellow.svg
{'Q17619325', 'points', '+2014', '+2500', 'Q24645209', 'Q30020302'}, -- Jersey green.svg
{'Q17619325', 'montagne', '+2014', '+2500', 'Q25265958', 'Q30020302'}, -- Jersey polkadot.svg
{'Q17619325', 'jeune', '+2014', '+2500', 'Q24645383', 'Q30020302'}, -- Jersey white.svg
{'Q17619325', 'winner_fighting', '+2016', '+2500', 'Q30035039', 'Q30020302'}} -- Jersey orange.svg
 
--timeofrace = '+1968-07-01T00:00:00Z'
timeofrace = string.sub(timeofrace, string.find(timeofrace, "+%d%d%d%d"))
for k, v in pairs(item) do
for key, value in pairs(data) do
if v == value[1] then
if winner_classification == value[2] then
if (timeofrace >= value[3]) and (timeofrace <= value[4]) then
jersey = value[5]
jerseyWPID = value[6]
end
end
end
end
end
 
if jersey~='' then --and (timeofrace > starttime) and (timeofrace < endtime) then
local entity_jersey = mw.wikibase.getEntity(jersey)
jersey = entity_jersey.claims['P18'][1].mainsnak.datavalue.value
jersey_name = entity_jersey:getLabel(wikilang) or ''
if jerseyWPID~= '' then
local entity = mw.wikibase.getEntity( jerseyWPID )
local Sitelink = entity:getSitelink(wiki..'wiki') -- link to WParticle
if Sitelink~= nil then jerseyWPID = wiki..':'..Sitelink else jerseyWPID = '' end
end
return jersey, jersey_name, jerseyWPID
else return '', '', ''
end
end
 
function p.stageinfobox(frame)
local vvv= ''
local tab
local entityId = frame.args[1]
local lang = mw.language.getContentLanguage()
local timeofrace
local a1, b1, c1temp, a2, b2, a3, b3temp2
local jerseyWPID, jersey_name
local t_g = {show=true, name=''"", icon=''"", picture=''"", caption=''"", course= ''"", race={}, is_a=''"", startplace=''"", endplace=''"", time=''"",
length=''"", length_unit=''"", speed=''"", speed_unit=''"", nr_participants_start="", nr_participants_end=''"", country={},
series_ordinal_previous="", series_ordinal_next="", map=''"", sectional_view=''"",previous="", next=""}
local t_s = {order={'results', 'classement_gen', 'classement_annex'},
results={show=false, header=15, order = {'first','second','third','winner_fighting','winner_fighting2','cima_coppi','cima_pantani'},
-- name rider, stageinfobox_translate number, gender, jersey, team name, time, time gap, points, speed, rank
first={"", 16, "", ''"", "", "", ''"", ''"", ''"", ''""},
second={"", 17, "", ''"", ''"", "", ''"", ''"", ''"", ''""},
third={"", 18, "", ''"", ''"", "", ''"", ''"", ''"", ''""},
winner_fighting={"", 19, "", ''"", ''"", ''"", ''"", ''"", ''"", ''""},
winner_fighting2={"", 19, "", ''"", ''"", ''"", ''"", ''"", ''"", ''""}, -- two winner_fighting possible
cima_coppi={"", 40, "", ''"", ''"", ''"", ''"", ''"", ''"", ''""},
cima_pantani={"", 41, "", ''"", ''"", ''"", ''"", ''"", ''"", ''""}},
 
classement_gen={show=false, header=20, order = {"leader", "deuxieme", "troisieme"},
-- name rider, stageinfobox_translate number, gender, jersey, team name, time, time gap, points, speed, rank
leader={"", 21, "", ''"", "", "", ''"", ''"", ''"", ''""},
deuxieme={"", 22, "", ''"", ''"", "", ''"", ''"", ''"", ''""},
troisieme={"", 23, "", ''"", ''"", "", ''"", ''"", ''"", ''""}},
 
classement_annex={show=false, header=24, order={"points","montagne","sprints","jeune","super_combatif","combine",
"stage_volantes","regularite","azzurri_ditalia","breakaway","equipe","equipe_points"},
-- name rider, stageinfobox_translate number, gender, jersey, team name, time, time gap, points, speed, rank
points={"", 25, "", ''"", "", ''"", "", ''"", ''"", ''""},
montagne={"", 26, "", ''"", ''"", ''"", "", ''"", ''"", ''""},
sprints={"", 27, "", ''"", ''"", ''"", "", ''"", ''"", ''""},
jeune={"", 28, "", ''"", ''"", ''"", ''"", ''"", ''"", ''""},
super_combatif={"", 29, "", ''"", "", "", ''"", ''"", ''"", ''""},
combine={"", 30, "", ''"", ''"", "", ''"", ''"", ''"", ''""},
stage_volantes={"",31,''"",''"",''"",''"",''"",''"", ''"", ''""},
regularite={"",32,''"",''"",''"",''"",''"",''"", ''"", ''""},
azzurri_ditalia={"",42,''"",''"",''"",''"",''"",''"", ''"", ''""},
breakaway={"",43,''"",''"",''"",''"",''"",''"", ''"", ''""},
equipe={"", 33, "", ''"", ''"", "", ''"", ''"", ''"", ''""},
equipe_points={"", 34, "", ''"", ''"", ''"", ''"", ''"", ''"", ''""}}
}
 
if type( entityId ) ~= 'string' then error( 'parameter must be a string') end
if not entityId:match( 'Q%d+' ) then error ( 'parameter must be a valid Wikidata item (ex: Q42)' ) end
local entity = mw.wikibase.getEntity( entityId )
 
t_g.name = getLabelFallback(entityId, {wikilang, 'en', 'fr'})
if entity:getLabel() ~= nil then t_g.name = entity:getLabel()
if wiki == 'fr' and t_g.name ~= "" then t_g.name= mw.ustring.gsub(t_g.name, "^(%d+)([re]+)", "%1<sup>%2</sup> ") end
else t_g.name = entity:getLabel() or entity:getLabel('en') or '' end
if wiki == 'fr' and t_g.name ~= '' then t_g.name= mw.ustring.gsub(t_g.name, "^(%d+)([re]+)", "%1<sup>%2</sup> ") end
t_g.name= mw.ustring.gsub(t_g.name, "^(%a)",function (x) return mw.ustring.upper(x) end)
 
temp=firstValue(entityId, 'P31','id')
a1, b1 = pcall(fooA, 'numeric-id', entity, 'P31', 1) -- If stage is a "stage" or a timetrial stage
if a1 == true and b1temp~=18131152'Q18131152' then t_g.is_a = 'Q'.. b1temp end
 
if t_g.is_a=='Q2266066' or t_g.is_a=='Q2348250' or t_g.is_a=='Q485321' then t_g.icon = " [[File:Cycling (track) pictogram.svg|35px]]"
else t_g.icon = " [[File:Cycling (road) pictogram.svg|35px]]" end
 
local p18 = wikibase.getAllStatements(entityId, 'P18')
a1, b1 = pcall(fooA, 'value', entity, 'P18', 1) -- picture, legende
if a1p18[1] and p18[1].mainsnak.snaktype == true'value' and t_g.picture == "" then
t_g.picture = p18[1].mainsnak.datavalue.value
local v
local q = p18[1].qualifiers
t_g.picture = b1
if pcall(foo3,q entity,and "P18",q.P2096 1,and "q.P2096", [1)].snaktype == 'value' then
for _, vq2096 in pairs(entityq.claims["P18"]P2096) do
if q2096.datavalue.value.language == wikilang then t_g.caption = q2096.datavalue.value.text end
pcall(function()
for num=1,#v.qualifiers["P2096"] do -- find right language
if v.qualifiers["P2096"][num].datavalue.value.language == lang:getCode() then
t_g.caption = v.qualifiers["P2096"][num].datavalue.value.text end
end
end)
end
end
 
-- Function that give the starting place of a race
a1,local b1, c1place = pcallfirstValue(fooAentityId, 'numeric-idP1427', entity, 'id') -- P1427 is ',start 1)point'
if a1 == true and t_g.startplace == ""place-- then i =and 1getPlaceLink(place)
local place = firstValue(entityId, 'P1444', 'id')
while a1 == true and c1 == 'deprecated' do
t_g.endplace = place --and getPlaceLink(place)
i = i + 1
a1, b1, c1 = pcall(fooA, 'numeric-id', entity, 'P1427', i)
end
t_g.startplace = "Q" .. b1
end
-- Function that give the finishing place of a race
a1, b1, c1 = pcall(fooA, 'numeric-id', entity, 'P1444', 1)
if a1 == true and t_g.endplace == "" then i = 1
while a1 == true and c1 == 'deprecated' do
i = i + 1
a1, b1, c1 = pcall(fooA, 'numeric-id', entity, 'P1444', i)
end
t_g.endplace = "Q" .. b1
end
 
-- This function give a format to dates when P585 (date) is used in a single day race
a1,local b1, c1pTime = pcallfirstValue(fooAentityId, 'timeP585', entity, 'P585time', 1)
if a1 == true and t_g.time == ""pTime then i = 1
t_g.time = func_date (pTime, 'long')
while a1 == true and c1 == 'deprecated' do
itimeofrace = i + 1pTime
a1, b1, c1 = pcall(fooA, 'time', entity, 'P585', i)
end
t_g.time = func_date (b1, 'long')
timeofrace = b1
end
 
-- Function that give the number of cyclists at the beginning and at the finishing of a race
a1,for b1_, c1p1132 =in pcallstatements(fooAentityId, 'amountP1132',) entity,do -- 'P1132 is ',number 1)of participants'
local amount = tonumber(p1132.mainsnak.datavalue.value.amount) -- tonumber to remove starting '+'
if a1 == true and t_g.nr_participants_start == "" and t_g.nr_participants_end == "" then i = 1
for _, q in qualifiers(p1132, 'P276') do -- P276 is 'location'
while a1 == true and c1 == 'deprecated' do
local location = q.value['numeric-id']
i = i + 1
if location == 529711 then -- Q529711 is 'beginning'
a1, b1, c1 = pcall(fooA, 'amount', entity, 'P1132', i)
if t_g.nr_participants_start=="" then t_g.nr_participants_start = amount end -- participants at start
end
elseif location == 12769393 then -- Q12769393 is 'end'
local v
if t_g.nr_participants_end=="" then t_g.nr_participants_end = amount end -- participants at end
for _, v in pairs(entity.claims["P1132"]) do
if pcall(function()
if v.qualifiers["P276"][1].datavalue.value["numeric-id"] == 529711 then
t_g.nr_participants_start = string.gsub(v.mainsnak.datavalue.value.amount, "+", "") end
end
) then else t_g.nr_participants_start = "" end
if pcall(function()
if v.qualifiers["P276"][1].datavalue.value["numeric-id"] == 12769393 then
t_g.nr_participants_end = string.gsub(v.mainsnak.datavalue.value.amount, "+", "") end
end
) then else t_g.nr_participants_end = "" end
end
end
 
t_g.length = getDistance(entityId, true) or ""
-- This function permits to display an unity (the kilometer) for a distance, with exceptions for macedionan, russian and japanese
t_g.speed = getSpeed(entityId, true) or ""
-- 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
 
-- This function gives countries where the race take place
a1, b1, c1 = pcall(fooA, 'amount', entity, 'P2043', 1)
local countrytemp = {}
if a1 == true and t_g.length == "" then i = 1
for _, p17 in statements(entityId, 'P17') do -- P17 is 'country'
while a1 == true and c1 == 'deprecated' do
countryID = p17.mainsnak.datavalue.value.id
i = i + 1
countrytemp [#countrytemp + 1] = flag(countryID, timeofrace) .. ' ' .. getCountryName(countryID)
a1, b1, c1 = pcall(fooA, 'amount', entity, 'P2043', i)
end
t_g.length = b1
a1, b1, _ = pcall(fooA, 'unit', entity, 'P2043', 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
t_g.country=countrytemp
-- This function permits to display an unity (the kilometer per hour) for an average speed, with exceptions for macedionan, russian and japanese
-- that have other symbols
a1, b1, c1 = pcall(fooA, 'amount', entity, 'P2052', 1)
if a1 == true and t_g.speed == "" then i = 1
while a1 == true and c1 == 'deprecated' do
i = i + 1
a1, b1, c1 = pcall(fooA, 'amount', entity, 'P2052', i)
end
t_g.speed = b1
a1, b1 = pcall(fooA, 'unit', entity, 'P2052', 1)
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 == "nl" then t_g.speed_unit = 'km/u' end
if wiki == "no" 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
 
a1, b1 = pcall(fooA, 'numeric-id', entity, 'P17', 1) -- This function gives countries where the race take place
if a1 == true then
for i, v in pairs(entity.claims["P17"]) do
t_g.country[i] = "Q" .. v.mainsnak.datavalue.value["numeric-id"]
end
end
 
temp = firstValue(entityId, 'P242', 'id')
a1, b1 = pcall(fooA, 'value', entity, 'P242', 1) -- locator map image
if a1temp =~= truenil and t_g.map == "" then t_g.map = b1temp end
temp = firstValue(entityId, 'P2713', 'id')
a1, b1 = pcall(fooA, 'value', entity, 'P2713', 1) -- sectional view
if a1temp =~= truenil and t_g.sectional_view == "" then t_g.sectional_view = b1temp end
 
a1, b1temp = pcallfirstValue(fooAentityId, 'numeric-idP155', entity, 'P155id', 1)
if a1temp =~= truenil and t_g.previous == "" then
t_g.previous = "Q"..b1temp
temp2 = firstValue(temp, 'P1545', 'value')
a2, b2 = pcall(fooA, 'value', mw.wikibase.getEntity( t_g.previous ), 'P1545', 1)
if a2temp2 =~= truenil then t_g.series_ordinal_previous = b2temp2 end
end
a1, b1temp = pcallfirstValue(fooAentityId, 'numeric-idP156', entity, 'P156id', 1)
if a1temp =~= truenil and t_g.next == "" then
t_g.next = "Q"..b1temp
temp2 = firstValue(temp, 'P1545', 'value')
a2, b2 = pcall(fooA, 'value', mw.wikibase.getEntity( t_g.next ), 'P1545', 1)
if a2temp2 =~= truenil then t_g.series_ordinal_next = b2=temp2 end
end
 
}
 
local deprecated, qual, id, id_time, id_time_gap, id_speed, id_points_a, id_points_b
a1, b1 = pcall(fooA, 'numeric-id', entity, "P1346", 1)
local riderId
if a1 == true then
local deprecated, qual, id, id_team, id_time, id_time_gap, id_speed, id_points_a, id_points_b
--Winner
for k, v in pairs(entity.claims["P1346"]) do
for _, p1346 in statements(entityId, 'P1346') do
id_team, id_speed, id_time, id_time_gap, id_points_a, id_points_b = '', '', '', '', '', ''
id_speed, id_time, id_time_gap, id_points_a, id_points_b,countryID = nil, nil, nil, nil, nil
a, b = pcall(fooC, 'numeric-id', entity, 'P1346', k, 'P54', 1)
local subwinnertable={}
if a == true then id_team = 'Q'..b end
--riderLink, riderTeam='', ''
 
local q = p1346.qualifiers
if pcall(function()
idriderId=v p1346.mainsnak.datavalue.value['numeric-id'] -- id = rider .id
deprecated = entity.claims["P1346"][k]p1346.rank
end) then
id_time = qualifieramount(p1346, 'P2781')
else id=nil end
id_time_gap =qualifieramount(p1346, 'P2911')
if id ~= nil then
id_speed =qualifieramount(p1346, 'P2052')
--timeofrace = "+2016-03-00T00:00:00Z"
id_points_a = qualifieramount(p1346, 'P1358')
-- function timeStartEnd finds the team of the rider at the time (timeofrace) of the race
id_points_b =qualifieramount(p1346, 'P1351')
if id_team == '' and timeofrace ~= nil and timeofrace ~= '' then
a, b = timeStartEnd('Q'..id, 'P54', 'numeric-id', timeofrace)
if a == true and briderId ~= nil then id_team = 'Q' .. b end
subwinnertable =subwinner(riderId, timeofrace, q) --sub function to avoid code in double
riderLink=subwinnertable[1]
riderTeam=subwinnertable[2]
-- looks into race item if the winner has a P642 statement for showing the type of winner (points, mountain, ..)
if q.P642 and q.P642[1].snaktype == 'value' then
for _, vv in pairs(q.P642) do
qual=vv.datavalue.value['numeric-id']
if riderId~=nil and qual~=nil and deprecated~='deprecated' then
if qual==21686770 and t_s['results']['winner_fighting'][1] ~= "" then t_P642[qual][2] = 'winner_fighting2' end
t_s[t_P642[qual][1]][t_P642[qual][2]][1]=riderLink
t_s[t_P642[qual][1]][t_P642[qual][2]][5]=riderTeam or ""
t_s[t_P642[qual][1]][t_P642[qual][2]][10]=deprecated
if id_time then t_s[t_P642[qual][1]][t_P642[qual][2]][6]=id_time end
if id_time_gap then t_s[t_P642[qual][1]][t_P642[qual][2]][7]=id_time_gap end
if id_points_a then t_s[t_P642[qual][1]][t_P642[qual][2]][8]=id_points_a end
if id_points_b then t_s[t_P642[qual][1]][t_P642[qual][2]][8]=id_points_b end
if id_speed then t_s[t_P642[qual][1]][t_P642[qual][2]][9]=id_speed end
if qual==27104271 and t_s.classement_annex.equipe_points[1]=="" then t_s.classement_annex.equipe_points[1]=riderId end
if qual==20882922 and t_s.classement_annex.equipe[1]=="" then t_s.classement_annex.equipe[1]=riderId end
t_s[t_P642[qual][1]][t_P642[qual][2]][3] =getgendercode(riderId,'f')
end
end
 
-- 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 = national_team('Q'..id, timeofrace, entity, 'P1346', k) -- timeofrace -> startOfSeason ?????
if id_team == nil then id_team = '' end
end
end)
 
pcall(function() -- for property 'race time'
for _, v in pairs(entity.claims['P1346'][k].qualifiers['P2781']) do
id_time = tonumber(v.datavalue.value.amount)
end
end)
 
pcall(function() -- for property 'time gap'
for _, v in pairs(entity.claims['P1346'][k].qualifiers['P2911']) do
id_time_gap = tonumber(v.datavalue.value.amount)
end
end)
 
pcall(function() -- for property 'speed'
for _, v in pairs(entity.claims['P1346'][k].qualifiers['P2052']) do
id_speed = tonumber(v.datavalue.value.amount)
end
end)
 
pcall(function() -- for property 'points for'
for _, v in pairs(entity.claims['P1346'][k].qualifiers['P1358']) do
id_points_a = tonumber(v.datavalue.value.amount)
end
end)
 
pcall(function() -- for property 'number of points/goals/set scored'
for _, v in pairs(entity.claims['P1346'][k].qualifiers['P1351']) do
id_points_b = tonumber(v.datavalue.value.amount)
end
end)
 
-- looks into race item if the winner has a P642 statement for showing the type of winner (points, mountain, ..)
pcall(function()
for _, vv in pairs(entity.claims["P1346"][k].qualifiers['P642']) do
qual=vv.datavalue.value['numeric-id']
 
if id~=nil and qual~=nil and v.rank~='deprecated' then
if qual==21686770 and t_s['results']['winner_fighting'][1] ~= '' then t_P642[qual][2] = 'winner_fighting2' end
pcall(function() -- inserts WD data into table t_s
t_s[t_P642[qual][1]][t_P642[qual][2]][1]='Q'..id
t_s[t_P642[qual][1]][t_P642[qual][2]][5]=id_team
t_s[t_P642[qual][1]][t_P642[qual][2]][10]=deprecated
if id_time~='' then t_s[t_P642[qual][1]][t_P642[qual][2]][6]=id_time end
if id_time_gap~='' then t_s[t_P642[qual][1]][t_P642[qual][2]][7]=id_time_gap end
if id_points_a~='' then t_s[t_P642[qual][1]][t_P642[qual][2]][8]=id_points_a end
if id_points_b~='' then t_s[t_P642[qual][1]][t_P642[qual][2]][8]=id_points_b end
if id_speed~='' then t_s[t_P642[qual][1]][t_P642[qual][2]][9]=id_speed end
end)
if qual==27104271 and t_s.classement_annex.equipe_points[1]=='' then t_s.classement_annex.equipe_points[1]='Q'..id end
if qual==20882922 and t_s.classement_annex.equipe[1]=='' then t_s.classement_annex.equipe[1]='Q'..id end
 
a1, b1 = pcall(fooA, 'numeric-id', mw.wikibase.getEntityObject('Q'..id), 'P21', 1) -- detect gender
if a1 == true then
if b1 == 6581097 then t_s[t_P642[qual][1]][t_P642[qual][2]][3] = 'm' -- men
elseif b1 == 6581072 then t_s[t_P642[qual][1]][t_P642[qual][2]][3] = 'f' -- female
end
else t_s[t_P642[qual][1]][t_P642[qual][2]][3] = 'f' -- female
end
end
end
end)
end
end
local rank, deprecated
local order = {'first', 'second', 'third'}
local property = 'P2417'
-- look into P2417, stage classification
a1, b1 = pcall(fooA, 'numeric-id', entity, property, 1)
for _, p2417 in statements(entityId, 'P2417') do
if a1 == true then
local q = p2417.qualifiers
for k, _ in pairs(entity.claims[property]) do -- look into P2417, stage classification
if q.P1352 and q.P1352[1].snaktype == 'value' then
for _, v in pairs(entity.claims[property][k].qualifiers['P1352']) do -- for property 'rank'
for _, q1352 in pairs(q.P1352) do
rank = tonumber(v.datavalue.value.amount)
rank = tonumber(q1352.datavalue.value.amount)
deprecated = entity.claims[property][k].rank
deprecated =q1352.rank
end
end
if rank == 1 or rank == 2 or rank == 3 then
if rank == 1 or rank == 2 or rank == 3 then --
t_s.results[order[rank]][10] = deprecated
if t_s.results[order[rank]][1] == '' or t_s.results[order[rank]][10] == 'normal' then -- name or rider / teamdeprecated
t_s.results[order[rank]][1]local thisid= 'Q' .. entity.claims[property][k]p2417.mainsnak.datavalue.value['numeric-.id']
if t_s.results[order[rank]][71] == ''getRiderLink( and t_s.results[order[rank]][6] ==thisid, ''timeofrace) then
local p27 = getStatementForTime(thisid, 'P27', timeofrace) --P27 is country of citizenship
pcall(function()
if p27 then
for _, v in pairs(entity.claims[property][k].qualifiers['P2911']) do -- for property 'time gap'
t_s.results[order[rank]][7]countryID = tonumber(vp27.mainsnak.datavalue.value.amount)id
end
end)
end
if countryID then
if t_s.results[order[rank]][7] == '' and t_s.results[order[rank]][6] == '' then
t_s.results[order[rank]][1] = flag(countryID, timeofrace) .. ' ' .. t_s.results[order[rank]][1]
pcall(function()
for _, v in pairs(entity.claims[property][k].qualifiers['P2781']) do -- for property 'race time'
t_s.results[order[rank]][6] = tonumber(v.datavalue.value.amount)
end
end)
end
if t_s.results[order[rank]][97] == ''"" and t_s.results[order[rank]][6] == "" then
t_s.results[order[rank]][7] = qualifieramount(p2417, 'P2911') or ""
pcall(function()
for _, v in pairs(entity.claims[property][k].qualifiers['P2052']) do -- for property 'speed'
t_s.results[order[rank]][9] = tonumber(v.datavalue.value.amount)
end
end)
end
a1,if b1t_s.results[order[rank]][7] == pcall(fooA,"" 'numeric-id',and mw.wikibase.getEntityObject(t_s.results[order[rank]][16]), 'P21', 1) --== detect"" genderthen
t_s.results[order[rank]][6] = qualifieramount(p2417, 'P2781') or ""
if a1 == true then
end
if b1 == 6581097 then t_s.results[order[rank]][3] = 'm' -- men
elseif b1 == 6581072 thenif t_s.results[order[rank]][39] == 'f'"" -- femalethen
t_s.results[order[rank]][9] = qualifieramount(p2417, 'P2052') or ""
end
else t_s.results[order[rank]][3] = 'f' -- female
end
t_s.results[order[rank]][3]=getgendercode(thisid, 'f')
end
end
end
end
order = {'leader', 'deuxieme', 'troisieme'}
for _, p2321 in statements(entityId, 'P2321') do
property = 'P2321'
local q = p2321.qualifiers
a1, b1 = pcall(fooA, 'numeric-id', entity, property, 1)
if a1q.P1352 and q.P1352[1].snaktype == true'value' then
for k_, _q1352 in pairs(entityq.claims[property]P1352) do -- look into P2321, stage classification
rank = tonumber(q1352.datavalue.value.amount)
for _, v in pairs(entity.claims[property][k].qualifiers['P1352']) do -- for property 'rank'
deprecated =q1352.rank
rank = tonumber(v.datavalue.value.amount)
end
deprecated = entity.claims[property][k].rank
if rank == 1 or rank == 2 or rank == 3 then
end
t_s.classement_gen[order[rank]][10] = deprecated
if rank == 1 or rank == 2 or rank == 3 then
local thisid=p2321.mainsnak.datavalue.value.id
t_s.classement_gen[order[rank]][10] = deprecated
if t_s.classement_gen[order[rank]][1] == '' or t_s.classement_gen[order[rank]][10] == 'normal' then -- name orgetRiderLink( riderthisid, /timeofrace) team
local p27 = getStatementForTime(thisid, 'P27', timeofrace) --P27 is country of citizenship
t_s.classement_gen[order[rank]][1] = 'Q' .. entity.claims[property][k].mainsnak.datavalue.value['numeric-id']
if p27 then
if t_s.classement_gen[order[rank]][7] == '' and t_s.classement_gen[order[rank]][6] == '' then
countryID = p27.mainsnak.datavalue.value.id
pcall(function()
for _, v in pairs(entity.claims[property][k].qualifiers['P2911']) do -- for property 'time gap'
t_s.classement_gen[order[rank]][7] = tonumber(v.datavalue.value.amount)
end
end)
end
if countryID then
if t_s.classement_gen[order[rank]][7] == '' and t_s.classement_gen[order[rank]][6] == '' then
t_s.classement_gen[order[rank]][1] = flag(countryID, timeofrace) .. ' ' .. t_s.classement_gen[order[rank]][1]
pcall(function()
for _, v in pairs(entity.claims[property][k].qualifiers['P2781']) do -- for property 'race time'
t_s.classement_gen[order[rank]][6] = tonumber(v.datavalue.value.amount)
end
end)
end
if t_s.classement_gen[order[rank]][97] == ''"" and t_s.classement_gen[order[rank]][6] == "" then
t_s.classement_gen[order[rank]][7] = qualifieramount(p2321, 'P2911') or ""
pcall(function()
for _, v in pairs(entity.claims[property][k].qualifiers['P2052']) do -- for property 'speed'
t_s.classement_gen[order[rank]][9] = tonumber(v.datavalue.value.amount)
end
end)
end
a1,if b1t_s.classement_gen[order[rank]][7] == pcall(fooA,"" 'numeric-id',and mw.wikibase.getEntityObject(t_s.classement_gen[order[rank]][16]), 'P21', 1) == --"" detectthen gender
t_s.classement_gen[order[rank]][6] =qualifieramount(p2321, 'P2781') or ""
if a1 == true then
end
if b1 == 6581097 then t_s.classement_gen[order[rank]][3] = 'm' -- men
elseif b1 == 6581072 thenif t_s.classement_gen[order[rank]][39] == 'f'"" -- femalethen
t_s.classement_gen[order[rank]][9] = qualifieramount(p2321, 'P2052') or ""
end
else t_s.classement_gen[order[rank]][3] = 'f' -- female
end
t_s.classement_gen[order[rank]][3] =getgendercode(thisid, 'f')
end
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
if wiki == 'fo' then t_g.length = string.gsub(t_g.length, "%.", ",") end
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 wiki == 'fo' then t_g.speed = string.gsub(t_g.speed, "%.", ",") end
end
 
local a, b
local span1, span2 = "<span style='color:#3366CC'>&#x25C0; </span>", "<span style='color:#3366CC'> &#x25B6;</span>"
 
if t_g.series_ordinal_previous ~= ''"" then
a, _ = string.gsub(t_g.series_ordinal_previous, "%a", "") -- 20, not 20a
if string.find(t_g.series_ordinal_previous, "%a") then b = string.sub(t_g.series_ordinal_previous, string.find(t_g.series_ordinal_previous, "%a"))
if t_g.series_ordinal_previous == "0" then label_previous = func_prologue() end
if mw.wikibase.sitelink( t_g.previous ) ~= nil then
local k = transformWPlinkpure(t_g.previous,'Q', timeofrace)
local i, _ = string.find(k, "|")
local j, _ = string.find(k, "]")
if t_g.series_ordinal_next == "0" then label_next = func_prologue() end
if mw.wikibase.sitelink( t_g.next ) ~= nil then
local k = transformWPlinkpure(t_g.next,'Q', timeofrace)
local i, _ = string.find(k, "|")
local j, _ = string.find(k, "]")
if i ~= nil and j ~= nil then
 
if t_g.course== '' then
a1, b1temp = pcallfirstValue(fooA, 'value', entityentityId, 'P1545', 1)
if a1 == truetemp then
a, _ = string.gsub(b1temp, "%a", "") -- 20, not 20a
if string.find(b1temp, "%a") then b = string.sub(b1temp, string.find(b1temp, "%a")) else b = "" end
local label = stageLink(b1temp, a, b)
if b1temp == "0" then label = func_prologue() end
t_g.course = label
a2, b2temp = pcallfirstValue(fooAentityId, 'numeric-idP361', entity, 'P361id', 1)
if a2 == truetemp then
raceId=temp
t_g.course = t_g.course .. ', '.. WPlink('Q'..b2,'pure')
local comma = ', '
if wiki == "ar" then t_g.course = t_g.course .. '، '.. WPlink('Q'..b2,'pure') end
if wiki == "ar" then comma = " ، " end
--t_g.race = 'Q'..b2
t_g.course = t_g.course .. comma.. WPlinkpure(raceId)
 
if wiki == "ar" then t_g.course = t_g.course .. '، '.. WPlinkpure(raceId) end
local entity_race = mw.wikibase.getEntity('Q'..b2)
a3for k, b3p31 =in pcallstatements(fooA, 'numeric-id', entity_raceraceId, 'P31',) 1)do
t_g.race[k] = p31.mainsnak.datavalue.value.id
if a3 == true then
for k, v in pairs(entity_race.claims["P31"]) do
t_g.race[k] = 'Q'..v.mainsnak.datavalue.value["numeric-id"]
end
end
end
return ''
end
 
---General table
local width= '320px' -- size standard 320px, special 340px
if t_s.classement_annex.show == true and (wiki == 'no' or wiki == '..') then width= '340px' end
tab=tab.."<tr><td colspan='2' style='background-color:#FFE7A0; text-align:center'>'''"..stageinfobox_translate(1).."'''</td></tr>" end
if t_g.course ~= "" then tab = tab.."<tr><td>'''"..stageinfobox_translate(2).."'''</td><td>" .. t_g.course .. "</td></tr>" end
if t_g.is_a ~= "" then tab = tab.."<tr><td>'''"..stageinfobox_translate(3).."'''</td><td>" ..stage_icon(t_g.is_a).. WPlinkWPlinkpure(t_g.is_a,'pure').. "</td></tr>" end
if t_g.time~="" then tab = tab.."<tr><td>'''"..stageinfobox_translate(4).."'''</td><td>" .. t_g.time.."</td></tr>" end
if t_g.length ~= "" then
if wiki ~= 'en' then -- As default show only kilometers, but if 'en.wiki' show kilometers and miles
iftab t_g.length ~= "" then tab = tab.. "<tr><td>'''" .. stageinfobox_translate(6) .. "'''</td><td>" .. t_g.length .." "..t_g.length_unit.."</td></tr>" end
else
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>" .. WPlinkWPlinkpure(t_g.startplace,'pure').. "</td></tr>" end
if t_g.endplace ~= "" then tab = tab.."<tr><td>'''"..stageinfobox_translate(10).."'''</td><td>" .. WPlinkWPlinkpure(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(7).."'''</td><td>" else tab = tab..stageinfobox_translate(8).."'''</td><td>" end
if t_g.nr_participants_start ~= "" then tab = tab.."<tr><td>'''"..stageinfobox_translate(11).."'''</td><td>" .. t_g.nr_participants_start .. "</td></tr>" end
if t_g.nr_participants_end ~= "" then tab = tab.."<tr><td>'''"..stageinfobox_translate(12).."'''</td><td>" .. t_g.nr_participants_end .. "</td></tr>" end
if t_g.speed ~= "" then
if wiki ~= 'en' then --As default show only kilometers/hour, but if 'en.wiki' show kilometers/hour and miles/hour
iftab 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
 
-- ranking table, general and stage
for _, value_order in ipairs(t_s.order) do
if t_s[value_order].show == true then -- if a section of the stageinfobox should be shown
for key, value in ipairs(t_s[value_order].order) do
if t_s[value_order][value][1]~="" then
a1, jersey_name, jerseyWPID = jerseyjersey_infobox(wiki, value, t_g.race, timeofrace)
if a1~='' then t_s[value_order][value][4] = a1 end
if t_s[value_order][value][9] ~= '' then
local title, k =mw.ustring.gsub(stageinfobox_translate(t_s[value_order][value][2]), " ", "&nbsp;")
if k > 0 then title=mw.ustring.gsub(title, "&nbsp;", "<br>", 1) end --&#32;
--Create an empty column on the left
if t_s[value_order][value][5]=="" and t_s[value_order][value][9] =="" then
tab=tab.."<tr style='vertical-align:top;'><td style='width:1%;background-color:#fff2cc;text-align:" .. textalign .. ";padding:0 2px 0 2px;white-space:nowrap'>'''"
else tab=tab.."<tr style='vertical-align:top;'><td rowspan='2' style='width:1%;background-color:#fff2cc;text-align:" .. textalign .. ";padding:0 2px 0 2px;white-space:nowrap'>'''"
end
end
if t_s[value_order][value][10] == 'deprecated' then
tab=tab.. "'''</td><td style='padding:0 0.5em 0 0.5em'>".. '<s>' .. transform(t_s[value_order][value][1],'f', timeofrace) .. '</s>' --the rider
else tab=tab.. "'''</td><td style='padding:0 0.5em 0 0.5em'>".. transform(t_s[value_order][value][1],'f', timeofrace)end end
tab=tab.."</td><td style='text-align:right;font-size:85%;white-space:nowrap'>"
if t_s[value_order][value][6]~=''"" then tab=tab.. calculate_time(t_s[value_order][value][6]) end
if t_s[value_order][value][7]~=''"" then tab=tab..'+ '.. calculate_time(t_s[value_order][value][7]) end
tab= tab.. t_s[value_order][value][8].. "</td></tr>"
end
 
if t_s[value_order][value][5]~="" and t_s[value_order][value][9] ~="" then -- team row
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:" .. textalign .. ";padding-left:2px'>("..transform(t_s[value_order][value][5],'t', timeofrace).. --add the team
")</td><td 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:" .. textalign .. ";padding-left:2px'>"
if t_s[value_order][value][5] ~= ''"" then tab=tab..'('..transform(t_s[value_order][value][5],'t', timeofrace)..')' end --add the team
tab = tab.. '<span style="float:right;font-size:85%;">'.. t_s[value_order][value][9].."</span></td></tr>"
end
end
 
--== E) List of teams
function transform(q_number, command, timeofrace)
-- transforms Q/q-number into flag / WPlink / WDlink
local wd = " [[File:Wikidata-logo S.svg|12px|link=d:"
if not string.find(q_number, "^Q%d+") then return q_number end -- test if q_number is an item
if command == "Q" then return WPlink( q_number ) end -- find variables with an item as value
if command == 'q' then -- with WDitem icon
--look into P27 (country of citizenship) to get the Qnumber of that country
a, b = timeStartEnd(q_number, "P27", 'numeric-id', timeofrace)
if a == true then return flag('Q'..b, timeofrace).." "..WPlink( q_number )..wd..q_number.."]]"
else
--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 )..wd..q_number.."]]"
else return WPlink( q_number )..wd..q_number.."]]" end
end
end
if command == "f" then -- no WDitem icon
--look into P27 (country of citizenship) to get the Qnumber of that country
a, b = timeStartEnd(q_number, "P27", 'numeric-id', timeofrace)
if a == true then return flag('Q'..b, timeofrace).." "..WPlink( q_number )
else
--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, 'team', timeofrace )
else return WPlink( q_number, 'team', 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
if command =="2t" then return q_number end
return q_number
end
 
--[[ Get a Wikidata statement for an entity and property valid at the given timevalue ]]
local function getStatementForTime(ID, property, time)
local all = mw.wikibase.getAllStatements(ID, property)
for _, s in pairs(all) do
if s.rank ~= 'deprecated' and s.mainsnak.snaktype == 'value' then
local start, END
local q = s.qualifiers
if q then
if q.P580 and q.P580[1] and q.P580[1].snaktype == 'value' then -- P580 is start time
start = q.P580[1].datavalue.value.time
end
if q.P582 and q.P582[1] and q.P582[1].snaktype == 'value' then -- P582 is end time
END = q.P582[1].datavalue.value.time
end
end
if not start or start <= time then
if not END then
return s
end
END = string.gsub(END, '-00', '-99')
if END > time then
return s
end
end
end
end
return nil
end
 
local function getOfficialName(teamID, timeOfRace)
local p1448 = getStatementForTime(teamID, 'P1448', timeOfRace) -- P1448 is official name
if p1448 then
if available_lang_priority and p1448.qualifiers and p1448.qualifiers.P1448 then
local q = p1448.qualifiers.P1448
local wantedLanguages = {}
local best = 999
local name
for i, lang in ipairs(translations.lang_priority) do
wantedLanguages[lang] = i
end
for _, l in pairs(q) do
if l.snaktype == 'value' then
local lang = l.datavalue.value.language
if wantedLanguages[lang] and wantedLanguages[lang] < best then
best = wantedLanguages[lang]
name = l.datavalue.value.text
end
end
end
if name then return name, true end
end
return p1448.mainsnak.datavalue.value.text, false
end
return mw.wikibase.getLabel(teamID) -- No official name, try label
end
 
local function getParentID(teamID)
local p = mw.wikibase.getBestStatements(teamID, 'P361') -- P361 is 'part of'
if not p[1] then
p = mw.wikibase.getBestStatements(teamID, 'P5138') -- P5138 is 'season of club or team'
end
if p[1] and p[1].mainsnak.snaktype == 'value' then
return p[1].mainsnak.datavalue.value.id
end
return nil
end
 
--[[ Get sitelink with no wiki no formating ]]
local function getRawTeamLink(teamID)
local sitelink
local parentID = getParentID(teamID)
if parentID then -- try parent team first
sitelink = mw.wikibase.getSitelink(parentID)
end
if not sitelink then
sitelink = mw.wikibase.getSitelink(teamID)
end
return sitelink
end
 
--[[ Get sitelink, categoryID and maybe country for a team.
Returns sitelink, team category ID, countryID (only countryID if country arg is true ]]
local function getTeamLinkCat(teamID, timeOfRace, country)
local catID, name, sitelink, parentID
-- Find team category
local p31 = mw.wikibase.getBestStatements(teamID, 'P31') -- P31 is instance of
if p31[1] and p31[1].mainsnak.snaktype == 'value' then
catID = p31[1].mainsnak.datavalue.value.id
end
-- Find country if needed
local countryID
if country or catID == 'Q23726798' or catID == 'Q20738667' then
local p17 = mw.wikibase.getBestStatements(teamID, 'P17') -- P17 is country
if p17[1] and p17[1].mainsnak.snaktype == 'value' then
countryID = p17[1].mainsnak.datavalue.value.id
end
end
if countryID and catID == 'Q23726798' or catID == 'Q20738667' then
-- It is a national cycling team
name = mw.wikibase.getLabel(countryID) or countryID -- Uses standard language fallback
if catID == 'Q20738667' then -- national cycling team U23
local s
if wiki == 'fr' then s = ' espoirs'
elseif wiki == 'mk' then s = ' под 23 години'
elseif wiki == 'ar' then s = ' تحت 23'
elseif wiki == 'es' then s = ' sub-23'
else s = ' U23'
end
name = name .. s
end
sitelink = getRawTeamLink(teamID)
else
-- It is not a national cycling team
local isLocal
parentID = getParentID(teamID)
if parentID then -- try parent team first
sitelink = mw.wikibase.getSitelink(parentID)
name, isLocal = getOfficialName(parentID, timeOfRace)
end
if not sitelink then
sitelink = mw.wikibase.getSitelink(teamID)
end
if not name or (not isLocal and available_lang_priority) then
local partName, partIsLocal = getOfficialName(teamID, timeOfRace)
if partName and (not name or partIsLocal) then
name = partName
end
end
end
if sitelink then
if name then
sitelink = '[[' .. sitelink .. '|' .. name .. ']]'
else
sitelink = '[[' .. sitelink .. ']]'
end
else
if name then
sitelink = name
else
sitelink = (ParentID and mw.wikibase.getLabel(ParentID)) or
mw.wikibase.getLabel(TeamID) or 'No name'
end
end
return sitelink, catID, countryID
end
 
function p.listofteams(frame)
local raceID = frame.args[1]
no = no + 1
local teamLink, teamCat, countryID = getTeamLinkCat(v.mainsnak.datavalue.value.id, timeOfRace, true)
table.insert(teams,local flagImage = countryID and {flag(countryID, timeOfRace) ..or ' ' .. teamLink, teamCat,
teams[#teams + 1] = {flagImage .. ' ' .. teamLink, teamCat,
teamCats[teamCat] and teamCats[teamCat][3] or 999, no})
teamCats[teamCat] and teamCats[teamCat][3] or 999, no}
end
end
local text
if not header then
-- Unknown team category. Get the label for the entity to display if possible
header = mw.wikibase.getLabel(CatID) orand getLabelFallback(CatID, --{wikilang, Language'en', 'fr', 'de'})) or fallback'Unknown isteam appliedcategory'
text = '<span style="font-size:1.2em;font-weight:bold;text-transform: capitalize;>' .. header .. '</span>'
else
list = list .. '<li style="text-indent:0em;width:20em;display:inline-block;vertical-align:text-top">' .. team[1] .. '</li>'
end
 
return '<table style="max-width:95%; padding:0.5em; margin-right:1em; border:1px solid rgb(200,200,200)"><tr><td>' ..
text .. getHeader(oldCatID, count) .. '<ol>' .. list ..
'</ol><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'..floattable..'">[[File:Wikidata-logo S.svg|12px|link=d:' ..
raceID .. '#P1923]]</span></th></tr></table></td></tr></table>'
end
 
--== F) Classifications
-- Kaldt med timeStartEnd_entity(entity, 'P1448', 'text', startOfSeason)
function p.UCIclassification(frame)
local function timeStartEnd_entity(entity, property, mode, timeofrace)
local s = {
-- mode = 'numeric-id', property = 'P54', Qid = 'Q123'
header_function = headoftableII, -- translations are in function headoftableII
--local entity = mw.wikibase.getEntity(Qid)
header_1 = 19, -- translation 10 in function headoftableII is printed in the upper part of the table header
local a, b = pcall(fooA, mode, entity, property, 1) -- holdets første officielle navn ifølge entity
header_2 = {1, 2, 7}, -- translations 1, 2, 3, 7 in function headoftableII are printed in this order in the lower part of the table header
local starttime, endtime = '+0000-01-01', '+9999-12-31'
item = string.gsub(frame.args[1], "%c", ""),
local available_lang_priority = available_lang_priority
property = 'P3494', -- property to use for this table
 
team_classification = false, -- it is not a team classification table, its a rider classification table
if a == true then
background = 'color', -- there is a background color for the first row
local timeStartEnd = {}
displayteam=false
local num = 1
local v}
return new_classification(frame, s)
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 -- starttid fot officiel navn
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 -- sluttid for officielt navn
local _,_,year,m,d = string.find(endtime,"(%d+)-(%d+)-(%d+)")
if m == '00' and d == '00' then endtime = '+'..year..'-12-31T23:59:59Z' end
if m == '01' and d == '01' then endtime = '+'..year..'-12-31T23:59:59Z' 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 WPlinkrider(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 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, ...)
local link=''
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)
-- 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 = '+0000-01-01', '+9999-12-31'
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-31T23:59:59Z' end
if m == '01' and d == '01' then endtime = '+'..year..'-12-31T23:59:59Z' 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)
["ar"] = {"المتسابق", "تاريخ الولادة", "الفريق السابق", "ملاحظة", "ملاحظة", "البلد", "قائمة الفريق"},
["fr"] = {"Cycliste", "Date de naissance", "Équipe précédente", "note", "note", "Pays", "Effectif"},
["en"] = {"Rider", "Date of birth", "Previous team", "note", "note", "Country", "Team roster"},
["br"] = {"Reder", "Deiziad genel", "Previous team", "note", "note", "Bro", "Team roster"},
["ca"] = {"Ciclista", "Data de naixement", "Equip previ", "Nota", "Nota", "Pais", "Team roster"},
["cs"] = {"Cyklista", "Datum narození", "Previous team", "note", "note", "Stát", "Team roster"},
["da"] = {"Rytter", "Fødselsdag", "Seneste hold", "note", "note", "Land", "Trup"},
["de"] = {"Name", "Geburtsdatum", "Vorheriges Team", "Anm.", "Anmerkung", "Land", "Team roster"},
["eo"] = {"Antaŭnomo Nomo", "Naskiĝtago", "Previous team", "note", "note", "Lando", "Team roster"},
["es"] = {"Corredor", "Fecha de nacimiento", "Equipo previo", "Nota", "Nota", "Pais", "Integrantes del Equipo"},
["eu"] = {"Izena", "Jaiotze-data", "Aurreko taldea", "Oharra", "Oharra", "Herrialdea", "Team roster"},
["fi"] = {"Ajaja", "Syntymäaika", "Edellinen joukkue", "huomio", "huomio", "Maa", "Team roster"},
["fo"] = {"Súkklari", "Føðingardagur", "Undanfarna lið", "note", "note", "Land", "Team roster"},
["he"] = {"רוכב", "תאריך לידה", "קבוצה קודמת", "הערה", "הערה", "מדינה", "סגל הקבוצה"},
["hu"] = {"Név", "Születésnap", "Előző csapat", "jegyzet", "jegyzet", "Ország", "Team roster"},
["it"] = {"Ciclista", "Data di nascita", "Previous team", "Nota", "Nota", "Paese", "Team roster"},
["ja"] = {"選手名", "生年月日", "前所属", "脚注", "脚注", "国", "Team roster"},
["lb"] = {"Coureur", "Gebuertsdatum", "Equipe virdrun", "Nott", "Nott", "Staat", "Team roster"},
["lv"] = {"Braucējs", "Dzimšanas datums", "Iepriekšējā komanda", "piezīme", "piezīme", "Valsts", "Komandas sastāvs"},
["mk"] = {"Велосипедист", "Датум на раѓање", "Претходна екипа", "Фуснота", "Фуснота", "Држава", "Team roster"},
["nl"] = {"Naam", "Geboortedatum", "Vorige ploeg", "noot", "noot", "Nationaliteit", "Renners"},
["no"] = {"Rytter", "Fødselsdato", "Tidligere lag", "note", "note", "Land", "Ryttere"},
["pl"] = {"Imię i nazwisko", "Data urodzenia", "Poprzednia grupa", "Przypis", "Przypis", "Państwo", "Team roster"},
["pt"] = {"Ciclista", "Data de nascimento", "Equipe anterior", "Nota", "Nota", "Pais", "Integrantes da equipe"},
["ro"] = {"Ciclist", "Data nașterii", "Previous team", "note", "note", "Țară", "Team roster"},
["ru"] = {"Гонщик", "Дата рождения", "Предыдущая команда", "Примечание", "Примечание", "Страна", "Состав"},
["sv"] = {"Namn", "Födelsedatum", "Previous team", "not", "not", "Land", "Team roster"},
["zh"] = {"車手", "出生日期", "Previous team", "脚注", "脚注", "国家", "Team roster"},
["ast"] = {"Corredor", "Data de nacencia", "Equipu previu", "Nota", "Nota", "País", "Integrantes del Equipu"},
}
local l10n = l10nDef[wiki]
if not l10n then l10n = l10nDef["en"] end -- default
return l10n[x]
end
 
function infobox_translate(x)
-- This function permits to translate fields of the infobox, take the line below, give a Wikipedia (ex : mk), and translate all fields. By default, English values are taken.
-- l10nDef["//??.wikipedia.org"] = {"RACE DETAILS", "COURSE", "COMPETITION", "COMPETITIONS", "STAGES", "DATE", "DATES", "DISTANCE", "COUNTRY", "COUNTRIES",
-- "JOURNEY ORIGIN", "JOURNEY DESTINATION", "TEAMS", "STARTING RIDERS", "ARRIVING RIDERS", "AVERAGE SPEED", "COST", "PALMARES", "WINNER", "SECOND", "THIRD",
-- "POINTS", "MOUNTAINS", "SPRINTS", "YOUTH", "COMBATIVITY", "COMBINATION", "TEAM", "Picture", "Caption", "Map", "Special 1", "Special 2", "Documentation",
-- "METAS VOLANTES", "REGULARIDAD", "TEAM POINTS"}
local l10nDef = {
["ar"] = {"تفاصيل السباق", "سلسلة", "منافسة", "مسابقات", "مراحل", "التاريخ", "التواريخ", "المسافات", "البلد", "البلدان",
"نقطة البداية", "نقطة النهاية", "الفرق", "عدد المتسابقين في البداية", "عدد المتسابقين في النهاية", "متوسط السرعة", "الكلفة", "المنصة", "الفائز", "الثاني",
"الثالث", "حسب النقاط", "تسلق الجبل", "سباقات السرعة", "أفضل شاب", "تصنيف القتال", "مجموعة", "الفريق", "صورة", "تعليق", "خريطة", "مميز 1", "مميز 2", "توثيق", "سباقات السرعة", "انتظام", "نقاط الفريق", "فوجا بيناريلو", "أزوري دي إيطاليا"},
["fr"] = {"Généralités", "Course", "Compétition", "Compétitions", "Étapes", "Date", "Dates", "Distance", "Pays", "Pays",
"Lieu de départ", "Lieu d'arrivée", "Équipes", "Partants", "Arrivants", "Vitesse moyenne", "Coût", "Résultats", "Vainqueur", "Deuxième", "Troisième",
"Classement par points", "Meilleur grimpeur", "Meilleur sprinteur", "Meilleur jeune", "Super-combatif", "Meilleur au combiné", "Meilleure équipe",
"Image", "Légende", "Carte", "Special 1", "Special 2", "Documentation", "Étapes volantes", "Régularité", "Meilleure équipe aux points",
"Fuga", "Azzurri d'Italia"},
["en"] = {"Race details", "Course", "Competition", "Competitions", "Stages", "Date", "Dates", "Distance", "Country", "Countries",
"Journey origin", "Journey destination", "Teams", "Starting riders", "Arriving riders", "Average speed", "Cost", "Palmares", "Winner", "Second",
"Third", "Points", "Mountains", "Sprints", "Youth", "Combativity", "Combination", "Team", "Picture", "Caption", "Map", "Special 1", "Special 2",
"Documentation", "Intermediate sprints", "Regularidad", "Team points", "Breakaway", "Azzurri d'Italia"},
["ja"] = {"レース詳細", "コース", "競技", "競技", "ステージ", "日付", "日付", "距離", "距離", "国",
"スタート", "ゴール", "チーム", "参加人数", "完走人数", "平均速度", "Cost", "結果", "優勝", "準優勝",
"3位", "ポイント賞", "山岳賞", "スプリント賞", "新人賞", "敢闘賞", "チーム総合時間賞", "チーム", "画像", "キャプション", "地図", "Special 1", "Special 2",
"ドキュメンテーション", "Metas volantes", "Regularidad", "チームポイント", "Breakaway", "Azzurri d'Italia"},
["br"] = {"Hollegezhioù", "Redadeg", "Kevezadeg", "Kevezadegoù", "Tennadoù", "Deiziad", "Deiziadoù", "Hed", "Bro", "Broioù",
"Lec'h loc'hañ", "Lec'h degouezhout", "Skipailhoù", "Loc'herien", "Erruerien", "Tizh keitat", "Koust", "Disoc'hoù", "Gounezer", "Eil", "Trede",
"Renkadur a-boentoù", "Kraper gwellañ", "Sprinter gwellañ", "Yaouank gwellañ", "Stourmer meur", "Gwellañ el liesrenkadur", "Skipailh gwellañ",
"Picture", "Caption", "Map", "Special 1", "Special 2", "Documentation", "Metas volantes", "Regularidad", "Team points", "Breakaway", "Azzurri d'Italia"},
["ca"] = {"Detalls de la cursa", "Cursa", "Competició", "Competicions", "Etapes", "Data", "Dates", "Distància", "País", "Països",
"Sortida", "Arribada", "Equips", "Inscrits", "Finalitzen", "Velocitat mitjana", "Cost", "Palmarès", "Vencedor", "Segon", "Tercer", "Punts", "Muntanya",
"Esprints", "Joves", "Combativitat", "Combinada", "Equip", "Picture", "Caption", "Map", "Special 1", "Special 2", "Documentació", "Metas volantes",
"Regularidad", "Team points", "Fuga", "Azzurri d'Italia"},
["cs"] = {"Přehled", "Závod", "Soutěž", "Soutěže", "Počet etap", "Datum", "Datum", "Celková délka", "Země", "Země", "Start", "Cíl",
"Týmy", "Běžci", "Příjezdy", "Rychlostní průměr", "Náklady", "Konečné pořadí", "Celkový vítěz", "2. místo", "3. místo", "Vítěz bodovací soutěže",
"Nejlepší vrchař", "Nejlepší sprinter", "Nejlepší mladý jezdec", "Nejaktivnější jezdec", "Nejlepší kombinovaná", "Nejlepší družstvo", "Picture",
"Caption", "Map", "Special 1", "Special 2", "Dokumentace", "Metas volantes", "Regularidad", "Team points", "Breakaway", "Azzurri d'Italia"},
["da"] = {"Løbsdetaljer", "Rute", "Konkurrence", "Konkurrencer", "Etaper", "Dato", "Datoer", "Distance", "Land", "Lande",
"Startby", "Målby", "Hold", "Startende ryttere", "Fuldførende ryttere", "Gennemsnitlig fart", "Pris", "Resultater", "Vinder", "Toer", "Treer",
"Pointtrøje", "Bjergtrøje", "Sprinttrøje", "Ungdomstrøje", "Mest angrebsivrige", "Kombinationstrøje", "Holdkonkurrence", "Billede", "Billedtekst",
"Kort", "Special 1", "Special 2", "Dokumentation", "Indlagt spurt", "Regularitet", "Holdkonkurrence efter point", "Breakaway", "Azzurri d'Italia"},
["de"] = {"Allgemeines", "Ausgabe", "Rennserie", " Wettbewerb", "Etappen", "Datum", "Datum", "Gesamtlänge", "Austragungsland",
"Austragungsländer", "Start", "Ziel", "Teams", "Fahrer am Start", "Fahrer im Ziel", "Durchschnitts&#173;geschwindigkeit", "Kosten", "Ergebnis",
"Sieger", "Zweiter", "Dritter", "Punktewertung", "Bergwertung", "Sprintwertung", "Nachwuchswertung", "Kämpferischster Fahrer", "Kombinationswertung",
"Teamwertung", "Bild", "Beschriftung", "Karte", "Special 1", "Special 2", "Dokumentation", "Metas volantes", "Regularidad", "Teamwertung (Punkte)",
"Breakaway", "Azzurri d'Italia"},
["eo"] = {"Gxeneralajxo", "Bicikla konkurso", "Konkuro", "Konkuroj", "Etapoj", "Dato", "Datoj", "Longo", "Lando", "Landoj",
"Komencloko", "Alvenloko", "Teamoj", "Startantoj", "Alvenantoj", "Averagxa rapido", "Kosto", "Rezultoj", "Venkinto", "Dua pozicio", "Tria pozicio",
"Klasifiko laux poentoj", "Plej bona grimpanto", "Plej bona sprinto", "Plej bona juno", "Superbatalema", "Plej bona por kombino", "Plej bona teamo",
"Picture", "Caption", "Map", "Special 1", "Special 2", "Dokumentado", "Metas volantes", "Regularidad", "Team points", "Breakaway", "Azzurri d'Italia"},
["es"] = {"Detalles", "Carrera", "Competición", "Competiciones", "Etapas", "Fecha", "Fechas", "Distancia total", "País", "Países",
"Lugar de inicio", "Lugar de llegada", "Equipos", "Ciclistas participantes", "Ciclistas finalizados", "Velocidad media", "Costo", "Clasificación final",
"Ganador", "Segundo", "Tercero", "Puntos", "Montaña", "Metas volantes", "Jóvenes", "Combatividad", "Combinada", "Equipo", "Imagen", "Leyenda", "Mapa",
"Especial 1", "Especial 2", "Documentación", "Metas volantes", "Regularidad", "Team points", "Fuga", "Azzurri d'Italia"},
["eu"] = {"Lasterketaren xehetasunak", "Ibilbidea", "Lehiaketa", "Lehiaketak", "Etapak", "Data", "Datak", "Distantzia",
"Herrialdea", "Herrialdeak", "Jardunaldiko abiapuntua", "Jardunaldiko helmuga", "Taldeak", "Abiatutako txirrindulariak", "Iritsitako txirrindulariak",
"Batez besteko abiadura", "Kostua", "Azken sailkapena", "Irabazlea", "Bigarrena", "Hirugarrena", "Puntuak", "Mendiak", "Esprintak", "Gazteak",
"Saiatuena", "Konbinatua", "Taldeak", "Picture", "Caption", "Map", "Special 1", "Special 2", "Dokumentazioa", "Metas volantes", "Regularidad",
"Team points", "Breakaway", "Azzurri d'Italia"},
["fi"] = {"Kilpailun tiedot", "Nimi", "Kilpailu", "Kilpailut", "Etapit", "Päivä", "Päivät", "Matka", "Maa", "Maat",
"Lähtöpaikka", "Saapumispaikka", "Joukkueet", "Osallistuneet pyöräilijät", "Maaliin saapuneet pyöräilijät", "Keskinopeus", "Kustannukset", "Lopputilanne",
"Voittaja", "Toinen", "Kolmas", "Pistekilpailu", "Mäkikirikilpailu", "Sprintit", "Nuoret", "Yritteliäin", "Yhdistelmä", "Joukkue", "Kuva", "Kuvateksti",
"Kartta", "Special 1", "Special 2", "Ohjesivu", "Metas volantes", "Regularidad", "Team points", "Breakaway", "Azzurri d'Italia"},
["fo"] = {"Smálutir", "Leið", "Kapping", "Kappingar", "Teinar", "Dagfesting", "Dagfestingar", "Strekki", "Land", "Lond", "Byrjunarbýur",
"Málbýur", "Lið", "Byrjandi súkklarar", "Fullførandi súkklarar", "Miðalferð", "Kostnaður", "Palmares", "Vinnari", "Nr. 2", "Nr. 3", "Stig", "Fjøll",
"Spurtar", "Ungdómur", "Mest álopssinnaður", "Kombinatión", "Lið", "Picture", "Caption", "Map", "Special 1", "Special 2", "Dokumentation", "Metas volantes",
"Regularidad", "Team points", "Breakaway", "Azzurri d'Italia"},
["lb"] = {"Detailer", "Course", "Kompetitioun", "Kompetitiounen", "Etappen", "Datum", "Datumer", "Distanz", "Land", "Länner",
"Depart", "Arrivée", "Equippen", "Um Depart", "Ukomm", "Vitess-Moyenne", "Käschten", "Palmarès", "Gewënner", "Zweeten", "Drëtten", "Beschte Sprinter",
"Biergpräis", "Sprinter", "Beschte Jonken", "Kombativitéit", "Kombinatioun", "Equipe", "Picture", "Caption", "Map", "Special 1", "Special 2",
"Dokumentatioun", "Étapes volantes", "Regularidad", "Team points", "Breakaway", "Azzurri d'Italia"},
["lv"] = {"Sacensību informācija", "Sacensības", "Kategorija", "Sacensības", "Posmi", "Datums", "Datumi", "Distance", "Valsts",
"Valstis", "Starts", "Finišs", "Komandas", "Braucēji startā", "Braucēji finišā", "Vidējais ātrums", "Izmaksas", "Rezultāti", "Uzvarētājs", "Otrais",
"Trešais", "Punkti", "Kalnu karalis", "Sprints", "Jaunais braucējs", "Cīnītājs", "Kombinācija", "Komanda", "Atēls", "Paraksts", "Karte", "Papildinformācija 1",
"Papildinformācija 2", "Dokumentācija", "Metas volantes", "Regularidad", "Team points", "Breakaway", "Azzurri d'Italia"},
["mk"] = {"Детали за трката", "Издание", "Натпреварување", "Натпреварувања", "Етапи", "Датум", "Датуми", "Растојание",
"Држава", "Држави", "Поаѓалиште", "Одредиште", "Екипи", "Возачи на почеток", "Возачи на крај", "Просечна брзина", "Трошоци", "Добитници на наградите",
"Победник", "Второпласиран", "Третопласиран", "Бодовен", "Планински", "Спринтерски", "Младински", "Борбеност", "Комбиниран", "Екипен", "слика", "опис",
"местоположбена карта", "Special 1", "Special 2", "Документација", "Metas volantes", "Regularidad", "Team points", "Breakaway", "Azzurri d'Italia"},
["nl"] = {"Wedstrijddetails", "Koers", "Wedstrijd", "Wedstrijden", "Etappes", "Datum", "Datums", "Afstand", "Land", "Landen",
"Startplaats", "Finishplaats", "Teams", "Aantal coureurs aan de start", "Aantal coureurs bij de aankomst", "Gemiddelde snelheid", "Kosten", "Palmares",
"Winnaar", "Tweede", "Derde", "Punten", "Bergen", "Sprints", "Jeugd", "Aanvalslust", "Combinatie", "Team", "Picture", "Caption", "Map", "Special 1",
"Special 2", "Documentatie", "Metas volantes", "Regularidad", "Teampunten", "Breakaway", "Azzurri d'Italia"},
["no"] = {"Detaljer", "Ritt", "Konkurranse", "Konkurranser", "Etapper", "Dato", "Datoer", "Distanse", "Land", "Land", "Startsted",
"Målsted", "Lag", "Startende ryttere", "Fullførende ryttere", "Gjennomsnittsfart", "Kostnad", "Resultater", "Vinner", "2. plass", "3. plass", "Poeng",
"Klatring", "Spurt", "Ungdom", "Mest offensive", "Kombinasjon", "Lagkonkurranse", "Bilde", "Bildetekst", "Kart", "Spesial 1", "Spesial 2", "Dokumentasjon",
"Innlagte spurter", "Regularitet", "Lagkonkurranse (poeng)", "Brudd", "Azzurri d'Italia"},
["pl"] = {"Wyrażenia ogólne", "Wyścig", "Konkurencja", "Konkursy", "Etapów", "Data", "Daty", "Dystans", "Państwo", "Państwy",
"Odejście", "Przyjazd", "Zespoły", "Zgłoszenia", "Ukończyło wyścig", "Średnia prędkość", "Koszt", "Podium", "Pierwsze miejsce", "Drugie miejsce",
"Trzecie miejsce", "Punktowa", "Górska", "Sprinterska", "Młodzieżowa", "Najaktywniejszych", "Kombinowana", "Drużynowa", "Picture", "Caption", "Map",
"Special 1", "Special 2", "Dokumentacja", "Metas volantes", "Regularidad", "Team points", "Breakaway", "Azzurri d'Italia"},
["pt"] = {"Detalhes", "Corrida", "Válida para", "Válida para", "Etapas", "Data", "Data", "Distância", "País", "Países",
"Partida", "Chegada", "Nº de equipes", "Ciclistas que iniciaram", "Ciclistas que finalizaram", "Velocidade média", "Custo", "Classificação final",
"Vencedor", "Segundo", "Terceiro", "Prêmio por pontos", "Prêmio de montanha", "Sprints", "Juventude", "Disputa", "Combinação", "Equipes", "Imagem",
"Legenda", "Mapa", "Special 1", "Special 2", "Documentação", "Metas volantes", "Regularidad", "Team points", "Breakaway", "Azzurri d'Italia"},
["ro"] = {"Detalii cursă", "Cursă", "Competiție", "Competiții", "Etape", "Dată", "Date", "Distanță", "Țară", "Țări", "Start",
"Sosire", "Echipe", "Cicliști la start", "Cicliști la sosire", "Viteză medie", "Cost", "Palmares", "Câștigător", "Al doilea", "Al treilea", "Clasament pe puncte",
"Cel mai bun cățărător", "Cel mai bun sprinter", "Cel mai bun tânăr", "Combativitate", "Combinat", "Echipă", "Picture", "Caption", "Map", "Special 1",
"Special 2", "Documentație", "Metas volantes", "Regularidad", "Team points", "Breakaway", "Azzurri d'Italia"},
["ru"] = {"Детали гонки", "Маршрут", "Соревнование", "Соревнования", "Этапы", "Дата", "Даты", "Дистанция", "Страна", "Страны",
"Место старта", "Место финиша", "Команды", "Стартовало гонщиков", "Финишировало гонщиков", "Средняя скорость", "Призовые", "Призёры", "Победитель",
"Второй", "Третий", "Очковая", "Горная", "Спринтерская", "Молодёжная", "Бойцовская", "Комбинированная", "Командная по времени", "Вид", "Описание", "Карта", "Сектор 1",
"Сектор 2", "Документация", "Промежуточные финиши", "Регулярность", "Командная по очкам", "Breakaway", "Azzurri d'Italia"},
["sv"] = {"Race details", "Course", "Competition", "Competitions", "Stages", "Date", "Dates", "Distance", "Country", "Countries",
"Journey origin", "Journey destination", "Teams", "Starting riders", "Arriving riders", "Average speed", "Cost", "Palmares", "Winner", "Second",
"Third", "Points", "Mountains", "Sprints", "Youth", "Combativity", "Combination", "Team", "Picture", "Caption", "Map", "Special 1", "Special 2",
"Documentation", "Metas volantes", "Regularidad", "Team points", "Breakaway", "Azzurri d'Italia"},
["ast"] = {"Detalles", "Carrera", "Competición", "Competiciones", "Etapes", "Data", "Dates", "Distancia total", "País", "Países",
"Llugar d'entamu", "Llugar de llegada", "Equipos", "Ciclistes participantes", "Ciclistes acabaos", "Velocidá media", "Costu", "Clasificación final", "Ganador", "Segundu",
"Terceru", "Puntos", "Monte", "Metes volantes", "Mozos", "Combatividá", "Combinada", "Equipu", "Imaxe", "Lleenda", "Mapa", "Especial 1", "Especial 2",
"Documentación", "Metes volantes", "Regularidá", "Team points", "Fuga", "Azzurri d'Italia"}
}
local l10n = l10nDef[wiki]
if not l10n then l10n = l10nDef["en"] end -- default
return l10n[x]
end
 
function unit(x)
local l10nDef = {
["ar"] = {"", " س ", " دقيقة ", " ث", ' كم/س', " نقطة", " نقطة"},
["fr"] = {"en", " h ", " min ", " s", ' km/h', " pt", " pts"},
["br"] = {"", "e ", "' ", '"', ' km/h', " pt", " pts"},
["da"] = {"", "t ", "' ", '"', ' km/t', " point", " point"},
["de"] = {"", " h ", " min ", " s", ' km/h', " P.", " P."},
["en"] = {"", "h ", "' ", '"', ' km/h', " pt", " pts"},
["es"] = {"", " h ", " min ", " s", ' km/h', " pt&nbsp;&nbsp;", " pts"},
["eu"] = {"", " h ", " min ", " s", ' km/h', " pt", " pt"},
["fo"] = {"", "t ", "' ", '"', ' km/t', " pt", " pts"},
["fi"] = {"", ".", ".", "", ' km/h', " pt", " pts"},
["hu"] = {"", " óra ", ":", "", ' km/h', " pt", " pts"},
["it"] = {"", "h", "'", '"', ' km/h', " pt", " pts"},
["ja"] = {"", "時間", "分", '秒', 'km/h', "ポイント", "ポイント"},
["lb"] = {"", " h ", " min ", " s", ' km/h', " pt", " pts"},
["mk"] = {"", "ч ", "' ", "", ' км/ч', " pt", " pts"},
["nl"] = {"", "u", "'", '"', ' km/u', " pt", " pts"},
["no"] = {"", "t ", "' ", '"', ' km/t', " poeng", " poeng"},
["pt"] = {"", "h", "m", "s", ' km/h', " pt", " pts"},
["ru"] = {"", "ч ", "' ", "", ' км/ч', " очко", " очков"},
["ast"] = {"", " h ", " min ", " s", ' km/h', " pt ", " pts"}
}
local l10n = l10nDef[wiki]
if not l10n then l10n = l10nDef["en"] 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
if wiki == "ca" then
if b==1 then str = b.."r"
elseif b==2 then str = b.."n"
elseif b==3 then str = b.."r"
elseif b==4 then str = b.."t"
else str = b.."è"
end
elseif wiki=="es" then
if gender == 'm' or gender == 'n' then str = b..".º"
elseif gender == 'f' then str = b..".ª"
else str = b.."."
end
elseif wiki=="fr" 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
elseif wiki=="nl" then str=b.."e"
elseif wiki=="ru" then str=b.."-й"
elseif wiki=="eo" then str=b.."-a"
elseif wiki=="ast" then
if gender == 'm' or gender == 'n' then str = b.."ᵘ"
elseif gender == 'f' then str = b..".ª"
else str = b.."."
end
else str = b .. ". "
end
return str
end
 
function calculate_time(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
 
local function getRiderLink(riderID)
local link
local sitelink = mw.wikibase.getSitelink(riderID)
 
if sitelink then
if wiki == "de" then
-- Russian riders get label as alias, to shorten the name
local label = mw.wikibase.getLabelByLang(riderID, wiki)
if label then
local p27 = mw.wikibase.getBestStatements(riderID, 'P27') -- P27 is country of citizenship
if p27[1] and p27[1].mainsnak.snaktype == 'value' then
local c = p27[1].mainsnak.datavalue.value.numeric-id
if c==159 or c==184 or c==212 or c==232 then -- Q159, Q184, Q212, Q232 is Russia, Belarus, Ukraine, Kazakhstan
link = "[[" .. sitelink .. "|" .. label .. "]]"
end
end
end
else
link = "[[" .. sitelink .. "|" .. mw.text.trim(mw.ustring.gsub(sitelink, "%b()", "")) .. "]]"
end
return link
end
 
-- No WP article. Display label, and make it a red link if no other article uses the title
local label = mw.wikibase.getLabelByLang(riderID, wiki)
if label then
if wiki == 'ar' then
local title = mw.title.new(label)
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
if black_list(wiki, label) then
link = label
else
local title = mw.title.new(label)
if title and title.exists then
link = label
else
link = "[[" .. label.. "]]"
end
end
end
return link
end
 
-- No label in the local language. Try other languages, but don't link.
if wiki == 'ar' then
link = getLabelFallback(riderID, {'en', 'fr', 'de'})
else
link = getLabelFallback(riderID, {'en', 'de'})
end
if link then
link = mw.ustring.gsub(link, "%b()", "")
else
link = "(label missing)"
end
return link
end
 
function getTeam(riderID, timeOfRace, q)
-- q: qualifiers of statement in race entity where the rider is the value
local teamID, link
if q.P54 and q.P54[1].snaktype == 'value' then -- P54 is member of sports team
teamID = q.P54[1].datavalue.value.id
link = getTeamLinkCat(teamID, timeOfRace)
else
p54 = getStatementForTime(riderID, 'P54', timeOfRace)
if p54 then
teamID = p54.mainsnak.datavalue.value.id
link = getTeamLinkCat(teamID, timeOfRace)
end
end
return link
end
 
 
function p.stageclassification(frame)
if tonumber(frame.args[2])==0 then
display_reftemp=tonumber(frame.args[2])
else
display_reftemp=0
else
display_reftemp=1
end
local s = {
 
function p.generalclassification(frame)
if tonumber(frame.args[2])==0 then
display_reftemp=tonumber(frame.args[2])0
else
display_reftemp=01
end
local s = {
end
 
function p.teamtimetrialclassificationgeneralclassificationforttt(frame)
if tonumber(frame.args[2])==0 then
display_reftemp=tonumber(frame.args[2])0
else
display_reftemp=1
end
local s = {
header_function = headoftableII, -- translations are in function headoftableII
header_1 = 9, -- translation 10 in function headoftableII is printed in the upper part of the table header
header_2 = {3, 2, 4, 5, 6}, -- translations 3, 2, 4, 5, 6 in function headoftableII are printed in this order in the lower part of the table header
item = frame.args[1],
property = 'P2321', -- 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.teamtimetrialclassification(frame)
if tonumber(frame.args[2])==0 then
display_reftemp=0
else
display_reftemp=1
end
 
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 p.custompointsclassification(frame)
local s = {
header_function = headoftableII, -- translations are in function headoftableII
header_2 = {1, 2, 3, 7}, -- translations 1, 2, 3, 7 in function headoftableII are printed in this order in the lower part of the table header
header_1_text=string.gsub(frame.args[3], "%c", ""),
item = string.gsub(frame.args[1], "%c", ""),
property = string.gsub(frame.args[2], "%c", ""), -- 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.customtimeclassification(frame)
local s = {
header_function = headoftableII, -- translations are in function headoftableII
header_2 = {1, 2, 3, 4}, -- translations 1, 2, 3, 7 in function headoftableII are printed in this order in the lower part of the table header
header_1_text=string.gsub(frame.args[3], "%c", ""),
item = string.gsub(frame.args[1], "%c", ""),
property = string.gsub(frame.args[2], "%c", ""), -- 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
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)
local jersey_string = ' '
local 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
for _, v in ipairs(h) do
local jersey_name
if jerseys[v] then
jersey_string = jersey_string .. '[[File:' .. jerseys[v].file .. '|20px'
jersey_name = jerseys[v]['name_' .. wiki] or mw.wikibase.getLabel(v) or jerseys[v]['name_fr']
if jersey_name then
jersey_string = jersey_string .. '|' .. jersey_name
end
jersey_string = jersey_string .. ']]'
else
p18 = mw.wikibase.getBestStatements(v, 'P18')
if p18[1] and p18[1].mainsnak.snaktype == 'value' then
jersey_string = jersey_string .. '[[File:' .. p18[1].mainsnak.datavalue.value .. '|20px'
jersey_name = getLabelFallback(v, {wikilang, 'en', 'fr'})
if jersey_name then
jersey_string = jersey_string .. '|' .. jersey_name
end
jersey_string = jersey_string .. ']]'
end
end
end
end
return jersey_string
end -- function end
 
local timeOfRace, errorMessage = getTimeOfRace(raceID)
end
local tableHeader2_size = table.getn(s.header_2)
 
if s.header_1_text ==nil then s.header_1_text=s.header_function(s.header_1) end --for custom title
 
local tableStart = '<table border="0" cellspacing="0" cellpadding="0"><tr><th colspan="' ..
'" style="padding:2px 2px; text-align:center; background-color:#FFDF80">'
local tableHeader1 = '<span style="float:left">[[File:Wikidata-logo S.svg|12px|link=d:' ..
raceID .. '#' .. s.property..']]</span>'.. s.header_function(s.header_1)header_1_text .. '</th></tr>'
local tableHeader2 = '<tr style="text-align:center;padding:2px 2px;white-space:nowrap">'
for i, k in ipairs(s.header_2) do
local riderID = m.mainsnak.datavalue.value.id
local q = m.qualifiers or {}
local rank, riderLink, gender, countryID, countryName, flagLink, teamLink
local flagLink, countryName = '', ''
local h = {
jersey = {}, -- lots of jerseyID
if wiki == 'es' or wiki == 'fr' or wiki == 'ast' then
--[[ These wikis need the gender to display the rank correct. Other wikis can skip this. ]]
local p21gender = mw.wikibase.getBestStatementsgetgendercode(riderID, 'P21n') -- P21 is gender
if p21[1] and p21[1].mainsnak.snaktype == 'value' then
local g = p21[1].mainsnak.datavalue.value.id
if g == 'Q6581097' then gender = 'm' -- Male
elseif g == 'Q6581072' then gender = 'f' -- Female
end
else
gender = 'n' -- For teams
end
end
 
if q.P1358 and q.P1358[1].snaktype == 'value' then -- P1358 is points
h.value[1] = tonumber(q.P1358[1].datavalue.value.amount)
end
if q.P2781 and q.P2781[1].snaktype == 'value' then -- P2781 is race time
h.value[2] = tonumber(q.P2781[1].datavalue.value.amount)
end
h.value[1] = qualifieramount(m, 'P1358')
h.value[2] = qualifieramount(m, 'P2781')
if q.P2911 and q.P2911[1].snaktype == 'value' then -- P2911 is time gap
h.value[3] = tonumber(q.P2911[1].datavalue.value.amount)
plus = '+ '
end
h.value[4] = qualifieramount(m, 'P2052')
if q.P2052 and q.P2052[1].snaktype == 'value' then -- P2052 is speed
h.value[4] = tonumber(q.P2052[1].datavalue.value.amount)
end
if q.P2912 then -- P2912 is distinctive jersey
for _, v in pairs(q.P2912) do
teamLink, _, countryID = getTeamLinkCat(riderID, timeOfRace, true)
else
riderLink = getRiderLink(riderID,timeOfRace)
teamLink = getTeam(riderID, timeOfRace, q)
local p27 = getStatementForTime(riderID, 'P27', timeOfRace) --P27 is country of citizenship
end
end
flagLink =if flag(countryID, timeOfRace)then
flagLink = flag(countryID, timeOfRace)
if available_list and country then
if type(translations.list)available_list ==and "function"country then
countryName =if type(translations.list(countryID) == "function" then
countryName = translations.list(countryID)
end
if countryName == '' then end
if countryName == '' then
local label, lang = mw.wikibase.getLabelWithLang(countryID)
local label, lang = mw.wikibase.getLabelWithLang(countryID)
--[[ Uses standard language fallback. Should not be nil, as all countries have English labels. ]]
--[[ Uses standard language fallback. Should not be nil, as all countries have English labels. ]]
if lang == wikilang then
countryNameif lang == wikilang labelthen
countryName = label
else
else
countryName = label .. ' (' .. lang .. ')'
countryName = label .. ' (' .. lang .. ')'
end
end
end
end
end
 
["Q43276992"] ="#FFC0CB" , -- Jersey pink.svg (Points)
["Q47945989"] ="#6495ED" , -- Jersey dark blue.svg (Points)
["Q56449834"] ="#E0FFFF" , -- Jersey blue dotted.png (Points)
["Q25265958"] ="#FFC0CB" , -- Jersey polkadot.svg (Mountain)
["Q25265959"] ="#E0FFFF" , -- Jersey blue dotted.png (Mountain)
["Q47537141"] ="#87CEEB" , -- MaillotCyan.PNG (Mountain)
["Q50822370"] ="#FFC0CB" , -- Jersey red lines volta.svg (Mountain)
["Q56246573"] ="#C0C0C0" , -- Jersey black white dotted.svg (Mountain)
["Q26858731"] ="#FFFFFF" , -- Jersey white.svg (Combinated)
["Q28823004"] ="#FFFF99" , -- Jersey combined.svg (Combinated)
["Q38929482"] ="#FFFF99" , -- Jersey yellow.svg (Best young)
["Q33026698"] ="#FF8666" , -- Jersey red.svg (Best young)
["Q56002706"] ="#87CEEB" , -- MaillotCyan.PNG (Best young)
["Q50822410"] ="#99CBFF" , -- Jersey blue lines volta.svg (Best young)
["Q26953919"] ="#8FBC8F" , -- Jersey dark green.svg (Combativity)
 
if not s.team_classification then
if not teamLink then teamLink = '' end
if not available_list then
if s.displayteam==false then
tBody = tBody .. flagLink .. ' '.. riderLink .. jersey(h.jersey) .. '</td><td>'.. teamLink
tBody = tBody .. flagLink .. ' '.. riderLink .. jersey(h.jersey)
else
tBody = tBody .. flagLink .. ' '.. riderLink .. jersey(h.jersey) .. '</td><td>'.. teamLink
end
else
if country == true then
if s.displayteam==false then
tBody = tBody .. riderLink .. jersey(h.jersey) ..'</td><td>' .. flagLink ..
tBody = tBody .. riderLink .. jersey(h.jersey) ..'</td><td>' .. flagLink ..
' '.. countryName
else
tBody = tBody .. riderLink .. jersey(h.jersey) ..'</td><td>' .. flagLink ..
' '.. countryName .. '</td><td style="text-align:' .. textalign ..
';padding:0 0.2em 0 0.2em">'.. teamLink
end
else
if s.displayteam==false then
tBody = tBody .. flagLink .. ' ' .. riderLink .. jersey(h.jersey) ..
tBody = tBody .. flagLink .. ' ' .. riderLink .. jersey(h.jersey)
else
tBody = tBody .. flagLink .. ' ' .. riderLink .. jersey(h.jersey) ..
'</td><td style="text-align:' .. textalign .. ';padding:0 0.2em 0 0.2em">'.. teamLink
end
end
end
end
 
if s.header_2[4] == 7 or (s.header_2[3] == 7 and s.header_2[1] == 1) then -- for table pointsclassification, adds points
--trick for UCI classification
tBody = tBody.. '<td style="text-align:right;padding:0 0.2em 0 0.2em">'.. h.value[1]
.. '<span style="font-size:80%">'
 
if s.header_2[3] == 4 then
if s.property == 'P2417' thenor --s.property for== table'P2321' teamtimetrialclassification, adds timethen
-- for tables teamtimetrialclassification or generaltttclassification, adds time
tBody = tBody.. '<td style="text-align:right;padding:0 0.2em 0 0.2em">'..
calculate_time(h.value[2]) .. '</td>'
end
tBody = tBody.. '</tr>'
t_Body[#t_Body + 1] = {(type(rank) == 'number') and rank or 999, tBody}
end
end
end
 
--=== G) Infobox ===
function references(entity, property, var1)
function p.infobox(frame)
local ref1, ref2, ref2b, ref3, ref4 = "", " ", "", "", ""
localframe = frame
local url, ref
-- If true, winners will have Wikidata logos with link to Wikidata
local lang = mw.language.getContentLanguage()
local WDlink_on = (wiki == "mk" or wiki == "ja")
local a, b
 
-- If true, winners will the team of the cyclist
if onwikidata then lang = mw.getLanguage('fr') end
local team = true
 
local details = {
a, b = pcall(fooB, 'value', entity, property, var1, 1, 'P854', 1) -- url
{ name = infobox_translate(2)}, -- course
if a == true then ref1 = b end
{ name = infobox_translate(3), name_plural = infobox_translate(4)}, -- competition
a, b = pcall(fooB, 'text', entity, property, var1, 1, 'P1476', 1) -- Originaltitel der webpage, "language": "fr"
{ name = infobox_translate(5)}, -- stages
if a == true then
{ name = infobox_translate(6), name_plural = infobox_translate(7)}, -- date
ref2 = b
{ name = infobox_translate(8)}, -- distance
ref2b= entity.claims[property][var1].references[1].snaks['P1476'][1].datavalue.value.language or ''
{ name = infobox_translate(9), name_plural = infobox_translate(10)}, -- country
if ref2b == wiki then ref2b = '' else ref2b = '(' .. ref2b .. ') ' end
{ name = infobox_translate(11)}, -- start place
end
{ name = infobox_translate(12)}, -- endplace
a, b = pcall(fooB, 'time', entity, property, var1, 1, 'P577', 1) -- publication date
{ name = infobox_translate(13)}, -- teams
if a == true then
{ name = infobox_translate(14)}, -- participants at start
local _, _, year, m, d = string.find(b,"(%d+)-(%d+)-(%d+)")
{ name = infobox_translate(15)}, -- participants at end
if d ~= '00' and m ~= '00' then
{ name = infobox_translate(16)}, -- speed
if wiki == "de" then ref3 = ', ' .. lang:formatDate( "j. F Y", b)
{ name = infobox_translate(17)}, -- cost
elseif wiki == "ar" then ref3 = '، ' .. lang:formatDate( "j F Y", b) .. '.'
{ name = infobox_translate(32), special = true}, -- special 1
elseif wiki == "en" then ref3 = ', ' .. lang:formatDate( "Y F, j", b) .. '.'
{ name = infobox_translate(33), special = true}, -- special 2
elseif wiki == "fr" then ref3 = ', ' .. lang:formatDate( "j F Y", b)
}
else ref3 = ', ' .. func_date (b, 'long') .. '.' --lang:formatDate( "j n Y", b) .. '.'
local others = {
end
{ name = infobox_translate(29)}, -- picture
elseif d == '00' and m ~= '00' then
{ name = infobox_translate(30)}, -- caption
d = '01'
{ name = infobox_translate(31)}, -- map
if wiki == "de" then ref3 = ', ' .. lang:formatDate( "F Y", year..'-'..m..'-'..d )
}
elseif wiki == "ar" then ref3 ='، ' .. lang:formatDate( "F Y", year..'-'..m..'-'..d )..'.'
local winners = {
elseif wiki == "en" then ref3 =', ' .. lang:formatDate( "Y F", year..'-'..m..'-'..d )..'.'
{ name = infobox_translate(19), QID = 'Q20882667' }, -- first
elseif wiki == "fr" then ref3 =', ' .. lang:formatDate( "F Y", year..'-'..m..'-'..d )
{ name = infobox_translate(20), QID = 'Q20882668' }, -- second
else ref3 = ', ' .. lang:formatDate( "F Y", year..'-'..m..'-'..d )..'.'
{ name = infobox_translate(21), QID = 'Q20882669' }, -- third
end
{ name = infobox_translate(22), QID = 'Q20883007' }, -- points
else ref3 = year
{ name = infobox_translate(23), QID = 'Q20883212' }, -- mountains
end
{ name = infobox_translate(24), QID = 'Q20883328' }, -- sprints
end
{ name = infobox_translate(25), QID = 'Q20883139' }, -- youth
a, b = pcall(fooB, 'time', entity, property, var1, 1, 'P813', 1) -- Retrieved
{ name = infobox_translate(26), QID = 'Q20893983' }, -- combativity
if a == true then
{ name = infobox_translate(35), QID = 'Q27067359' }, -- volantes
if wiki == "de" then ref4 = ", (abgerufen am " .. lang:formatDate( "j. F Y", b).. ')'
{ name = infobox_translate(36), QID = 'Q27067170' }, -- regularity
elseif wiki == "ar" then ref4 = " تاريخ الوصول " .. lang:formatDate( "j F Y", b) .. '.'
{ name = infobox_translate(27), QID = 'Q20893979' }, -- combination
elseif wiki == "en" then ref4 = " Retrieved " .. lang:formatDate( "Y F, j", b) .. '.'
{ name = infobox_translate(38), QID = 'Q27907715' }, -- breakaway
elseif wiki == "fr" then ref4 = " (consulté le " .. lang:formatDate( "j F Y", b) .. ')'
{ name = infobox_translate(39), QID = 'Q27907747' }, -- azzurri
else ref4 = " Retrieved " .. func_date (b, 'long').. '.' --lang:formatDate( "j n Y", b) .. '.'
{ name = infobox_translate(40), QID = 'Q28092831' }, -- rookie
end
{ name = infobox_translate(28), QID = 'Q20882921' }, -- teams
end
{ name = infobox_translate(37), QID = 'Q27104269' }, -- teamspoints
}
 
local entityID = mw.text.trim(frame.args[1])
if ref1~='' then --and ref2~='' then
local _, startwiki = string.find( ref1, '//' )wiki
local wikilang = wikilang
local ende, _ = string.find( ref1, '/', start + 1 )
local wikibase = mw.wikibase
local s = string.sub(ref1, start + 1, ende - 1)
if type(entityID) ~= 'string' then error('parameter must be a string') end
local s2 = string.gsub(s, "www.", "")
if not entityID:match('Q%d+') then error ('parameter must be a valid Wikidata item (ex: Q42)') end
if wiki == "fr" then
-- fr: "(en) « Lloyd Mondory ... EPO », sur velonews.competitor.com (consulté le 30 april 2016), 30 octobre 2015."
if ref2~=' ' then url= ', sur <span style="font-style:italic;">' .. s2 .. '</span>' else url='' end
ref = ref2b .. '« ['.. ref1.. ' '.. ref2.. '] »' .. url .. ref4 .. ref3 ..'.'
elseif wiki == "en" then
-- en: "Inflation ... recession", Pittsburgh Post-Gazette, October 16, 2009. Retrieved 2010-01-21.
if ref2~=' ' then url= ', <span style="font-style:italic;">' .. s2 .. '</span>' else url='' end
ref = '"['.. ref1.. ' '.. ref2.. '"]'.. ref2b .. url .. ref3 .. ref4
elseif wiki == "de" then
if ref2~=' ' then url= ' In: <span style="font-style:italic;">' .. s2 .. '</span>' else url='' end
ref = '<span style="font-style:italic;">['.. ref1.. ' '.. ref2.. '.]</span> '.. url.. ref3 .. ref4 ..'.'
else
if ref2~=' ' then url= ' <span style="font-style:italic;">' .. s2 .. '</span>' else url='' end
ref = ref2b .. '['.. ref1.. ' '.. ref2.. '] ' .. url.. ref3 .. ref4
end
return ref or ''
else return ''
end
end
 
function p.infobox(frame)
local t = {is_a="", class="", stage="", starttime="", endtime="", time="", date="", dates="", length="", length_unit="",
startplace="", endplace="", nr_teams="", nr_participants_start="", nr_participants_end="", speed="", speed_unit="", cost="", cost_unit="",
first="", first_team="", second="", second_team="", third="", third_team="", winner_point="", winner_point_team="", winner_mountain="", winner_mountain_team="",
winner_sprint="", winner_sprint_team="", winner_young="", winner_young_team="", winner_fighting="", winner_fighting_team="", winner_combination="",
winner_combination_team="", winner_metas_volantes="", winner_metas_volantes_team="", winner_regularity="", winner_regularity_team="",
winner_breakaway="", winner_breakaway_team="", winner_azzurri_ditalia="", winner_azzurri_ditalia_team="", winner_team="",
winner_team_points="", previous="", next=""}
local ref = {stage="", starttime="", endtime="", time="", date="", dates="", length="", nr_participants_start="", nr_participants_end="",
speed="", speed_unit="", cost="", first="", second="", third="", winner_point="", winner_mountain="", winner_sprint="", winner_young="",
winner_fighting="", winner_metas_volantes="", winner_regularity="", winner_combination="", winner_breakaway="", winner_azzurri_ditalia="",
winner_team="", winner_team_points=""}
local tt = {icon="", picture="", caption="", name="", nr="", map="" }
local ttt = {tour={}, country={}}
local tttt = {special_1a="", special_1b="", special_2a="", special_2b=""}
 
local entity = ""
local y, m, d = "", "", ""
local y2, m2, d2 = "", "", ""
local a, b, c, k, num, i
local entityId = frame.args[1]
local lang = mw.language.getContentLanguage()
local results = false
local a1, b1, c1, a2, b2, c2
local timeofrace
 
if type( entityId ) ~= 'string' then error( 'parameter must be a string') end
if not entityId:match( 'Q%d+' ) then error ( 'parameter must be a valid Wikidata item (ex: Q42)' ) end
local entity = mw.wikibase.getEntity( entityId )
 
local localFrame
if string.match(frame:getParent():getTitle(), '%P+') == mw.site.namespaces.Template.name then
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
localFrame = frame
if wiki == "ar" and entity:getLabel( 'en' ) ~= nil then tt.name = entity:getLabel( 'en' )
elseif entity:getLabel( 'fr' ) ~= nil then tt.name = entity:getLabel( 'fr' ).. " (fr)"
else tt.name = "Wikidata doesn´t know" end
end
getLocalContent(details, localFrame.args)
getLocalContent(others, localFrame.args)
getLocalContent(winners, localFrame.args)
 
local name, dateOfRace, class
a, b = pcall(fooA, 'numeric-id', entity, 'P641', 1)
iflocal aicon == true(firstValue(entityID, then'P641', 'numeric--id') icon== for3609) roadand bicycle-- racingP641 is 'sport', Q3609 (is 'road bicycle racing)'
if b == 3609 then tt.icon = "' [[File:Cycling (road) pictogram.svg|35px]]"' or end''
end
a, b = pcall(fooA, 'value', entity, 'P18', 1)
if a == true and tt.picture == "" then
local v
tt.picture = b
if pcall(foo3, entity, "P18", 1, "P2096", 1) then
for _, v in pairs(entity.claims["P18"]) do
for num=1,#v.qualifiers["P2096"] do
if v.qualifiers["P2096"][num].datavalue.value.language == lang:getCode() then
tt.caption = v.qualifiers["P2096"][num].datavalue.value.text end
end
end
end
end
 
local name = wikibase.getLabel(entityID)
-- For FR Wiki and Wikidata, exception that permit to display 1er, 2e... for the edition number ;
if not name then
-- for RU Wiki, -й is written after the value of P393
a, b name = pcallgetLabelFallback(fooAentityID, {'valueen', entity, 'P393fr', 1'de'}) or ''
if a == true and tt.nr == "" then
tt.nr = b .. ". "
if wiki == "fr" 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 == "ru" then tt.nr = b .."-й " 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
if not others[1].content then --picture
-- Class of a cycling race. Class is: 1.UWT, 2.UWT, 1.HC, ... add new classes, no problem
others[1].content, others[2].content = getImage(entityID) -- picture, caption
local class = { "Q22231106", "Q22231107", "Q22231108", "Q22231109", "Q22231110", "Q22231111", "Q22231112",
"Q22231113", "Q22231114", "Q22231115", "Q22231116", "Q22231117", "Q22231118", "Q22231119", "Q23015458", "Q23005601", "Q23005603" }
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"..b == class[i] then t.class = "c"..b t.is_a = "Q"..d break end
if "Q"..d == class[i] then t.class = "c"..d t.is_a = "Q"..b break end
end
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 not others[3].content then -- map
if t.is_a == "Q27020041" then -- if is_a = season so try to find it from "season of"
others[3].content = firstValue(entityID, 'P242') -- P242 is 'locator map image'
a, b = pcall(fooA, 'numeric-id', entity, 'P3450', 1)
if a == true then t.is_a = "Q"..b end
end
 
if not details[1].content then -- course
a, b = pcall(fooA, 'numeric-id', entity, 'P361', 1) -- Competition of the cycling race : UCI World Tour 2016, UCI Europe Tour 2016...
-- For FR Wiki and Wikidata, exception that permit to display 1er, 2e... for the edition number ;
if a == true then --ttt.tour = "Q" .. b end
-- for RU Wiki, -й is written after the value of P393
local i, v
local nr = firstValue(entityID, 'P393') -- P393 is 'edition number'
for i, v in pairs(entity.claims["P361"]) do
if nr then
ttt.tour[i] = "T" .. v.mainsnak.datavalue.value["numeric-id"]
if wiki == 'fr' then nr = (nr == 1) and "1<sup>re</sup> " or (nr .. "<sup>e</sup> ")
elseif wiki == "nl" then nr = nr .. "e "
elseif wiki == "ru" then nr = nr .. "-й "
elseif wiki == "eo" then nr = nr .. "-a "
elseif wiki == "hu" then nr = nr .. "-ik "
else nr = nr .. ". "
end
end
local is_a
end
for _, p31 in statements(entityID, 'P31') do -- P31 is 'instance of'
 
local instanceOf = p31.mainsnak.datavalue.value.id
if t.stage == "" then
if instanceOf == 'Q27968055' then -- Q27968055 is 'recurrent event edition'
if pcall(function() -- This function count the number of value for P527 to determine the number of stages
-- do nothing
t.stage = table.getn(entity.claims["P527"])
elseif classes[instanceOf] then
class = classLink(instanceOf)
elseif instanceOf == "Q27020041" then -- Q27020041 is 'sports season'
local season = firstValue(entityID, 'P3450', 'id') -- P3450 is 'sports season of league or competition'
if season then
is_a = raceLink(season)
end
else
is_a = raceLink(instanceOf)
end
end
if nr and is_a then
) then else t.stage = "" end
details[1].content = nr .. ' ' .. is_a
end
 
a1, b1, c1 = pcall(fooA, 'time', entity, 'P580', 1)
if a1 == true and t.starttime == "" then i = 1
while a1 == true and c1 == 'deprecated' do
i = i + 1
a1, b1, c1 = pcall(fooA, 'time', entity, 'P580', i)
end
--b1 = "+2015-07-04T00:00:00Z"
_, _, y, m, d = string.find(b1, "(%d+)-(%d+)-(%d+)")
end
a2, b2, c2 = pcall(fooA, 'time', entity, 'P582', 1)
if a2not == true and tdetails[2].endtime == ""content then i =-- 1competition
-- Class of a cycling race. Class is: 1.UWT, 2.UWT, 1.HC, ... add new classes, no problem
while a2 == true and c2 == 'deprecated' do
-- Competition of the cycling race : UCI World Tour 2016, UCI Europe Tour 2016...
i = i + 1
local tours = {}
a2, b2, c2 = pcall(fooA, 'time', entity, 'P582', i)
for _, p361 in statements(entityID, 'P361') do -- P361 is 'part of'
tours[#tours + 1] = raceLink(p361.mainsnak.datavalue.value.id)
end
if tours[1] then
--b2 = "+2015-07-05T00:00:00Z"
if #tours > 1 then
_, _, y2, m2, d2 = string.find(b2, "(%d+)-(%d+)-(%d+)")
details[2].name = details[2].name_plural
end
end
if a1 == true and t.starttime == "" then
if class then
if y ~= y2 then t.starttime = lang:formatDate( "j F Y", b1 )
tours[1] = tours[1] .. ' ' .. class
elseif m ~= m2 then t.starttime = lang:formatDate( "j F", b1 )
end
else t.starttime = lang:formatDate( "j", b1 )
details[2].content = table.concat(tours, '<br/>')
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 )
elseif m ~= m2 then t.starttime = lang:formatDate( "j", b1 ) .." a viz ".. lang:formatDate( "F", b1 )
else t.starttime = lang:formatDate( "j", b1 ) .." "
end end
if wiki == "ca" or wiki == "es" or wiki == "ast" then
if y ~= y2 then t.starttime = lang:formatDate( "j", b1 ) .." de ".. lang:formatDate( "F", b1 ) .." de ".. lang:formatDate( "Y", b1 )
elseif m ~= m2 then t.starttime = lang:formatDate( "j", b1 ) .." de ".. lang:formatDate( "F", b1 )
else t.starttime = lang:formatDate( "j", b1 ) .." "
end end
if wiki == "cs" then
if y ~= y2 then t.starttime = lang:formatDate( "j. xg Y", b1 )
elseif m ~= m2 then t.starttime = lang:formatDate( "j. xg", b1 )
else t.starttime = lang:formatDate( "j", b1 )
end end
if wiki == "de" or wiki == "da" or wiki == "fi" or wiki == "fo" or wiki == "no" then
if y ~= y2 then t.starttime = lang:formatDate( "j. F Y", b1 )
elseif m ~= m2 then t.starttime = lang:formatDate( "j. F", b1 )
else t.starttime = lang:formatDate( "j.", b1 )
end end
if wiki == "en" then
if y ~= y2 then t.starttime = lang:formatDate( "F d, Y", b1 )
elseif m ~= m2 then t.starttime = lang:formatDate( "F d", b1 )
else t.starttime = lang:formatDate( "F d", b1 )
end end
if wiki == "eo" then
if y ~= y2 then t.starttime = lang:formatDate( "j", b1 ) .."-a de ".. lang:formatDate( "F Y", b1 )
elseif m ~= m2 then t.starttime = lang:formatDate( "j", b1 ) .."-a de ".. lang:formatDate( "F", b1 )
else t.starttime = lang:formatDate( "j", b1 ) .."-a "
end end
if wiki == "eu" then
if y ~= y2 then t.starttime = lang:formatDate( "Y", b1 ) ..".eko ".. lang:formatDate( "F", b1 ) .."k ".. lang:formatDate( "j", b1 )
elseif m ~= m2 then t.starttime = lang:formatDate( "F", b1 ) .."k ".. lang:formatDate( "j", b1 )
else t.starttime = lang:formatDate( "F", b1 ) .."k ".. lang:formatDate( "j", b1 )
end end
if wiki == "hu" then
if y ~= y2 then t.starttime = lang:formatDate( "Y", b1 ) ..". ".. lang:formatDate( "F j", b1 ) .."."
elseif m ~= m2 then t.starttime = lang:formatDate( "F j", b1 ) .."."
else t.starttime = lang:formatDate( "F j", b1 ) .."."
end end
if wiki == "ja" then
if y ~= y2 then t.starttime = lang:formatDate( "Y年m月d日", b1 )
elseif m ~= m2 then t.starttime = lang:formatDate( "Y年m月d日", b1 )
else t.starttime = lang:formatDate( "Y年m月d日", b1 )
end end
if wiki == "lv" then
if y ~= y2 then t.starttime = lang:formatDate( "Y. \\g\\a\\d\\a j. F", b1 )
elseif m ~= m2 then t.starttime = lang:formatDate( "Y. \\g\\a\\d\\a j. F", b1 )
else t.starttime = lang:formatDate( "Y. \\g\\a\\d\\a j.", b1 )
end end
if wiki == "pl" then
local date_pl = {"stycznia", "lutego", "marca", "kwietnia", "maja", "czerwca", "lipca", "sierpnia", "września", "października", "listopada", "grudnia"}
if y ~= y2 then t.starttime = lang:formatDate( "j ", b1 ) .. date_pl[tonumber(lang:formatDate( "n", b1 ))] .. lang:formatDate( " Y", b1 )
elseif m ~= m2 then t.starttime = lang:formatDate( "j ", b1 ) .. date_pl[tonumber(lang:formatDate( "n", b1 ))]
else t.starttime = lang:formatDate( "j", b1 )
end end
end -- if a1
if a2 == true and t.endtime == "" then
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" or wiki == "ast" then t.endtime = lang:formatDate( "j", b2 ) .." de ".. lang:formatDate( "F", b2 ) .." de ".. lang:formatDate( "Y", b2 ) end
if wiki == "cs" then t.endtime = lang:formatDate( "j. xg Y", b2 ) end
if wiki == "de" or wiki == "da" or wiki == "fi" or wiki == "fo" or wiki == "no" then t.endtime = lang:formatDate( "j. F Y", b2 ) end
if wiki == "en" then
if y ~= y2 then t.endtime = lang:formatDate( "F d, Y", b2 )
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
if wiki == "hu" then t.endtime = lang:formatDate( "Y", b2 ) ..". ".. lang:formatDate( "F j", b2 ) .."." end
if wiki == "ja" then
if y ~= y2 then t.endtime = lang:formatDate( "Y年m月d日", b2 )
elseif m ~= m2 then t.endtime = lang:formatDate( "m月d日", b2 )
else t.endtime = lang:formatDate( "d日", b2 )
end end
if wiki == "lv" then
if y ~= y2 then t.endtime = lang:formatDate( "Y. \\g\\a\\d\\a j. F", b2 )
elseif m ~= m2 then t.endtime = lang:formatDate( "j. F", b2 )
else t.endtime = lang:formatDate( "j. F", b2 )
end end
if wiki == "pl" then
local date_pl = {"stycznia", "lutego", "marca", "kwietnia", "maja", "czerwca", "lipca", "sierpnia", "września", "października", "listopada", "grudnia"}
t.endtime = lang:formatDate( "j ", b2 ) .. date_pl[tonumber(lang:formatDate( "n", b2 ))] .. lang:formatDate( " Y", 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
while a1 == true and c1 == 'deprecated' do
i = i + 1
a1, b1, c1 = pcall(fooA, 'time', entity, 'P585', i)
end
t.time = func_date (b1, 'long')
timeofrace = b1
end
 
if not details[3].content then -- stages
-- This function permits to display an unity (the kilometer) for a distance, with exceptions for macedionan, russian and japanese
local stages = #wikibase.getAllStatements(entityID, 'P527') -- P527 is 'has part'
-- that have other symbols
if stages > 0 then
a1, b1, c1 = pcall(fooA, 'amount', entity, 'P3157', 1)
details[3].content = stages
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
 
if not details[4].content then -- date
a1, b1, c1 = pcall(fooA, 'amount', entity, 'P2043', 1)
local sTime = firstValue(entityID, 'P580', 'time') -- P580 is 'start time'
if a1 == true and t.length == "" then i = 1
local eTime = firstValue(entityID, 'P582', 'time') -- P582 is 'end time'
while a1 == true and c1 == 'deprecated' do
iif =sTime iand +eTime 1then
local startTime, endTime = getStartEndTime(sTime, eTime)
a1, b1, c1 = pcall(fooA, 'amount', entity, 'P2043', i)
details[4].content = startTime .. ' – ' .. endTime
end
details[4].name = details[4].name_plural
t.length = b1
dateOfRace = eTime
a1, b1, _ = pcall(fooA, 'unit', entity, 'P2043', 1)
else
if b1 == "http://www.wikidata.org/entity/Q828224" then
-- This function give a format to dates when P585 (date) is used in a single day race
t.length_unit = 'km'
local pTime = firstValue(entityID, 'P585', 'time') -- P585 is 'point in time'
if wiki == "ar" then t.length_unit = 'كم' end
if wiki == "mk"pTime then t.length_unit = 'км' end
details[4].content = func_date (pTime, 'long')
if wiki == "ru" then t.length_unit = 'км' end
dateOfRace = pTime
if wiki == "ja" then t.length_unit = 'キロメートル' end
end
end
end
if not details[5].content then details[5].content = getDistance(entityID, true) end -- distance
 
if not details[6].content then -- country
a, b = pcall(fooA, 'numeric-id', entity, 'P17', 1) -- This function gives countries where the race take place
-- This function gives countries where the race take place
if a == true then --and ttt.country == "" then ttt.country = "Q" .. b end
local i,country v= {}
for i_, vp17 in pairsstatements(entity.claims["entityID, 'P17"]') do -- P17 is 'country'
ttt.country[i]countryID = "C" .. vp17.mainsnak.datavalue.value["numeric-.id"]
country[#country + 1] = flag(countryID, dateOfRace) .. ' ' .. getCountryName(countryID)
end
end
-- Function that give the starting place of a race
a1, b1, c1 = pcall(fooA, 'numeric-id', entity, 'P1427', 1)
if a1 == true and t.startplace == "" then i = 1
while a1 == true and c1 == 'deprecated' do
i = i + 1
a1, b1, c1 = pcall(fooA, 'numeric-id', entity, 'P1427', i)
end
if country[1] then
t.startplace = "Q" .. b1
if #country > 1 then
end
details[6].name = details[6].name_plural
-- Function that give the finishing place of a race
a1, b1, c1 = pcall(fooA, 'numeric-id', entity, 'P1444', 1)
if a1 == true and t.endplace == "" then i = 1
while a1 == true and c1 == 'deprecated' do
i = i + 1
a1, b1, c1 = pcall(fooA, 'numeric-id', entity, 'P1444', i)
end
t.endplace = "Q" .. b1
end
-- This function counts the number of value for P1923 (participating teams) and give the number of team that participate at the race
if pcall(function()
t.nr_teams = table.getn(entity.claims["P1923"])
end
) then else t.nr_teams = "" end
 
-- Function that give the number of cyclists at the beginning and at the finishing of a race
a1, b1, c1 = pcall(fooA, 'amount', entity, 'P1132', 1)
if a1 == true and t.nr_participants_start == "" and t.nr_participants_end == "" then i = 1
while a1 == true and c1 == 'deprecated' do
i = i + 1
a1, b1, c1 = pcall(fooA, 'amount', entity, 'P1132', i)
end
local v
for _, v in pairs(entity.claims["P1132"]) do
if pcall(function()
if v.qualifiers["P276"][1].datavalue.value["numeric-id"] == 529711 then
t.nr_participants_start = string.gsub(v.mainsnak.datavalue.value.amount, "+", "") end
end
) then else t.nr_participants_start = "" end
if pcall(function()
if v.qualifiers["P276"][1].datavalue.value["numeric-id"] == 12769393 then
t.nr_participants_end = string.gsub(v.mainsnak.datavalue.value.amount, "+", "") end
end
details[6].content = table.concat(country, '<br/>')
) then else t.nr_participants_end = "" end
end -- for
end -- if a1
 
-- This function permits to display an unity (the kilometer per hour) for an average speed, with exceptions for macedionan, russian and japanese
-- that have other symbols
a1, b1, c1 = pcall(fooA, 'amount', entity, 'P2052', 1)
if a1 == true and t.speed == "" then i = 1
while a1 == true and c1 == 'deprecated' do
i = i + 1
a1, b1, c1 = pcall(fooA, 'amount', entity, 'P2052', i)
end
t.speed = b1
a1, b1 = pcall(fooA, 'unit', entity, 'P2052', 1)
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
if wiki == "mk" then t.speed_unit = 'км/ч' end
if wiki == "ru" then t.speed_unit = 'км/ч' end
if wiki == "ja" then t.speed_unit = 'キロメートル毎時' end
end
end -- if a1
-- This function permits to display an unity for the cost of a cycling race
a, b = pcall(fooA, 'amount', entity, 'P2130', 1)
if a == true and t.cost == "" then
t.cost = b
a, b = pcall(fooA, 'unit', entity, 'P2130', 1)
if b == "http://www.wikidata.org/entity/Q4916" then t.cost_unit = '€' end
if b == "http://www.wikidata.org/entity/Q4917" then t.cost_unit = '$' end
end
 
if not details[7].content then -- start place
a, b = pcall(fooA, 'value', entity, 'P242', 1) -- locator map image
local place = firstValue(entityID, 'P1427', 'id') -- P1427 is 'start point'
if a == true and tt.map == "" then tt.map = b end
details[7].content = place and getPlaceLink(place)
a, b = pcall(fooA, 'numeric-id', entity, 'P155', 1)
if a == true and t.previous == "" then t.previous = "Q"..b end
a, b = pcall(fooA, 'numeric-id', entity, 'P156', 1)
if a == true and t.next == "" then t.next = "Q"..b 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 == "mk" or wiki == "ja" then note = 'q'
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
local k, v, vv
for k, v in pairs(entity.claims["P1346"]) do
id_team = ''
--id_team = 't26973671'
a, b = pcall(fooC, 'numeric-id', entity, 'P1346', k, 'P54', 1)
if a == true then id_team = 't'..b end
 
if pcall(function() id=v.mainsnak.datavalue.value['numeric-id'] end) then else id=nil end -- id = rider id
if id ~= nil then
--timeofrace = "+2016-03-00T00:00:00Z"
-- function timeStartEnd finds the team of the rider at the time (timeofrace) of the race
if id_team == '' and timeofrace ~= nil and timeofrace ~= '' then
a, b = timeStartEnd('Q'..id, 'P54', 'numeric-id', timeofrace)
if a == true and b ~= nil then id_team = 't' .. b end
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('Q'..id, timeofrace, entity, 'P1346', k).. ')'
end
end)
 
-- looks into race item if the winner has a P642 statement for showing the type of winner (points, mountain, ..)
pcall(function()
for _, vv in pairs(entity.claims["P1346"][k].qualifiers['P642']) do
qual=vv.datavalue.value['numeric-id']
if id~=nil then
if 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_breakaway=="" then t.winner_breakaway=note..id t.winner_breakaway_team=id_team ref.winner_breakaway=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
a, b = pcall(fooA, 'numeric-id', mw.wikibase.getEntity( 'Q'..id ), 'P31', 1)
if a == true and (b == 20738667 or b == 23726798) then -- test if 'national cycling team U23' or 'national cycling team'
t.winner_team = '2t' .." "..national_team('Q'..id, timeofrace, entity, 'P1346', k)
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_breakaway=="" then t.winner_breakaway=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
end -- end if pcall
 
if not details[8].content then -- end place
-- code for references
local place = firstValue(entityID, 'P1444', 'id') -- P1444 is 'destination point'
local list = {} -- list[1][1] = value from ref.first, list [1][2] = 'first'
details[8].content = place and getPlaceLink(place)
local k
for k in pairs(ref) do
if ref[k]~='' then table.insert(list, {ref[k], k}) end
end
local w, ww
if not details[9].content then -- teams
num = #list
local teams = #wikibase.getBestStatements(entityID, 'P1923') -- P1923 is 'participating teams'
for w=num,1,-1 do
if teams > 0 then
for ww=1,w do
details[9].content = teams
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
else list[w][1] = frame:extensionTag{name='ref', content=list[w][1], args={name=entityId..ww}} end
end
end
for i=1,num do
ref[ list[i][2] ] = list[i][1] --list[num+1-i][1]
end
 
-- Function that give the number of cyclists at the beginning and at the finishing of a race
-- transform Q/q-number into flag / WPlink / WDlink
for _, p1132 in statements(entityID, 'P1132') do -- P1132 is 'number of participants'
local k
local amount = tonumber(p1132.mainsnak.datavalue.value.amount) -- tonumber to remove starting '+'
local team = true
for _, q in qualifiers(p1132, 'P276') do -- P276 is 'location'
local wd = " [[File:Wikidata-logo S.svg|12px|link=d:"
local location = q.value['numeric-id']
 
if location == 529711 then -- Q529711 is 'beginning'
for k in pairs(ttt) do -- "^C" ttt.country, "^T" ttt.tour
if not details[10].content then details[10].content = amount end -- participants at start
if ttt[k][1]~=nil and string.find(ttt[k][1], "^C") then for i=1,#ttt[k] do ttt[k][i] = string.gsub(ttt[k][i], "C", "Q") ttt[k][i] = flag(ttt[k][i], timeofrace).." ".. WPlink( ttt[k][i] ) end end
elseif location == 12769393 then -- Q12769393 is 'end'
if ttt[k][1]~=nil and string.find(ttt[k][1], "^T") then for i=1,#ttt[k] do ttt[k][i] = string.gsub(ttt[k][i], "T", "Q") ttt[k][i] = WPlink( ttt[k][i], 'race') end end
if not details[11].content then details[11].content = amount end -- participants at end
end
for k in pairs(t) do
if string.find(t[k], "^Q") then --t[k], k = startplace, endplace, ... find variables with an item as value
if pcall(foo1, t[k]) then t[k] = WPlink( t[k] ) end
end
if string.find(t[k], "^q") then -- find variables with an item as value (in section Résultats)
t[k] = mw.ustring.upper( t[k] )
--look into P27 (country of citizenship) to get the Qnumber of that country
a, b = timeStartEnd(t[k], "P27", 'numeric-id', timeofrace)
if a == true and pcall(foo1, t[k]) then t[k] = flag('Q'..b, timeofrace).." "..WPlink( t[k] )..ref[k]..wd..t[k].."]]"
else
--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] )..ref[k]..wd..t[k].."]]" end
end
end
if string.find(t[k], "^f") then -- no WDitem, frWP
t[k] = string.gsub(t[k], "f", "Q")
--look into P27 (country of citizenship) to get the Qnumber of that country
a, b = timeStartEnd(t[k], "P27", 'numeric-id', timeofrace)
if a == true and pcall(foo1, t[k]) then t[k] = flag('Q'..b, timeofrace).." "..WPlink( t[k] )..ref[k]
else
--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], 'team', timeofrace )..ref[k] else t[k] = WPlink( t[k], 'team', timeofrace )..ref[k] end
end
end
if string.find(t[k], "^c") then -- find "class"-items, first asci = "c"
t[k] = string.gsub(t[k], "c", "Q")
if pcall(foo1, t[k]) then t[k] = WPlink( t[k], "Q22348500" ) end
end
if string.find(t[k], "^t") then
t[k] = string.gsub(t[k], "t", "Q")
--timeofrace = "+2008-04-09T00:00:00Z"
if pcall(foo1, t[k]) then t[k] = " (" .. WPlink( t[k], 'team', timeofrace ) .. ")" end
end
if string.find(t[k], "^2t") then t[k] = string.gsub(t[k], "2t", "") end
end
 
if not details[12].content then details[12].content = getSpeed(entityID, true) end --speed
--local nl ="&#10;"
-- local tooltip = infobox_bottom(2) .. nl .. mw.text.encode( property(1) .. ' (P393)' ) .. nl .. mw.text.encode( property(2) ..' (P17)')
 
if not details[13].content then -- cost
local miles
local cost = firstValue(entityID, 'P2130') -- P2130 is cost
local miles_h
if t.length ~= ""cost then
local unit = cost.unit
if wiki == 'en' then -- To show distance in kilometers and miles
cost = contentLanguage:formatNum(tonumber(cost.amount))
miles = math.modf(10*t.length/1.609344)/10
if wiki == 'fo' then cost = string.gsub(t.cost, "%.", ",") end
miles = lang:formatNum(tonumber(miles)) -- formats t_g.miles in the way it is done in the local Wiki
if unit == "http://www.wikidata.org/entity/Q4916" then cost = cost .. ' €'
elseif unit == "http://www.wikidata.org/entity/Q4917" then cost = cost .. ' $'
end
details[13].content = cost
end
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
 
local tab
if t.cost ~= "" then
t.cost,if _wiki = string.gsub(t.cost,= "[+]eo", "")then
tab = "<table style='width:23em; border:1px solid rgb(200,200,200);" ..
t.cost = lang:formatNum(tonumber(t.cost))
"margin:0 0 0.5em 0.5em; background-color:rgb(255, 255, 255); color:black; padding:5px;" ..
if wiki == 'fo' then t.cost = string.gsub(t.cost, "%.", ",") end
"text-align:" .. textalign .. "; font-size:85%; line-height:1.6em;' class='infobox' >"
else
tab = "<table cellpadding='4' cellspacing='0' style='float:" .. floatinfobox ..
"; width:300px; border:1px solid rgb(200,200,200);" ..
"margin:0 0 0.5em 0.5em; background-color:rgb(255, 255, 255); color:black; padding:5px; clear:left; " ..
"text-align:" .. textalign .. "; font-size:85%; line-height:1.6em;'>"
end
tab = tab ..
"<tr><td colspan='2' style='border-bottom:5px solid white; font-size:175%; background:#FFDF80; text-align:center'>" ..
"<table style='width:100%'><tr><td>" .. name .."</td><td>" .. icon .. "</td></tr></table></td></tr>"
 
if others[1].content then -- picture
local span1, span2 = "<span style='color:#3366CC'>&#x25C0; </span>", "<span style='color:#3366CC'> &#x25B6;</span>"
tab = tab .. "<tr><td colspan='2' style='text-align:center'>[[File:" .. others[1].content ..
local k = t.previous
"|center|300px]]</td></tr>"
local i, _ = string.find(k, "|")
if others[2].content then -- caption
local j, _ = string.find(k, "]")
tab = tab .. "<tr><td colspan='2' style='text-align:center; font-size:80%'>" ..
if i ~= nil and j ~= nil then
others[2].content .. "</td></tr>"
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
if wiki == "ar" then t.previous = span2 .. t.previous end
end
end
tab = tab .. "<tr><td colspan='2' style='background-color:#FFDF80; text-align:center'>'''" ..
 
infobox_translate(1) .. "'''</td></tr>"
k = t.next
for _, row in ipairs(details) do
i, _ = string.find(k, "|")
if row.content then
j, _ = string.find(k, "]")
tab = tab .. "<tr style= 'vertical-align:top'><td style='width:40%'>'''" .. row.name ..
if i ~= nil and j ~= nil then
"'''</td><td>" .. row.content .. "</td></tr>"
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
if wiki == "ar" then t.next = span1 .. t.next end
end
end
 
local winRows = ''
tt.caption = string.gsub(tt.caption, "{{(%w+)}}", function (n) return frame:expandTemplate{ title = n } end)
local win = {}
-- for overwriting Wikidata content with data in Wikipedia articles. numbers are from function infobox_translate
for _, v in pairs(winners) do
local z = {stage=5, date=6, dates=7, length=8, startplace=11, endplace=12, nr_teams=13, nr_participants_start=14, nr_participants_end=15,
if not v.content then
speed=16, cost=17, first=19, second=20, third=21, winner_point=22, winner_mountain=23, winner_sprint=24, winner_young=25, winner_fighting=26,
win[v.QID] = ''
winner_combination=27, winner_team=28, winner_team_points=37, winner_metas_volantes=35, winner_regularity=36, winner_breakaway=38,
winner_azzurri_ditalia=39}
 
local i, k, s
for i,k in pairs(z) do
s = localFrame.args[mw.ustring.gsub(infobox_translate(k), "&#173;", "")] -- filter soft hyphen out
if s~="" and s~=nil then
t[i] = s
if i=="length" then t.length_unit="" end
if i=="speed" then t.speed_unit="" end
if i=="cost" then t.cost_unit="" end
else
if k>=19 and k<=27 then t[i] = t[i].. t[i..'_team'] end
if k>=35 and k<=36 then t[i] = t[i].. t[i..'_team'] end
if k>=38 and k<=39 then t[i] = t[i].. t[i..'_team'] end
end
end
winner(entityID, win, dateOfRace, true, WDlink_on, team, true)
 
for _, v in pairs(winners) do
if localFrame.args[infobox_translate(32)]~="" and localFrame.args[infobox_translate(32)]~=nil then
if not v.content then
i, k = string.find(localFrame.args[infobox_translate(32)] , ":")
local QID = v.QID
tttt.special_1a = string.sub(localFrame.args[infobox_translate(32)], 1, i-1)
if win[v.QID] ~= '' then
tttt.special_1b = string.sub(localFrame.args[infobox_translate(32)], k+1)
v.content = win[v.QID]
end
end
if v.content then
winRows = winRows .. "<tr style= 'vertical-align:top'><td>'''" .. v.name ..
"'''</td><td>" .. v.content .. "</td></tr>"
end
end
if winRows ~= '' then
if localFrame.args[infobox_translate(33)]~="" and localFrame.args[infobox_translate(33)]~=nil then
tab = tab .. "<tr><td colspan='2' style='border-bottom:5px solid white; background-color:#FFDF80; text-align:center'>'''"
i, k = string.find(localFrame.args[infobox_translate(33)] , ":")
tttt .special_2a = string.sub(localFrame.args[ infobox_translate(3318)], 1,.. i-1)"'''</td></tr>" .. winRows
tttt.special_2b = string.sub(localFrame.args[infobox_translate(33)], k+1)
end
 
if others[3].content then -- map
if wiki == "fi" then
tab = tab .. "<tr><td colspan='2' style='text-align:center'>[[File:".. others[3].content .. "|center|300px]]</td></tr>"
if t.starttime ~= "" then t.starttime = mw.ustring.gsub(t.starttime, "%a+", "%0ta") end
if t.endtime ~= "" then t.endtime = mw.ustring.gsub(t.endtime, "%a+", "%0ta") end
if t.time ~= "" then t.time = mw.ustring.gsub(t.time, "%a+", "%0ta") end
end
tab = tab .. getPreviousNextLine(entityID)
 
tab = "<table cellpadding='4' cellspacing='0' style='float:"..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:" .. 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:" .. 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'>"
tab = tab .. "<table style='width:100%'><tr><td>" .. tt.name .."</td><td>" .. tt.icon .. "</td></tr></table></td></tr>"
if tt.picture ~= "" then tab = tab .. "<tr><td colspan='2' style='text-align:center'>".." [[File:".. tt.picture .."|center|300px]]</td></tr>" end
if tt.picture ~= "" and tt.caption ~= "" then tab = tab .. "<tr><td colspan='2' style='text-align:center; font-size:80%'>"..tt.caption.."</td></tr>" end
tab = tab .. "<tr><td colspan='2' style='background-color:#FFDF80; text-align:center'>'''"..infobox_translate(1).."'''</td></tr>"
if tt.nr ~= "" and t.is_a ~= "" then tab = tab.."<tr><td style='width:40%'>'''"..infobox_translate(2).."'''</td><td>" .. tt.nr .. " " .. t.is_a .. "</td></tr>" end
if ttt.tour[1] ~= nil then tab = tab.."<tr><td style= 'vertical-align:top'>'''"
if #ttt.tour == 1 then tab = tab..infobox_translate(3).."'''</td><td>" else tab = tab..infobox_translate(4).."'''</td><td>" end
for i=1,#ttt.tour do tab = tab .. ttt.tour[i] if i == 1 then tab = tab .. " " ..t.class end tab = tab .. "<br>" end
tab = tab.."</td></tr>" end
if t.stage ~= "" then tab = tab.."<tr><td>'''"..infobox_translate(5).."'''</td><td>" .. t.stage.."</td></tr>" end
if (t.starttime~="" or t.endtime~="") and t.date=="" and t.dates=="" then tab = tab.."<tr><td>'''"..infobox_translate(7).."'''</td><td>" .. t.starttime.." – " ..t.endtime .."</td></tr>"
--if t.endtime ~= "" then tab = tab.."<tr><td>".."Date de fin".."</td><td>" .. t.endtime .. "</td></tr>" end
elseif t.time~="" and t.date=="" and t.dates=="" then tab = tab.."<tr><td>'''"..infobox_translate(6).."'''</td><td>" .. t.time.."</td></tr>" end
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
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
for i=1,#ttt.country-1 do tab = tab .. ttt.country[i].."<br>" end tab = tab .. ttt.country[#ttt.country].."</td></tr>" end
if t.startplace ~= "" then tab = tab.."<tr><td>'''"..infobox_translate(11).."'''</td><td>" .. t.startplace .. "</td></tr>" end
if t.endplace ~= "" then tab = tab.."<tr><td>'''"..infobox_translate(12).."'''</td><td>" .. t.endplace .. "</td></tr>" end
if t.nr_teams ~= "" then tab = tab.."<tr><td>'''"..infobox_translate(13).."'''</td><td>" .. t.nr_teams .. "</td></tr>" 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
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 tttt.special_2a ~= "" then tab = tab.."<tr><td>'''"..tttt.special_2a.."'''</td><td>" .. tttt.special_2b.. "</td></tr>" end
 
if results then tab = tab.."<tr><td colspan='2' style='border-bottom:5px solid white; background-color:#FFDF80; text-align:center'>'''"..infobox_translate(18).."'''</td></tr>" end
if t.first ~= "" then tab = tab.."<tr><td>'''"..infobox_translate(19).."'''</td><td>" .. t.first .. "</td></tr>" end
if t.second ~= "" then tab = tab.."<tr><td>'''"..infobox_translate(20).."'''</td><td>" .. t.second .. "</td></tr>" end
if t.third ~= "" then tab = tab.."<tr><td>'''"..infobox_translate(21).."'''</td><td>" .. t.third .. "</td></tr>" end
if t.winner_point ~= "" then tab = tab.."<tr><td>'''"..infobox_translate(22).."'''</td><td>" .. t.winner_point .. "</td></tr>" end
if t.winner_mountain ~= "" then tab = tab.."<tr><td>'''"..infobox_translate(23).."'''</td><td>" .. t.winner_mountain .. "</td></tr>" end
if t.winner_sprint ~= "" then tab = tab.."<tr><td>'''"..infobox_translate(24).."'''</td><td>" .. t.winner_sprint .. "</td></tr>" end
if t.winner_young ~= "" then tab = tab.."<tr><td>'''"..infobox_translate(25).."'''</td><td>" .. t.winner_young .. "</td></tr>" end
if t.winner_fighting ~= "" then tab = tab.."<tr><td>'''"..infobox_translate(26).."'''</td><td>" .. t.winner_fighting .. "</td></tr>" end
if t.winner_metas_volantes ~= "" then tab = tab.."<tr><td>'''"..infobox_translate(35).."'''</td><td>" .. t.winner_metas_volantes .. "</td></tr>" end
if t.winner_regularity ~= "" then tab = tab.."<tr><td>'''"..infobox_translate(36).."'''</td><td>" .. t.winner_regularity .. "</td></tr>" end
if t.winner_breakaway ~= "" then tab = tab.."<tr><td>'''"..infobox_translate(38).."'''</td><td>" .. t.winner_breakaway .. "</td></tr>" end
if t.winner_azzurri_ditalia ~= "" then tab = tab.."<tr><td>'''"..infobox_translate(39).."'''</td><td>" .. t.winner_azzurri_ditalia .. "</td></tr>" end
if t.winner_combination ~= "" then tab = tab.."<tr><td>'''"..infobox_translate(27).."'''</td><td>" .. t.winner_combination .. "</td></tr>" end
if t.winner_team ~= "" then tab = tab.."<tr><td>'''"..infobox_translate(28).."'''</td><td>" .. t.winner_team .. "</td></tr>" end
if t.winner_team_points ~= "" then tab = tab.."<tr><td>'''"..infobox_translate(37).."'''</td><td>" .. t.winner_team_points .. "</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
 
prevNextLine = "<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 "[[" =.. tabs .. "<span style='float:right' title='|" .. tooltipinfobox_translate(34) .. "'>]] [[File:HighWikidata-contrast-help-browserlogo S.svg|10px|right12px|link=]]</span>d:".. entityID ..
tab = tab .. "]]</td></tr></table>"
tab= tab.."</table>"
return tab
end
 
--=== H) Team roster
function national_team(riderID, startOfSeason, entity, property, k)
function p.teamroster(frame)
-- property: statement where the rider is the value
localframe=frame
-- k: loop
if frame.args[1] ~= nil then squadID = string.gsub(frame.args[1], "%c", "") end
local national_team, team, nationality, teamID
local flags, pays = {}, {}
-- national team for U23 or older riders
local riderIds, riderNames, riderBirthdays, givenname, familyname, riderTeam, timeTeam = {}, {}, {}, {}, {}, {}, {}
if pcall(function()
local riderStart, riderEnd, riderPosition, riderReason, riderRef, riderReasonTable, errorbool, errortext = {}, {}, {}, {}, {}, {}, {}, {}
local i,j, s
local index, riderNames_transl, riderNames_notransl = {}, {}, {}
for _, v in pairs(entity.claims[property][k].qualifiers['P54']) do -- for property 'member of sports team'
local labelMissing = false
teamID = 'Q'.. v.datavalue.value['numeric-id'] break
local lang = mw.language.getContentLanguage()
end
local WDlink_on
local teamID, startOfSeason, stagiaire
 
local function getreason(riderReason, riderRef, p527)
national_team = mw.wikibase.getEntity( teamID )
local listofproperty={'P1642','P1643','P1534'}
-- calculate s for national team item
local outputTable={}
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 riderReason == nil then --if no riderReason before then look for it, otherwise don't touch it
if wiki == 'fr' then s = ' espoirs'
for _,v in ipairs(listofproperty) do
elseif wiki == 'mk' then s = ' под 23 години'
for _, q in qualifiers(p527, v) do
elseif wiki == 'ar' then s = ' تحت 23'
riderReason =q.value.id--q.datavalue.value.id
elseif wiki == 'es' then s = ' sub-23'
end
elseif wiki == 'ast' then s = ' sub-23'
end
else s = ' U23'
if riderReason ~= nil then
end
local label= string.gsub(wikibase.label(riderReason), "%b()", "") or getLabelFallback(riderReason,{'en', 'fr', 'de'})
elseif a == true and (b == 1194951 or b == 23726798) then s = '' end
riderRef = getReference(p527,1)
-- Q1194951 = national sports team, Q23726798 = national cycling team
riderReason = ', ' .. label
 
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
outputTable[1]= riderReason
outputTable[2]= riderRef
return outputTable
end
 
local function getposition(riderPosition,v)
a, b = timeStartEnd(riderID, "P17", 'numeric-id', startOfSeason)
local stagiaire
if a == true then --team = 'abc'.. b --riderID
if riderPosition == nil then -- find the 'position' (P39) of a rider
local nation = mw.wikibase.getEntityObject( 'Q'..b )
for _, q in qualifiers(v, 'P39') do
nationality = nation:getLabel() or nation:getLabel('en') .. ' (en)'
stagiaire =q.value.id
if national_team:getSitelink() == nil then
label=string.gsub(wikibase.label(stagiaire), "%b()", "") or getLabelFallback(stagiaire,{'en', 'fr', 'de'})
team = nationality.. s
riderPosition = ', ' ..label
else
team = "[[".. national_team:getSitelink().. "|".. nationality.. s.. ']]'
end
end
return riderPosition
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
 
local formats = {
[''] = { long = 'j F Y', small = 'j M', onlyday = 'j' },
ar = { long = 'j F Y', small = 'j F', onlyday = 'j' },
br = { long = 'j "a viz" F Y', small = 'j "a viz" M', onlyday = 'j' },
ca = { long = 'j "de" F "de" Y', small = 'j "de" M', onlyday = 'j' },
cs = { long = 'j. xg Y', small = 'j. M', onlyday = 'j' },
da = { long = 'j. F Y', small = 'j. M', onlyday = 'j.' }, -- copy of de
de = { long = 'j. F Y', small = 'j. M', onlyday = 'j.' },
eo = { long = 'j"-a de" F Y', small = 'j"-a de" M', onlyday = 'j' },
en = { long = 'F d, Y', small = 'M d', onlyday = 'd' },
es = { long = 'j "de" F "de" Y', small = 'j "de" M', onlyday = 'j' }, -- copy of ca
eu = { long = 'Y".eko" F"k" j', small = 'M"k" j', onlyday = 'j' },
fi = { long = 'j. F"ta" Y', small = 'j. M', onlyday = 'j.' },
fo = { long = 'j. F Y', small = 'j. M', onlyday = 'j.' }, -- copy of de
he = { long = 'j xg Y', small = 'j F', onlyday = 'j' },
hu = { long = 'Y. F j.', small = 'M. j', onlyday = 'j' },
ja = { long = 'Y年m月d日', small = 'm月d日', onlyday = 'd日' },
lv = { long = 'Y. "gada" j. F', small = 'j. M', onlyday = 'j.' },
hu = { long = 'j xg Y', small = 'j M', onlyday = 'j' },
no = { long = 'j. F Y', small = 'j. M', onlyday = 'j.' }, -- copy of de
}
function func_date (date, mode)
-- local date = '+2016-05-20'
-- local mode = 'small'
local contentLanguage = contentLanguage
local format = formats[wiki] or formats['']
return contentLanguage:formatDate(format[mode], date)
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 lang = mw.language.getContentLanguage()
local WDlink_on
local team, rider, startOfSeason
local v = ''
 
local function trans(date, month, day)
if date ~= '' and date~=nil then
local _, _, y, m, d = string.find(date, "(%d+)-(%d+)-(%d+)")
if m == '00' then m = month end
else return '' end
end
local function name(i, wiki, transl, names, givenname, familyname)
-- transform name "A B ..." into "B ... A"
if givenname==nil then givenname=0 end
if familyname==nil then familyname=0 end
if names==nil then names='' end
local _, count = mw.ustring.gsub(names, " ", " ")
local a,b,c,d = '', '', '', ''
end
 
local localFrame
local sort
--[[
]]
if string.match(frame:getParent():getTitle(), '%P+') == mw.site.namespaces.Template.name
then localFramelocalframe = frame:getParent() else localFramelocalframe = frame end
if localFramelocalframe.args[2] ~= nil then
if mw.ustring.find(mw.ustring.lower(localFramelocalframe.args[2]), "sort") then sort = true else sort = false end
end
if wiki == "lv" or wiki == "mk" or wiki == "ru" then sort = true end
 
local temp=firstValue(squadID, 'P361', 'id')
pcall(function() team = squadSeason.claims["P361"][1].mainsnak.datavalue.value['numeric-id'] end)
if temp then teamID=temp end
 
-- WDlink_on is used to decide if a Wikidata flag will be shown
if wiki == "mk" or wiki == "ja" or wiki == "ru" or wiki == "he" then WDlink_on = true else WDlink_on = false end
 
local temp=firstValue(squadID, 'P580', 'time')
if pcall(function() startOfSeason = squadSeason.claims["P580"][1].mainsnak.datavalue.value.time end) then
if temp then
startOfSeason =temp
else
local Sitelink=getSitelinkFallback(squadID,{'en', 'fr', 'de'})
local Sitelink = squadSeason:getSitelink(wiki .. 'wiki') or squadSeason:getSitelink('enwiki') or squadSeason:getSitelink('frwiki') or squadSeason:getSitelink('dewiki') or ''
if Sitelink == ''nil 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
 
for i, p527 in statements(squadID, 'P527') do
local i = 1
errortext[i]=''
pcall(function()
riderIds[i] = p527.mainsnak.datavalue.value.id
while squadSeason.claims["P527"][i] do
local riderID=riderIds[i]
riderIds[i] = 'Q' .. squadSeason.claims["P527"][i].mainsnak.datavalue.value['numeric-id']
riderNames[i] = WPlinkgetRiderLink(riderIds[i]riderID, startOfSeason) --label
local timeofrace = startOfSeason
 
local temp=firstValue(riderID, 'P569','time')
rider = mw.wikibase.getEntityObject(riderIds[i])
if pcall(function()temp then riderBirthdays[i] = rider.claims["P569"][1].mainsnak.datavalue.value.timetemp 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
 
for k, _ in statements(squadID, 'P735') do givenname[i] = k end --highest value saved
pcall(function()
for k, _ in statements(squadID, 'P734') do familyname[i] = k end --highest value saved
local language
local label=wikibase.label(riderID)
language = wiki
if wiki == 'mk' or wiki == 'ru' then
local entity=mw.wikibase.getEntity(riderIds[i])
if label ~= nil and (mw.ustring.byte(label, 1, 1) > 127 and mw.ustring.byte(label, 3, 3) > 127) then
if wiki == 'mk' or wiki == 'ru' then
riderNames_transl[i] = label
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)
else
then riderNames_transl[i] = entity.labels[language].value riderNames_notransl[i] = ''
else riderNames_notransl[i] = entity.labels[getLabelFallback(riderID, {'en'].value, or entity.labels['fr'].value, or entity.labels['de'].value}) riderNames_transl[i] = ''
end
end
else
if wiki ~= 'mk' and wiki ~= 'ru' then
if label ~= nil then
if entity:getLabel(language) ~= nil then riderNames_transl[i] = entity.labels[language].value riderNames_notransl[i] = ''
riderNames_transl[i] = label
else riderNames_notransl[i] = entity.labels['en'].value or entity.labels['fr'].value or entity.labels['de'].value riderNames_transl[i] = ''
endelse
riderNames_notransl[i] = getLabelFallback(riderID, {'en', 'fr', 'de'})
end
end)
riderReasonTable=getreason(riderReason[i],riderRef[i],p527)
 
riderReason[i]=riderReasonTable[1]
riderRef[i]=riderReasonTable[2]
if sort == true then
riderNames_transl[i] = name(i, wiki, 'transl', riderNames_transl[i], givenname[i], familyname[i])
end
 
for _, q in qualifiers(p527, 'P580') do
if pcall(function()
local startdate = q.value['time']
local date = squadSeason.claims["P527"][i].qualifiers["P580"][1].datavalue.value.time or ''
timeofrace = startdate
riderStart[i] = func_date(trans(date,'01', '01'), 'small')
riderStart[i] = func_date(trans(startdate,'01', '01'), 'small')
end
for _, q in qualifiers(p527, 'P582') do
) then else riderStart[i] = '' end
local enddate=q.value['time']
 
riderEnd[i] = func_date(trans(enddate,'12', '31'), 'small')
if pcall(function()
local date = squadSeason.claims["P527"][i].qualifiers["P582"][1].datavalue.value.time
riderEnd[i] = func_date(trans(date,'12', '31'), 'small')
end
riderPosition[i]=getposition(riderPosition[i],p527)
) then else riderEnd[i] = '' end
 
local y1, m1, d1, y2, m2, d2, y3, m3, d3, date1, date2
if pcall(function()
local changedTime = '+0000-00-00'
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
 
if teamID == nil then
riderReason[i] = ''
p54 = getStatementForTime(riderID, 'P54', timeofrace)
pcall(function() riderReason[i] = 'Q'.. squadSeason.claims["P527"][i].qualifiers["P1643"][1].datavalue.value['numeric-id'] end)
if riderReason[i] == ''p54 then pcall(function() riderReason[i]teamID = 'Q'p54.. squadSeason.claims["P527"][i].qualifiers["P1642"][1]mainsnak.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
riderRef[i] = references(squadSeason, 'P527', i)
riderReason[i] = ', ' .. label
end
 
local a, b
local timeofrace
local changedTime = '+0000-00-00'
local changedTeam = ''
local entity, label
local stagiaire
time[i]='' riderTeam[i] = ''
if pcall(function() timeofrace = squadSeason.claims["P527"][i].qualifiers["P580"][1].datavalue.value.time end)
then else timeofrace = startOfSeason 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
end
if a == true and bteamID ~= nil then
for _, v in statements(riderID, 'P54') do -- look into all P54 teams
pcall(function()
date1=nil date2=nil date2temp=nil stagiaire=nil
local v
thisteamID=v.mainsnak.datavalue.value.id
for _, v in pairs(rider.claims["P54"]) do -- look into all P54 teams
if thisteamID==teamID then
pcall(function() -- get trainee data from rider item
riderReasonTable=getreason(riderReason[i],riderRef[i],v)
if v.mainsnak.datavalue.value['numeric-id'] == b then -- print riderStart[i], riderEnd[i], riderPosition[i], riderReason[i]
riderReason[i]=riderReasonTable[1]
if riderReason[i] == '' then pcall(function() riderReason[i] = 'Q'.. v.qualifiers["P1643"][1].datavalue.value['numeric-id'] end) end
riderRef[i]=riderReasonTable[2]
if riderReason[i] == '' then pcall(function() riderReason[i] = 'Q'.. v.qualifiers["P1642"][1].datavalue.value['numeric-id'] end) end
if riderReason[i]v.qualifiers ==and '' then pcall(function() riderReasonv.qualifiers[i"P580"] = 'Q'..and v.qualifiers["P1534P580"][1].datavalue.snaktype == 'value['numeric-id'] end)then end
date1=v.qualifiers["P580"][1].datavalue.value.time
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] )
date1 = trans(date1,'01','01')
local label = string.gsub(entity:getLabel(), "%b()", "") or entity:getLabel('en')
_, _, y1, m1, d1 = string.find(date1, "(%d+)-(%d+)-(%d+)")
if pcall(function() riderRef[i] = references(squadSeason, 'P527', i) end) then else riderRef[i]='' end
if v.qualifiers and v.qualifiers["P582"] and v.qualifiers["P582"][1].snaktype == 'value' then
-- riderRef[i] = references(squadSeason, 'P527', i)
date2temp=v.qualifiers["P582"][1].datavalue.value.time
riderReason[i] = ', ' .. label
end
if date2temp==nil then
 
if y1==nil then y1='2040' errorbool[i]=2 end
local date1 = v.qualifiers["P580"][1].datavalue.value.time
date2='+'..y1..'-12-31T00:00:00Z'
date1 = trans(date1,'01','01')
else date2=date2temp end
local _, _, y1, m1, d1 = string.find(date1, "(%d+)-(%d+)-(%d+)")
localdate2 = trans(date2,'12','31')
_, _, y2, m2, d2 = string.find(date2, "(%d+)-(%d+)-(%d+)")
if pcall(function() date2 = v.qualifiers["P582"][1].datavalue.value.time end) then else date2='+'..y1..'-12-31T00:00:00Z' end
_, _, y3, m3, d3 = string.find(startOfSeason, "(%d+)-(%d+)-(%d+)")
date2 = trans(date2,'12','31')
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 _, _, y2, m2, d2 = string.find(date2, "(%d+)-(%d+)-(%d+)")
-- riders who start after 1 January or end earlier then 31 December in the season
local _, _, y3, m3, d3 = string.find(startOfSeason, "(%d+)-(%d+)-(%d+)")
riderStart[i] = func_date(date1, 'small')
 
if date2temp==nil then
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
if y1==nil then y1='2040' errorbool[i]=1 end
-- riders who start after 1 January or end earlier then 31 December in the season
riderStartriderEnd[i] = func_date(date1'+'..y1..'-12-31T00:00:00Z', 'small')
if pcall(function()else
riderEnd[i] = func_date(date2temp, 'small')
local date = v.qualifiers["P582"][1].datavalue.value.time
end
riderEnd[i] = func_date(date2, 'small')
riderPosition[i]=getposition(riderPosition[i],v)
end
end
) then else riderEnd[i] = func_date('+'..y1..'-12-31T00:00:00Z', 'small') end
else -- thisteamID~=teamID
 
for _, q in qualifiers(v, 'P39') do
if riderPosition[i] == '' then -- find the 'position' (P39) of a rider
stagiaire =q.value.id
pcall(function() riderPosition[i] ='Q' ..v.qualifiers["P39"][1].datavalue.value['numeric-id']
end
local entity = mw.wikibase.getEntity( riderPosition[i] )
if not stagiaire then
local label = string.gsub(entity:getLabel(), "%b()", "") or entity:getLabel( 'en' )
if v.qualifiers and v.qualifiers["P580"] and v.qualifiers["P580"][1].snaktype == 'value' then
riderPosition[i] = ', ' .. label
date1=v.qualifiers["P580"][1].datavalue.value.time
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 _, _, y1, m1, d1 = string.find(date1, "(%d+)-(%d+)-(%d+)")
if v.qualifiers and v.qualifiers["P582"] and v.qualifiers["P582"][1].snaktype == 'value' then
local date2
if pcall(function() date2 date2temp= v.qualifiers["P582"][1].datavalue.value.time end) then else date2='+'..y1..'-12-31T00:00:00Z' end
date2=date2temp
else
if y1==nil then y1='2040' errorbool[i]=2 end
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()if date2temp~=nil then
local timeP582 = v.qualifiers["P582"][1].datavalue.value.timetrans(date2temp,'12', '31')
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
local _, _, y4, m4, d4 = string.find(timeP582, "(%d+)-(%d+)-(%d+)")
if y4 > y3 then changedTime = '+'..y3..'-12-31T00:00:00Z' else changedTime = timeP582 end
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] = WPlinkgetTeam( 'Q'..changedTeam riderID, 'team'changedTime, changedTime ) endnil)
local _, _, y1, _, _ = string.find(changedTime, "(%d+)-(%d+)-(%d+)")
timetimeTeam[i] = ' ('..y1..')'
end
end
end -- end if
end -- end for
if errorbool[i]==1 then
end) -- end function
errortext[i]=errortext[i]..'missing qualifiers by team'
end -- end if
elseif errorbool[i]==2 then
 
errortext[i]=errortext[i]..'missing qualifiers by rider'
local a, b = timeStartEnd( riderIds[i], 'P27', 'numeric-id', startOfSeason )
end
if a then
end
flags[i] = flag( 'Q' .. b, startOfSeason )
end
if available_list == true and type( translations.list ) == 'function' then
--get the country
pays[i] = translations.list('Q'..b)
local p27 = getStatementForTime(riderID, 'P27', timeofrace) --P27 is country of citizenship
if pays[i] == '' then
if p27 then
local country = mw.wikibase.getEntityObject( 'Q'..b )
countryID = p27.mainsnak.datavalue.value.id
pays[i] = country:getLabel() or country:getLabel('en') .. ' (en)'
end
if countryID then
end
pays[i] = getCountryName(countryID)
else
flags[i] = ''flag(countryID, timeofrace)
pays[i] = ''
end
 
i = i + 1
end
end)
 
-- sorting names after surname
end
 
local tableBody= ''
local tableHeader = '<table border="0" cellspacing="0" cellpadding="2" class="sortable">'
if available_list==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]]~=''nil or riderEnd[index[i]]~=''nil then
tableBody=tableBody..'<span style="font-size:80%; color:#686868"> ('..riderStart[index[i]]..'–'..riderEnd[index[i]].. (riderPosition[index[i]] or '')
if riderReason[index[i]] ~= ''nil then
note = ', [[#tr_'..i..frame.args[1]..'|'..getSquadTableColumn(4)..']]'
if wiki == "ar" then note = '، [[#tr_'..i..frame.args[1]..'|'..getSquadTableColumn(4)..']]' end
end
tableBody=tableBody .. ')</span>'
elseif riderReason[index[i]]~='' nil then
tableBody=tableBody.. '<span style="font-size:80%; color:#686868"> ([[#tr_'..i..frame.args[1]..'|'..getSquadTableColumn(4)..']]'.. ')</span>'
end
if wiki == 'lv' then
local _, _, y1, m1, d1 = string.find(startOfSeason,"(%d+)-(%d+)-0*(%d+)")
local _, _, y2, m2, d2 = string.find(riderBirthdays[index[i]] or '',"(%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]] or '', '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">'
end
 
if riderTeam[index[i]] ~= nil then tableBody = tableBody.. riderTeam[index[i]].. time[index[i]] end
if riderTeam[index[i]] ~= nil then tableBody = tableBody.. riderTeam[index[i]].. timeTeam[index[i]]..errortext[index[i]] end
tableBody = tableBody..'</td></tr>'
 
if riderReason[index[i]] ~= nil or errortext[index[i]] ~= '' then
local temp=errortext[index[i]]
if iii == 1 then tableEndText = tableEndText.. getSquadTableColumn(5)..': '.. riderNames[index[i]].. riderReason[index[i]]
if riderReason[index[i]] and errortext[index[i]] then
else tableEndText = tableEndText.. '<span style="color:white">'.. getSquadTableColumn(5)..': </span>'.. riderNames[index[i]].. riderReason[index[i]] end
temp=riderReason[index[i]] ..errortext[index[i]]
elseif riderReason[index[i]] then
temp=riderReason[index[i]]
end
if iii == 1 then
tableEndText = tableEndText.. getSquadTableColumn(5)..': '.. riderNames[index[i]].. temp
else
tableEndText = tableEndText.. '<span style="color:white">'.. getSquadTableColumn(5)..': </span>'.. riderNames[index[i]].. temp
end
iii = iii + 1
if riderRef[index[i]] ~= ''nil then tableEndText = tableEndText..
frame:extensionTag{name='ref', content=riderRef[index[i]], args = {name='tr_'..i..frame.args[1]}} end
tableEndText = tableEndText.. '<br>'
end
 
--== I) List of winners ==
function timeStartEnd(Qid, property, mode, timeofrace)
function p.listofwinnersChamp(frame)
-- mode = 'numeric-id', property = 'P54', Qid = 'Q123'
local winnersProperty = {'Q20882667','Q20882668','Q20882669'}
local entity = mw.wikibase.getEntity(Qid)
local s = {
local a, b = pcall(fooA, mode, entity, property, 1)
countryflag=false,
local starttime, endtime
endyear=0,
local available_lang_priority = available_lang_priority
beginyear=0,
 
winnersProperty=winnersProperty
if a == true then
}
local timeStartEnd = {}
return listofwinners_main(frame, s)
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 black_listp.listofwinners(wiki, Labelframe)
local winnersProperty = {'Q20882667','Q20882668','Q20882669'}
--[[ List of Wikipedia articles with the same lemma as the non existing rider article. Those lemmas are printed
local s = {
as text "black" in the tables, not "blue" or "red". This way there will be no false wikilinks at the WhatLinksHere entry.
countryflag=true,
List should be updated maybe once a year. ]]
endyear=0,
local black_list = {}
beginyear=0,
if wiki=='de' then black_list={ ["Ryan Anderson"]=true, ["Chris Butler"]=true, ["Josef Černý"]=true, ["Brad Evans"]=true, ["Robert Fontaine"]=true,
winnersProperty=winnersProperty
["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,
return listofwinners_main(frame, s)
["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 p.listofwinnersfirstpart(frame) --return a html table to be copied directly in wikipedia
function WPlink(Qnumber, ...)
local link=''endyeartemp
if frame.args[2] ~= nil then
local entity = mw.wikibase.getEntity( Qnumber )
endyeartemp=tonumber(frame.args[2])
local Sitelink = entity:getSitelink() -- link to WParticle
else
local Sitelink2 = Sitelink
endyeartemp=0
local Label = entity:getLabel() or ''
local Label_fr = entity:getLabel( 'fr' ) or ''
local a, b
local official_name = ""
 
if arg[1] == nil then
if pcall(foo1, Qnumber) then
if 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
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 and title.exists
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 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
end -- if arg[1] == nil
 
if arg[1] == 'team' then -- add '(team of the winner)'
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
 
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(Qnumber, '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 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
 
-- mw.log('Sitelink=', Sitelink, 'Sitelink2=', Sitelink2, 'official_name=', official_name)
end -- end arg[1]
if arg[1] == 'pure' then
if pcall(foo1, Qnumber) 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
end
if Sitelink ~= nil then link = "[[" .. Sitelink .. "|" .. mw.text.trim(mw.ustring.gsub(Sitelink2, "%b()", "")..' ') .. "]]"
elseif wiki == 'ar' then
local title = mw.title.new(Label)
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
local winnersProperty = {'Q20882667','Q20882668','Q20882669'}
if arg[1] == 'race' then -- for infobox "Competitions"
local a, b = pcall(fooA, 'numeric-id', entity, 'P31', 1)
local s = {
if a == true and b == 1137352 then
countryflag=true,
local entity_race = mw.wikibase.getEntity( 'Q' .. b )
endyear=endyeartemp,
local Label_race = entity_race:getLabel() or ''
beginyear=0,
local Sitelink_race = entity_race:getSitelink() or ''
winnersProperty=winnersProperty
if Label_race ~= '' and Sitelink ~= nil then link = '[[' .. Sitelink .. '|' .. Label_race .. ']]'
}
elseif Sitelink ~= nil then link = '[[' .. Sitelink .. ']]'
return frame:extensionTag{ name = 'nowiki', content =listofwinners_main(frame, s)}
else if Sitelink_race ~= '' then link = '[[' .. Sitelink_race ..'|' .. mw.text.trim(mw.ustring.gsub(Sitelink_race, "%b()", "") .. ' ') .. ']]'
else link = Label_race or Label end
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
end
if arg[1] == "Q22348500" then -- add weblink from item "Q22348500" if available
local Sitelink_claas = mw.wikibase.getEntity( 'Q22348500' ):getSitelink()
if pcall(foo1, Qnumber) then --Sitelink_claas
if Sitelink == nil then
if Sitelink_claas ~= nil then link = "[[" .. Sitelink_claas .. "|" .. Label .. "]]"
elseif entity:getLabel( 'ar' )~=nil then link = entity:getLabel( 'ar' )
elseif entity:getLabel( 'fr' )~=nil then link = entity:getLabel( 'fr' )
elseif entity:getLabel( 'en' )~=nil then link = entity:getLabel( 'en' )
elseif entity:getLabel( 'de' )~=nil then link = entity:getLabel( 'de' )
else link = Label
end
end
end
end
return link
end
 
function p.listofwinnerssecondpart(frame)--start the list winners from a given year
function getMissingLabelTrackingCategory()
local l10nDef = {endyeartemp
if frame.args[2] ~= nil then
["//cs.wikipedia.org"] = '[[Kategorie:Údržba:Doplnit štítek na Wikidatech]]',
beginyeartemp=tonumber(frame.args[2])
["//lv.wikipedia.org"] = '[[Category:Vikidatos trūkst nosaukuma latviešu valodā]]',
else
["//he.wikipedia.org"] = '[[קטגוריה:ויקינתונים:ערכים חסרי תווית בעברית: קבוצת אופניים]]',
beginyeartemp=0
}
local l10n = l10nDef[mw.site.server]
if not l10n then
l10n = ''
end
return l10n
local winnersProperty = {'Q20882667','Q20882668','Q20882669'}
local s = {
countryflag=true,
endyear=0,
beginyear=beginyeartemp,
winnersProperty=winnersProperty
}
return listofwinners_main(frame, s)
end
 
function p.listofwinnersChampfirstpart(frame)
function changetemplate () -- for eoWiki
local endyeartemp
local frame = mw.getCurrentFrame()
if frame.args[2] ~= nil then
local n = frame:expandTemplate {title="sxangxu sxablonon2", args = {["sxablono"] = "Cycling race/infobox"}}
endyeartemp=tonumber(frame.args[2])
return n
else
end
endyeartemp=0
 
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
local winnersProperty = {'Q20882667','Q20882668','Q20882669'}
return snak, entity.claims[property][var].rank
local s = {
countryflag=false,
endyear=endyeartemp,
beginyear=0,
winnersProperty=winnersProperty
}
return frame:extensionTag{ name = 'nowiki', content =listofwinners_main(frame, s)}
end
 
function p.listofwinnersChampsecondpart(frame)
function fooB (mode, entity_var, property, var1, var2, ref, var3)
local snakendyeartemp
if frame.args[2] ~= nil then
if mode == 'value' then snak = entity_var.claims[property][var1].references[var2].snaks[ref][var3].datavalue.value
beginyeartemp=tonumber(frame.args[2])
else snak = entity_var.claims[property][var1].references[var2].snaks[ref][var3].datavalue.value[mode]
else
beginyeartemp=0
end
local winnersProperty = {'Q20882667','Q20882668','Q20882669'}
return snak
local s = {
countryflag=false,
endyear=0,
beginyear=beginyeartemp,
winnersProperty=winnersProperty
}
return listofwinners_main(frame, s)
end
 
function p.listofpointswinners(frame)
function fooC (mode, entity_var, property, var1, quali, var2)
local winnersProperty = {'Q20883007'}
local snak
local s = {
if mode == 'value' then snak = entity_var.claims[property][var1].references[var2].snaks[ref][var3].datavalue.value
countryflag=true,
else snak = entity_var.claims[property][var1].qualifiers[quali][var2].datavalue.value[mode]
endyear=0,
end
beginyear=0,
return snak
winnersProperty=winnersProperty
}
return listofwinners_main(frame, s)
end
 
function foo1 p.listofmountainwinners(argframe)
local winnersProperty = {'Q20883212'}
local entity = mw.wikibase.getEntity( arg )
local s = {
countryflag=true,
endyear=0,
beginyear=0,
winnersProperty=winnersProperty
}
return listofwinners_main(frame, s)
end
 
function p.listofyoungwinners(frame)
function foo2 (entity_var, property, var)
local winnersProperty = {'Q20883139'}
local snak = entity_var.claims[property][var].mainsnak.datavalue.value.amount
local s = {
end
countryflag=true,
 
endyear=0,
function foo3 (entity_var, property, var1, quali, var2)
beginyear=0,
local snak = entity_var.claims[property][var1].qualifiers[quali][var2].datavalue.value.amount
winnersProperty=winnersProperty
end
}
 
return listofwinners_main(frame, s)
local function winner(raceID, winners, timeOfRace, countryflag, WDlink_on)
local p = mw.wikibase.getAllStatements(raceID, 'P1346') -- P1346 is 'winner'
for _, winner in pairs(p) do
local wID = winner.mainsnak.snaktype == 'value' and winner.mainsnak.datavalue.value.id
local wOf, wCause, wCriterion, riderLink
if winner.qualifiers then
local q = winner.qualifiers
wOf = q.P642 and q.P642[1].snaktype == 'value' and q.P642[1].datavalue.value.id
-- P642 is 'of'; Q20882667 is 'overall winner general classification'
if not wOf then
-- Try P1346 (winner) instead, assume Q20882667 (overall winner) if neither is are found
wOf = q.P1346 and q.P1346[1].snaktype == 'value' and q.P1346[1].datavalue.value.id or 'Q20882667'
end
wCause = q.P828 and q.P828[1].snaktype == 'value' and q.P828[1].datavalue.value.id
-- P828 is 'has cause'
wCriterion = q.P1013 and q.P1013[1].snaktype == 'value' and q.P1013[1].datavalue.value.id
-- P1013 is 'criterion used'
end
if winners[wOf] then
if wID then
riderLink = getRiderLink(wID)
if countryflag then
local p27 = getStatementForTime(wID, 'P27', timeOfRace) --P27 is country of citizenship
if p27 then
riderLink = flag(p27.mainsnak.datavalue.value.id, timeOfRace) .. ' ' .. riderLink
countryID = p27.mainsnak.datavalue.value.id
end
end
if WDlink_on then
riderLink = riderLink .. ' ' .. wdLink(wID)
end
else
riderLink = wCriterion and mw.language.getContentLanguage():ucfirst(mw.wikibase.getLabel(wCriterion) or '')
or ''
if wCause then
local cause = mw.wikibase.getLabel(wCause)
if cause then
riderLink = riderLink .. ' (' .. cause .. ')'
end
end
end
if winners[wOf] == '' then
winners[wOf] = riderLink
else
winners[wOf] = winners[wOf] .. '<br/>' .. riderLink
end
end
end
end
 
function p.listofwinnersChamp(frame)
local countryflag = false
return listofwinners_main(frame, countryflag)
end
 
function p.listofwinners(frame)
local countryflag = true
return listofwinners_main(frame, countryflag)
end
 
function listofwinners_main(frame, countryflags)
local rows = {}
frame.args[1] = string.gsub(frame.args[1], "%c", "")
-- WDlink_on is used to decide if a Wikidata logo will be shown
local WPcontent = {}
local countryflag=s.countryflag
local beginyear=s.beginyear
local endyear=s.endyear
 
local localFrame
end
local year = timeOfRace and string.sub(timeOfRace, 2, 5) or '?'
localif sitelinkyear == "?" then mw.wikibase.getSitelinklog("no year at " .. partID ) end
if endyear==nil or endyear==0 or (endyear~=0 and tonumber(year)<=endyear) then
if sitelink then
if beginyear==nil or beginyear==0 or (beginyear~=0 and tonumber(year)>=beginyear) then
sitelink = '[[' .. sitelink .. '|' .. year .. ']]'
local sitelink = mw.wikibase.getSitelink(partID)
else
sitelink if =sitelink yearthen
sitelink = '[[' .. sitelink .. '|' .. year .. ']]'
else
sitelink = year
end
if WDlink_on then
sitelink = sitelink .. ' ' .. wdLink(partID)
end
local winners = {}
for _, property in ipairs(s.winnersProperty) do winners[property]='' end
winner(partID, winners, timeOfRace, countryflag, WDlink_on)
local temprow = "<tr><td style='text-align:center'>" .. sitelink
for _, property in ipairs(s.winnersProperty) do
temprow=temprow.."</td><td>" ..winners[property]
end
rows[#rows+1]={year, temprow .. "</td></tr>"}
end
end
end
if WDlink_on then
sitelink = sitelink .. ' ' .. wdLink(partID)
end
local winners = {
Q20882667 = '', -- Q20882667 is 'overall winner general classification'
Q20882668 = '', -- Q20882668 is 'second overall'
Q20882669 = '', -- Q20882669 is 'third overall'
}
winner(partID, winners, timeOfRace, countryflag, WDlink_on)
rows[#rows+1] = {year, "<tr><td style='text-align:center'>" .. sitelink ..
"</td><td>" .. winners.Q20882667 ..
"</td><td>" .. winners.Q20882668 ..
"</td><td>" .. winners.Q20882669 .. "</td></tr>"}
end
end
table.sort(rows, function(a, b) return a[1] < b[1] end) -- Sort by year
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:" .. textalign .. "; vertical-align:top; font-size:85%; line-height:1.6em;'>"
raceID .. '#P527]]</span>'
end
table_proto = table_proto .. headoftableIV(1) .. "</th><th>".. headoftableIV(2) .. "</th><th>" ..
headoftableIV(3) table_proto ..= "</th><th>"table_proto .. headoftableIV(41) .. "</th></tr>"
for kk, _ in ipairs(s.winnersProperty) do
table_proto = table_proto.."<th>".. headoftableIV(kk+1) .. "</th>"
end
table_proto =table_proto .."</tr>"
local table_center, table_last = "", "</table>"
 
table_center = table_center .. row[2]
end
--firstpart with header no foot
return table_first .. table_proto .. table_center .. table_last
if endyear~=nil and endyear~=0 then
return table_first .. table_proto .. table_center
elseif beginyear~=nil and beginyear~=0 then
return table_center .. table_last
else
return table_first .. table_proto .. table_center .. table_last
end
end
 
--== J) List of stages
function p.listofstages(frame)
-- WDlink_on is used to decide if a Wikidata logo will be shown
if frame.args[1] ~= nil then frame.args[1] = string.gsub(frame.args[1], "%c", "") end
local i,WDlink_on k,= v,wiki uu,== ii,"mk" nationalityor wiki == "ja"
local entity, etape, stage = {}, {}, {}
local series_ordinal, point_of_time, length = {}, {}, {}
local sitelinks_etape, sitelinks1, sitelinks2, sitelinks3, sitelinks4 = {}, {}, {}, {}, {}
local y, m, d = {}, {}, {}
local flag1, flag2 = {}, {}
local number0, number1, number2 = {}, {}, {}
local level = false
local a, b, num, var
local entity0 = mw.wikibase.getEntityObject( frame.args[1] )
local WDlink_on
local _, _, key1, key01, key11, key12, key2, key21, key22, val
local WPcontent = {}
local raceID = frame.args[1]
 
local localFrame
if string.match(frame:getParent():getTitle(), '%P+') == mw.site.namespaces.Template.name then
then localFrame = frame:getParent() else localFrame = frame end
else
if localFrame.args[1] ~= nil then localFrame.args[1] = string.gsub(localFrame.args[1], "%c", "") end
localFrame = frame
--[=[ It is possible to give the table listofstages in the article commands which overwrites data from Wikidata. It could look like this:
end
if localFrame.args[1] then
localFrame.args[1] = string.gsub(localFrame.args[1], "%c", "")
end
--[=[ It is possible to give the table listofstages in the article commands which overwrites data from Wikidata.
It could look like this:
{{Cycling race/listofstages|Q18574623
| RoW 1: locaTION Ab : [[1a1b]]
| after row 1 : icon : [[File:Stage rest day.svg|vbght frthzt fdgtr]]
| after row 1: text : rest day at [[aaa bbb ccc]]
| row 4: location A : [[4a4a]]abc
| row 3 : winner a : <sup>tzhgt</sup>
| row 4 : winner b : kjuzhgt<br />bbjje
| row 4 : distance : <s>141.8</s> 122<ref>test</ref>
}}
The first paramer is "row x" or "after row x". "after row" adds a new row after row x into the table to print e.g. a rest day. The second parameters are
The second parameters are "location [a/b/ab]", "date", "icon", "text", "winner [a/b]" and "distance". "a" and "b" means the first and the second location or winner. "ab" could be used if
"a" and "b" means the first and the second location or winner. "ab" could be used if start location and
start location and end location are the same. The file data for the icon looks this way: [[File:Stage rest day.svg|any text]]
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, WPnew_row, WPcourse, WPtext, WPdate, WPwinner, WPicon, WPdistance
-- 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'
local _, key, key2, val
for num,var in pairs(localFrame.args) do
local key01, key11, key12
if num > 1 and mw.ustring.find(mw.ustring.lower(localFrame.args[num]), WProw) then
local key21, key22
_, _, key1, key2, val = mw.ustring.find(localFrame.args[num], "([^:]+)%s*:?%s*([^:]*)%s*:%s*(%C+)")
for num, var in pairs(localFrame.args) do
if num > 1 and mw.ustring.find(mw.ustring.lower(var), WProw) then
_, _, key1, key2, val = mw.ustring.find(var, "([^:]+)%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)
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(not 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
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
WPcontent[key12]['icon'] = val end
if key11 == WProw and key21 == WPdistance then WPcontent[key12]['distance'] = val end
end
end
end
local rows = {}
-- if there is one 'P527' then level = true
local stages = mw.wikibase.getBestStatements(raceID, 'P527') -- P527 is 'has part'
a, b = pcall(fooA, 'numeric-id', entity0, 'P527', 1)
for _, v in pairs(stages) do
if a == true then level = true end
if v.mainsnak.snaktype == 'value' then
local stageID = v.mainsnak.datavalue.value.id
local p = mw.wikibase.getBestStatements(stageID, 'P1545') -- P1545 is 'series ordinal'
local sOrdinal = p[1] and p[1].mainsnak.snaktype == 'value' and p[1].mainsnak.datavalue.value
or ''
local _, _, sNumber, sLetter = string.find(sOrdinal, '(%d+)(.*)')
if not sNumber then sNumber = '' end
if not sLetter then sLetter = '' end
local WDLink = WDlink_on and wdLink(stageID) or ''
local sitelink = mw.wikibase.getSitelink(stageID)
 
p = mw.wikibase.getBestStatements(stageID, 'P585') -- P585 is 'point in time'
-- read series_ordinal and the Qnumber and sort them after series_ordinal, eg: 1 2a 2b 3 4 5
local timeOfRace = p[1] and p[1].mainsnak.snaktype == 'value' and p[1].mainsnak.datavalue.value.time
local parts = {}
or ''
for num, v in pairs(entity0.claims["P527"]) do
local _, _, year, month, day = string.find(timeOfRace, "(%d+)-0?(%d+)-0?(%d+)")
etape[num] = 'Q'..v.mainsnak.datavalue.value['numeric-id']
entity[num] = mw.wikibase.getEntityObject( etape[num] )
a, b = pcall(fooA, 'value', entity[num], 'P1545', 1)
if a == true then series_ordinal[num] = b else series_ordinal[num] = " " end
table.insert(parts, num, {nr = series_ordinal[num], Qnum = etape[num]})
end
 
p = mw.wikibase.getBestStatements(stageID, 'P1427') -- P1427 is 'start point'
-- sort parts after nr = series_ordinal[num], not Qnum
local sPointID = p[1] and p[1].mainsnak.snaktype == 'value' and p[1].mainsnak.datavalue.value.id
table.sort(parts, function(a, b)
local sPoint = sPointID and getPlaceLink(sPointID) or ''
local num1, num2
p = mw.wikibase.getBestStatements(stageID, 'P1444') -- P1444 is 'destination point'
if wiki == "ar" then
local dPointID = p[1] and p[1].mainsnak.snaktype == 'value' and p[1].mainsnak.datavalue.value.id
if string.find(a.nr, "%d+") then num1 = string.sub(a.nr, string.find(a.nr, "%d+") or '' ) else num1 = "" end
local dPoint = dPointID and getPlaceLink(dPointID) or ''
if string.find(b.nr, "%d+") then num2 = string.sub(b.nr, string.find(b.nr, "%d+") or '' ) else num2 = "" end
local sDistance = getDistance(stageID, false) or ''
else
local winners = {
num1 = string.sub(a.nr, string.find(a.nr, "%d+"))
Q20882747 = '', -- Q20882747 is 'stage winner'
num2 = string.sub(b.nr, string.find(b.nr, "%d+"))
Q20882763 = '', -- Q20882763 is 'overall leader at the end of the stage'
end
}
local char1, char2
winner(stageID, winners, timeOfRace, true, WDlink_on)
if string.find(a.nr, "%a") then char1 = string.sub(a.nr, string.find(a.nr, "%a")) else char1 = "" end
if string.find(b.nr, "%a") then char2 = string.sub(b.nr, string.find(b.nr, "%a")) else char2 = "" end
 
-- find the type of stage
local comp
local sType = ''
if char1 == "" and char2 == "" then comp = tonumber(num1) < tonumber(num2) end
p = mw.wikibase.getBestStatements(stageID, 'P31') -- P31 is 'instance of'
if char1 ~= "" or char2 ~= "" then comp = tonumber(num1) < tonumber(num2) end
for _,t in pairs(p) do
if char1 ~= "" and char2 ~= "" then
if num1t.mainsnak.snaktype == num2'value' then comp = char1 < char2
local iOf = t.mainsnak.datavalue.value['numeric-id']
else comp = tonumber(num1) < tonumber(num2)
if iOf == 20646667 then sType = typeofstage('plain stage') break end
if iOf == 20646670 then sType = typeofstage('hilly stage') break end
if iOf == 20680270 then sType = typeofstage('intermediate stage') break end
if iOf == 20646668 then sType = typeofstage('mountain stage') break end
if iOf == 485321 then sType = typeofstage('time trial stage', 485321) break end -- prologue
if iOf == 2266066 then sType = typeofstage('time trial stage', 2266066) break end -- individual time trial
if iOf == 2348250 then sType = typeofstage('time trial stage', 2348250) break end -- team time trial
if iOf == 20679712 then sType = typeofstage('uphill time trial stage') break end
end
end
end
return comp end)
 
local label, section_title
-- WDlink_on is used to decide if a Wikidata flag will be shown
if sOrdinal == "0" then
if wiki == "mk" or wiki == "ja" or wiki == "ru" then WDlink_on = true else WDlink_on = false end
label, section_title = func_prologue(), "#" .. func_prologue()
else
label, section_title = stageLink(sOrdinal, sNumber, sLetter)
end
-- if there is a Wikipedia article of that stage show it or show the section
local sLink = sitelink and ("[[" .. sitelink .. "|" .. label .. "]]") or
("[[" .. section_title .. "|" .. label .. "]]")
 
if day == "1" and wiki == "fr" then day = "1<sup>er</sup>" end
var = #entity0.claims["P527"]
if wiki == "lv" then sLink = sOrdinal end
for num=1,var do
local month = func_month(tonumber(month)) or ""
-- collect data from Wikidata in tables
local sDate
entity[num] = mw.wikibase.getEntityObject( parts[num].Qnum )
if WDlink_onwiki == false"br" then number0[num]sDate = "day .. " elsea number0[num] =viz "&nbsp;" .. wdLink(parts[num].Qnum) endmonth
elseif wiki == "ca" or wiki == "es" then sDate = day .. " de ".. month
sitelinks_etape[num] = entity[num]:getSitelink()
elseif wiki == "eo" then sDate = day .. "-a de " .. month
elseif wiki == "eu" then sDate = month .. "k " .. day
elseif wiki == "hu" then sDate = month .. " " .. day .. "."
elseif wiki == "ja" then sDate = month .. day .. "日"
elseif wiki == "de" or wiki == "da" or wiki == "fi" or wiki == "fo" or wiki == "no" or wiki == "lv" then
sDate = day .. ". " .. month
elseif wiki == "cs" then sDate = day .. ". xg " .. month
elseif wiki == "en" then sDate = month .. " " .. day
else sDate = day .. ' ' .. month
end
 
rows[#rows + 1] = {
a, b = pcall(fooA, 'value', entity[num], 'P1545', 1)
tonumber(sNumber), sLetter, -- Sort keys
if a == true then series_ordinal[num] = b else series_ordinal[num] = " " end
sLink, sDate, WDLink, sPoint, dPoint, sType, sDistance, winners['Q20882747'], winners['Q20882763'] -- Content
a, b = pcall(fooA, 'time', entity[num], 'P585', 1)
}
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], 'P3157', 1)
if a == true then length[num] = b
else
a, b = pcall(fooA, 'amount', entity[num], 'P2043', 1)
if a == true then length[num] = b else length[num] = " " end
end
end
 
table.sort(rows, function(a, b)
flag1[num] = ' '
if a[1] ~= b[1] then return a[1] < b[1] end
sitelinks3[num] = ' '
return a[2] < b[2]
number1[num] = ' '
end)
local id, qual
-- find the vainqueur d'étape, Q20882747
if pcall(foo3, entity[num], "P1346", 1, "P642", 1) then
local v
for _, v in pairs(entity[num].claims["P1346"]) do
if pcall(function() id = v.mainsnak.datavalue.value['numeric-id'] end) then else id = nil end
qual = v.qualifiers["P642"][1].datavalue.value["numeric-id"]
if id ~= nil and v.rank ~= 'deprecated' then
if qual == 20882747 then
number1[num] = 'Q' .. id
a, b = timeStartEnd(number1[num], "P27", 'numeric-id', point_of_time[num])
if a == true then
flag1[num] = flag('Q'..b, point_of_time[num])
sitelinks3[num] = WPlink( number1[num] )
else
a, b = pcall(fooA, 'numeric-id', mw.wikibase.getEntityObject(number1[num]), 'P17', 1)
if a == true then
flag1[num] = flag('Q'..b, point_of_time[num])
sitelinks3[num] = WPlink( number1[num], 'team', point_of_time[num] )
end
end
if WDlink_on == false then number1[num]="" else number1[num] =
"<span style='white-space:nowrap'>&nbsp;[[File:Wikidata-logo S.svg|12px|link=d:".. number1[num] .. ']]</span>' end
end
end -- if id
end -- for
end -- end if pcall
 
flag2[for num], row =in 'pairs(rows) 'do
local sLink, sDate, WDLink, sPoint, dPoint, sType, sDistance, sSWin, sGWin
sitelinks4[num] = ' '
= row[3], row[4], row[5], row[6], row[7], row[8], row[9], row[10], row[11]
number2[num] = ' '
local id, qual
-- find the leader du classement général à l'issue de l'étape, Q20882763
if pcall(foo3, entity[num], "P1346", 1, "P642", 1) then
local v
for _, v in pairs(entity[num].claims["P1346"]) do
if pcall(function() id = v.mainsnak.datavalue.value['numeric-id'] end) then else id = nil end
qual = v.qualifiers["P642"][1].datavalue.value["numeric-id"]
if id ~= nil and v.rank ~= 'deprecated' then
if qual == 20882763 or qual == 20882667 then
number2[num] = 'Q' .. id
a, b = timeStartEnd(number2[num], "P27", 'numeric-id', point_of_time[num])
if a == true then
flag2[num] = flag( 'Q'..b, point_of_time[num])
sitelinks4[num] = WPlink( number2[num] )
else
a, b = pcall(fooA, 'numeric-id', mw.wikibase.getEntityObject(number2[num]), 'P17', 1)
if a == true then
flag2[num] = flag( 'Q'..b, point_of_time[num])
sitelinks4[num] = WPlink( number2[num], 'team' )
end
end
if WDlink_on == false then number2[num]="" else number2[num] =
"<span style='white-space:nowrap'>&nbsp;[[File:Wikidata-logo S.svg|12px|link=d:"..number2[num] .. ']]</span>' end
end
end -- if id
end -- for
end -- end if pcall
 
local WPc = WPcontent[num]
if pcall(function()
if WPc then
-- find the type of stages
if WPc['a'] then sPoint = WPc['a'] end
i = 1
if WPc['b'] then dPoint = WPc['b'] end
stage[num] = ""
if WPc['ab'] then sPoint, dPoint = WPc['ab'], '' end
uu = entity[num].claims["P31"][i].mainsnak.datavalue.value['numeric-id']
if WPc['icon'] then sType = WPc['icon'] end
while entity[num].claims["P31"][i] do
if uu == 20646667WPc['distance'] then stage[num]sDistance = typeofstage(WPc['plain stagedistance') break] end
if uu == 20646670 then stage[num] = typeofstage('hilly stage') break end
if uu == 20680270 then stage[num] = typeofstage('intermediate stage') break end
if uu == 20646668 then stage[num] = typeofstage('mountain stage') break end
if uu == 485321 then stage[num] = typeofstage('time trial stage', 485321) break end -- prologue
if uu == 2266066 then stage[num] = typeofstage('time trial stage', 2266066) break end -- individual time trial
if uu == 2348250 then stage[num] = typeofstage('time trial stage', 2348250) break end -- team time trial
if uu == 20679712 then stage[num] = typeofstage('uphill time trial stage') break end
i = i + 1
end
end)
then else stage[num] = " " end
 
local t = "<tr><td style='text-align:center; white-space:nowrap'>" .. sLink ..
_, _, y[num], m[num], d[num] = string.find(point_of_time[num], "(%d+)-(%d+)-(%d+)") -- d = day, m = month
"<span style='white-space:nowrap'>&nbsp;".. WDLink ..
"</span></td><td style='white-space:nowrap; text-align:right; padding-right:0px'>" .. sDate ..
"</td><td style='padding-right:0px'>" .. sPoint
if dPoint ~= '' then t = t .. " – " .. dPoint end
t = t .. "</td><td style='padding-top:10px'>" .. sType ..
"</td><td style='text-align:center'>" .. sDistance .. "</td>"
 
if WPc and WPc['stage winner'] then
end -- end for num=1,var do
t = t .. "<td style='text-align:" .. textalign .. "'>" .. WPc['stage winner'] .. "</td>"
 
else
local table_first, table_proto, table_last
t = t .. "<td>" .. sSWin .. "</td>"
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:" .. 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)..
"</th>".. "<th style='color:#FFDF80'>type</th>" .."<th>".. headoftable(4).. "</th><th>".. headoftable(5).."</th><th>".. headoftable(6).. "</th></tr>"
table_last = "</table>"
 
-- build table for output
local table_center = ""
var = #entity0.claims["P527"]
for num=1, var do
local a, b
a, _ = string.gsub(series_ordinal[num], "%a", "") -- 20, not 20a
if string.find(series_ordinal[num], "%a") then b = string.sub(series_ordinal[num], string.find(series_ordinal[num], "%a"))
else b = "" end
local ee, er = stageLink(series_ordinal[num], a, b)
if series_ordinal[num] == "0" then
er = "#"..func_prologue()
ee = func_prologue()
end
if WPc and WPc['general winner'] then
local stageNr -- if there is a wikipedia article of that stage show it or show the section
t = t .. "<td style='text-align:" .. textalign .. "'>" .. WPc['general winner'] .. "</td></tr>"
if sitelinks_etape[num] == nil then stageNr = "[["..er.."|"..ee.."]]" else stageNr = "[["..sitelinks_etape[num].."|"..ee.."]]" end
 
local day = tostring(tonumber(d[num]))
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" or wiki == "ast" then date = day .. " de ".. month end
if wiki == "eo" then date = day.. "-a de ".. month end
if wiki == "eu" then date = month.. "k ".. day end
if wiki == "hu" then date = month.. " ".. day .."." end
if wiki == "ja" then date = month.. day .. "日" end
if wiki == "de" or wiki == "da" or wiki == "fi" or wiki == "fo" or wiki == "no" or wiki == "lv" then date = day.. ". ".. month end
if wiki == "cs" then date = day.. ". xg ".. month end
if wiki == "en" then date = month.. " ".. day end
 
local miles
if wiki == 'en' then --If 'en.wiki' express distance in kilometers and miles
if pcall(function()
miles = math.modf(10*length[num]/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
t = t .. "<td>" .. sGWin .. "</td></tr>"
if pcall(function()
length[num] = mw.language.getContentLanguage():formatNum(tonumber(length[num]))
end
) then else length[num] = " " end
end
if WPc and (WPc['date'] or WPc['text'] or WPc['icon (new row)']) then
 
t = t .. "<tr><td></td>"
if type(WPcontent[num]) == 'table' and WPcontent[num]['a'] ~= nil then sitelinks1[num] = WPcontent[num]['a'] end
if WPc['icon (new row)'] == '' then
if type(WPcontent[num]) == 'table' and WPcontent[num]['b'] ~= nil then sitelinks2[num] = WPcontent[num]['b'] end
t = t .. "<td style='text-align:right; padding:3px 0px 10px 0px;white-space:nowrap'>" .. WPc['date'] ..
if type(WPcontent[num]) == 'table' and WPcontent[num]['ab'] ~= nil then sitelinks1[num] = WPcontent[num]['ab'] sitelinks2[num] = '' end
"</td><td style='text-align:" .. textalign .. "; padding:3px 4px 10px'>" .. WPc['text']
if type(WPcontent[num]) == 'table' and WPcontent[num]['icon'] ~= nil then stage[num] = WPcontent[num]['icon'] end
else
if type(WPcontent[num]) == 'table' and WPcontent[num]['distance'] ~= nil then length[num] = WPcontent[num]['distance'] end
t = t .. "<td style='text-align:right; padding-right:0px'>" .. WPc['date'] ..
if type(WPcontent[num]) == 'table' and WPcontent[num]['stage winner'] ~= nil then
"</td><td style='text-align:" .. textalign .. "'>" .. WPc['text']
flag1[num] = '' sitelinks3[num] = WPcontent[num]['stage winner'] number1[num]= '' end
end
if type(WPcontent[num]) == 'table' and WPcontent[num]['general winner'] ~= nil then
t = t .. "</td><td style='padding-top:10px'>" .. WPc['icon (new row)'] .. "</td><td colspan='3' ></td></tr>"
flag2[num] = '' sitelinks4[num] = WPcontent[num]['general winner'] number2[num]= '' end
 
table_center = table_center.. "<tr><td style='text-align:center; white-space:nowrap'>".. stageNr .. "<span style='white-space:nowrap'>&nbsp;".. number0[num].."</span>"..
"</td><td style='white-space:nowrap; text-align:right; padding-right:0px'>"..date.. "</td><td style='padding-right:0px'>".. sitelinks1[num]
if sitelinks2[num] ~= '' then table_center = table_center.. " – " 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:" .. 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:" .. 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 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:" .. textalign .. "; padding:3px 4px 10px'>"..WPcontent[num]['text']
else table_center = table_center.."</td><td style='text-align:" .. 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
rows[num] = t
end
end
 
return "<table border='0' 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:" ..
local tabl = table_first.. table_proto
textalign .. "; font-size:85%; line-height:1.6em;'>" ..
if level == true then tabl = tabl.. table_center.. table_last else tabl = tabl.. table_last end
"<tr style='background:#FFDF80; text-align:center;'><th style='white-space:nowrap'>" ..
return tabl
(not WDlink_on and ("[[File:Wikidata-logo S.svg|12px|link=d:" .. raceID .. "#P527]]")) ..
headoftable(1) .. "</th><th>" .. headoftable(2) .. "</th><th>".. headoftable(3) ..
"</th><th style='color:#FFDF80'>type</th><th>".. headoftable(4) .. "</th><th>".. headoftable(5) ..
"</th><th>" .. headoftable(6) .. "</th></tr>", table.concat(rows), "</table>"
end
 
--[[ Give access to a local variable. Used by other modules. ]]
function func_prologue() -- returns the word "Prologue"
function p.getLocal(name)
local l10nDef = { ["fr"]="Prologue", ["ar"]="المقدمة", ["en"]="Prologue", ["br"]="Prolog", ["ca"]="Pròleg", ["cs"]="Prolog", ["de"]="Prolog", ["da"]="Prolog", ["eo"]="Prologo",
if name == 'getTeamLinkCat' then return getTeamLinkCat end
["es"]="Prólogo", ["eu"]="Aitzinetapa", ["fi"]="Prologi", ["fo"]="Forteinur", ["hu"]="Prolog", ["it"]="Prologo", ["ja"]="プロローグ", ["la"]="Incipit prologus", ["lb"]="Prolog", ["lv"]="Prologs",
if name == 'getStatementForTime' then return getStatementForTime end
["mk"]="Пролог", ["nl"]="Proloog", ["no"]="Prolog", ["pl"]="Prologu", ["pt"]="Prólogo", ["ro"]="Prolog", ["ru"]="Пролог", ["sk"]="Prológ", ["sv"]="Prolog", ["ast"]="Prólogu"}
 
if l10nDef[wiki] ~= nil then return l10nDef[wiki] else return l10nDef["en"] end -- if no translation, show en translation
end
 
function stageLinkchamptitle(x, a, bh) --!h x=is 10a: a = 10, b = ah. x = 5: a = 5, b = ""jersey
local road, ITT, result
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",
if type(h) == 'table' and h[1] then
["lv"]="Posms", ["mk"]="Етапа", ["nl"]="Etappe", ["no"]="etappe", ["pl"]="Etap", ["pt"]="Etapa", ["ro"]="Etapa", ["ru"]="Этап", ["sk"]="Etapa",
for _, v in ipairs(h) do
["sv"]="Etapp", ["ast"]="etapa" }
Racelabel= mw.wikibase.getLabelByLang(v,"fr")
 
if Racelabel~=nil then
local word1, word2
Racelabelmod=mw.ustring.gsub( Racelabel, '-', 'x' )
word2=l10nDef[wiki]
testMenRoadrace=string.find( Racelabel, 'Course en ligne masculine aux' )
if word2 == nil then word2=l10nDef["en"] end -- if no translation, show en translation
testMenITT=string.find( Racelabelmod, 'Contrexlaxmontre masculin aux' )
local word = word2
testWomenRoadrace=string.find( Racelabel, 'Course en ligne féminine aux' )
 
testWomenITT=string.find( Racelabelmod, 'Contrexlaxmontre féminin aux' )
-- fr: {{1re}} étape, {{2e}} étape
end
if wiki=="fr" or wiki=="lb" then
if testWomenRoadrace ~= nil or testMenRoadrace ~= nil then road=1 end
if b == "" then -- series_ordinal without character
if testWomenITT ~= nil or testMenITT ~= nil then ITT=1 end
if a == "1" then word1 = "1<sup>re</sup> "..word else word1 = a.."<sup>e</sup> "..word end -- table text = {{1re}} étape, {{2ae}} étape,
if a == "1" then word2 = "#1re "..word else word2 = "#"..a.."e "..word end --text of section header = #1re étape, #2e étape
return word1, word2
end
end
if b ~= "" then -- series_ordinal with character: instead of eg "1a re" it is "1re a"
if road~=nil and ITT~=nil then
if a == "1" then word1 = "1<sup>re</sup> "..b.." "..word else word1 = a.."<sup>e</sup> "..b.." "..word end -- table text = {{1re}} étape, {{2ae}} étape,
local image={}
if a == "1" then word2 = "#1re "..b.." "..word else word2 = "#"..a.."e"..b.." "..word end --text of section header = #1re étape, #2e étape
for ii, v in ipairs(h) do
return word1, word2
p18 = mw.wikibase.getBestStatements(v, 'P18')
if p18[1] and p18[1].mainsnak.snaktype == 'value' then
local temp=p18[1].mainsnak.datavalue.value
local alreadythere=0
for i, vv in ipairs(image) do
if vv==temp then alreadythere=1 end
end
if alreadythere==0 then
table.insert(image,temp)
else h[ii]=nil
end
end
end
--avoid double display of jersey
result="("..Startlist_translate(10).." "..Startlist_translate(12).." "..Startlist_translate(11)..")"
elseif road~=nil then
 
result="("..Startlist_translate(10)..")"
elseif ITT~=nil then
result="("..Startlist_translate(11)..")"
else
result=""
end
return jersey(h)..result
if wiki=="de" or wiki=="da" or wiki=="fo" or wiki=="no" then return a..". "..b.." "..word, "#"..a..". "..b.." "..word end
if wiki=="ca" then return a.."a "..b.." "..word, "#"..a..". "..b.." "..word end
if wiki=="es" then return a..".<sup>a</sup> "..b.." "..word, "#"..a..". "..b.." "..word end
if wiki=="ast" then return a.."ª "..b.." "..word, "#"..a..". "..b.." "..word end
-- default
word1 = x -- table text = 1, 2a, 3
word2 = "#"..word.." ".. x -- text of section header = #Etappe 2a, #Stage 4
return word1, word2
end
 
function func_monthp.startlist(xframe)
local l10nDef = {IDtemp
if frame.args[1] ~= nil then
["ar"] = {"يناير", "فبراير", "مارس", "أبريل", "مايو", "يونيو", "يوليو", "أغسطس", "سبتمبر", "أكتوبر", "نوفمبر", "ديسمبر"},
IDtemp=string.gsub(frame.args[1], "%c", "")
["fr"] = {"janv.", "févr.", "mars", "avr.", "mai", "juin", "juil.", "août", "sept.", "oct.", "nov.", "déc."},
end
["en"] = {"January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"},
["be"] = {"studz.", "liut.", "sak.", "kras.", "mai.", "cherv.", "lip.", "zhniven'", "veras", "kastr.", "list.", "snezh."},
["bg"] = {"ian.", "fevr.", "mart", "april", "mai", "iuni", "iuli", "avg.", "sept.", "okt.", "noem.", "dek."},
["br"] = {"Genver", "C'hwevrer", "Meurzh", "Ebrel", "Mae", "Mezheven", "Gouere", "Eost", "Gwengolo", "Here", "Du", "Kerzu"},
["ca"] = {"gener", "febrer", "març", "abril", "maig", "juny", "juliol", "agost", "setembre", "octubre", "novembre", "desembre"},
["cs"] = {"led.", "ún.", "bře.", "dub.", "kvě.", "čvn.", "čvc.", "srp.", "září.", "říj.", "list.", "pros."},
["da"] = {"jan.", "febr.", "marts", "april", "maj", "juni", "juli", "aug.", "sept.", "okt.", "nov.", "dec."},
["de"] = {"Jan.", "Feb.", "März", "Apr.", "Mai", "Juni", "Juli", "Aug.", "Sept.", "Okt.", "Nov.", "Dez."},
["eo"] = {"janu.", "febr.", "marto", "apr.", "majo", "jun.", "jul.", "auxg.", "sept.", "okt.", "nov.", "dec."},
["es"] = {"enero", "febrero", "marzo", "abril", "mayo", "junio", "julio", "agosto", "septiembre", "octubre", "noviembre", "diciembre"},
["et"] = {"jaan.", "veebr.", "märts", "apr.", "mai", "juuni", "juuli", "aug.", "sept.", "okt.", "nov.", "dets."},
["eu"] = {"urtarrila", "otsaila", "martxoa", "apirila", "maiatza", "ekaina", "uztaila", "abuztua", "iraila", "urria", "azaroa", "abendua"},
["fi"] = {"tammikuuta", "helmikuuta", "maaliskuuta", "huhtikuuta", "toukokuuta", "kesäkuuta", "heinäkuuta", "elokuuta", "syyskuuta", "lokakuuta", "marraskuuta", "joulukuuta"},
["fo"] = {"januar", "februar", "mars", "apríl", "mai", "juni", "juli", "august", "september", "oktober", "november", "desember"},
["hu"] = {"január", "február", "március", "április", "május", "június", "július", "augusztus", "szeptember", "október", "november", "december"},
["id"] = {"Djan.", "Peb.", "Mrt.", "Apr.", "Mai", "Djuni", "Djuli", "Ag.", "Sept.", "Okt.", "Nop.", "Des."},
["it"] = {"genn.", "febbr.", "mar.", "apr.", "magg.", "giugno", "luglio", "ag.", "sett.", "ott.", "nov.", "dic."},
["ja"] = {"1月", "2月", "3月", "4月", "5月", "6月", "7月", "8月", "9月", "10月", "11月", "12月"},
["la"] = {"Ian.", "Febr.", "Mart.", "Apr.", "Mai.", "Iun.", "Iul.", "Aug.", "Sept.", "Oct.", "Nov.", "Dec."},
["lb"] = {"Januar", "Februar", "Mäerz", "Abrëll", "Mee", "Juni", "Juli", "August", "September", "Oktober", "November", "Dezember"},
["lt"] = {"saus.", "vas.", "kovas", "bal.", "geg.", "birz", "liepa", "rugp.", "rugs.", "spalis", "lapkr.", "gr."},
["lv"] = {"janvāris", "februāris", "marts", "aprīlis", "maijs", "jūnijs", "jūlijs", "augusts", "septembris", "oktobris", "novembris", "decembris"},
["mk"] = {"јануари", "февруари", "март", "април", "мај", "јуни", "јули", "август", "септември", "октомври", "ноември", "декември"},
["ms"] = {"Jan.", "Feb.", "Mac", "Apr.", "Mei", "Jun", "Julai", "Og", "Sept.", "Okt.", "Nov.", "Dis."},
["no"] = {"jan.", "feb.", "mar.", "apr.", "mai", "jun.", "jul.", "aug.", "sep.", "okt.", "nov.", "des."},
["nl"] = {"jan.", "feb.", "maart", "apr.", "mei", "juni", "juli", "aug.", "sept.", "okt.", "nov.", "dec."},
["pl"] = {"stycznia", "lutego", "marca", "kwietnia", "maja", "czerwca", "lipca", "sierpnia", "września", "października", "listopada", "grudnia"},
["pt"] = {"jan", "fev", "mar", "abr", "mai", "jun", "jul", "ago", "set", "out", "nov", "dez"},
["ro"] = {"Ian.", "Feb.", "Mar.", "Apr.", "Mai", "Iun.", "Iul.", "Aug.", "Sep.", "Oct.", "Nov.", "Dec."},
["ru"] = {"января", "февраля", "марта", "апреля", "мая", "июня", "июля", "августа", "сентября", "октября", "ноября", "декабря"},
["sh"] = {"sijec.", "velj.", "ozuj.", "trav.", "svib.", "lip.", "srp.", "kol.", "ruj.", "list.", "stud.", "pros."},
["sk"] = {"jan.", "feb.", "mar.", "apr.", "máj", "jún.", "júl.", "aug.", "sept.", "okt.", "nov.", "dec."},
["sl"] = {"jan.", "feb.", "mar.", "apr.", "maj", "jun.", "jul.", "avg.", "sept.", "okt.", "nov.", "dec."},
["sv"] = {"jan.", "febr.", "mars", "april", "maj", "juni", "juli", "aug.", "sept.", "okt.", "nov.", "dec."},
["zh"] = {"1月", "2月", "3月", "4月", "5月", "6月", "7月", "8月", "9月", "10月", "11月", "12月"},
["ast"] = {"xineru", "febreru", "marzu", "abril", "mayu", "xunu", "xunetu", "agostu", "setiembre", "ochobre", "payares", "avientu"},
}
local l10n = l10nDef[wiki]
if not l10n then l10n = l10nDef["en"] end -- default
return l10n[x]
end
 
local s = {
function headoftable(x) -- En-tête du tableau listant les étapes
header_function = Startlist_translate,
local l10nDef={
header_1 = 1, -- translation 1 in function victories_translate is printed in the upper part of the table header
["ar"] = {"المرحلة", "التاريخ", "الدورة", "المسافة (كم)", "الفائز بالمرحلة", "القائد العام"},
header_2 = {2, 3,4,5},-- translations 2, 3, 4, 5, 6 in function victories_translate are printed in this order
["fr"] = {"Étape", "Date", "Villes étapes", "Distance (km)", "Vainqueur d'étape", "Leader du classement général"},
item=IDtemp,
["en"] = {"Stage", "Date", "Course", "Distance - km (mi)", "Stage winner", "Overall leader"},
title="Start list", -- in the lower part of the table header. The second value 3 in {4, 3} tells where the icon will go.
["br"] = {"Tennad", "Deiziad", "Kêr loc'hañ ha kêr degouezhout", "Hed (km)", "Trec'hour", "E penn ar renkamant hollek"},
data_sort_type={'unsortable', 'unsortable', 'unsortable'},
["ca"] = {"Etapa", "Data", "Ciutats d'etapa", "Distància (km)", "Vencedor de l'etapa", "Líder de la general"},
property ='P710',
["cs"] = {"Etapa", "Datum", "Trasa", "Vzdálenost (km)", "Vítěz", "Průběžný lídr"},
no_country = {}
["da"] = {"Etape", "Dato", "Start – Mål", "Afstand (km)", "Etapevinder", "Førende rytter"},
["de"] = {"Etappe", "Datum", "Etappenorte", "Länge (km)", "Etappen&shy;sieger", "Gesamt&shy;führender"},
["eo"] = {"Etapo", "Dato", "Etapa urbo", "Longo (km)", "Venkinto de la etapo", "Estro de la gxeneralo klasado"},
["es"] = {"Etapa", "Fecha", "Recorrido", "Distancia (km)", "Ganador", "Líder"},
["eu"] = {"Etapa", "Data", "Ibilbidea", "Distantzia (km)", "Irabazlea", "Liderra"},
["fi"] = {"Etappi", "Päivä", "Reitti", "Pituus (km)", "Voittaja", "Kokonaiskilpailun johtaja"},
["fo"] = {"Teinur", "Dagur", "Byrjan – Mál", "Vegalongd (km)", "Teina&shy;vinnari", "Gula troyggjan"},
["hu"] = {"Szakasz", "Időpont", "Végpontok", "Hossz (km)", "Szakasz&shy;győztes", "Általános vezető"},
["it"] = {"Tappa", "Data", "Percorso", "Distanza (km)", "Vincitore di tappa", "Leader cl. generale"},
["ja"] = {"ステージ", "開催日", "コース", "距離 (km)", "ステージ勝者", "全体リーダー"},
["la"] = {"Statio", "Dies", "Iter", "Distantia (km)", "Victor", "Altiore princeps"},
["lb"] = {"Etapp", "Datum", "Etappestied", "Längt (km)", "Gewënner", "General&shy;klassement"},
["lv"] = {"Posms", "Datums", "Maršruts", "Posma garums (km)", "Uzvarētājs", "Kopvērtējuma līderis"},
["mk"] = {"Етапа", "Датум", "Тек", "Растојание (км)", "Победник", "Cевкупен лидер"},
["nl"] = {"Etappe", "Datum", "Start – Finish", "Afstand (km)", "Winnaar", "Klassements&shy;leider"},
["no"] = {"Etappe", "Dato", "Start – Målgang", "Distanse (km)", "Etappe&shy;vinner", "Sammenlagt&shy;leder"},
["pl"] = {"Etap", "Data", "Start – Meta", "Dystans (km)", "Zwycięzca etapu", "Lider"},
["pt"] = {"Etapa", "Data", "Percurso", "Distância (km)", "Vencedor", "Líder geral"},
["ro"] = {"Etapa", "Dată", "Start – Sosire", "Distanță (km)", "Câștigător", "Liderul global"},
["ru"] = {"Этап", "Дата", "Маршрут", "Длина (км)", "Победитель", "Лидер генеральной классификации"},
["sk"] = {"Etapa", "Dátum", "Trasa", "Vzdialenosť (km)", "Víťaz", "Priebežný líder"},
["sv"] = {"Etapp", "Datum", "Start – mål", "Distans (km)", "Skede vinnare", "Övergripande ledare"},
["ast"] = {"Etapa", "Data", "Percorríu", "Distancia (km)", "Ganador", "Líder"},
}
--return frame:extensionTag{ name = 'nowiki', content =
local l10n = l10nDef[wiki]
return tableB(s, startlist_main(s)) --}
if not l10n then l10n = l10nDef["en"] end -- default
return l10n[x]
end
 
function startlist_main(s)
function headoftableII(x) -- En-têtes des tableaux générant les classements
local tableBody, sortindex, fn_datetable, riderLinktable, h,ridertable, DStable = {}, {}, {}, {}, {},{},{}
local l10nDef = {
local tBody = '' --row in our case
["ar"] = {"العداء", "البلد", "الفريق", "الوقت", "إزاحة الوقت", "السرعة", "النقاط", "تصنيف الفرق ضد الساعة", "التصنيف العام", "تصنيف النقاط", "تصنيف الجبال", "تصنيف أفضل عداء", "تصنيف أفضل شاب", "تصنيف الفرق حسب الوقت", "ترتيب الفرق حسب النقاط", "تصنيف المجموعة", "تصنيف أفضل مقاتل", "التصنيف تحت 23"},
local temp, riderID, riderTeam, riderDossard, riderLink, riderLabel, riderRank, q, gender, riderTeamCode, riderDNF
["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"},
local DSID,DSLinktable,DSLink,DSteamID,DSteam, ThisDS
["en"] = {"Rider", "Country", "Team", "Time", "Time Gap", "Speed", "Points", "Stage classification", "General classification", "Points classification", "Mountains classification", "Sprints classification", "Best young classification", "Teams classification", "Points classification for teams", "Combination classification", "Combative classification", "U23 classification"},
local numberoflines, ii
["br"] = {"Reder", "Bro", "Skipailh", "Amzer", "Time Gap", "Speed", "Poentoù", "Renkadur an tennad", "Renkadur hollek", "Renkadur a-boentoù", "Renkadur ar menez", "Renkadur ar sprintoù", "Renkadur ar yaouank gwellañ", "Renkadur a-skipailh", "Renkadur a-skipailh", "Combination classification", "Combative classification", "U23 classification"},
["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"},
["da"] = {"Rytter", "Land", "Hold", "Tid", "Tidsforskel", "Gns. fart", "Point", "Etaperesultat", "Samlede stilling", "Pointkonkurrence", "Bjergkonkurrence", "Sprintkonkurrence", "Ungdomskonkurrence", "Holdkonkurrence", "Holdkonkurrence efter point", "Kombinationskonkurrence", "Mest angrebsivrige rytter", "U23-konkurrence"},
["de"] = {"Fahrer", "Land", "Team", "Zeit", "Zeitabstand", "Geschw.", "Punkte", "Etappenergebnis", "Gesamtwertung", "Punktewertung", "Bergwertung", "Sprintwertung", "Nachwuchswertung", "Mannschaftswertung", "Mannschaftswertung", "Combination classification", "Combative classification", "U23 classification"},
["eo"] = {"Kuranto", "Lando", "Teamo", "Tempo", "Time Gap", "Rapido", "Poentoj", "Etapa klasifiko", "Gxenerala klasifiko", "Klasifiko laux poentoj", "Klasifiko por la montaro", "Klasifiko por la sprintoj", "Klasifiko de la plej bona juno", "Klasifiko po teamo", "Klasifiko po teamo", "Combination classification", "Combative classification", "U23 classification"},
["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"},
["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"},
["fi"] = {"Pyöräilijä", "Maa", "Joukkue", "Aika", "Aikaero", "Nopeus", "Pisteet", "Etapin tulokset", "Kokonaistilanne", "Pistekilpailu", "Vuoristokilpailu", "Sprinttikilpailu", "Nuorten kilpailu", "Joukkuekilpailu", "Joukkuekilpailu", "Combination classification", "Combative classification", "U23 classification"},
["fo"] = {"Súkklari", "Land", "Lið", "Tíð", "Time Gap", "Ferð", "Stig", "Teinaplasering", "Samlað plasering", "Stigkappingin", "Fjallakappingin", "Spurtkappingin", "Ungdómskappingin", "Liðkappingin", "Liðkappingin", "Kombinatiónsheiðurkappingin", "Combative classification", "U23 classification"},
["hu"] = {"Versenyző", "Ország", "Équipe", "Idő", "Időkülönbség", "Átlagsebesség", "Pont", "Szakasz verseny", "Összetett verseny", "Pontverseny", "Hegyi pontverseny", "Gyorsulverseny", "Fiatalok versenye", "Csapatverseny", "Csapatverseny", "Combination classification", "Combative classification", "U23 classification"},
["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"},
["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"},
["mk"] = {"Возач", "Земја", "Екипа", "Време", "Разлика", "Брзина", "Бодови", "Етапен резултат", "Генерален пласман", "Бодовен пласман", "Планински пласман", "Спринтерски пласман", "Пласман за млад возач", "Екипен пласман", "Екипен пласман", "Combination classification", "Combative classification", "U23 classification"},
["no"] = {"Rytter", "Land", "Lag", "Tid", "Tidsforskjell", "Fart", "Poeng", "Etappeplassering", "Sammenlagtplassering", "Poengkonkurranse", "Klatrekonkurranse", "Spurtkonkurranse", "Ungdomskonkurranse", "Lagkonkurranse", "Lagkonkurranse (poeng)", "Kombinasjonkonkurranse", "Mest offensive rytter", "U23-konkurranse"},
["nl"] = {"Renner", "Land", "Ploeg", "Tijd", "Tijdsverschil", "Snelheid", "Punten", "Etappeklassement", "Algemeen Klassement", "Puntenklassement", "Bergklassement", "Sprintklassement", "Jongerenklassement", "Ploegenklassement", "Ploegenklassement", "Combinatieklassement", "Combative classification", "U23 classification"},
["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"},
["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"},
["ru"] = {"Гонщик", "Страна", "Команда", "Время", "Отставание", "Скорость", "Очки", "Результаты этапа", "Генеральная классификация", "Очковая классификация", "Горная классификация", "Спринтерская классификация", "Молодёжная классификация", "Командная классификация по времени", "Командная классификация по очкам", "Комбинированная классификация", "Бойцовская калссификация", "Классификация U23"},
["ast"] = {"Ciclista", "País", "Equipu", "Tiempu", "Intervalu de tiempu", "Velocidá media", "Puntos", "Clasificación de la etapa", "Clasificación xeneral", "Clasificación per puntos", "Clasificación de monte", "Clasificación de les metes volantes", "Clasificación del meyor mozu", "Clasificación per equipos", "Clasificación per equipos", "Clasificación de la combinada", "Clasificación de la combatividá", "Clasificación sub-23"},
}
local l10n = l10nDef[wiki]
if not l10n then l10n = l10nDef["en"] end -- default
return l10n[x]
end
 
fn_datetable=fn_date(s.item)
function headoftableIII(x) -- En-tête du tableau listant les équipes participantes (P1923)
timeOfRace=fn_datetable[1]
local l10nDef = {
["ar"] = {"اسم الفريق", "البلد", "الرمز", "فريق عالمي", "فرق عالمية", "فريق برو", "فرق برو", "فريق قاري محترف", "فرق قارية محترفة", "فريق قاري", "فرق قارية", "فريق وطني", "فرق وطنية", "فريق إقليمي ونادي", "فرق إقليمية وأندية", "فريق دراجات محترف", "فرق دراجات محترفة", "فريق هواة دراجات", "فرق هواة دراجات", "مجموعة رياضية أولى", "مجموعات رياضية أولى", "مجموعة رياضية ثانية", "مجموعات رياضية ثانية", "مجموعة رياضية ثالثة", "مجموعات رياضية ثالثة", "فريق مختلط", "فرق مختلطة", "فريق إناث محترف", "فرق إناث محترفة", "فريق هواة دراجات إناث", "فرق هواة دراجات إناث"},
["fr"] = {"Nom de l'équipe", "Pays", "Code", "WorldTeam", "WorldTeams", "ProTeam", "ProTeams", "Équipe continentale professionnelle", "Équipes continentales professionnelles", "Équipe continentale", "Équipes continentales", "Équipe nationale", "Équipes nationales", "Équipe régionale et de club", "Équipes régionales et de clubs", "Équipe cycliste professionnelle", "Équipes cyclistes professionnelles", "Équipe cycliste amateur", "Équipes cyclistes amateurs", "Groupe sportif I", "Groupes sportifs I", "Groupe sportif II", "Groupes sportifs II", "Groupe sportif III", "Groupes sportifs III", "Équipe mixte", "Équipes mixtes", "Équipe féminine professionnelle", "Équipes féminines professionnelles", "Équipe cycliste amateur féminine", "Équipe cycliste amateur féminines"},
["en"] = {"Team name", "Country", "Code", "WorldTeam", "WorldTeams", "ProTeam", "ProTeams", "Professional continental team", "Professional continental teams", "Continental team", "Continental teams", "National team", "National teams", "Regional and club team", "Regional and club teams", "Professional cycling team", "Professional cycling teams", "Amateur cycling team", "Amateur cycling teams", "Trade Team I", "Trade Teams I", "Trade Team II", "Trade Teams II", "Trade Team III", "Trade Teams III", "Mixed team", "Mixed teams", "Professional woman team", "Professional women teams", "Women's amateur cycling team", "Women's amateur cycling teams"},
["ja"] = {"チーム名", "国", "コード", "ワールドチーム", "ワールドチーム", "プロチーム", "プロチーム", "プロフェッショナルコンチネンタルチーム", "プロフェッショナルコンチネンタルチーム", "コンチネンタルチーム", "コンチネンタルチーム", "ナショナルチーム", "ナショナルチーム", "地域・クラブチーム", "地域・クラブチーム", "プロ自転車チーム", "プロ自転車チーム", "アマ自転車チーム", "アマ自転車チーム", "Groupe sportif I", "Groupes sportifs I", "Groupe sportif II", "Groupes sportifs II", "Groupe sportif III", "Groupes sportifs III", "Mixt team", "Mixt teams", "プロ女子チーム", "プロ女子チーム", "Women's amateur cycling team", "Women's amateur cycling teams"},
["br"] = {"Anv skipailh", "Bro", "Kod", "WorldTeam", "WorldTeams", "ProTeam", "ProTeams", "Skipailh kevandir a-vicher", "Skipailhoù kevandir a-vicher", "Skipailh kevandir", "Skipailhoù kevandir", "Skipailh bro", "Skipailhoù bro", "Skipailh rannvro ha klub", "Skipailhoù rannvro ha 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"},
["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"},
["da"] = {"Holdnavn", "Land", "Kode", "WorldTeam", "WorldTeams", "ProTeam", "ProTeams", "Professionelt kontinentalhold", "Professionelle kontinentalhold", "Kontinentalhold", "Kontinentalhold", "Landshold", "Landshold", "Regional- og klubhold", "Regional- og klubhold", "Prohold", "Prohold", "Amatørhold", "Amatørhold", "Sportsgruppe I", "Sportsgruppe I", "Sportsgruppe II", "Sportsgruppe II", "Sportsgruppe III", "Sportsgruppe III", "Mix-hold", "Mix-hold", "Kvindehold", "Kvindehold", "Amatørkvindehold", "Amatørkvindehold"},
["de"] = {"Team", "Land", "Code", "WorldTeam", "WorldTeams", "ProTeam", "ProTeams", "Professional Continental Team", "Professional Continental Teams", "Continental Team", "Continental Teams", "Nationalmannschaft", "Nationalmannschaften", "Regionale Teams und Vereine", "Regionale Teams und Vereine", "Profi-Radsportteam", "Profi-Radsportteams", "Amateurmannschaft", "Amateurmannschaften", "Groupe Sortif I", "Groupes Sportifs I", "Groupe Sportif II", "Groupes Sportifs II", "Groupe Sportif III", "Groupes Sportifs III", "Mixed Team", "Mixed Teams", "UCI Women's Team", "UCI Women's Teams", "Sonstiges Frauenteam", "Sonstige Frauenteams"},
["eo"] = {"Nomo de la teamo", "Lando", "Kodo", "Monda teamo", "Mondaj teamoj", "ProTeamo", "ProTeamoj", "Profesiista kontinenta teamo", "Profesiistaj kontinentaj teamoj", "Kontinenta teamo", "Kontinentaj teamoj", "Nacia teamo", "Naciaj teamoj", "Regiona aux kluba teamo", "Regionaj aux klubaj teamoj", "Profesiista bicikla teamo", "Profesiistaj biciklaj teamoj", "Amatora bicikla teamo", "Amatoraj biciklaj teamoj", "Sporta grupo 1", "Sportaj grupoj 1", "Sporta grupo 2", "Sportaj grupoj 2", "Sporta grupo 3", "Sportaj grupoj 3", "Miksa teamo", "Miksaj teamoj", "Ina teamo", "Inaj teamoj", "Women's amateur cycling team", "Women's amateur cycling teams"},
["es"] = {"Nombre del equipo", "País", "Código", "WorldTeam", "WorldTeams", "ProTeam", "ProTeams", "Equipo continental profesional", "Equipos continentales profesionales", "Equipo continental", "Equipos continentales", "Equipo nacional", "Equipos nacionales", "Equipo regional y de club", "Equipos regionales y de clubes", "Equipo ciclista profesional", "Equipos ciclistas profesionales", "Equipo ciclista aficionado", "Equipos ciclistas aficionados", "Grupo deportivo I", "Grupos deportivos I", "Grupo deportivo II", "Grupos deportivos II", "Grupo deportivo III", "Grupos deportivos III", "Equipo mixto", "Equipos mixtos", "Equipo femenino", "Equipos femeninos", "Equipo femenino de ciclismo amateur", "Equipos femeninos de ciclismo amateur"},
["eu"] = {"Taldearen izena", "Herrialdea", "Kodea", "Munduko taldea", "Munduko taldeak", "Pro taldea", "Pro taldeak", "Kontinenteko talde profesionala", "Kontinenteko talde profesionala", "Kontinenteko taldea", "Kontinenteko taldeak", "Estatuko taldea", "Estatuko taldeak", "Eskualdeko eta klubeko taldea", "Eskualdeko eta klubeko taldeak", "Txirrindulari talde profesionala", "Txirrindulari talde profesionalak", "Txirrindulari talde amateurra", "Txirrindulari talde amateurrak", "I. mailako kirol taldea", "I. mailako kirol taldeak", "II. mailako kirol taldea", "II. mailako kirol taldeak", "III. mailako kirol taldea", "III. mailako kirol taldeak", "Talde mistoa", "Talde mistoak", "Emakume taldea", "Emakume taldeak", "Women's amateur cycling team", "Women's amateur cycling teams"},
["fi"] = {"Joukkueen nimi", "Maa", "Koodi", "WorldTeam", "WorldTeams", "ProTeam", "ProTeams", "Professional continental -joukkue", "Professional continental -joukkueet", "Continental-joukkue", "Continental-joukkueet", "Maajoukkue", "Maajoukkueet", "Alue- ja seurajoukkue", "Alue- ja seurajoukkueet", "Ammattilaispyöräilytalli", "Ammattilaispyöräilytallit", "Amatööripyöräilytalli", "Amatööripyöräilytallit", "Groupe sportif I", "Groupes sportifs I", "Groupe sportif II", "Groupes sportifs II", "Groupe sportif III", "Groupes sportifs III", "Mixt team", "Mixt teams", "Naisten ammattilaisjoukkue", "Naisten ammattilaisjoukkueet", "Women's amateur cycling team", "Women's amateur cycling teams"},
["fo"] = {"Liðnavn", "Land", "Kota", "WorldTeam", "WorldTeams", "ProTeam", "ProTeams", "Professionelt kontinentallið", "Professionel kontinentallið", "Kontinentallið", "Kontinental lið", "Landslið", "Landslið", "Regional- og klublið", "Regional- og felagslið", "Prolið", "Prolið", "Amatørlið", "Amatørlið", "Ítróttarbólkur I", "Ítróttarbólkur I", "Ítróttarbólkur II", "Ítróttarbólkur II", "Ítróttarbólkur III", "Ítróttarbólkur III", "Blandaðlið", "Blandaðlið", "Kvinulið", "Kvinnulið", "Women's amateur cycling team", "Women's amateur cycling teams"},
["lb"] = {"Equippennumm", "Land", "Code", "WorldTeam", "WorldTeams", "ProTeam", "ProTeams", "Professionell Kontinentalequipe", "Professionell Kontinentalequippen", "Kontinentalequipe", "Kontinentalequippen", "Nationalequipe", "Nationalequippen", "Regional- a Klubequipe", "Regional- a Klubequippen", "Professionell Vëlosequipe", "Professionell Vëlosequippen", "Amateursequipe", "Amateursequippen", "Sportsgrupp I", "Sportsgruppen I", "Sportsgrupp II", "Sportsgruppen II", "Sportsgrupp III", "Sportsgruppen III", "Gemëscht Equipe", "Gemëscht Equippen", "Dammenequipe", "Dammenequippen", "Women's amateur cycling team", "Women's amateur cycling teams"},
["lv"] = {"Komandas nosaukums", "Valsts", "Kods", "WorldTeam", "WorldTeam komandas", "ProTeam", "ProTeam komandas", "Profesionālā kontinentālā komanda", "Profesionālās kontinentālās komandas", "Kontinentālā komanda", "Kontinentālās komandas", "Nacionālā izlase", "Nacionālās izlases", "Reģionālā vai klubu komanda", "Reģionālās vai klubu komandas", "Profesionāla riteņbraukšanas komanda", "Profesionālas riteņbraukšanas komandas", "Amatieru riteņbraukšanas komanda", "Amatieru riteņbraukšanas komandas", "1. sporta grupa", "1. sporta grupa", "2. sporta grupa", "3. sporta grupa", "3. sporta grupa", "3. sporta grupa", "Jauktā komanda", "Jauktās komandas", "Profesionāla sieviešu komanda", "Profesionālas sieviešu komandas", "Amatieru sieviešu komanda", "Amatieru sieviešu komandas"},
["mk"] = {"Име на екипата", "Земја", "Код", "Екипа од Светската турнеја UCI", "Екипи од Светската турнеја UCI", "ProTeam", "ProTeams", "Професионална континентална екипа", "Професионални континентални екипи", "Континентална екипа", "Континентални екипи", "Национална екипа", "Национални екипи", "Регионална екипа и клуб", "Регионални екипи и клубови", "Професионална велосипедска екипа", "Професионални велосипедски екипи", "Аматерска велосипедска екипа", "Аматерски велосипедски екипи", "Groupe sportif I", "Groupes sportifs I", "Groupe sportif II", "Groupes sportifs II", "Groupe sportif III", "Groupes sportifs III", "Мешана екипа", "Мешани екипи", "Професионална женска екипа", "Професионални женски екипи", "Women's amateur cycling team", "Women's amateur cycling teams"},
["nl"] = {"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"},
["no"] = {"Lagnavn", "Land", "Kode", "WorldTour-lag", "WorldTour-lag", "ProTour-lag", "ProTour-lag", "Profesjonelt kontinentallag", "Profesjonelle kontinentallag", "Kontinentallag", "Kontinentallag", "Landslag", "Landslag", "Regional- og klubblag", "Regional- og klubblag", "Profflag", "Profflag", "Amatørlag", "Amatørlag", "Trade Team I", "Trade Teams I", "Trade Team II", "Trade Teams II", "Trade Team III", "Trade Teams III", "Mix-lag", "Mix-lag", "Profflag", "Profflag", "Amatørlag", "Amatørlag"},
["pt"] = {"Nome da equipe", "País", "Código", "Equipe WorldTeam", "Equipes WorldTeam", "Equipe ProTeam", "Equipes ProTeam", "Equipe profissional Continental", "Equipes profissionais Continentais", "Equipe Continental", "Equipes Continentais", "Equipe nacional", "Equipes nacionais", "Equipe regional e clube", "Equipes regionais e clubes", "Equipe profissional de ciclismo", "Equipes profissionais de ciclismo", "Equipe amadora de ciclismo", "Equipes amadoras de ciclismo", "Grupo esportivo I", "Grupos esportivos I", "Grupo esportivo II", "Grupos esportivos II", "Grupo esportivo III", "Grupos esportivos III", "Equipe mista", "Equipes mistas", "Equipe feminina profissional", "Equipes femininas profissionais", "Women's amateur cycling team", "Women's amateur cycling teams"},
["ro"] = {"Numele echipei", "Țară", "Cod", "WorldTeam", "WorldTeams", "ProTeam", "ProTeams", "Echipă continentală profesionistă", "Echipe continentale profesioniste", "Echipă continentală", "Echipe continentale", "Echipă națională", "Echipe naționale", "Echipă regională și de club", "Echipe regionale și de club", "Echipă ciclistă profesionistă", "Echipe cicliste profesioniste", "Echipă ciclistă de amatori", "Echipe cicliste de amatori", "Grup sportiv I", "Grupuri sportive I", "Grup sportiv II", "Grupuri sportive II", "Grup sportiv III", "Grupuri sportive III", "Echipă mixtă", "Echipe mixte", "Echipă feminină", "Echipe feminine", "Women's amateur cycling team", "Women's amateur cycling teams"},
["ru"] = {"Команда", "Страна", "Код", "[[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|Женские профессиональные команды]]", "Женская любительская велокоманда", "Женские любительские велокоманды"},
["ast"] = {"Nome del equipu", "País", "Códigu", "WorldTeam", "WorldTeams", "ProTeam", "ProTeams", "Equipu continental profesional", "Equipos continentales profesionales", "Equipu continental", "Equipos continentales", "Equipu nacional", "Equipos nacionales", "Equipu rexonal y de club", "Equipos rexonales y de clubes", "Equipu ciclista profesional", "Equipos ciclistes profesionales", "Equipu ciclista aficionáu", "Equipos ciclistes aficionaos", "Grupu deportivu I", "Grupos deportivos I", "Grupu deportivu II", "Grupos deportivos II", "Grupu deportivu III", "Grupos deportivos III", "Equipu mestu", "Equipos mestos", "Equipu femenín", "Equipos femeninos", "Equipu femenín de ciclismu amateur", "Equipos femeninos de ciclismu amateur"},
}
local l10n = l10nDef[wiki]
if not l10n then l10n = l10nDef["en"] end -- default
return l10n[x]
end
 
for _,p286 in statements(s.item, 'P286') do--look for DS
function headoftableIV(x) -- En-tête du tableau du palmarès d'une course cycliste
DSID = p286.mainsnak.datavalue.value.id
local l10nDef = {
DSLink= getRiderLink(DSID, timeOfRace)
["ar"] = {"السنة", "الفائز", "الثاني", "الثالث"},
q= p286.qualifiers
["fr"] = {"Année", "Vainqueur", "Deuxième", "Troisième"},
if q.P642 and q.P642[1].snaktype == 'value' then
["en"] = {"Year", "Winner", "Second", "Third"},
DSteamID=q.P642[1].datavalue.value.id
["br"] = {"Bloavezh", "1añ", "2l", "3de"},
DSteam=getTeamLinkCat(DSteamID, timeOfRace)
["ca"] = {"Any", "Vencedor", "Segon", "Tercer"},
end
["cs"] = {"Ročník", "Vítěz", "Druhý", "Třetí"},
table.insert(DStable, {DSLink=DSLink, DSteam=DSteam})
["da"] = {"År", "Vinder", "Toer", "Treer"},
end
["de"] = {"Jahr", "Sieger", "Zweiter", "Dritter"},
["eo"] = {"Jaro", "Venkinto", "Dua pozicio", "Tria pozicio"},
["es"] = {"Año", "Ganador", "Segundo", "Tercero"},
["eu"] = {"Urtea", "Irabazlea", "Bigarrena", "Hirugarrena"},
["fi"] = {"Vuosi", "Voittaja", "Toinen", "Kolmas"},
["fo"] = {"Ár", "Vinnari", "Nr. 2", "Nr. 3"},
["hu"] = {"Év", "Versenyző", "Második", "Harmadik"},
["it"] = {"Anno", "Vincitore", "Secondo", "Terzo"},
["ja"] = {"年", "優勝", "準優勝", "3位"},
["lb"] = {"Joer", "Gewënner", "Zweeten", "Drëtten"},
["lv"] = {"Gads", "Uzvarētājs", "Otrais", "Trešais"},
["mk"] = {"Година", "Победник", "Второпласиран", "Третопласиран"},
["nl"] = {"Jaar", "Winnaar", "Tweede", "Derde"},
["no"] = {"År", "Vinner", "Andreplass", "Tredjeplass"},
["pl"] = {"Rok", "Pierwsze", "Drugie", "Trzecie"},
["pt"] = {"Ano", "Vencedor", "Segundo", "Terceiro"},
["ro"] = {"An", "Câștigător", "Locul doi", "Locul trei"},
["ru"] = {"Год", "Победитель", "Второй", "Третий"},
["sr"] = {"Година", "Побед