Modul:Cycling race
Das Modul Cycling race ist ein in Lua geschriebenes Programm und gehört zum Wikidata:WikiProjekt Radsport. Das Modul übernimmt nur Daten aus der Wikidata; mit Hilfe entsprechender Vorlagen werden diese Inhalte in einer Tabelle, Infobox, o. Ä. dargestellt und dürfen für die Wikipedia-Artikel verwendet werden. Das Modul selbst wird ebenso als Module:Cycling race auf Wikidata bereitgestellt, wo der entsprechende Quelltext von der Community weiterentwickelt wird. Der Code wird in regelmäßigen Abständen aktualisiert. Das Modul steht für alle Sprachversionen der Wikipedia zur Verfügung.
Allgemeine Hinweise
Es wird empfohlen, dass jede Verbesserung des Moduls bzw. des Codes zunächst auf der entsprechenden Hauptseite erfolgen soll. Verbesserungsvorschläge, Wünsche oder Fehlermeldungen sollen ebenso auf der Diskussionsseite des Moduls (in englischer Sprache) eingereicht und besprochen werden.
Sämtliche Updates auf der Wikidata-Hauptseite können 1:1 für die deutschsprachige Wikipedia-Seite übernommen werden. Nach dem Update wird empfohlen, die Vorlagen auf ihre vollständige Funktion zu überprüfen. Der Inhalt des Quellcodes darf nicht umgenannt werden.
Vorlagen
| Vorlage | Beschreibung | Kopiervorlage |
|---|---|---|
| Vorlage:Cycling race/bestyoungclassification | Nachwuchswertung (Zeit) | {{Cycling race/bestyoungclassification|Wikidata-ID}}
|
| Vorlage:Cycling race/bestyoungclassificationbypoints | Nachwuchswertung (Punkte) | {{Cycling race/bestyoungclassificationbypoints|Wikidata-ID}}
|
| Vorlage:Cycling race/calendar | Rennkalender (inkl. Ergebnis) für UCI-Rennserien | {{Cycling race/calendar|Kürzel|Jahr}}
|
| Vorlage:Cycling race/combinationclassification | Kombinationswertung | {{Cycling race/combinationclassification|Wikidata-ID}}
|
| Vorlage:Cycling race/combativeclassification | Kämpferischster Fahrer | {{Cycling race/combativeclassification|Wikidata-ID}}
|
| Vorlage:Cycling race/custompointsclassification | Titelname ändern (Punkteklassements) | {{Cycling race/custompointsclassification|Wikidata-ID|p=Pxxxx|t=Titelname}}
|
| Vorlage:Cycling race/generalclassification | Gesamtwertung (Zeit) | {{Cycling race/generalclassification|Wikidata-ID}}
|
| Vorlage:Cycling race/infobox | Infobox (für jeweilige Ausgabe einer Rundfahrt & eines Eintagesrennen; nicht für Etappen und Radrennen im Allgemeinen) | {{Cycling race/infobox|Wikidata-ID}}
|
| Vorlage:Cycling race/listofstages | Etappenliste | {{Cycling race/listofstages|Wikidata-ID}}
|
| Vorlage:Cycling race/listofstagesclassification | Wertungen im Tourverlauf | {{Cycling race/listofstagesclassification|Wikidata-ID}}
|
| Vorlage:Cycling race/listofteams | Übersicht teilnehmender Teams bei Rundfahrt & Eintagesrennen | {{Cycling race/listofteams|Wikidata-ID}}
|
| Vorlage:Cycling race/listofwinners | Siegerliste (Rundfahrt und Eintagesrennen; Platz 1 bis 3 je Ausgabe) | {{Cycling race/listofwinners|Wikidata-ID}}
|
| Vorlage:Cycling race/mountainsclassification | Bergwertung | {{Cycling race/mountainsclassification|Wikidata-ID}}
|
| Vorlage:Cycling race/pointsclassification | Punktewertung | {{Cycling race/pointsclassification|Wikidata-ID}}
|
| Vorlage:Cycling race/raceinfobox | Infobox (Radrennen im Allgemeinen) | {{Cycling race/raceinfobox|Wikidata-ID}}
|
| Vorlage:Cycling race/sprintsclassification | Sprintwertung im Zwischensprint | {{Cycling race/sprintsclassification|Wikidata-ID}}
|
| Vorlage:Cycling race/stageclassification | Etappenergebnis (Zeit) | {{Cycling race/stageclassification|Wikidata-ID}}
|
| Vorlage:Cycling race/stageinfobox | Infobox (Etappen) | {{Cycling race/stageinfobox|Wikidata-ID}}
|
| Vorlage:Cycling race/stagetitle | Etappentitel (Start und Ziel, Etappenprofil und Streckenlänge) | {{Cycling race/stagetitle|Wikidata-ID}}
|
| Vorlage:Cycling race/startlist | Fahrerfeld/Startliste (Rundfahrt & Eintagesrennen) | {{Cycling race/startlist|Wikidata-ID}}
|
| Vorlage:Cycling race/teamranking | Bestplatzierung eines Teams (inkl. bester Fahrer) in einer UCI-Radrennserie | {{Cycling race/teamranking|Wikidata-ID|Kürzel}}
|
| Vorlage:Cycling race/teamriderCompetitionranking | Bestplatzierung in einer vordefinierten UCI-Radrennserie in einer Saison | {{Cycling race/teamriderCompetitionranking|Wikidata-ID|Kürzel}}
|
| Vorlage:Cycling race/teamsclassificationbytime | Mannschaftswertung (Zeit) | {{Cycling race/teamsclassificationbytime|Wikidata-ID}}
|
| Vorlage:Cycling race/teamsclassificationbypoints | Mannschaftswertung (Punkte) | {{Cycling race/teamsclassificationbypoints|Wikidata-ID}}
|
| Vorlage:Cycling race/teamtimetrialclassification | Etappenergebnis (nur bei Teamzeitfahren) | {{Cycling race/teamtimetrialclassification|Wikidata-ID}}
|
| Vorlage:Cycling race/teamroster | Übersicht Teamkader | {{Cycling race/teamroster|Wikidata-ID}}
|
| Vorlage:Cycling race/UCIclassification | UCI-Rangliste in einer Saison (Team) | {{Cycling race/UCIclassification|Wikidata-ID}}
|
| Vorlage:Cycling race/victories | Siegerliste (Team) | {{Cycling race/victories|Wikidata-ID}}
|
Übersetzung der Vorlagen
- Für die deutschsprachige Begriffe (in Tabelle, Infobox, etc.): Modul:Cycling race/l10n
- Für die deutschsprachige Begriffe in der Wikidata: Wikidata:WikiProject Cycling/Kit to translate
- Für die deutschsprachige Bezeichnung der Länder: Modul:Cycling race/lang
- Für die deutschsprachige Bezeichnung der Wertungstrikots: Wikidata:WikiProject Cycling/Kit to translate/Jerseys
- Für die deutschsprachige Bezeichnung der Nationalteams: Wikidata:WikiProject Cycling/Kit to translate/National teams
Saisons im UCI-Kalender und Grand Tours (inkl. Wertungstrikots)
- Für die Verknüpfung in den entsprechendenden Tabellen: Modul:Cycling race/data
local p = {}
function infobox_left(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"}
local l10nDef = { }
l10nDef["//fr.wikipedia.org"] = {"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"}
l10nDef["//en.wikipedia.org"] = {"Race details", "Course", "Competition", "Competitions", "Stages", "Date", "Dates", "Distance", "Country", "Countries",
"Journey origin", "Journey destination", "Teams", "Starting riders", "Arriving riders", "Average speed", "Cost", "Palmares", "Winner", "Second",
"Third", "Points", "Mountains", "Sprints", "Youth", "Combativity", "Combination", "Team"}
l10nDef["//ca.wikipedia.org"] = {"Detalls de la cursa", "Cursa", "Competició", "Competicions", "Etapes", "Data", "Dates", "Distància", "País", "Països",
"Sortida", "Arribada", "Equips", "Inscrits", "Finalitzen", "Velocitat mitjana", "Cost", "Palmarès", "Vencedor", "Segon", "Tercer", "Punts", "Muntanya",
"Esprints", "Joves", "Combativitat", "Combinada", "Equip"}
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",
"Dritter", "Punktewertung", "Bergwertung", "Sprintwertung", "Nachwuchswertung", "Kämpferischster Fahrer", "Kombinationswertung", "Teamwertung"}
l10nDef["//es.wikipedia.org"] = {"Detalles", "Carrera", "Válida para", "Válida para", "Etapas", "Fecha", "Fechas", "Distancia total", "País", "Países",
"Lugar de inicio", "Lugar de llegada", "Equipos", "Ciclistas que iniciaron", "Ciclistas que finalizaron", "Velocidad media", "Costo", "Clasificación final",
"Ganador", "Segundo", "Tercero", "Puntos", "Montaña", "Sprints", "Jóvenes", "Combatividad", "Combinación", "Equipo"}
l10nDef["//lb.wikipedia.org"] = {"Detailer", "Course", "Kompetitioun", "Kompetitiounen", "Etappen", "Datum", "Datumer", "Distanz", "Land", "Länner",
"Depart", "Arrivée", "Equippen", "Um Depart", "Ukomm", "Vitesse-Moyenne", "Käschten", "Palmarès", "Gewënner", "Zweeten", "Drëtten", "Beschte Sprinter", "Biergpräis",
"Sprinter", "Beschte Jonken", "Kombativitéit", "Kombinatioun", "Equipe"}
l10nDef["//mk.wikipedia.org"] = {"Детали за трката", "Издание", "Натпреварување", "Натпреварувања", "Етапи", "Датум", "Датуми", "Растојание",
"Држава", "Држави", "Поаѓалиште", "Одредиште", "Екипи", "Возачи на почеток", "Возачи на крај", "Просечна брзина", "Трошоци", "Добитници на наградите",
"Победник", "Второпласиран", "Третопласиран", "Бодовен", "Планински", "Спринтерски", "Младински", "Борбеност", "Комбиниран", "Екипен"}
l10nDef["//nl.wikipedia.org"] = {"wedstrijddetails", "koers", "wedstrijd", "wedstrijden", "etappes", "datum", "datums", "afstand", "land", "landen", "startplaats",
"finishplaats", "teams", "aantal coureurs aan de start", "aantal coureurs bij de aankomst", "gemiddelde snelheid", "kosten", "palmares", "winnaar", "tweede",
"derde", "punten", "bergen", "sprints", "jeugd", "aanvalslust", "combinatie", "team"}
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ă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"] = {"Детали гонки", "Маршрут", "Соревнование", "Соревнования", "Этапы", "Дата", "Даты", "Дистанция", "Страна", "Страны",
"Место старта", "Пункт назначения", "Команды", "Вышло на старт гонщиков", "Финишировало гонщиков", "Средняя скорость", "Призовые", "Призёры", "Победитель",
"Второй", "Третий", "Очковая", "Горная", "Спринтерская", "Молодёжная", "Бойцовская", "Комбинированная", "Командная"}
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]
end
function infobox_bottom(x) -- This function give the bottom of the infobox, with a link to the documentation, and the tooltip
local l10nDef = { }
l10nDef["//fr.wikipedia.org"] = {"[[d:Module:Cycling race/doc|Documentation]]", "In Wikidata missing:"}
l10nDef["//en.wikipedia.org"] = {"[[d:Module:Cycling race/doc|Documentation]]", "In Wikidata missing:"}
l10nDef["//ca.wikipedia.org"] = {"[[d:Module:Cycling race/doc|Documentació]]", "In Wikidata missing:"}
l10nDef["//de.wikipedia.org"] = {"[[d:Module:Cycling race/doc|Dokumentation]]", "In Wikidata missing:"}
l10nDef["//es.wikipedia.org"] = {"[[d:Module:Cycling race/doc|Documentación]]", "In Wikidata missing:"}
l10nDef["//lb.wikipedia.org"] = {"[[d:Module:Cycling race/doc|Dokumentatioun]]", "In Wikidata missing:"}
l10nDef["//mk.wikipedia.org"] = {"[[d:Module:Cycling race/doc|Документација]]", "In Wikidata missing:"}
l10nDef["//ro.wikipedia.org"] = {"[[d:Module:Cycling race/doc|Documentație]]", "In Wikidata missing:"}
l10nDef["//ru.wikipedia.org"] = {"[[d:Module:Cycling race/doc|Документация]]", "In Wikidata missing:"}
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]
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", "carte de localisation", "course cyclist", "classe", "é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" }
l10nDef["//en.wikipedia.org"] = {"picture", "caption", "edition number", "locator map image", "cycling race", "class", "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" }
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]
end
function p.infobox(frame)
local t = {is_a="", class="", stage="", starttime="", endtime="", time="", length="", length_unit="",
startplace="", endplace="", nr_teams="", nr_participants_start="", nr_participants_end="", speed="", speed_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 wiki = 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
if not entityId:match( 'Q%d+' ) then error ( 'parameter must be a valid Wikidata item (ex: Q42)' ) end
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 tt.map = frame.args[property(4)] end
i = 5
for k in pairs(t) do --t[k], k = startplace, endplace, ...
if frame.args[property(i)] then t[k] = frame.args[property(i)] end
i = i + 1
end
if entity:getLabel() ~= nil then tt.name = entity:getLabel()
else
if entity:getLabel( 'fr' ) ~= nil then tt.name = entity:getLabel( 'fr' ).. " (fr)"
else tt.name = "Wikidata doesn´t know" end
end
a, b = pcall(fooA, 'numeric-id', entity, 'P641', 1)
if a == true then -- icon for road bicycle racing, Q3609 (road bicycle racing)
if b == 3609 then tt.icon = " [[File:Cycling (road) pictogram.svg|35px]]" end
end
a, b = pcall(fooA, 'value', entity, 'P18', 1)
if a == true and tt.picture == "" then
tt.picture = b
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
a, b = pcall(fooA, 'amount', entity, 'P1132', 1) -- Function for the number of cyclists participing at the race
if a == true and t.nr_participants_start == "" and t.nr_participants_end == "" then
for _, v in pairs(entity.claims["P1132"]) do
if v.mainsnak then
if v.qualifiers["P276"][1].datavalue.value["numeric-id"] == 15053706 then
t.nr_participants_start = string.gsub(v.mainsnak.datavalue.value.amount, "+", "") end
if v.qualifiers["P276"][1].datavalue.value["numeric-id"] == 15053716 then
t.nr_participants_end = string.gsub(v.mainsnak.datavalue.value.amount, "+", "") end
end
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)
if a == true and tt.nr == "" then
tt.nr = b .. ". "
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
if 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
local class = { "Q22231106", "Q22231107", "Q22231108", "Q22231109", "Q22231110", "Q22231111", "Q22231112",
"Q22231113", "Q22231114", "Q22231115", "Q22231116", "Q22231117", "Q22231118", "Q22231119" }
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 t.is_a = "Q"..b end -- if there is only one value, assume it is not a class
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 then --ttt.tour = "Q" .. b end
for i, v in pairs(entity.claims["P361"]) do
ttt.tour[i] = "T" .. v.mainsnak.datavalue.value["numeric-id"]
end
end
if pcall(function() -- This function count the number of value for P527 to determine the number of stages
t.stage = table.getn(entity.claims["P527"])
end
) then else t.stage = "" 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
--b = "+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 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 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 == "//ja.wikipedia.org" 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 == "//en.wikipedia.org" 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 == "//lv.wikipedia.org" then
if y ~= y2 then t.starttime = lang:formatDate( "Y. j. F", b1 )
elseif m ~= m2 then t.starttime = lang:formatDate( "Y. j. F", b1 )
else t.starttime = lang:formatDate( "Y. j.", b1 )
end end
end -- if a1
if a2 == true and t.endtime == "" then
t.endtime = lang:formatDate( "j F Y", b2 )
if wiki == "//de.wikipedia.org" or wiki == "//no.wikipedia.org" then
t.endtime = lang:formatDate( "j. F Y", b2 ) end
if wiki == "//ja.wikipedia.org" 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 == "//en.wikipedia.org" 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 == "//lv.wikipedia.org" then
if y ~= y2 then t.endtime = lang:formatDate( "Y. j. F", b2 )
elseif m ~= m2 then t.endtime = lang:formatDate( "j. F", b2 )
else t.endtime = lang:formatDate( "j. F", b2 )
end 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 = lang:formatDate( "j F Y", b1 )
if wiki == "//de.wikipedia.org" or wiki == "//no.wikipedia.org" then
t.time = lang:formatDate( "j. F Y", b1 ) end
if wiki == "//ja.wikipedia.org" then
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
-- 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 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, '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 wiki == "//mk.wikipedia.org" then t.length_unit = 'км' end
if wiki == "//ru.wikipedia.org" then t.length_unit = 'км' end
if wiki == "//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 ttt.country == "" then ttt.country = "Q" .. b end
for i, v in pairs(entity.claims["P17"]) do
ttt.country[i] = "C" .. v.mainsnak.datavalue.value["numeric-id"]
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
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
-- 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
for _, v in pairs(entity.claims["P1132"]) do
if v.qualifiers["P276"][1].datavalue.value["numeric-id"] == 15053706 then
if pcall(function()
t.nr_participants_start = string.gsub(v.mainsnak.datavalue.value.amount, "+", "")
end
) then else t.nr_participants_start = "" end
end
if v.qualifiers["P276"][1].datavalue.value["numeric-id"] == 15053716 then
if pcall(function()
t.nr_participants_end = string.gsub(v.mainsnak.datavalue.value.amount, "+", "")
end
) then else t.nr_participants_end = "" 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 == "//mk.wikipedia.org" then t.speed_unit = 'км/ч' end
if wiki == "//ru.wikipedia.org" then t.speed_unit = 'км/ч' end
if wiki == "//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)
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
a, b = pcall(fooA, 'value', entity, 'P242', 1) -- locator map image
if a == true and tt.map == "" then tt.map = b end
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
-- 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 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", 1, "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 v.rank ~= 'deprecated' then
if qual == 20882667 and t.first == "" then t.first = note .. id results = true end
if qual == 20882668 and t.second == "" then t.second = note .. id results = true end
if qual == 20882669 and t.third == "" then t.third = note .. id results = true end
if qual == 20883007 and t.winner_point == "" then t.winner_point = note .. id results = true end
if qual == 20883212 and t.winner_mountain == "" then t.winner_mountain = note .. id results = true end
if qual == 20883328 and t.winner_sprint == "" then t.winner_sprint = note .. id results = true end
if qual == 20883139 and t.winner_young == "" then t.winner_young = note .. id results = true end
if qual == 20893983 and t.winner_fighting == "" then t.winner_fighting = note .. id results = true end
if qual == 20893979 and t.winner_combination == "" then t.winner_combination = note .. id results = true end
if qual == 20882921 and t.winner_team == "" then t.winner_team = note .. id results = true end
end -- if id
end -- for
end -- end if pcall
-- transform Q/q-number into flag / WPlink / WDlink
local k
local team = true
local d1, datum_stagerace = pcall(fooA, 'time', entity, 'P580', 1) -- stage race
local d2, datum_singleday = pcall(fooA, 'time', entity, 'P585', 1) -- single day race
local wd = " [[File:Wikidata-logo S.svg|12px|link=d:"
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 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 = pcall(fooA, 'numeric-id', mw.wikibase.getEntity( t[k] ), 'P27', 1)
if a == true and pcall(foo1, t[k]) then t[k] = flag( getNationalityOnDate (t[k], datum), datum).." "..WPlink( t[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, datum).." "..WPlink( t[k], team )..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 = pcall(fooA, 'numeric-id', mw.wikibase.getEntity( t[k] ), 'P27', 1)
if a == true and pcall(foo1, t[k]) then t[k] = flag( getNationalityOnDate (t[k], datum), datum).." "..WPlink( 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, datum).." "..WPlink( t[k], team ) 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
end
-- references, not done
if pcall(foo12, entity, 'P569', 1, 2, 'P248', 1) then
snak2 = entity.claims['P569'][1].references[2].snaks["P248"][1].datavalue.value["numeric-id"]
end
if pcall(foo12, entity, 'P569', 1, 2, 'P345', 1) then
snak3 = entity.claims['P569'][1].references[2].snaks["P345"][1].datavalue.value
end
if pcall(foo12, entity, 'P569', 1, 2, 'P813', 1) then
snak4 = entity.claims['P569'][1].references[2].snaks["P813"][1].datavalue.value.time
_, _, y2, m2, d2 = string.find(snak4, "(%d+)-(%d+)-(%d+)") -- d = day, m = month "[".."http://www.spiegel.de/".."]" --
end
--tab1 = "<table class='wikitable'><tr><td>".."name".."</td><td>".. "Tour de France 2016" .. "</td></tr>" .."<tr><td>".."date de début".."</td><td>"
--tab1 = tab1 .. d1.."."..m1.."."..y1 --.. frame:extensionTag{name='ref',content="Q"..snak2.." | ".."[http://www.imdb.com/name/"..snak3.."]".." | "..d2.."."..m2.."."..y2,args={name='foo'}}
--tab1 = tab1 .. "</td></tr></table>"
local nl =" "
local tooltip = infobox_bottom(2) .. nl .. mw.text.encode( property(1) .. ' (P393)' ) .. nl .. mw.text.encode( property(2) ..' (P17)')
if t.length ~= "" then
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
end
if t.speed ~= "" then
t.speed, _ = string.gsub(t.speed, "[+]", "")
t.speed = lang:formatNum(tonumber(t.speed))
end
if t.cost ~= "" then
t.cost, _ = string.gsub(t.cost, "[+]", "")
t.cost = lang:formatNum(tonumber(t.cost))
end
local span1, span2 = "<span style='color:#3366CC'>◀ </span>", "<span style='color:#3366CC'> ▶</span>"
local k = t.previous
local i, _ = string.find(k, "|")
local j, _ = string.find(k, "]")
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 = string.gsub(k, "%D", "") if t.previous ~= "" then t.previous = span1 .. t.previous end end
k = t.next
i, _ = string.find(k, "|")
j, _ = string.find(k, "]")
if i ~= nil and j ~= nil then
t.next = string.sub(k, 1, i) .. string.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)
tab = "<table cellpadding='4' cellspacing='0' style='float:right; width:300px; border:1px solid rgb(200,200,200);"
tab = tab .. "margin:0 0.5em 0.5em 0; background-color:rgb(255, 255, 255); color:black; padding:5px; clear:left; "
tab = tab .. "text-align:left; font-size:85%; line-height:1.6em;'>"
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>[[File:Wikidata-logo S.svg|30px|link=d:".. frame.args[1] .. "]]</td><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_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 ttt.tour[1] ~= nil then tab = tab.."<tr><td style= 'vertical-align:top'>'''"
if #ttt.tour == 1 then tab = tab..infobox_left(3).."'''</td><td>" else tab = tab..infobox_left(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_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
--if t.endtime ~= "" then tab = tab.."<tr><td>".."Date de fin".."</td><td>" .. t.endtime .. "</td></tr>" end
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 ttt.country[1] ~= nil then tab = tab.."<tr><td style= 'vertical-align:top'>'''"
if #ttt.country == 1 then tab = tab..infobox_left(9).."'''</td><td>" else tab = tab..infobox_left(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_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
if t.nr_teams ~= "" then tab = tab.."<tr><td>'''"..infobox_left(13).."'''</td><td>" .. t.nr_teams .. "</td></tr>" end
if t.nr_participants_start ~= "" then tab = tab.."<tr><td>'''"..infobox_left(14).."'''</td><td>" .. t.nr_participants_start .. "</td></tr>" end
if t.nr_participants_end ~= "" then tab = tab.."<tr><td>'''"..infobox_left(15).."'''</td><td>" .. t.nr_participants_end .. "</td></tr>" end
if t.speed ~= "" then tab = tab.."<tr><td>'''"..infobox_left(16).."'''</td><td>" .. t.speed .. " "..t.speed_unit.."</td></tr>" end
if t.cost ~= "" then tab = tab.."<tr><td>'''"..infobox_left(17).."'''</td><td>" .. t.cost .. " "..t.cost_unit.. "</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_left(18).."'''</td></tr>" end
if t.first ~= "" then tab = tab.."<tr><td>'''"..infobox_left(19).."'''</td><td>" .. t.first .. "</td></tr>" end
if t.second ~= "" then tab = tab.."<tr><td>'''"..infobox_left(20).."'''</td><td>" .. t.second .. "</td></tr>" end
if t.third ~= "" then tab = tab.."<tr><td>'''"..infobox_left(21).."'''</td><td>" .. t.third .. "</td></tr>" end
if t.winner_point ~= "" then tab = tab.."<tr><td>'''"..infobox_left(22).."'''</td><td>" .. t.winner_point .. "</td></tr>" end
if t.winner_mountain ~= "" then tab = tab.."<tr><td>'''"..infobox_left(23).."'''</td><td>" .. t.winner_mountain .. "</td></tr>" end
if t.winner_sprint ~= "" then tab = tab.."<tr><td>'''"..infobox_left(24).."'''</td><td>" .. t.winner_sprint .. "</td></tr>" end
if t.winner_young ~= "" then tab = tab.."<tr><td>'''"..infobox_left(25).."'''</td><td>" .. t.winner_young .. "</td></tr>" end
if t.winner_fighting ~= "" then tab = tab.."<tr><td>'''"..infobox_left(26).."'''</td><td>" .. t.winner_fighting .. "</td></tr>" end
if t.winner_combination ~= "" then tab = tab.."<tr><td>'''"..infobox_left(27).."'''</td><td>" .. t.winner_combination .. "</td></tr>" end
if t.winner_team ~= "" then tab = tab.."<tr><td>'''"..infobox_left(28).."'''</td><td>" .. t.winner_team .. "</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
tab = tab.."<tr><td>"..t.previous.."</td><td style='text-align:right'>" .. t.next .. "</td></tr>"
tab = tab .. "<tr><td colspan='2' style='text-align:right; border-top:3px solid #FFDF80; font-size:75%'>" .. infobox_bottom(1)
--tab = tab .. "<span style='float:right' title='".. tooltip .. "'>[[File:High-contrast-help-browser.svg|10px|right|link=]]"
tab = tab .. "</span></td></tr></table>"
return tab
end
function getNationalityOnDate (rider, date) -- rider Qnumber, date = e.g. "+1985-05-20T00:00:00Z"
local entity = mw.wikibase.getEntity( rider )
local nationalities = entity.claims["P27"]
local possibleNationalities = {}
local num = 1
for _, v in pairs(nationalities) do
if v.qualifiers then
if (not v.qualifiers["P580"] or v.qualifiers["P580"][1].datavalue.value.time <= date)
and
(not v.qualifiers["P582"] or v.qualifiers["P582"][1].datavalue.value.time >= date)
then
possibleNationalities[num] = "Q" .. v.mainsnak.datavalue.value['numeric-id']
num = num + 1
end
else
possibleNationalities[num] = "Q" .. v.mainsnak.datavalue.value['numeric-id']
num = num + 1
end
end
return possibleNationalities[1]
end
function WPlink(Qnumber, ...)
local link
local entity = mw.wikibase.getEntity( Qnumber )
local Sitelink = entity:getSitelink() -- link to WParticle
local Label = entity:getLabel()
local Label_fr = entity:getLabel( 'fr' )
local Sitelink_claas = mw.wikibase.getEntity( 'Q22348500' ):getSitelink()
local a, b
local official_name = ""
if pcall(foo1, Qnumber) then -- "[[" .. sitelinks1[num] .. "|" .. string.gsub(sitelinks1[num], "%b()", "") .. "]]"
if Sitelink ~= nil then link = "[[" .. Sitelink .. "|" .. string.gsub(Sitelink, "%b()", "") .. "]]" else link = Label end
else return "unknown ID in function WPlink" end
if link == nil then
link = Label_fr
if link == nil then link = "(label missing)" else link = string.gsub(link, "%b()", "") .. " (fr)" end -- if no fr:label else fr.label plus ...
end
if arg[1] == true then -- Qnumber of a team
a, b = pcall(fooA, 'text', entity, 'P1448', 1)
if a == true then official_name = b end
if pcall(foo1, Qnumber) then
if Sitelink ~= nil and official_name == b then link = "[[" .. Sitelink .. "|" .. official_name .. "]]" else link = official_name end
else return "unknown ID in function WPlink" end
if link == nil then
link = Label_fr
if link == nil then link = "(label missing)" else link = link .. " (fr)" end -- if no fr:label else fr.label plus ...
end
end -- end arg[1]
if arg[1] == "Q22348500" then -- add weblink from item "Q22348500" if available
if pcall(foo1, Qnumber) then --Sitelink_claas
if Sitelink == nil then
if Sitelink_claas ~= nil then link = "[[" .. Sitelink_claas .. "|" .. Label .. "]]" else link = Label end
end
end
end
return link
end
function fooA (mode,entity,property,var)
local snak
if mode=="value" then snak=entity.claims[property][var].mainsnak.datavalue.value
else snak=entity.claims[property][var].mainsnak.datavalue.value[mode]
end
return snak, entity.claims[property][var].rank
end
function foo1 (arg)
local entity = mw.wikibase.getEntity( arg )
end
function foo2 (entity_var, property, var)
local snak = entity_var.claims[property][var].mainsnak.datavalue.value.amount
end
function foo3 (entity_var, property, var1, quali, var2)
local snak = entity_var.claims[property][var1].qualifiers[quali][var2].datavalue.value.amount
end
function foo12 (entity_var, property, var1, var2, ref, var3)
local snak = entity_var.claims[property][var1].references[var2].snaks[ref][var3].datavalue
end
function winner (t, winner_id)
tt = {}
for num=1,t.main.number do
table.insert(tt, "")
end
local winner, time_var, sitelink, nationality
local go
for num=1,t.main.number do
-- winner: Qnumber of vainqueur du classement général
i = 1
if pcall(foo2, t.main.race[num][2], "P1346", i) then
while t.main.race[num][2].claims["P1346"][i] do -- suche nach "Gewinner der Gesamtwertung"
if pcall(foo3, t.main.race[num][2], "P1346", i, "P642", 1) then go = true else go = false end
if go == true and t.main.race[num][2].claims["P1346"][i].qualifiers.P642[1].datavalue.value['numeric-id'] == winner_id then
winner = "Q"..t.main.race[num][2].claims["P1346"][i].mainsnak.datavalue.value['numeric-id']
if mw.site.server == "//www.wikidata.org" then sitelink = mw.wikibase.getEntity( winner ):getSitelink( 'frwiki' )
else sitelink = mw.wikibase.sitelink( winner )
end
if sitelink == nil then
if mw.wikibase.getEntity( winner ):getLabel() == nil then sitelink = "—"
else sitelink = mw.wikibase.getEntity( winner ):getLabel()
end
if mw.site.server == "//lv.wikipedia.org" and mw.wikibase.getEntity( winner ):getLabel() == nil then
sitelink = mw.wikibase.getEntity( winner ):getLabel('en') .. " (en)" end
if mw.site.server == "//mk.wikipedia.org" and mw.wikibase.getEntity( winner ):getLabel() == nil then
sitelink = mw.wikibase.getEntity( winner ):getLabel('en') .. " (en)" end
if mw.site.server == "//ja.wikipedia.org" and mw.wikibase.getEntity( winner ):getLabel() == nil then
sitelink = mw.wikibase.getEntity( winner ):getLabel('en') .. " (en)" end
else sitelink = "[[" .. sitelink .. "|" .. string.gsub(sitelink, "%b()", "") .. "]]"
end
-- get date of the race, e.g. "+2016-01-01T00:00:00Z"
-- P585 (point in time for a single day race) or P580 (start time for a stage race)
if pcall(foo2, t.main.race[num][2], "P585", 1) then
time_var = t.main.race[num][2].claims["P585"][1].mainsnak.datavalue.value.time
elseif pcall(foo2, t.main.race[num][2], "P580", 1) then
time_var = t.main.race[num][2].claims["P580"][1].mainsnak.datavalue.value.time
else end
-- get nationality of the winner, nationality could have changed, therefore look for qualifiers p580 and p582
if pcall(foo2, mw.wikibase.getEntity( winner ), "P27", 1) then -- standard: only one nationality
nationality = "Q"..mw.wikibase.getEntity( winner ).claims["P27"][1].mainsnak.datavalue.value['numeric-id']
tt[num] = flag(nationality, time_var) .. " " .. sitelink .. " " .. wdLink(winner)
else tt[num] = " " .. sitelink .. " " .. wdLink(winner) end
if pcall(foo2, mw.wikibase.getEntity( winner ), "P27", 2) then -- if person has more than one nationality calculate tt[num] again
tt[num] = flag( getNationalityOnDate (winner, time_var), time_var) .. " " .. sitelink .. " " .. wdLink(winner) end
end -- end if
i = i + 1
end -- end while
else end -- end if pcall
end -- end for
return tt
end
function p.listofwinners(frame)
local table_first, table_proto, table_last, table_center
table_first = "<table cellpadding='4' cellspacing='0' style='border:1px solid rgb(200,200,200); color:black;"
table_first = table_first .. "margin:0 0 0.5em 0; background-color:rgb(255, 255, 255); padding:5px; clear:left; "
table_first = table_first .. "text-align:left; vertical-align:top; font-size:85%; line-height:1.6em;'>"
table_proto = {"<tr style='background:#FFDF80; text-align:center;'><th>", headoftableIV(1), "</th><th>",
headoftableIV(2), "</th><th>", headoftableIV(3), "</th><th>", headoftableIV(4), "</th></tr>"}
table_center = ""
table_last = "</table>"
local t = {main={entity0="", race={}}, year={}, vainqueur={}, deuxieme={}, troisieme={}}
-- entity0 =
-- race = {{q1, ..., 2013}, {q2, ..., 2014}} race[1]={race_Qnr, entity, time}
-- year =
-- vainqueur =
-- deuxieme =
-- troisieme =
if pcall(foo1, frame.args[1]) then t.main.entity0 = mw.wikibase.getEntity( frame.args[1] ) end
local tt, k, sitelink
local num = 1
local go
if pcall(foo2, t.main.entity0, "P527", num) then go = true else go = false end
while go == true and t.main.entity0.claims["P527"][num] do
race = 'Q'..t.main.entity0.claims["P527"][num].mainsnak.datavalue.value['numeric-id'] -- Qnumbers of the parts of a tour
tt = {}
table.insert(tt, race)
table.insert(tt, mw.wikibase.getEntityObject(race))
if pcall(foo2, tt[2], "P585", 1) then -- P585(point in time for a single day race) or P580(start time for a stage race)
k = tt[2].claims["P585"][1].mainsnak.datavalue.value.time
elseif pcall(foo2, tt[2], "P580", 1) then
k = tt[2].claims["P580"][1].mainsnak.datavalue.value.time
else return "! not enoght data on Wikidata available" end
local _, _, year, _, _ = string.find(k, "(%d+)-(%d+)-(%d+)")
table.insert(tt, year)
table.insert(t.main.race, tt)
table.sort(t.main.race, function(a,b) return a[3] < b[3] end) -- t.main.race is sorted after year
num = num + 1
end -- end while
t.main.number = num - 1
tt = {}
for num=1,t.main.number do -- build first column with link to wikipedia article and to wikidata item
if mw.site.server == "//www.wikidata.org" then sitelink = t.main.race[num][2]:getSitelink( 'frwiki' )
else sitelink = mw.wikibase.sitelink( t.main.race[num][1] )
end
if sitelink == nil then sitelink = t.main.race[num][3]
else sitelink = "[[" .. sitelink .. "|" .. t.main.race[num][3] .. "]]"
end
table.insert(tt, sitelink.. " " .. wdLink(t.main.race[num][1]) )
end
table.insert(t.year, tt)
table.insert(t.vainqueur, winner(t, 20882667))
table.insert(t.deuxieme, winner(t, 20882668))
table.insert(t.troisieme, winner(t, 20882669))
local table_center = ""
for var=1, t.main.number do -- t.main.race[var][3]
table_center = table_center .. "<tr><td>"..t.year[table.getn(t.year)][var].."</td>"
table_center = table_center .. "<td>"..t.vainqueur[table.getn(t.vainqueur)][var].."</td>"
table_center = table_center .. "<td>"..t.deuxieme[table.getn(t.deuxieme)][var].."</td>"
table_center = table_center .. "<td>"..t.troisieme[table.getn(t.troisieme)][var].."</td></tr>"
end
--return tt[1]..tt[2]..tt[3]
return table_first .. table.concat(table_proto) .. table_center .. table_last
end
function p.listofstages(frame)
local i, v, uu, ii, nationality
local etape = {}
local entity = {}
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 stage = {}
local level = 1
local a, b
entity0 = mw.wikibase.getEntityObject( frame.args[1] ) -- Q18589873 (Quatre jours de Dunkerque 2015)
-- begin level 1
local table_first, table_proto, table_last
table_first = "<table cellpadding='4' cellspacing='0' style='border:1px solid rgb(200,200,200); color:black;"
table_first = table_first .. "margin:0 0 0.5em 0; background-color:rgb(255, 255, 255); padding:5px; clear:left; "
table_first = table_first .. "text-align:left; vertical-align:top; font-size:85%; line-height:1.6em;'>"
table_proto = {"<tr style='background:#FFDF80; text-align:center;'><th>", headoftable(1), "</th><th colspan='2'>",
headoftable(2), "</th><th>", headoftable(3), "</th><th>", headoftable(4), "</th><th>",
headoftable(5), "</th><th>", headoftable(6), "</th></tr>"}
table_last = "</table>"
-- missing is that the names in table_proto are taken from WD if possible
-- end level 1
local pp = entity0:getProperties()
-- look in all values of array `pp' and if there is one P527 then increase to level = 2
for i,v in ipairs(pp) do if v == 'P527' then level = 2 end end
-- only for level: 2
-- read series_ordinal and the Qnumber and sort them after series_ordinal, eg: 1 2a 2b 3 4 5
local num = 1
local parts = {}
while level == 2 and entity0.claims["P527"][num] do
etape[num] = 'Q'..entity0.claims["P527"][num].mainsnak.datavalue.value['numeric-id']
entity[num] = mw.wikibase.getEntityObject( etape[num] )
if pcall(function ()
series_ordinal[num] = entity[num].claims["P1545"][1].mainsnak.datavalue.value
end
) then else series_ordinal[num] = " " end
table.insert(parts, num, {nr = series_ordinal[num], Qnum = etape[num]})
num = num + 1
end
-- sort parts after nr = series_ordinal[num], not Qnum
table.sort(parts, function(a, b)
local num1 = string.sub(a.nr, string.find(a.nr, "%d+"))
local num2 = string.sub(b.nr, string.find(b.nr, "%d+"))
local char1, char2
if string.find(a.nr, "%a") then char1 = string.sub(a.nr, string.find(a.nr, "%a")) else char1 = "" end
if string.find(b.nr, "%a") then char2 = string.sub(b.nr, string.find(b.nr, "%a")) else char2 = "" end
local comp
if char1 == "" and char2 == "" then comp = tonumber(num1) < tonumber(num2) end
if char1 ~= "" and char2 == "" then comp = tonumber(num1) < tonumber(num2) end
if char1 == "" and char2 ~= "" then comp = tonumber(num1) < tonumber(num2) end
if char1 ~= "" and char2 ~= "" then comp = char1 < char2 end
return comp end)
--return a.nr < b.nr end)
num = 1
while level == 2 and entity0.claims["P527"][num] do -- begin while loop 1; P527 (has part)
-- collect data from Wikidata in tables
entity[num] = mw.wikibase.getEntityObject( parts[num].Qnum )
number0[num] = " " .. wdLink(parts[num].Qnum)
sitelinks_etape[num] = entity[num]:getSitelink()
a, b = pcall(fooA, 'value', entity[num], 'P1545', 1)
if a == true then series_ordinal[num] = b else series_ordinal[num] = " " end
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 ) else sitelinks1[num] = " " end
a, b = pcall(fooA, 'numeric-id', entity[num], 'P1444', 1)
if a == true then sitelinks2[num] = WPlink( 'Q'..b ) else sitelinks2[num] = " " end
a, b = pcall(fooA, 'amount', entity[num], 'P2043', 1)
if a == true then length[num] = formatNumber( b ) else length[num] = " " end
-- find the vainqueur d'étape, Q20882747
i = 1
sitelinks3[num] = "" -- "unknown3"
number1[num] = ""
flag1[num] = ""
if pcall(function()
local t = entity[num].claims["P1346"][i] -- error or no error?
end
) then -- t: no error
while entity[num].claims["P1346"][i] do
if pcall(function()
local t = entity[num].claims["P1346"][i].qualifiers.P642[1].datavalue.value['numeric-id']
end
) then -- t: no error
if entity[num].claims["P1346"][i].qualifiers.P642[1].datavalue.value['numeric-id'] == 20882747 then
number1[num] = 'Q'..entity[num].claims["P1346"][i].mainsnak.datavalue.value['numeric-id']
-- get nationality of the winner, nationality could have changed, therefore look for qualifiers p580 and p582
if pcall(foo2, mw.wikibase.getEntity( number1[num] ), "P27", 1) then -- standard: only one nationality
nationality = "Q"..mw.wikibase.getEntity( number1[num] ).claims["P27"][1].mainsnak.datavalue.value['numeric-id']
flag1[num] = flag(nationality, point_of_time[num])
end
if pcall(foo2, mw.wikibase.getEntity( number1[num] ), "P27", 2) then -- if person has more than one nationality calculate flag1[num] again
flag1[num] = flag(getNationalityOnDate(number1[num], point_of_time[num]), point_of_time[num])
end
if pcall(foo2, mw.wikibase.getEntity( number1[num] ), "P17", 1) then -- standard: only one nationality
nationality = "Q"..mw.wikibase.getEntity( number1[num] ).claims["P17"][1].mainsnak.datavalue.value['numeric-id']
flag1[num] = flag(nationality, point_of_time[num])
end
if pcall(foo2, mw.wikibase.getEntity( number1[num] ), "P17", 2) then -- if team has more than one nationality calculate flag1[num] again
flag1[num] = flag(getNationalityOnDate(number1[num], point_of_time[num]), point_of_time[num])
end
if pcall(function() -- find name of winner
sitelinks3[num] = " [[" .. mw.wikibase.sitelink(number1[num]) .. " |" .. string.gsub(mw.wikibase.sitelink(number1[num]), "%b()", "") .. "]]"
end
) then else
if mw.wikibase.label(number1[num]) ~= nil then sitelinks3[num] = " [[" .. mw.wikibase.label(number1[num]) .. "]]"
else sitelinks3[num] = " " .. mw.wikibase.getEntity( number1[num] ):getLabel('en') .. " (en)" .. " " end
end
number1[num] = " " .. wdLink(number1[num])
else
end -- end if
else -- t: error,
number1[num] = 'Q'..entity[num].claims["P1346"][i].mainsnak.datavalue.value['numeric-id']
--sitelinks3[num] = " [[" .. mw.wikibase.sitelink(number1[num]) .. "]]"
if pcall(function() -- find name of winners
sitelinks3[num] = " [[" .. mw.wikibase.sitelink(number1[num]) .. "|" .. string.gsub(mw.wikibase.sitelink(number1[num]), "%b()", "") .. "]]"
end
) then else sitelinks3[num] = " n.v. " end
if pcall(function()
flag1[num] = flag ('Q'..mw.wikibase.getEntity( number1[num] ).claims["P27"][1].mainsnak.datavalue.value['numeric-id'], point_of_time[num] )
end
) then else -- winning racing team (time trial) has no P27 but P17
flag1[num] = flag ('Q'..mw.wikibase.getEntity( number1[num] ).claims["P17"][1].mainsnak.datavalue.value['numeric-id'], point_of_time[num] )
end
number1[num] = " " .. wdLink(number1[num])
end -- end pcall
i = i + 1
end -- end while loop
else -- t: error
number1[num] = ""
sitelinks3[num] = "" -- "unknown3"
flag1[num] = ""
end -- end pcall
-- find the leader du classement général à l'issue de l'étape, Q20882763
i = 1
sitelinks4[num] = "" --"unknown4"
number2[num] = ""
flag2[num] = ""
if pcall(function()
local t = entity[num].claims["P1346"][i] -- error or no error?
end
) then -- t: no error
while entity[num].claims["P1346"][i] do
if pcall(function()
local t = entity[num].claims["P1346"][i].qualifiers.P642[1].datavalue.value['numeric-id']
end
) then -- t: no error
if entity[num].claims["P1346"][i].qualifiers.P642[1].datavalue.value['numeric-id'] == 20882763 or entity[num].claims["P1346"][i].qualifiers.P642[1].datavalue.value['numeric-id'] == 20882667 then
number2[num] = 'Q'..entity[num].claims["P1346"][i].mainsnak.datavalue.value['numeric-id']
-- get nationality of the winner, nationality could have changed
if pcall(foo2, mw.wikibase.getEntity( number2[num] ), "P27", 1) then -- standard: only one nationality
nationality = "Q"..mw.wikibase.getEntity( number2[num] ).claims["P27"][1].mainsnak.datavalue.value['numeric-id']
flag2[num] = flag(nationality, point_of_time[num])
end
if pcall(foo2, mw.wikibase.getEntity( number2[num] ), "P27", 2) then -- if person has more than one nationality calculate flag2[num] again
flag2[num] = flag(getNationalityOnDate(number2[num], point_of_time[num]), point_of_time[num])
end
if pcall(foo2, mw.wikibase.getEntity( number2[num] ), "P17", 1) then -- standard: only one nationality
nationality = "Q"..mw.wikibase.getEntity( number2[num] ).claims["P17"][1].mainsnak.datavalue.value['numeric-id']
flag2[num] = flag(nationality, point_of_time[num])
end
if pcall(foo2, mw.wikibase.getEntity( number2[num] ), "P17", 2) then -- if team has more than one nationality calculate flag2[num] again
flag2[num] = flag(getNationalityOnDate(number2[num], point_of_time[num]), point_of_time[num])
end
if pcall(function() -- find name of winner
sitelinks4[num] = " [[" .. mw.wikibase.sitelink(number2[num]) .. "|" .. string.gsub(mw.wikibase.sitelink(number2[num]), "%b()", "") .. "]]"
end
) then else
if mw.wikibase.label(number2[num]) ~= nil then sitelinks4[num] = " [[" .. mw.wikibase.label(number2[num]) .. "]]"
else sitelinks4[num] = " " .. mw.wikibase.getEntity( number2[num] ):getLabel('en') .. " (en)" .. " " end
end
number2[num] = " " .. wdLink(number2[num])
else
end -- end if
else -- t: error,
number2[num] = 'Q'..entity[num].claims["P1346"][i].mainsnak.datavalue.value['numeric-id']
--sitelinks4[num] = " [[" .. mw.wikibase.sitelink(number2[num]) .. "]]"
if pcall(function() -- find name of winners
sitelinks4[num] = " [[" .. mw.wikibase.sitelink(number2[num]) .. "|" .. string.gsub(mw.wikibase.sitelink(number2[num]), "%b()", "") .. "]]"
end
) then else sitelinks4[num] = " n.v." end
if pcall(function()
flag2[num] = flag ('Q'..mw.wikibase.getEntity( number2[num] ).claims["P27"][1].mainsnak.datavalue.value['numeric-id'], point_of_time[num] )
end
) then else -- winning racing team (time trial) has no P27 but P17
flag2[num] = flag ('Q'..mw.wikibase.getEntity( number2[num] ).claims["P17"][1].mainsnak.datavalue.value['numeric-id'], point_of_time[num] )
end
number2[num] = " " .. wdLink(number2[num])
end -- end pcall
i = i + 1
end -- end while loop
else -- t: error
number2[num] = ""
sitelinks4[num] = "" --"unknown4"
flag2[num] = ""
end -- end pcall
if pcall(function()
-- find the type of stages
i = 1
stage[num] = ""
uu = entity[num].claims["P31"][i].mainsnak.datavalue.value['numeric-id']
while entity[num].claims["P31"][i] do
if uu == 20646667 then stage[num] = typeofstage('plain stage') end
if uu == 20646670 then stage[num] = typeofstage('hilly stage') end
if uu == 20680270 then stage[num] = typeofstage('intermediate stage') end
if uu == 20646668 then stage[num] = typeofstage('mountain stage') end
if uu == 485321 then stage[num] = typeofstage('time trial stage', 485321) end -- prologue
if uu == 2266066 then stage[num] = typeofstage('time trial stage', 2266066) end -- individual time trial
if uu == 2348250 then stage[num] = typeofstage('time trial stage', 2348250) end -- team time trial
if uu == 20679712 then stage[num] = typeofstage('uphill time trial stage') end
i = i + 1
end
end
) then else stage[num] = " " end
if pcall(function()
-- if type of stages == "team time trial" (Q2348250) then label3 = [[label3|official name]]
i = 1
uu = entity[num].claims["P31"][i].mainsnak.datavalue.value['numeric-id']
while entity[num].claims["P31"][i] do
if uu == 2348250 then -- "team time trial"
ii = 1
while entity[num].claims["P1346"][ii] do -- find the ii of the stage winner
local number = "Q"..entity[num].claims["P1346"][ii].mainsnak.datavalue.value['numeric-id'] -- e.g. Q19516702, Qnumber of stage winner
if pcall(function()
local official_name = mw.wikibase.getEntity( number ).claims["P1448"][1].mainsnak.datavalue.value.text
if mw.wikibase.label(number) ~= nil then sitelinks3[num] = string.sub(string.gsub(sitelinks3[num], "%b|]", "") , 0, -3).."|"..official_name.."]]" end
end -- end of function
) then end -- end of if
ii = ii + 1
end -- end while loop
end -- end of if
i = i + 1
end -- end while loop
end -- end of function
) then end -- end of if
_, _, y[num], m[num], d[num] = string.find(point_of_time[num], "(%d+)-(%d+)-(%d+)") -- d = day, m = month
num = num + 1
end -- end while loop 1
-- build table for output
local table_center = ""
for var=1, num-1 do
local a, b
a, _ = string.gsub(series_ordinal[var], "%a", "") -- 20, not 20a
if string.find(series_ordinal[var], "%a") then b = string.sub(series_ordinal[var], string.find(series_ordinal[var], "%a"))
else b = "" end
local ee, er = stageLink(series_ordinal[var], a, b)
if series_ordinal[var] == "0" then
er = "#"..func_prologue()
ee = func_prologue()
end
local stageNr -- if there is a wikipedia article of that stage show it or show the section
if sitelinks_etape[var] == nil then stageNr = "[["..er.."|"..ee.."]]" else stageNr = "[["..sitelinks_etape[var].."|"..ee.."]]" end
local day = tostring(tonumber(d[var]))
if day == "1" and (mw.site.server == "//fr.wikipedia.org" or mw.site.server == "//www.wikidata.org") then day = "1<sup>er</sup>"
else if mw.site.server ~= "//fr.wikipedia.org" then day = day .. "." end end
if mw.site.server == "//lv.wikipedia.org" then stageNr = series_ordinal[var] end
local month = func_month(m[var])
local date = day.."</td><td>"..month
if mw.site.server == "//ja.wikipedia.org" then date = month .. "</td><td style='padding-left:0px'>" .. day .. "日" end
if pcall(function()
length[var] = mw.language.getContentLanguage():formatNum(tonumber(length[var]))
end
) then else length[var] = " " end
--length[var] = mw.language.getContentLanguage():formatNum(tonumber(length[var]))
table_center = table_center.."<tr style='vertical-align:top'><td style='text-align:right'>".. stageNr .. number0[var]
table_center = table_center.."</td><td style='text-align:right; padding-right:0px'>"..date
table_center = table_center.."</td><td>"..sitelinks1[var].." – "..sitelinks2[var]..stage[var].."</td><td style='text-align:center'>"
table_center = table_center..length[var].." </td><td>"..flag1[var]..sitelinks3[var]..number1[var]
table_center = table_center.."</td><td>"..flag2[var]..sitelinks4[var]..number2[var].."</td></tr>"
end
if level == 1 then return table_first .. table.concat(table_proto) .. table_last end
return table_first .. table.concat(table_proto) .. table_center .. table_last
end
function func_prologue() -- returns the word "Prologue"
local translDef = { ["//www.wikidata.org"] = "Prologue",
["//fr.wikipedia.org"] = "Prologue",
["//en.wikipedia.org"] = "Prologue",
["//br.wikipedia.org"] = "Prolog",
["//ca.wikipedia.org"] = "Pròleg",
["//cs.wikipedia.org"] = "Prolog",
["//de.wikipedia.org"] = "Prolog",
["//da.wikipedia.org"] = "Prolog",
["//es.wikipedia.org"] = "Prólogo",
["//fi.wikipedia.org"] = "Prologi",
["//hu.wikipedia.org"] = "Prolog",
["//it.wikipedia.org"] = "Prologo",
["//ja.wikipedia.org"] = "プロローグ",
["//la.wikipedia.org"] = "Incipit prologus",
["//lb.wikipedia.org"] = "Prolog",
["//lv.wikipedia.org"] = "Prologs",
["//mk.wikipedia.org"] = "Пролог",
["//nl.wikipedia.org"] = "Proloog",
["//no.wikipedia.org"] = "Prolog",
["//pl.wikipedia.org"] = "Prologu",
["//pt.wikipedia.org"] = "Prólogo",
["//ro.wikipedia.org"] = "Prolog",
["//ru.wikipedia.org"] = "Пролог",
["//sk.wikipedia.org"] = "Prológ",
["//sv.wikipedia.org"] = "Prolog" }
local word = translDef[mw.site.server]
if not word then word = translDef["//fr.wikipedia.org"] end -- default
return word
end
function stageLink(x, a, b) -- x= 10a: a = 10, b = a. x = 5: a = 5, b = ""
local translDef = { ["//www.wikidata.org"] = "étape",
["//fr.wikipedia.org"] = "étape",
["//en.wikipedia.org"] = "Stage",
["//br.wikipedia.org"] = "Tennad",
["//ca.wikipedia.org"] = "Etapa",
["//cs.wikipedia.org"] = "Etapa",
["//de.wikipedia.org"] = "Etappe",
["//da.wikipedia.org"] = "Etape",
["//es.wikipedia.org"] = "Etapa",
["//fi.wikipedia.org"] = "Etappi",
["//hu.wikipedia.org"] = "Szakasz",
["//it.wikipedia.org"] = "Tappa",
["//ja.wikipedia.org"] = "ステージ",
["//la.wikipedia.org"] = "Statio",
["//lb.wikipedia.org"] = "Etapp",
["//lv.wikipedia.org"] = "Posms",
["//mk.wikipedia.org"] = "Етапа",
["//nl.wikipedia.org"] = "Etappe",
["//no.wikipedia.org"] = "Etappe",
["//pl.wikipedia.org"] = "Etap",
["//pt.wikipedia.org"] = "Etapa",
["//ro.wikipedia.org"] = "Etapa",
["//ru.wikipedia.org"] = "Этап",
["//sk.wikipedia.org"] = "Etapa",
["//sv.wikipedia.org"] = "Etapp" }
local word = translDef[mw.site.server]
local word1, word2
if not word then
word2 = translDef["//fr.wikipedia.org"] -- default
end
-- fr: {{1re}} étape, {{2e}} étape
if mw.site.server == "//www.wikidata.org" or mw.site.server == "//fr.wikipedia.org" then
if b == "" then -- series_ordinal without character
if a == "1" then word1 = "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
-- default
word1 = x -- table text = 1, 2a, 3
word2 = "#"..word.." ".. x -- text of section header = #Etappe 2a, #Stage 4
--return table text, text of section header
return word1, word2
end
function func_month(x) -- l10nDef["//.wikipedia.org"] = {"", "", "", "", "", "", "", "", "", "", "", ""}
local l10nDef = { }
l10nDef["//fr.wikipedia.org"] = {"janv.", "févr.", "mars", "avr.", "mai", "juin", "juil.", "août", "sept.", "oct.", "nov.", "déc."}
l10nDef["//en.wikipedia.org"] = {"January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"}
l10nDef["//be.wikipedia.org"] = {"studz.", "liut.", "sak.", "kras.", "mai.", "cherv.", "lip.", "zhniven'", "veras", "kastr.", "list.", "snezh."}
l10nDef["//bg.wikipedia.org"] = {"ian.", "fevr.", "mart", "april", "mai", "iuni", "iuli", "avg.", "sept.", "okt.", "noem.", "dek."}
l10nDef["//br.wikipedia.org"] = {"Genver", "C'hwevrer", "Meurzh", "Ebrel", "Mae", "Mezheven", "Gouere", "Eost", "Gwengolo", "Here", "Du", "Kerzu"}
l10nDef["//ca.wikipedia.org"] = {"gener", "febrer", "març", "abril", "maig", "juny", "juliol", "agost", "setembre", "octubre", "novembre", "desembre"}
l10nDef["//cs.wikipedia.org"] = {"led.", "ún.", "brez.", "dub.", "kvet.", "cerv.", "cerven.", "srp.", "záríj.", "ríj.", "list.", "pros."}
l10nDef["//da.wikipedia.org"] = {"jan.", "febr.", "marts", "april", "maj", "juni", "juli", "aug.", "sept.", "okt.", "nov.", "dec."}
l10nDef["//de.wikipedia.org"] = {"Jan.", "Feb.", "März", "Apr.", "Mai", "Juni", "Juli", "Aug.", "Sept.", "Okt.", "Nov.", "Dez."}
l10nDef["//es.wikipedia.org"] = {"enero", "feb.", "marzo", "abr.", "mayo", "jun.", "jul.", "agosto", "sept.", "oct.", "nov.", "dic."}
l10nDef["//et.wikipedia.org"] = {"jaan.", "veebr.", "märts", "apr.", "mai", "juuni", "juuli", "aug.", "sept.", "okt.", "nov.", "dets."}
l10nDef["//hu.wikipedia.org"] = {"jan.", "feb.", "márc.", "ápr.", "máj.", "jun.", "jul.", "aug.", "szept.", "okt.", "nov.", "dec."}
l10nDef["//id.wikipedia.org"] = {"Djan.", "Peb.", "Mrt.", "Apr.", "Mai", "Djuni", "Djuli", "Ag.", "Sept.", "Okt.", "Nop.", "Des."}
l10nDef["//it.wikipedia.org"] = {"genn.", "febbr.", "mar.", "apr.", "magg.", "giugno", "luglio", "ag.", "sett.", "ott.", "nov.", "dic."}
l10nDef["//ja.wikipedia.org"] = {"1月", "2月", "3月", "4月", "5月", "6月", "7月", "8月", "9月", "10月", "11月", "12月"}
l10nDef["//la.wikipedia.org"] = {"Ian.", "Febr.", "Mart.", "Apr.", "Mai.", "Iun.", "Iul.", "Aug.", "Sept.", "Oct.", "Nov.", "Dec."}
l10nDef["//lb.wikipedia.org"] = {"Januar", "Februar", "Mäerz", "Abrëll", "Mee", "Juni", "Juli", "August", "September", "Oktober", "November", "Dezember"}
l10nDef["//lt.wikipedia.org"] = {"saus.", "vas.", "kovas", "bal.", "geg.", "birz", "liepa", "rugp.", "rugs.", "spalis", "lapkr.", "gr."}
l10nDef["//lv.wikipedia.org"] = {"janvāris", "februāris", "marts", "aprīlis", "maijs", "jūnijs", "jūlijs", "augusts", "septembris", "oktobris", "novembris", "decembris"}
l10nDef["//mk.wikipedia.org"] = {"јануари", "февруари", "март", "април", "мај", "јуни", "јули", "август", "септември", "октомври", "ноември", "декември"}
l10nDef["//ms.wikipedia.org"] = {"Jan.", "Feb.", "Mac", "Apr.", "Mei", "Jun", "Julai", "Og", "Sept.", "Okt.", "Nov.", "Dis."}
l10nDef["//no.wikipedia.org"] = {"jan.", "feb.", "mar.", "apr.", "mai", "jun.", "jul.", "aug.", "sep.", "okt.", "nov.", "des."}
l10nDef["//nl.wikipedia.org"] = {"jan.", "feb.", "maart", "apr.", "mei", "juni", "juli", "aug.", "sept.", "okt.", "nov.", "dec."}
l10nDef["//pl.wikipedia.org"] = {"stycz.", "luty", "mar.", "kwiec.", "maj", "czerw.", "lip.", "sierp.", "wrzes.", "pazdz.", "listop.", "grudz."}
l10nDef["//pt.wikipedia.org"] = {"jan.", "fev.", "março", "abril", "maio", "junho", "julho", "agosto", "set.", "out.", "nov.", "dez."}
l10nDef["//ro.wikipedia.org"] = {"Ian.", "Feb.", "Mar.", "Apr.", "Mai", "Iun.", "Iul.", "Aug.", "Sep.", "Oct.", "Nov.", "Dec."}
l10nDef["//ru.wikipedia.org"] = {"Января", "Февраля", "Марта", "Апреля", "Мая", "Июня", "Июля", "Августа", "Сентября", "Октября", "Ноября", "Декабря"}
l10nDef["//sh.wikipedia.org"] = {"sijec.", "velj.", "ozuj.", "trav.", "svib.", "lip.", "srp.", "kol.", "ruj.", "list.", "stud.", "pros."}
l10nDef["//sk.wikipedia.org"] = {"l'ad.", "ún.", "brez.", "dub.", "kvet", "cerv.", "cerven.", "srp.", "zári.", "ruj.", "list.", "pros."}
l10nDef["//sl.wikipedia.org"] = {"jan.", "feb.", "mar.", "apr.", "maj", "jun.", "jul.", "avg.", "sept.", "okt.", "nov.", "dec."}
l10nDef["//sv.wikipedia.org"] = {"jan.", "febr.", "mars", "april", "maj", "juni", "juli", "aug.", "sept.", "okt.", "nov.", "dec."}
local l10n = l10nDef[mw.site.server]
if not l10n then l10n = l10nDef["//fr.wikipedia.org"] end -- default
return l10n[tonumber(x)]
end
function headoftable(x) -- En-tête du tableau listant les étapes
local l10nDef = { }
l10nDef["//fr.wikipedia.org"] = {"Étape", "Date", "Villes étapes", "Distance (km)", "Vainqueur d'étape", "Leader du classement général"}
l10nDef["//en.wikipedia.org"] = {"Stage", "Date", "Course", "Distance (km)", "Stage winner", "Overall leader"}
l10nDef["//br.wikipedia.org"] = {"Tennad", "Deiziad", "Kêr loc'hañ ha kêr degouezhout", "Hed (km)", "Trec'hour", "E penn ar renkamant hollek"}
l10nDef["//ca.wikipedia.org"] = {"Etapa", "Data", "Ciutats d'etapa", "Distància (km)", "Vencedor de l'etapa", "Líder de la general"}
l10nDef["//cs.wikipedia.org"] = {"Etapa", "Datum", "Trasa", "Vzdálenost (km)", "Vítěz", "Průběžný lídr"}
l10nDef["//da.wikipedia.org"] = {"Etape", "Dato", "Start – Mål", "Afstand (km)", "Etapevinder", "Den gule trøje"}
l10nDef["//de.wikipedia.org"] = {"Etappe", "Datum", "Etappenorte", "Länge (km)", "Etappensieger", "Gesamtführender"}
l10nDef["//es.wikipedia.org"] = {"Etapa", "Fecha", "Recorrido", "Distancia (km)", "Ganador", "Líder"}
l10nDef["//fi.wikipedia.org"] = {"Etappi", "Päivä", "Reitti", "Pituus (km)", "Voittaja", "Yleinen johtaja"}
l10nDef["//hu.wikipedia.org"] = {"Szakasz", "Időpont", "Végpontok", "Hossz (km)", "Szakaszgyőztes", "Általános vezető"}
l10nDef["//it.wikipedia.org"] = {"Tappa", "Data", "Percorso", "Distanza (km)", "Vincitore di tappa", "Leader cl. generale"}
l10nDef["//ja.wikipedia.org"] = {"ステージ", "開催日", "コース", "距離 (km)", "ステージ勝者", "全体リーダー"}
l10nDef["//la.wikipedia.org"] = {"Statio", "Dies", "Iter", "Distantia (km)", "Victor", "Altiore princeps"}
l10nDef["//lb.wikipedia.org"] = {"Etapp", "Datum", "Etappestied", "Längt (km)", "Gewënner", "Generalklassement"}
l10nDef["//lv.wikipedia.org"] = {"Posms", "Datums", "Maršruts", "Posma garums (km)", "Uzvarētājs", "Kopvērtējuma līderis"}
l10nDef["//mk.wikipedia.org"] = {"Етапа", "Датум", "Тек", "Растојание (км)", "Победник", "Cевкупен лидер"}
l10nDef["//nl.wikipedia.org"] = {"Etappe", "Datum", "Start – Finish", "Afstand (km)", "Winnaar", "Klassementsleider"}
l10nDef["//no.wikipedia.org"] = {"Etappe", "Dato", "Start – Målgang", "Lengde (km)", "Etappevinner", "Sammenlagtleder"}
l10nDef["//pl.wikipedia.org"] = {"Etap", "Data", "Start – Meta", "Dystans (km)", "Zwycięzca etapu", "Lider"}
l10nDef["//pt.wikipedia.org"] = {"Etapa", "Data", "Percurso", "Distância (km)", "Vencedor", "Líder geral"}
l10nDef["//ro.wikipedia.org"] = {"Etapa", "Dată", "Start – Sosire", "Distanță (km)", "Câștigător", "Liderul global"}
l10nDef["//ru.wikipedia.org"] = {"Этап", "Дата", "Маршрут", "Длина (км)", "Победитель", "Лидер генеральной классификации"}
l10nDef["//sk.wikipedia.org"] = {"Etapa", "Dátum", "Trasa", "Vzdialenosť (km)", "Víťaz", "Priebežný líder"}
l10nDef["//sv.wikipedia.org"] = {"Etapp", "Datum", "Start – mål", "Distans (km)", "Skede vinnare", "Övergripande ledare"}
l10nDef["//als.wikipedia.org"] = l10nDef["//de.wikipedia.org" ]
l10nDef["//www.wikidata.org"] = {"Étape", "Date", "Villes étapes", "Dist. (km)", "Vainqueur d'étape", "Leader du classement général"}
local l10n = l10nDef[mw.site.server]
if not l10n then l10n = l10nDef["//fr.wikipedia.org"] end -- default
return l10n[x]
end
function headoftableII(x) -- En-têtes des tableaux générant les classements
local l10nDef = { }
l10nDef["//fr.wikipedia.org"] = {"Coureur", "Pays", "Équipe", "Temps", "Points", "Classement de l'étape", "Classement général", "Classement par points", "Classement de la montagne", "Classement des sprints", "Classement du meilleur jeune", "Classement par équipes"}
l10nDef["//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["//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]
end
function headoftableIII(x) -- En-tête du tableau listant les équipes participantes (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["//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["//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]
end
function headoftableIV(x) -- En-tête du tableau du palmarès d'une course cycliste
local l10nDef = { }
l10nDef["//fr.wikipedia.org"] = {"Année", "Vainqueur", "Deuxième", "Troisième"}
l10nDef["//en.wikipedia.org"] = {"Year", "Winner", "Second", "Third"}
l10nDef["//br.wikipedia.org"] = {"Bloavezh", "1añ", "2l", "3de"}
l10nDef["//ca.wikipedia.org"] = {"Any", "Vencedor", "Segon", "Tercer"}
l10nDef["//cs.wikipedia.org"] = {"Ročník", "Vítěz", "Druhý", "Třetí"}
l10nDef["//de.wikipedia.org"] = {"Jahr", "Sieger", "Zweiter", "Dritter"}
l10nDef["//es.wikipedia.org"] = {"Año", "Ganador", "Segundo", "Tercero"}
l10nDef["//eu.wikipedia.org"] = {"Urtea", "Irabazlea", "Bigarrena", "Hirugarrena"}
l10nDef["//hu.wikipedia.org"] = {"Év", "Versenyző", "Második", "Harmadik"}
l10nDef["//it.wikipedia.org"] = {"Anno", "Vincitore", "Secondo", "Terzo"}
l10nDef["//ja.wikipedia.org"] = {"年", "優勝", "準優勝", "3位"}
l10nDef["//lb.wikipedia.org"] = {"Joer", "Gewënner", "Zweeten", "Drëtten"}
l10nDef["//lv.wikipedia.org"] = {"Gads", "Uzvarētājs", "Otrais", "Trešais"}
l10nDef["//mk.wikipedia.org"] = {"Година", "Победник", "Второпласиран", "Третопласиран"}
l10nDef["//nl.wikipedia.org"] = {"Jaar", "Winnaar", "Tweede", "Derde"}
l10nDef["//no.wikipedia.org"] = {"År", "Vinner", "Andreplass", "Tredjeplass"}
l10nDef["//pl.wikipedia.org"] = {"Rok", "Pierwsze", "Drugie", "Trzecie"}
l10nDef["//pt.wikipedia.org"] = {"Ano", "Vencedor", "Segundo", "Terceiro"}
l10nDef["//ro.wikipedia.org"] = {"An", "Câștigător", "Locul doi", "Locul trei"}
l10nDef["//ru.wikipedia.org"] = {"Год", "Победитель", "Второй", "Третий"}
l10nDef["//sr.wikipedia.org"] = {"Година", "Победник", "Други", "Трећи"}
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]
end
function typeofstage(x, typ)
-- plain, hilly, inter, ... must be "" or "any text"
-- l10nDef["//.wikipedia.org"] = {plain = "", hilly="", inter='', mount='', time_prologue='', time_team='', time_indiv='', uphill='', rest=''}
local l10nDef = { }
l10nDef["//fr.wikipedia.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'}
l10nDef["//en.wikipedia.org"] = {plain = "plain stage", hilly="hilly stage", inter='intermediate stage', mount='mountain stage', time_prologue='time trial stage', time_team='team time trial stage', time_indiv='individual time trial stage', uphill='uphill time trial stage', rest='rest day'}
l10nDef["//br.wikipedia.org"] = {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'}
l10nDef["//ca.wikipedia.org"] = {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'}
l10nDef["//cs.wikipedia.org"] = {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=''}
l10nDef["//de.wikipedia.org"] = {plain = "Flachetappe", hilly="Hügelige Etappe", inter='Mittelschwere Etappe', mount='Hochgebiergsetappe', time_prologue='Prolog', time_team='Teamzeitfahren', time_indiv='Einzelzeitfahren', uphill='Bergzeitfahren', rest='Ruhetag'}
l10nDef["//ja.wikipedia.org"] = {plain = "平坦ステージ", hilly="丘陵ステージ", inter='中間ステージ', mount='山岳ステージ', time_prologue='タイムトライアルステージ', time_team='チームタイムトライアルステージ', time_indiv='個人タイムトライアルステージ', uphill='アップヒルタイムトライアルステージ', rest='休養日'}
l10nDef["//lb.wikipedia.org"] = {plain = "Flaach Etapp", hilly="Hiwweleg Etapp", inter='Mëttelschwéier Etapp', mount='Biergetapp', time_prologue='Prolog', time_team='Contre-la-montre (Equipe)', time_indiv='Contre-la-montre (Eenzel)', uphill='Biergcourse', rest='Roudag'}
l10nDef["//lv.wikipedia.org"] = {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'}
l10nDef["//mk.wikipedia.org"] = {plain = "рамна етапа", hilly="ридеста етапа", inter='среднопланинска етапа', mount='планинска етапа', time_prologue='пролог', time_team='екипен хронометар', time_indiv='индивидуален хронометар', uphill='', rest='ден за одмор'}
l10nDef["//nl.wikipedia.org"] = {plain = "vlakke rit", hilly="heuvelrit", inter='heuvelrit', mount='bergrit', time_prologue='proloog', time_team='ploegentijdrit', time_indiv='individuele tijdrit', uphill='klimtijdrit', rest='rustdag'}
l10nDef["//no.wikipedia.org"] = {plain = "flat etappe", hilly="kupert etappe", inter='middels klatreetappe', mount='klatreetappe', time_prologue='prolog', time_team='lagtempo', time_indiv='temporitt', uphill='klatretempoetappe', rest='hviledag'}
l10nDef["//ro.wikipedia.org"] = {plain = "etapă de plat", hilly="etapă valonată", inter='etapă intermediară', mount='etapă de munte', time_prologue='prolog', time_team='contratimp pe echipe', time_indiv='contratimp individual', uphill='', rest='zi de repaus'}
l10nDef["//ru.wikipedia.org"] = {plain = "равнинный", hilly="холмистый", inter='горный', mount='высокогорный', time_prologue='пролог', time_team='командная разделка', time_indiv='индивидуальная разделка', uphill='горная разделка', rest='день отдыха'}
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
local y = ""
if x == 'plain stage' then y = "[[File:Plainstage.svg|border|right|20px|" .. l10n.plain .."]]" end
if x == 'hilly stage' then y = "[[File:Hillystage.svg|border|right|20px|" .. l10n.hilly .."]]" end
if x == 'intermediate stage' then y = "[[File:Mediummountainstage.svg|right|border|20px|" .. l10n.inter .."]]" end
if x == 'mountain stage' then y = "[[File:Mountainstage.svg|border|right|20px|" .. l10n.mount .."]]" end
--if x == 'time trial stage' then y = "[[File:Time Trial.svg|right|20px|" .. l10n.time .."]]" end
if x == 'uphill time trial stage' then y = "[[File:Mountainstage.svg|border|right|20px|" .. l10n.uphill .."]]" end
if x == 'rest day' then y = "[[File:Stage rest day.svg|border|right|20px|" .. l10n.rest .."]]" end
if x == 'time trial stage' then
if typ == 2348250 then y = "[[File:Time Trial.svg|right|20px|" .. l10n.time_team .."]]" end
if typ == 2266066 then y = "[[File:Time Trial.svg|right|20px|" .. l10n.time_indiv .."]]" end
if typ == 485321 then y = "[[File:Time Trial.svg|right|20px|" .. l10n.time_prologue .."]]" end
end
return y
end
function formatNumber (number)
-- cut off the first character, a plus sign
number = number:sub(2, -1)
if mw.site.server == "//lv.wikipedia.org" then
number = number:gsub("%.", ",")
end
return number;
end
function wdLink (id)
return "[[File:Wikidata-logo S.svg|12px|link=d:" .. id .. "]]"
end
function flag (x, date)
_, _, yr, m, d = string.find(date, "(%d+)-(%d+)-(%d+)") -- yr = year, m = month, d = day
-- yr="1970" for test
local year = tonumber(yr)
-- testing if x is the value of p27 (pays de nationalité/country of citizenship) of a person
if x == 'Q16' then return "[[File:Flag of Canada (Pantone).svg|border|20px|CAN]]" end
if x == 'Q17' then return "[[File:Flag of Japan.svg|border|20px|JPN]]" end
if x == 'Q20' then return "[[File:Flag of Norway.svg|border|20px|NOR]]" end
if x == 'Q27' then return "[[File:Flag of Ireland.svg|border|20px|IRL]]" end
if x == 'Q28' then return "[[File:Flag of Hungary.svg|border|20px|HUN]]" end
if x == 'Q29' then if year >= 1977 and year <= 1981 then return "[[File:Flag of Spain (1977 - 1981).svg|border|20px|ESP]]" end
return "[[File:Flag of Spain.svg|border|20px|ESP]]" end
if x == 'Q30' then return "[[File:Flag of the United States (Pantone).svg|border|20px|USA]]" end
if x == 'Q31' then return "[[File:Flag of Belgium (civil).svg|border|20px|BEL]]" end
if x == 'Q32' then return "[[File:Flag of Luxembourg.svg|border|20px|LUX]]" end
if x == 'Q33' then return "[[File:Flag of Finland.svg|border|20px|FIN]]" end
if x == 'Q34' then return "[[File:Flag of Sweden.svg|border|20px|SWE]]" end
if x == 'Q35' then return "[[File:Flag of Denmark.svg|border|20px|DEN]]" end
if x == 'Q36' then return "[[File:Flag of Poland.svg|border|20px|POL]]" end
if x == 'Q37' then return "[[File:Flag of Lithuania.svg|border|20px|LTU]]" end
if x == 'Q38' then if year >= 1861 and year <= 1946 then return "[[File:Flag of Italy (1861-1946) crowned.svg|border|20px|ITA]]" end
return "[[File:Flag of Italy.svg|border|20px|ITA]]" end
if x == 'Q39' then return "[[File:Flag of Switzerland (Pantone).svg|border|15px|SUI]]" end
if x == 'Q40' then return "[[File:Flag of Austria.svg|border|20px|AUT]]" end
if x == 'Q41' then return "[[File:Flag of Greece.svg|border|20px|GRE]]" end
if x == 'Q43' then return "[[File:Flag of Turkey.svg|border|20px|TUR]]" end
if x == 'Q45' then return "[[File:Flag of Portugal.svg|border|20px|POR]]" end
if x == 'Q55' then return "[[File:Flag of the Netherlands.svg|border|20px|NED]]" end
if x == 'Q77' then return "[[File:Flag of Uruguay.svg|border|20px|URU]]" end
if x == 'Q79' then return "[[File:Flag of Egypt.svg|border|20px|EGY]]" end
if x == 'Q96' then return "[[File:Flag of Mexico.svg|border|20px|MEX]]" end
if x == 'Q114' then return "[[File:Flag of Kenya.svg|border|20px|KEN]]" end
if x == 'Q115' then return "[[File:Flag of Ethiopia.svg|border|20px|ETH]]" end
if x == 'Q117' then return "[[File:Flag of Ghana.svg|border|20px|GHA]]" end
if x == 'Q142' then return "[[File:Flag of France.svg|border|20px|FRA]]" end
if x == 'Q145' then return "[[File:Flag of the United Kingdom.svg|border|20px|GBR]]" end
if x == 'Q148' then return "[[File:Flag of the People's Republic of China.svg|border|20px|CHN]]" end
if x == 'Q155' then return "[[File:Flag of Brazil.svg|border|20px|BRA]]" end
if x == 'Q159' then return "[[File:Flag of Russia.svg|border|20px|RUS]]" end
if x == 'Q176' then return "[[File:Flag of Quebec.svg|border|20px]]" end
if x == 'Q183' then return "[[File:Flag of Germany.svg|border|20px|GER]]" end
if x == 'Q184' then return "[[File:Flag of Belarus.svg|border|20px|BLR]]" end
if x == 'Q189' then return "[[File:Flag of Iceland.svg|border|20px|ISL]]" end
if x == 'Q191' then return "[[File:Flag of Estonia.svg|border|20px|EST]]" end
if x == 'Q211' then return "[[File:Flag of Latvia.svg|border|20px|LAT]]" end
if x == 'Q212' then return "[[File:Flag of Ukraine.svg|border|20px|UKR]]" end
if x == 'Q213' then return "[[File:Flag of the Czech Republic.svg|border|20px|CZE]]" end
if x == 'Q214' then return "[[File:Flag of Slovakia.svg|border|20px|SVK]]" end
if x == 'Q215' then return "[[File:Flag of Slovenia.svg|border|20px|SLO]]" end
if x == 'Q217' then return "[[File:Flag of Moldova.svg|border|20px|MDA]]" end
if x == 'Q218' then return "[[File:Flag of Romania.svg|border|20px|ROU]]" end
if x == 'Q219' then return "[[File:Flag of Bulgaria.svg|border|20px|BUL]]" end
if x == 'Q221' then return "[[File:Flag of Macedonia.svg|border|20px|MKD]]" end
if x == 'Q222' then return "[[File:Flag of Albania.svg|border|20px|ALB]]" end
if x == 'Q224' then return "[[File:Flag of Croatia.svg|border|20px|CRO]]" end
if x == 'Q225' then return "[[File:Flag of Bosnia and Herzegovina.svg|border|20px|BIH]]" end
if x == 'Q227' then return "[[File:Flag of Azerbaijan.svg|border|20px|AZE]]" end
if x == 'Q228' then return "[[File:Flag of Andorra.svg|border|20px|AND]]" end
if x == 'Q229' then return "[[File:Flag of Cyprus (1960-2006).svg|border|20px|CYP]]" end
if x == 'Q230' then return "[[File:Flag of Georgia.svg|border|20px|GEO]]" end
if x == 'Q232' then return "[[File:Flag of Kazakhstan.svg|border|20px|KAZ]]" end
if x == 'Q233' then return "[[File:Flag of Malta.svg|border|20px|MLT]]" end
if x == 'Q235' then return "[[File:Flag of Monaco.svg|border|20px|MON]]" end
if x == 'Q236' then return "[[File:Flag of Montenegro.svg|border|20px|MNE]]" end
if x == 'Q237' then return "[[File:Flag of the Vatican City.svg|border|15px|VAT]]" end
if x == 'Q238' then return "[[File:Flag of San Marino.svg|border|20px|SMR]]" end
if x == 'Q241' then return "[[File:Flag of Cuba.svg|border|20px|CUB]]" end
if x == 'Q242' then return "[[File:Flag of Belize.svg|border|20px|BIZ]]" end
if x == 'Q244' then return "[[File:Flag of Barbados.svg|border|20px|BAR]]" end
if x == 'Q252' then return "[[File:Flag of Indonesia.svg|border|20px|INA]]" end
if x == 'Q258' then return "[[File:Flag of South Africa.svg|border|20px|RSA]]" end
if x == 'Q262' then return "[[File:Flag of Algeria.svg|border|20px|ALG]]" end
if x == 'Q265' then return "[[File:Flag of Uzbekistan.svg|border|20px|UZB]]" end
if x == 'Q298' then return "[[File:Flag of Chile.svg|border|20px|CHI]]" end
if x == 'Q334' then return "[[File:Flag of Singapore.svg|border|20px|SIN]]" end
if x == 'Q347' then return "[[File:Flag of Liechtenstein.svg|border|20px|LIE]]" end
if x == 'Q398' then return "[[File:Flag of Bahrain.svg|border|20px|BRN]]" end
if x == 'Q399' then return "[[File:Flag of Armenia.svg|border|20px|ARM]]" end
if x == 'Q403' then return "[[File:Flag of Serbia.svg|border|20px|SRB]]" end
if x == 'Q408' then return "[[File:Flag of Australia (converted).svg|border|20px|AUS]]" end
if x == 'Q414' then return "[[File:Flag of Argentina.svg|border|20px|ARG]]" end
if x == 'Q419' then return "[[File:Flag of Peru.svg|border|20px|PER]]" end
if x == 'Q423' then return "[[File:Flag of North Korea.svg|border|20px|PRK]]" end
if x == 'Q424' then return "[[File:Flag of Cambodia.svg|border|20px|CAM]]" end
if x == 'Q574' then return "[[File:Flag of East Timor.svg|border|20px|TLS]]" end
if x == 'Q657' then return "[[File:Flag of Chad.svg|border|20px|CHA]]" end
if x == 'Q664' then return "[[File:Flag of New Zealand.svg|border|20px|NZL]]" end
if x == 'Q668' then return "[[File:Flag of India.svg|border|20px|IND]]" end
if x == 'Q672' then return "[[File:Flag of Tuvalu.svg|border|20px|TUV]]" end
if x == 'Q678' then return "[[File:Flag of Tonga.svg|border|20px|TGA]]" end
if x == 'Q683' then return "[[File:Flag of Samoa.svg|border|20px|SAM]]" end
if x == 'Q685' then return "[[File:Flag of the Solomon Islands.svg|border|20px|SOL]]" end
if x == 'Q686' then return "[[File:Flag of Vanuatu.svg|border|20px|VAN]]" end
if x == 'Q691' then return "[[File:Flag of Papua New Guinea.svg|border|20px|PNG]]" end
if x == 'Q695' then return "[[File:Flag of Palau.svg|border|20px|PLW]]" end
if x == 'Q697' then return "[[File:Flag of Nauru.svg|border|20px|NRU]]" end
if x == 'Q702' then return "[[File:Flag of the Federated States of Micronesia.svg|border|20px|FSM]]" end
if x == 'Q709' then return "[[File:Flag of the Marshall Islands.svg|border|20px|MHL]]" end
if x == 'Q710' then return "[[File:Flag of Kiribati.svg|border|20px|KIR]]" end
if x == 'Q711' then return "[[File:Flag of Mongolia.svg|border|20px|MGL]]" end
if x == 'Q712' then return "[[File:Flag of Fiji.svg|border|20px|FIJ]]" end
if x == 'Q717' then return "[[File:Flag of Venezuela.svg|border|20px|VEN]]" end
if x == 'Q730' then return "[[File:Flag of Suriname.svg|border|20px|SUR]]" end
if x == 'Q733' then return "[[File:Flag of Paraguay.svg|border|20px|PAR]]" end
if x == 'Q734' then return "[[File:Flag of Guyana.svg|border|20px|GUY]]" end
if x == 'Q736' then return "[[File:Flag of Ecuador.svg|border|20px|ECU]]" end
if x == 'Q739' then return "[[File:Flag of Colombia.svg|border|20px|COL]]" end
if x == 'Q750' then return "[[File:Flag of Bolivia (state).svg|border|20px|BOL]]" end
if x == 'Q754' then return "[[File:Flag of Trinidad and Tobago.svg|border|20px|TTO]]" end
if x == 'Q757' then return "[[File:Flag of Saint Vincent and the Grenadines.svg|border|20px|VIN]]" end
if x == 'Q760' then return "[[File:Flag of Saint Lucia.svg|border|20px|LCA]]" end
if x == 'Q763' then return "[[File:Flag of Saint Kitts and Nevis.svg|border|20px|SKN]]" end
if x == 'Q766' then return "[[File:Flag of Jamaica.svg|border|20px|JAM]]" end
if x == 'Q769' then return "[[File:Flag of Grenada.svg|border|20px|GRN]]" end
if x == 'Q774' then return "[[File:Flag of Guatemala.svg|border|20px|GUA]]" end
if x == 'Q778' then return "[[File:Flag of the Bahamas.svg|border|20px|BAH]]" end
if x == 'Q781' then return "[[File:Flag of Antigua and Barbuda.svg|border|20px|ANT]]" end
if x == 'Q783' then return "[[File:Flag of Honduras.svg|border|20px|HON]]" end
if x == 'Q784' then return "[[File:Flag of Dominica.svg|border|20px|DMA]]" end
if x == 'Q786' then return "[[File:Flag of the Dominican Republic.svg|border|20px|DOM]]" end
if x == 'Q790' then return "[[File:Flag of Haiti.svg|border|20px|HAI]]" end
if x == 'Q792' then return "[[File:Flag of El Salvador.svg|border|20px|ESA]]" end
if x == 'Q794' then return "[[File:Flag of Iran.svg|border|20px|IRI]]" end
if x == 'Q796' then return "[[File:Flag of Iraq.svg|border|20px|IRQ]]" end
if x == 'Q800' then return "[[File:Flag of Costa Rica.svg|border|20px|CRC]]" end
if x == 'Q801' then return "[[File:Flag of Israel.svg|border|20px|ISR]]" end
if x == 'Q804' then return "[[File:Flag of Panama.svg|border|20px|PAN]]" end
if x == 'Q805' then return "[[File:Flag of Yemen.svg|border|20px|YEM]]" end
if x == 'Q810' then return "[[File:Flag of Jordan.svg|border|20px|JOR]]" end
if x == 'Q811' then return "[[File:Flag of Nicaragua.svg|border|20px|NCA]]" end
if x == 'Q813' then return "[[File:Flag of Kyrgyzstan.svg|border|20px|KGZ]]" end
if x == 'Q817' then return "[[File:Flag of Kuwait.svg|border|20px|KUW]]" end
if x == 'Q819' then return "[[File:Flag of Laos.svg|border|20px|LAO]]" end
if x == 'Q822' then return "[[File:Flag of Lebanon.svg|border|20px|LIB]]" end
if x == 'Q826' then return "[[File:Flag of Maldives.svg|border|20px|MDV]]" end
if x == 'Q833' then return "[[File:Flag of Malaysia.svg|border|20px|MAS]]" end
if x == 'Q836' then return "[[File:Flag of Myanmar.svg|border|20px|MYA]]" end
if x == 'Q837' then return "[[File:Flag of Nepal.svg|15px|NEP]]" end
if x == 'Q842' then return "[[File:Flag of Oman.svg|border|20px|OMA]]" end
if x == 'Q843' then return "[[File:Flag of Pakistan.svg|border|20px|PAK]]" end
if x == 'Q846' then return "[[File:Flag of Qatar.svg|border|20px|QAT]]" end
if x == 'Q851' then return "[[File:Flag of Saudi Arabia.svg|border|20px|KSA]]" end
if x == 'Q854' then return "[[File:Flag of Sri Lanka.svg|border|20px|SRI]]" end
if x == 'Q858' then return "[[File:Flag of Syria.svg|border|20px|SYR]]" end
if x == 'Q863' then return "[[File:Flag of Tajikistan.svg|border|20px|TJK]]" end
if x == 'Q865' then return "[[File:Flag of the Republic of China.svg|border|20px|TPE]]" end
if x == 'Q869' then return "[[File:Flag of Thailand.svg|border|20px|THA]]" end
if x == 'Q874' then return "[[File:Flag of Turkmenistan.svg|border|20px|THM]]" end
if x == 'Q878' then return "[[File:Flag of the United Arab Emirates.svg|border|20px|UAE]]" end
if x == 'Q881' then return "[[File:Flag of Vietnam.svg|border|20px|VIE]]" end
if x == 'Q884' then return "[[File:Flag of South Korea.svg|border|20px|KOR]]" end
if x == 'Q889' then return "[[File:Flag of Afghanistan.svg|border|20px|AFG]]" end
if x == 'Q902' then return "[[File:Flag of Bangladesh.svg|border|20px|BAN]]" end
if x == 'Q912' then return "[[File:Flag of Mali.svg|border|20px|MLI]]" end
if x == 'Q916' then return "[[File:Flag of Angola.svg|border|20px|ANG]]" end
if x == 'Q917' then return "[[File:Flag of Bhutan.svg|border|20px|BHU]]" end
if x == 'Q921' then return "[[File:Flag of Brunei.svg|border|20px|BRU]]" end
if x == 'Q924' then return "[[File:Flag of Tanzania.svg|border|20px|TAN]]" end
if x == 'Q928' then return "[[File:Flag of the Philippines.svg|border|20px|PHI]]" end
if x == 'Q929' then return "[[File:Flag of the Central African Republic.svg|border|20px|CAF]]" end
if x == 'Q945' then return "[[File:Flag of Togo.svg|border|20px|TOG]]" end
if x == 'Q948' then return "[[File:Flag of Tunisia.svg|border|20px|TUN]]" end
if x == 'Q953' then return "[[File:Flag of Zambia.svg|border|20px|ZAM]]" end
if x == 'Q954' then return "[[File:Flag of Zimbabwe.svg|border|20px|ZIM]]" end
if x == 'Q958' then return "[[File:Flag of South Sudan.svg|border|20px|SSD]]" end
if x == 'Q962' then return "[[File:Flag of Benin.svg|border|20px|BEN]]" end
if x == 'Q963' then return "[[File:Flag of Botswana.svg|border|20px|BOT]]" end
if x == 'Q965' then return "[[File:Flag of Burkina Faso.svg|border|20px|BUR]]" end
if x == 'Q967' then return "[[File:Flag of Burundi.svg|border|20px|BDI]]" end
if x == 'Q970' then return "[[File:Flag of the Comoros.svg|border|20px|COM]]" end
if x == 'Q971' then return "[[File:Flag of the Republic of the Congo.svg|border|20px|CGO]]" end
if x == 'Q974' then return "[[File:Flag of the Democratic Republic of the Congo.svg|border|20px|COD]]" end
if x == 'Q977' then return "[[File:Flag of Djibouti.svg|border|20px|DJI]]" end
if x == 'Q983' then return "[[File:Flag of Equatorial Guinea.svg|border|20px|GEQ]]" end
if x == 'Q986' then return "[[File:Flag of Eritrea.svg|border|20px|ERI]]" end
if x == 'Q1000' then return "[[File:Flag of Gabon.svg|border|20px|GAB]]" end
if x == 'Q1005' then return "[[File:Flag of The Gambia.svg|border|20px|GAM]]" end
if x == 'Q1006' then return "[[File:Flag of Guinea.svg|border|20px|GUI]]" end
if x == 'Q1007' then return "[[File:Flag of Guinea-Bissau.svg|border|20px|GBS]]" end
if x == 'Q1008' then return "[[File:Flag of Côte d'Ivoire.svg|border|20px|CIV]]" end
if x == 'Q1009' then return "[[File:Flag of Cameroon.svg|border|20px|CMR]]" end
if x == 'Q1011' then return "[[File:Flag of Cape Verde.svg|border|20px|CPV]]" end
if x == 'Q1013' then return "[[File:Flag of Lesotho.svg|border|20px|LES]]" end
if x == 'Q1014' then return "[[File:Flag of Liberia.svg|border|20px|LBR]]" end
if x == 'Q1016' then return "[[File:Flag of Libya (1951).svg|border|20px|LBA]]" end
if x == 'Q1019' then return "[[File:Flag of Madagascar.svg|border|20px|MAD]]" end
if x == 'Q1020' then return "[[File:Flag of Malawi.svg|border|20px|MAW]]" end
if x == 'Q1025' then return "[[File:Flag of Mauritania.svg|border|20px|MTN]]" end
if x == 'Q1027' then return "[[File:Flag of Mauritius.svg|border|20px|MRI]]" end
if x == 'Q1028' then return "[[File:Flag of Morocco.svg|border|20px|MAR]]" end
if x == 'Q1029' then return "[[File:Flag of Mozambique.svg|border|20px|MOZ]]" end
if x == 'Q1030' then return "[[File:Flag of Namibia.svg|border|20px|NAM]]" end
if x == 'Q1032' then return "[[File:Flag of Niger.svg|border|20px|NIG]]" end
if x == 'Q1033' then return "[[File:Flag of Nigeria.svg|border|20px|NGR]]" end
if x == 'Q1036' then return "[[File:Flag of Uganda.svg|border|20px|UGA]]" end
if x == 'Q1037' then return "[[File:Flag of Rwanda.svg|border|20px|RWA]]" end
if x == 'Q1039' then return "[[File:Flag of Sao Tome and Principe.svg|border|20px|STP]]" end
if x == 'Q1041' then return "[[File:Flag of Senegal.svg|border|20px|SEN]]" end
if x == 'Q1042' then return "[[File:Flag of Seychelles.svg|border|20px|SEY]]" end
if x == 'Q1044' then return "[[File:Flag of Sierra Leone.svg|border|20px|SLE]]" end
if x == 'Q1045' then return "[[File:Flag of Somalia.svg|border|20px|SOM]]" end
if x == 'Q1049' then return "[[File:Flag of Sudan.svg|border|20px|SUD]]" end
if x == 'Q1050' then return "[[File:Flag of Swaziland.svg|border|20px|SWZ]]" end
if x == 'Q1246' then return "[[File:Flag of Kosovo.svg|border|20px|KOS]]" end
if x == 'Q8646' then return "[[File:Flag of Hong Kong.svg|border|20px|HKG]]" end
if x == 'Q15180' then return "[[File:Flag of the Soviet Union.svg|border|20px|URS]]" end
if x == 'Q16957' then return "[[File:Flag of East Germany.svg|border|20px|GDR]]" end
if x == 'Q26988' then return "[[File:Flag of the Cook Islands.svg|border|20px|COK]]" end
if x == 'Q28513' then return "[[File:Flag of Austria-Hungary (1869-1918).svg|border|20px]]" end
if x == 'Q33946' then return "[[File:Flag of the Czech Republic.svg|border|20px|TCH]]" end
if x == 'Q34020' then return "[[File:Flag of Niue.svg|border|20px]]" end
if x == 'Q34266' then return "[[File:Flag of Russia.svg|border|20px|RU1]]" end
if x == 'Q36704' then return "[[File:Flag of SFR Yugoslavia.svg|border|20px|YUG]]" end
return ""
end
return p