Модул:Cycling race: Разлика помеѓу преработките

[проверена преработка][проверена преработка]
Избришана содржина Додадена содржина
update
update
Ред 10:
"Journey origin", "Journey destination", "Teams", "Starting riders", "Arriving riders", "Average speed", "Cost", "Palmares", "Winner", "Second",
"Third", "Points", "Mountains", "Sprints", "Youth", "Combativity", "Combination", "Team"}
l10nDef["//ca.wikipedia.org"] = {"Detalls de la cursa", "Cursa", "COMPETITIONCompetició", "COMPETITIONSCompeticions", "Etapes", "Data", "DATESDates", "Distància", "País", "Països",
"Sortida", "Arribada", "TEAMSEquips", "Inscrits", "Finalitzen", "AVERAGEVelocitat SPEEDmitjana", "COSTCost", "Palmarès", "Vencedor", "Segon", "Tercer", "Punts", "Muntanya",
"SPRINTSEsprints", "Joves", "Combativitat", "Combinada", "Equip"}
l10nDef["//de.wikipedia.org"] = {"Einzelheiten", "Ausgabe", "Rennserie", " Wettbewerb", "Etappen", "Datum", "Datum", "Gesamtlänge", "Austragungsland", "Austragungsländer",
"Start", "Ziel", "Teams", "Fahrer am Start", "Fahrer im Ziel", "Geschwindigkeit im Durchschnitt", "Kosten", "Sieger", "Gesamtwertung", "Zweiter",
Ред 25:
"Држава", "Држави", "Поаѓалиште", "Одредиште", "Екипи", "Возачи на почеток", "Возачи на крај", "Просечна брзина", "Трошоци", "Добитници на наградите",
"Победник", "Второпласиран", "Третопласиран", "Бодовен", "Планински", "Спринтерски", "Младински", "Борбеност", "Комбиниран", "Екипен"}
l10nDef["//nonl.wikipedia.org"] = {"Detaljerwedstrijddetails", "COURSEkoers", "COMPETITIONwedstrijd", "COMPETITIONSwedstrijden", "Etapperetappes", "Datodatum", "DATESdatums", "Distanseafstand", "COUNTRYland", "COUNTRIESlanden", "startplaats",
"Startbyfinishplaats", "Målbyteams", "TEAMS",aantal "STARTINGcoureurs RIDERS",aan "ARRIVINGde RIDERSstart", "AVERAGEaantal SPEEDcoureurs bij de aankomst", "COSTgemiddelde snelheid", "Resultaterkosten", "Vinnerpalmares", "2. plasswinnaar", "3. plasstweede",
"derde", "punten", "bergen", "sprints", "jeugd", "aanvalslust", "combinatie", "team"}
l10nDef["//no.wikipedia.org"] = {"Detaljer", "Ritt", "Turnering", "Turneringer", "Etapper", "Dato", "Datoer", "Distanse", "Land", "Land",
"Startby", "Målby", "Lag", "Startende ryttere", "Fullførende ryttere", "Gjennomsnittsfart", "Kostnad", "Resultater", "Vinner", "2. plass", "3. plass",
"Poeng", "Klatre", "Sprint", "Ungdom", "Mest offensive", "Kombinasjon", "Lagkonkurranse"}
l10nDef["//ro.wikipedia.org"] = {"Detalii cursă", "Cursă", "Competiție", "Competiții", "Etape", "Dată", "Date", "Distanță", "Țară", "Țări", "Start", "Sosire",
"Echipe", "Cicliști la start", "Cicliști la sosire", "Viteză medie", "Cost", "Palmares", "CăștigătorCâș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ă"}
l10nDef["//ru.wikipedia.org"] = {"Детали гонки", "Маршрут", "Соревнование", "Соревнования", "Этапы", "Дата", "Даты", "Дистанция", "Страна", "Страны",
Ред 36 ⟶ 39:
l10nDef["//www.wikidata.org"] = l10nDef["//en.wikipedia.org"]
local l10n = l10nDef[mw.site.server]
if not l10n then l10n = l10nDef["//en.wikipedia.org"] end -- default
return l10n[x]
l10n = l10nDef["//en.wikipedia.org"] -- default
end
return l10n[x]
end
 
Ред 55 ⟶ 56:
l10nDef["//www.wikidata.org"] = l10nDef["//fr.wikipedia.org"]
local l10n = l10nDef[mw.site.server]
if not l10n then l10n = l10nDef["//en.wikipedia.org"] end -- default
return l10n[x]
l10n = l10nDef["//en.wikipedia.org"] -- default
end
return l10n[x]
end
 
function property(x) -- This function allows you to overwrite wikidata information
local l10nDef = { }
l10nDef["//fr.wikipedia.org"] = {"image", "légende", "numéro d'édition", "partiecarte de localisation", "étapescourse cyclist", "paysclasse", "étapes", "date de début", "date de fin", "date",
"longueur", "point de départ", "destination du parcours", "équipes", "nombre de participants au départ", "nombre de participants à l'arrivée", "vitesse", "coût",
"vainqueur du classement général", "deuxième du classement général", "troisième du classement général", "vainqueur du classement par points",
"vainqueur du classement de la montagne", "vainqueur du classement des sprints", "vainqueur du classement du meilleur jeune", "vainqueur du classement de la combativité",
"vainqueur du classement du combiné", "vainqueur du classement de la meilleure équipe", "carte de localisation"}
l10nDef["//en.wikipedia.org"] = {"picture", "caption", "edition number", "partlocator ofmap image", "stagescycling race", "countryclass", "stages", "start time", "end time", "time",
"length", "journey origin", "journey destination", "teams", "number of participants at start", "number of participants at end", "speed", "cost",
"overall winner", "second overall winner", "third overall winner", "winner of the point classification", "winner of the mountain classification",
"winner of the sprint classification", "winner of the young rider classification", "winner of the fighting spirit classification",
"winner of the combination classification", "winner of the team classification", "locator map image"}
l10nDef["//www.wikidata.org"] = l10nDef["//fr.wikipedia.org"]
local l10n = l10nDef[mw.site.server]
if not l10n then l10n = l10nDef["//en.wikipedia.org"] end -- default
return l10n[x]
l10n = l10nDef["//en.wikipedia.org"] -- default
end
return l10n[x]
end
 
function p.infobox(frame)
local t = {is_a="", tourclass={}"", classstage="", stagestarttime="", countryendtime={}"", starttimetime="", endtimelength="", timelength_unit="",
lengthstartplace="", length_unitendplace="", startplacenr_teams="", endplacenr_participants_start="", nr_teamsnr_participants_end="", nr_participants_startspeed="", nr_participants_endspeed_unit="", speedcost="", speed_unitcost_unit="",
cost="", cost_unit="", first="", second="", third="", winner_point="", winner_mountain="", winner_sprint="", winner_young="", winner_fighting="",
winner_combination="", winner_team="", previous="", next=""}
local tt = {icon="", picture="", caption="", name="", nr="", map="" }
local ttt = {tour={}, country={}}
local entity = ""
local y, m, d = "", "", ""
local y2, m2, d2 = "", "", ""
local snak, snak2, snak3, snak4
local a, b, c, k, num, i
local entityId = frame.args[1]
local lang = mw.language.getContentLanguage()
local serverwiki = mw.site.server
local results = false
local a1, b1, c1, a2, b2, c2
 
if type( entityId ) ~= 'string' then error( 'parameter must be a string') end
Ред 101 ⟶ 100:
local entity = mw.wikibase.getEntity( entityId )
 
if frame.args[ property(1) ] then tt.picture = frame.args[ property(1) ] end
if frame.args[ property(2) ] then tt.caption = frame.args[ property(2) ] end
if frame.args[ property(3) ] then tt.nr = frame.args[ property(3) ] end
--if frame.args[ property(4) ] then ttt.tourmap = frame.args[ property(4) ] end
i = 5
if frame.args[ property(5) ] then t.stage = frame.args[ property(5) ] end
for k in pairs(t) do --t[k], k = startplace, endplace, ...
--if frame.args[ property(6) ] then t.country = frame.args[ property(6) ] end
if frame.args[ property(7i) ] then t.starttime[k] = frame.args[ property(7i) ] end
i = i + 1
if frame.args[ property(8) ] then t.endtime = frame.args[ property(8) ] end
end
if frame.args[ property(9) ] then t.time = frame.args[ property(9) ] end
if frame.args[ property(10)] then t.length = frame.args[ property(10) ] end
if frame.args[ property(11)] then t.startplace = frame.args[ property(11) ] end
if frame.args[ property(12)] then t.endplace = frame.args[ property(12) ] end
if frame.args[ property(13)] then t.nr_teams = frame.args[ property(13) ] end
if frame.args[ property(14)] then t.nr_participants_start = frame.args[ property(14) ] end
if frame.args[ property(15)] then t.nr_participants_end = frame.args[ property(15) ] end
if frame.args[ property(16)] then t.speed = frame.args[ property(16) ] end
if frame.args[ property(17)] then t.cost = frame.args[ property(17) ] end
if frame.args[ property(18)] then t.first = frame.args[ property(18) ] end
if frame.args[ property(19)] then t.second = frame.args[ property(19) ] end
if frame.args[ property(20)] then t.third = frame.args[ property(20) ] end
if frame.args[ property(21)] then t.winner_point = frame.args[ property(21) ] end
if frame.args[ property(22)] then t.winner_mountain = frame.args[ property(22) ] end
if frame.args[ property(23)] then t.winner_sprint = frame.args[ property(23) ] end
if frame.args[ property(24)] then t.winner_young = frame.args[ property(24) ] end
if frame.args[ property(25)] then t.winner_fighting = frame.args[ property(25) ] end
if frame.args[ property(26)] then t.winner_combination = frame.args[ property(26) ] end
if frame.args[ property(27)] then t.winner_team = frame.args[ property(27) ] end
if frame.args[ property(28)] then tt.map = frame.args[ property(28) ] end
if entity:getLabel() ~= nil then tt.name = entity:getLabel()
Ред 162 ⟶ 142:
end
end
-- For FR Wiki and Wikidata, exception that permit to display 1er, 2e... for the edition number ;
 
-- for RU Wiki, -й is written after the value of P393
a, b = pcall(fooA, 'value', entity, 'P393', 1) -- For FR Wiki and Wikidata, exception that permit to display 1er, 2e... for the edition number
a, b = pcall(fooA, 'value', entity, 'P393', 1)
if a == true and tt.nr == "" then
tt.nr = b .. ". "
if server == "//www.wikidata.org" or server == "//fr.wikipedia.org" then
if wiki == "//fr.wikipedia.org" then
if b == 1 then tt.nr = "1<sup>re</sup> " else tt.nr = b .."<sup>e</sup> " end end
elseif wiki == "//ru.wikipedia.org" or wiki == "//www.wikidata.org" then tt.nr = b .."-й "." end
end
-- Class of a cycling race. Class is: 1.UWT, 2.UWT, 1.HC, ... add new classes, no problem
Ред 182 ⟶ 164:
 
a, b = pcall(fooA, 'numeric-id', entity, 'P361', 1) -- Competition of the cycling race : UCI World Tour 2016, UCI Europe Tour 2016...
if a == true and t.tour == "" then t--ttt.tour = "Q" .. b end
for i, v in pairs(entity.claims["P361"]) do
local num = 1
ttt.tour[i] = "T" .. v.mainsnak.datavalue.value["numeric-id"]
for _, v in pairs(entity.claims["P361"]) do
end
if v.mainsnak then
end
t.tour[num] = "Q" .. v.mainsnak.datavalue.value["numeric-id"]
num = num + 1
end
end
 
if pcall(function() -- This function count the number of value for P527 to determine the number of stages
Ред 196 ⟶ 175:
) then else t.stage = "" end
 
aa1, bb1, c1 = pcall(fooA, 'time', entity, 'P580', 1) -- d = day, m = month, y = year
if a1 == true and t.starttime == "" then i = 1
--b = "+2015-07-04T00:00:00Z"
while a1 == true and c1 == 'deprecated' do
_, _, y, m, d = string.find(b, "(%d+)-(%d+)-(%d+)")
i = i + 1
c, d = pcall(fooA, 'time', entity, 'P582', 1)
a1, b1, c1 = pcall(fooA, 'time', entity, 'P580', i)
--d = "+2015-07-05T00:00:00Z"
end
_, _, y2, m2, d2 = string.find(d, "(%d+)-(%d+)-(%d+)")
--b = "+2015-07-04T00:00:00Z"
if a == true and t.starttime == "" then -- = d..". "..func_month(m).." "..y
_, _, y, m, d = string.find(b1, "(%d+)-(%d+)-(%d+)")
if y ~= y2 then t.starttime = lang:formatDate( "j. F Y", b )
end
elseif m ~= m2 then t.starttime = lang:formatDate( "j. F", b )
a2, b2, c2 = pcall(fooA, 'time', entity, 'P582', 1)
else t.starttime = lang:formatDate( "j.", b )
if a2 == true and t.endtime == "" then i = 1
while a2 == true and c2 == 'deprecated' do
i = i + 1
a2, b2, c2 = pcall(fooA, 'time', entity, 'P582', i)
end
--d = "+2015-07-05T00:00:00Z"
_, _, y2, m2, d2 = string.find(b2, "(%d+)-(%d+)-(%d+)")
end
if a1 == true and t.starttime == "" 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
if wiki == "//de.wikipedia.org" or wiki == "//no.wikipedia.org" then
if server == "//fr.wikipedia.org" or server == "//mk.wikipedia.org" or server == "//br.wikipedia.org" or server == "//ca.wikipedia.org" or server == "//es.wikipedia.org" or server == "//it.wikipedia.org" or server == "//mk.wikipedia.org" or server == "//pt.wikipedia.org" or server == "//pl.wikipedia.org" or server == "//ro.wikipedia.org" then
if y ~= y2 then t.starttime = lang:formatDate( "j. F Y", bb1 )
elseif m ~= m2 then t.starttime = lang:formatDate( "j. F", bb1 )
else t.starttime = lang:formatDate( "j.", bb1 )
end end
if serverwiki == "//ja.wikipedia.org" then
if y ~= y2 then t.starttime = lang:formatDate( "Y年m月d日", bb1 )
elseif m ~= m2 then t.starttime = lang:formatDate( "Y年m月d日", bb1 )
else t.starttime = lang:formatDate( "Y年m月d日", bb1 )
end end
if serverwiki == "//en.wikipedia.org" then
if y ~= y2 then t.starttime = lang:formatDate( "F d, Y", bb1 )
elseif m ~= m2 then t.starttime = lang:formatDate( "F d", bb1 )
else t.starttime = lang:formatDate( "F d", bb1 )
end end
if serverwiki == "//lv.wikipedia.org" then
if y ~= y2 then t.starttime = lang:formatDate( "Y. j. F", bb1 )
elseif m ~= m2 then t.starttime = lang:formatDate( "Y. j. F", bb1 )
else t.starttime = lang:formatDate( "Y. j.", bb1 )
end end
end -- if a1
if ca2 == true and t.endtime == "" then
t.endtime = lang:formatDate( "j. F Y", db2 )
if wiki == "//de.wikipedia.org" or wiki == "//no.wikipedia.org" then
if server == "//fr.wikipedia.org" or server == "//mk.wikipedia.org" or server == "//br.wikipedia.org" or server == "//ca.wikipedia.org" or server == "//es.wikipedia.org" or server == "//it.wikipedia.org" or server == "//mk.wikipedia.org" or server == "//pt.wikipedia.org" or server == "//pl.wikipedia.org" or server == "//ro.wikipedia.org" then
t.endtime = lang:formatDate( "j. F Y", db2 ) end
if serverwiki == "//ja.wikipedia.org" then
if y ~= y2 then t.endtime = lang:formatDate( "Y年m月d日", db2 )
elseif m ~= m2 then t.endtime = lang:formatDate( "m月d日", db2 )
else t.endtime = lang:formatDate( "d日", db2 )
end end
if serverwiki == "//en.wikipedia.org" then
if y ~= y2 then t.endtime = lang:formatDate( "F d, Y", db2 )
elseif m ~= m2 then t.endtime = lang:formatDate( "F d, Y", db2 )
else t.endtime = lang:formatDate( "d, Y", db2 )
end end
if serverwiki == "//lv.wikipedia.org" then
if y ~= y2 then t.endtime = lang:formatDate( "Y. j. F", db2 )
elseif m ~= m2 then t.endtime = lang:formatDate( "j. F", db2 )
else t.endtime = lang:formatDate( "j. F", db2 )
end end
end -- if a2
 
a, b = pcall(fooA, 'time', entity, 'P585', 1) -- This function give a format to dates when P585 (date) is used in a single day race
ifa1, ab1, c1 == truepcall(fooA, and t.'time ', ==entity, ""'P585', then1)
if a1 == true and t.time = lang:formatDate(= "j." Fthen Y",i b= )1
while a1 == true and c1 == 'deprecated' do
if server == "//fr.wikipedia.org" or server == "//mk.wikipedia.org" or server == "//br.wikipedia.org" or server == "//ca.wikipedia.org" or server == "//es.wikipedia.org" or server == "//it.wikipedia.org" or server == "//mk.wikipedia.org" or server == "//pt.wikipedia.org" or server == "//pl.wikipedia.org" or server == "//ro.wikipedia.org" then
i = i + 1
t.time = lang:formatDate( "j F Y", b ) end
a1, b1, c1 = pcall(fooA, 'time', entity, 'P585', i)
if server == "//ja.wikipedia.org" then
end
t.time = lang:formatDate( "Y年m月d日", b ) end
t.time = lang:formatDate( "j F Y", b1 )
if server == "//en.wikipedia.org" then
if wiki == "//de.wikipedia.org" or wiki == "//no.wikipedia.org" then
t.time = lang:formatDate( "F d, Y", b ) end
t.time = lang:formatDate( "j. F Y", b1 ) end
if server == "//lv.wikipedia.org" then
if wiki == "//ja.wikipedia.org" then
t.time = lang:formatDate( "Y. j. F", b ) end
t.time = lang:formatDate( "Y年m月d日", b1 ) end
if wiki == "//en.wikipedia.org" then
t.time = lang:formatDate( "F d, Y", b1 ) end
if wiki == "//lv.wikipedia.org" then
t.time = lang:formatDate( "Y. j. F", b1 ) end
end
 
a, b = pcall(fooA, 'amount', entity, 'P2043', 1) -- This function permits to display an unity (the kilometer) for a distance, with exceptions for macedionan, russian and japanese
-- that have other symbols
a1, b1, c1 = pcall(fooA, 'amount', entity, 'P2043', 1)
if a == true and t.length == "" then
if a1 == true and t.length == "" then i = b1
a,while ba1 == pcall(fooA,true 'unit',and entity,c1 == 'P2043deprecated', 1)do
i = i + 1
if b == "http://www.wikidata.org/entity/Q828224" then
a1, b1, c1 = pcall(fooA, 'amount', entity, 'P2043', i)
end
t.length = b1
a1, b1, _ = pcall(fooA, 'unit', entity, 'P2043', 1)
if b1 == "http://www.wikidata.org/entity/Q828224" then
t.length_unit = 'km'
if serverwiki == "//mk.wikipedia.org" then t.length_unit = 'км' end
if serverwiki == "//ru.wikipedia.org" then t.length_unit = 'км' end
if serverwiki == "//ja.wikipedia.org" then t.length_unit = 'キロメートル' end
end
end
 
a, b = pcall(fooA, 'numeric-id', entity, 'P17', 1) -- This function gives countries where the race take place
if a == true then --and tttt.country == "" then tttt.country = "Q" .. b end
for i, v in pairs(entity.claims["P17"]) do
local num = 1
ttt.country[i] = "C" .. v.mainsnak.datavalue.value["numeric-id"]
for _, v in pairs(entity.claims["P17"]) do
end
if v.mainsnak then
t.country[num] = "Q" .. v.mainsnak.datavalue.value["numeric-id"]
num = num + 1
end
end
-- Function that give the starting place of a race
 
aa1, bb1, c1 = pcall(fooA, 'numeric-id', entity, 'P1427', 1) -- Function that give the starting place of a race
if aa1 == true and t.startplace == "" then t.startplacei = "Q" .. b end1
while a1 == true and c1 == 'deprecated' do
a, b = pcall(fooA, 'numeric-id', entity, 'P1444', 1) -- Function that give the finishing place of a race
i = i + 1
if a == true and t.endplace == "" then t.endplace = "Q" .. b end
a1, b1, c1 = pcall(fooA, 'numeric-id', entity, 'P1427', i)
 
end
if pcall(function() -- This function counts the number of value for P1923 (participating teams) and give the number of team that participate at the race
t.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.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
 
a, b = pcall(fooA, 'amount', entity, 'P1132', 1) -- 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 a == true and t.nr_participants_start == "" and t.nr_participants_end == "" then
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
for _, v in pairs(entity.claims["P1132"]) do
if v.qualifiers["P276"][1].datavalue.value["numeric-id"] == 15053706 then
Ред 309 ⟶ 326:
) then else t.nr_participants_end = "" end
end
end -- for
end -- if a1
 
a, b = pcall(fooA, 'amount', entity, 'P2052', 1) -- 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 a == true and t.speed == "" then
if a1 == true and t.speed == "" then i = b1
a,while ba1 == pcall(fooA,true 'unit',and entity,c1 == 'P2052deprecated', 1)do
i = i + 1
if b == "http://www.wikidata.org/entity/Q180154" then
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 serverwiki == "//mk.wikipedia.org" then t.speed_unit = 'км/ч' end
if serverwiki == "//ru.wikipedia.org" then t.speed_unit = 'км/ч' end
if serverwiki == "//ja.wikipedia.org" 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) -- This function permits to display an unity for the cost of a cycling race
if a == true and t.cost == "" then
t.cost = b
Ред 339 ⟶ 362:
if a == true and t.next == "" then t.next = "Q"..b end
 
local note, qual, id -- By entering a value just below, the Wikipedia added will not have Wikidata logos associated with cyclists in the infobox
local note, qual, id
if server == "//fr.wikipedia.org" or server == "//en.wikipedia.org" or server == "//br.wikipedia.org" or server == "//ca.wikipedia.org" or server == "//de.wikipedia.org" or server == "//es.wikipedia.org" or server == "//lb.wikipedia.org" or server == "//no.wikipedia.org" or server == "//pt.wikipedia.org" or server == "//ro.wikipedia.org" then
if wiki == "//fr.wikipedia.org" or wiki == "//en.wikipedia.org" or wiki == "//br.wikipedia.org" or wiki == "//ca.wikipedia.org" or
wiki == "//de.wikipedia.org" or wiki == "//es.wikipedia.org" or wiki == "//lb.wikipedia.org" or wiki == "//no.wikipedia.org" or
wiki == "//pt.wikipedia.org" or wiki == "//ro.wikipedia.org" then
note = 'f' else note = 'q' end
if pcall(foo3, entity, "P1346", num1, "P642", 1) then
for _, v in pairs(entity.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 qualv.rank =~= 20882667'deprecated' then t.first = note .. id results = true end
if id~qual == nil20882667 and qualt.first == 20882668"" then t.secondfirst = note .. id results = true end
if id~qual == nil20882668 and qualt.second == 20882669"" then t.thirdsecond = note .. id results = true end
if id~qual == nil20882669 and qualt.third == 20883007"" then t.winner_pointthird = note .. id results = true end
if id~qual == nil20883007 and qualt.winner_point == 20883212"" then t.winner_mountainwinner_point = note .. id results = true end
if id~qual == nil20883212 and qualt.winner_mountain == 20883328"" then t.winner_sprintwinner_mountain = note .. id results = true end
if id~qual == nil20883328 and qualt.winner_sprint == 20883139"" then t.winner_youngwinner_sprint = note .. id results = true end
if id~qual == nil20883139 and qualt.winner_young == 20893983"" then t.winner_fightingwinner_young = note .. id results = true end
if id~qual == nil20893983 and qualt.winner_fighting == 20893979"" then t.winner_combinationwinner_fighting = note .. id results = true end
if id~qual == nil20893979 and qualt.winner_combination == 20882921"" then t.winner_teamwinner_combination = note .. id results = true end
if qual == 20882921 and t.winner_team == "" then t.winner_team = note .. id results = true end
end
end -- if id
end -- for
end -- end if pcall
 
-- transform Q/q-number into flag / WPlink / WDlink
-- not done
local k
local team = true
Ред 369 ⟶ 396:
if d1 == true then datum = datum_stagerace end
if d2 == true then datum = datum_singleday end
 
for k in pairs(ttt) do -- "^C" ttt.country, "^T" ttt.tour
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], datum).." ".. WPlink( ttt[k][i] ) end end
if ttt[k][i]~=nil and string.find(ttt[k][1], "^T") then for i=1,#ttt[k] do ttt[k][i] = WPlink( string.gsub(ttt[k][i], "T", "Q") ) end 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 type(t[k]) == 'table' then
forif i=1pcall(foo1,# t[k]) dothen t[k][i] = WPlink( t[k][i] ) end
end
if type(t[k]) == 'string' and string.find(t[k], "^Q") then -- find variables with an item as value
--t[k] = t[k] -- k = startplace, endplace, ...
if pcall(foo1, t[k]) then
t[k] = WPlink( t[k] )
end
end
if type(t[k]) == 'string' and 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
Ред 391 ⟶ 416:
end
end
if type(t[k]) == 'string' and 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
Ред 402 ⟶ 427:
end
end
if type(t[k]) == 'string' and 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
t[k] = WPlink( t[k], "Q22348500" )
end
end
end
Ред 441 ⟶ 464:
end
local span1, span2 = "<span style='color:#3366CC'>&#x25C0; </span>", "<span style='color:#3366CC'> &#x25B6;</span>"
local span2 = "<span style='color:#3366CC'> &#x25B6;</span>"
local k = t.previous
local i, _ = string.find(k, "|")
Ред 448 ⟶ 470:
if i ~= nil and j ~= nil then
t.previous = string.sub(k, 1, i) .. span1 .. string.gsub(string.sub(k, i+1, j-1), "%D", "") .. string.sub(k, j)
else t.previous = span1 .. string.gsub(k, "%D", "") if t.previous ~= "" then t.previous = span1 .. t.previous end end
k = t.next
Ред 455 ⟶ 477:
if i ~= nil and j ~= nil then
t.next = string.sub(k, 1, i) .. string.gsub(string.sub(k, i+1, j-1), "%D", "") .. span2 .. string.sub(k,j)
else t.next = string.gsub(k, "%D", "") if t.next ~="" then t.next = t.next .. span2 end end
tt.caption = string.gsub(tt.caption, "{{(%w+)}}", function (n) return frame:expandTemplate{ title = n } end)
Ред 469 ⟶ 491:
tab = tab .. "<tr><td colspan='2' style='background-color:#FFDF80; text-align:center'>'''"..infobox_left(1).."'''</td></tr>"
if tt.nr ~= "" and t.is_a ~= "" then tab = tab.."<tr><td style='width:40%'>'''"..infobox_left(2).."'''</td><td>" .. tt.nr .. " " .. t.is_a .. "</td></tr>" end
if tttt.tour[1] ~= ""nil then tab = tab.."<tr><td style= 'vertical-align:top'>'''"
if #tttt.tour == 1 then tab = tab..infobox_left(3).."'''</td><td>" else tab = tab..infobox_left(4).."'''</td><td>" end
for i=1,#tttt.tour do tab = tab .. tttt.tour[i] if i == 1 then tab = tab .. " " ..t.class end tab = tab .. "\n<br>" end
tab = tab.."</td></tr>" end
if t.stage ~= "" then tab = tab.."<tr><td>'''"..infobox_left(5).."'''</td><td>" .. t.stage.."</td></tr>" end
if t.starttime ~= "" or t.endtime ~= "" then tab = tab.."<tr><td>'''"..infobox_left(7).."'''</td><td>" .. t.starttime.." – " ..t.endtime .."</td></tr>" end
Ред 478 ⟶ 500:
if t.time ~= "" then tab = tab.."<tr><td>'''"..infobox_left(6).."'''</td><td>" .. t.time.."</td></tr>" end
if t.length ~= "" then tab = tab.."<tr><td>'''"..infobox_left(8).."'''</td><td>" .. t.length.." "..t.length_unit.."</td></tr>" end
if tttt.country[1] ~= ""nil then tab = tab.."<tr><td style= 'vertical-align:top'>'''"
if #tttt.country == 1 then tab = tab..infobox_left(9).."'''</td><td>" else tab = tab..infobox_left(10).."'''</td><td>" end
for i=1,#tttt.country-1 do tab = tab .. tttt.country[i].."," if i==3 or i==6 then tab = tab .. "<br>" end tab = tab .. ttt.country[#ttt.country].." </td></tr>" end
tab = tab..t.country[#t.country].."</td></tr>" end
if t.startplace ~= "" then tab = tab.."<tr><td>'''"..infobox_left(11).."'''</td><td>" .. t.startplace .. "</td></tr>" end
if t.endplace ~= "" then tab = tab.."<tr><td>'''"..infobox_left(12).."'''</td><td>" .. t.endplace .. "</td></tr>" end
Ред 571 ⟶ 592:
end
 
function fooA (mode, entity, property, var)
local snak
if mode == "timevalue" then snak = entity.claims[property][var].mainsnak.datavalue.value.time end
if mode == "numeric-id" thenelse snak = entity.claims[property][var].mainsnak.datavalue.value['numeric-id'mode] end
end
if mode == "amount" then snak = entity.claims[property][var].mainsnak.datavalue.value.amount end
if mode == "value" thenreturn snak =, entity.claims[property][var].mainsnak.datavalue.value endrank
if mode == "unit" then snak = entity.claims[property][var].mainsnak.datavalue.value.unit end
if mode == "text" then snak = entity.claims[property][var].mainsnak.datavalue.value.text end
return snak
end
 
Ред 1.137 ⟶ 1.155:
 
local l10n = l10nDef[mw.site.server]
if not l10n then l10n = l10nDef["//fr.wikipedia.org"] end -- default
return l10n[tonumber(x)]
l10n = l10nDef["//fr.wikipedia.org"] -- default
end
return l10n[tonumber(x)]
end
 
function headoftable(x) -- En-tête du tableau listant les étapes
Ред 1.173 ⟶ 1.189:
 
local l10n = l10nDef[mw.site.server]
if not l10n then l10n = l10nDef["//fr.wikipedia.org"] end -- default
return l10n[x]
l10n = l10nDef["//fr.wikipedia.org"] -- default
end
return l10n[x]
end
 
function headoftableII(x) -- En-têtetêtes dudes tableautableaux dugénérant classementles généralclassements
local l10nDef = { }
l10nDef["//fr.wikipedia.org"] = {"Coureur", "Pays", "Équipe", "Temps", "Points", "Classement de l'étape", "Classement général", "CoureurClassement par points", "PaysClassement de la montagne", "ÉquipeClassement des sprints", "TempsClassement du meilleur jeune", "Classement par équipes"}
l10nDef["//ca.wikipedia.org"] = {"Corredor", "País", "Equip", "Temps", "Punts", "Classificació de l'etapa", "Classificació general", "Classificació per punts", "Classificació de la muntanya", "Classificació dels esprints", "Classificació del millor jove", "Classificació per equips"}
l10nDef["//www.wikidata.org"] = {"Classement général", "Coureur", "Pays", "Équipe", "Temps"}
l10nDef["//lb.wikipedia.org"] = {"Coureur", "Land", "Equipe", "Zäit", "Punkten", "Etappeklassement", "Generalklassement", "Klassement no Punkten", "Biergpräis", "Sprintklassement", "Beschte Jonken", "Equippeklassement"}
l10nDef["//ro.wikipedia.org"] = {"Ciclist", "Țară", "Echipă", "Timp", "Puncte", "Clasamentul etapei", "Clasament general", "Clasament pe puncte", "Clasament cățărători", "Clasament sprinteri", "Clasamentul celui mai bun tânăr", "Clasament pe echipe"}
l10nDef["//www.wikidata.org"] = l10nDef["//fr.wikipedia.org"]
local l10n = l10nDef[mw.site.server]
if not l10n then l10n = l10nDef["//fr.wikipedia.org"] end -- default
return l10n[x]
l10n = l10nDef["//fr.wikipedia.org"] -- default
end
return l10n[x]
end
 
function headoftableIII(x) -- En-tête du tableau dulistant classementles d'uneéquipes étapeparticipantes (P1923)
local l10nDef = { }
l10nDef["//fr.wikipedia.org"] = {"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", "Équipes féminines"}
l10nDef["//fr.wikipedia.org"] = {"Classement de l'étape", "Coureur", "Pays", "Équipe", "Temps"}
l10nDef["//ca.wikipedia.org"] = {"Nom de l'equip", "País", "Codi", "WorldTeam", "WorldTeams", "ProTeam", "ProTeams", "Equip continental professional", "Equips continentals professionals", "Equip continental", "Equips continentals", "Equip nacional", "Equips nacionals", "Equip regional i de club", "Equips regionals i de clubs", "Equip ciclista professional", "Equips ciclistes professionals", "Equip ciclista amateur", "Equips ciclistes amateurs", "Grup esportiu I", "Grups esportius I", "Grup esportiu II", "Grups esportius II", "Grup esportiu III", "Grups esportius III", "Equip mixt", "Equips mixtos", "Equip femení", "Equips femenins"}
l10nDef["//www.wikidata.org"] = {"Classement de l'étape", "Coureur", "Pays", "Équipe", "Temps"}
l10nDef["//lb.wikipedia.org"] = {"Equippennumm", "Land", "Code", "WorldTeam", "WorldTeams", "ProTeam", "ProTeams", "Professionell Kontinentalequipe", "Professionell Kontinentalequippen", "Kontinentalequipe", "Kontinentalequippen", "Nationalequipe", "Nationalequippen", "Regional- a Klubequipe", "Regional- a Klubequippen", "Professionell Vëlosequipe", "Professionell Vëlosequippen", "Amateursequipe", "Amateursequippen", "Sportsgrupp I", "Sportsgruppen I", "Sportsgrupp II", "Sportsgruppen II", "Sportsgrupp III", "Sportsgruppen III", "Gemëscht Equipe", "Gemëscht Equippen", "Dammenequipe", "Dammenequippen"}
l10nDef["//ro.wikipedia.org"] = {"Numele echipei", "Țară", "Cod", "WorldTeam", "WorldTeams", "ProTeam", "ProTeams", "Echipă continentală profesionistă", "Echipe continentale profesioniste", "Echipă continentală", "Echipe continentale", "Echipă națională", "Echipe naționale", "Echipă regională și de club", "Echipe regionale și de club", "Echipă ciclistă profesionistă", "Echipe cicliste profesioniste", "Echipă ciclistă de amatori", "Echipe cicliste de amatori", "Grup sportiv I", "Grupuri sportive I", "Grup sportiv II", "Grupuri sportive II", "Grup sportiv III", "Grupuri sportive III", "Echipă mixtă", "Echipe mixte", "Echipă feminină", "Echipe feminine"}
l10nDef["//www.wikidata.org"] = l10nDef["//fr.wikipedia.org"]
local l10n = l10nDef[mw.site.server]
if not l10n then l10n = l10nDef["//fr.wikipedia.org"] end -- default
return l10n[x]
l10n = l10nDef["//fr.wikipedia.org"] -- default
end
return l10n[x]
end
 
function headoftableIV(x) -- En-tête du tableau du palmarès d'une course cycliste
-- l10nDef["//.wikipedia.org"] = {"", "", "", ""}
local l10nDef = { }
l10nDef["//fr.wikipedia.org"] = {"Année", "Vainqueur", "Deuxième", "Troisième"}
Ред 1.227 ⟶ 1.242:
l10nDef["//www.wikidata.org"] = {"Année", "Vainqueur", "Deuxième", "Troisième"}
local l10n = l10nDef[mw.site.server]
if not l10n then l10n = l10nDef["//fr.wikipedia.org"] end -- default
return l10n[x]
l10n = l10nDef["//fr.wikipedia.org"] -- default
end
return l10n[x]
end
 
function typeofstage(x, typ)
Ред 1.253 ⟶ 1.266:
l10nDef["//www.wikidata.org"] = {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'}
local l10n = l10nDef[mw.site.server]
if not l10n then l10n = l10nDef["//fr.wikipedia.org"] end -- default
l10n = l10nDef["//fr.wikipedia.org"] -- default
end
 
local y = ""