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

[проверена преработка][проверена преработка]
Избришана содржина Додадена содржина
update
update
Ред 1:
local p = {}
flag_table = {}
wiki = string.match(mw.site.server, "%a+")
if wiki == "www" then available, translations = pcall( require, "Module:Cycling race-WD" )
else available, translations = pcall( require, "Module:Cycling race/lang" )
end
 
function victories_translate(wiki,x)
l10nDef["fr"] = {"Date", "Course", "Pays", "Classe", "Vainqueur"}
l10nDef["en"] = {"Date", "Race", "Country", "Class", "Winner"}
l10nDef["da"] = {"Dato", "Løb", "Land", "Klasse", "Vinder"}
l10nDef["es"] = {"Fecha", "Carrera", "País", "Clase", "Ganador"}
l10nDef["no"] = {"Dato", "Løp", "Land", "Klasse", "Vinner"}
local l10n = l10nDef[wiki]
if not l10n then l10n = l10nDef["fr"] end -- default
return l10n[x]
end
 
function stageinfobox_translate(wiki,x)
-- This function permits to translate fields of the infobox for stages. Take the line below, give a Wikipedia (ex : mk), and translate all fields. By default, English values are taken.
local l10nDef = { }
l10nDef["fr"] = {"Généralités", "Course", "Type", "Date", "Dates", "Distance", "Pays", "Pays", "Lieu de départ", "Lieu d'arrivée", "Partants",
"Arrivants", "Vitesse moyenne", "Coût", "Résultats de l’étape", "Vainqueur", "Deuxième", "Troisième", "Combatif",
"Classement général à l’issue de l’étape", "Leader", "Deuxième", "Troisième",
"Classements annexes à l’issue de l’étape", "Points", "Montagne", "Sprints", "Jeune", "Super- combatif", "Combiné", "Étapes volantes", "Régularité",
"Équipe", "Équipe aux points",
"Image", "Légende", "Carte", "Vue en coupe", "Documentation", "Cima Coppi", "Cima Pantani", "Azzurri d'Italia", "Fuga Pinarello"}
l10nDef["en"] = {"Race details", "Race", "Type", "Date", "Dates", "Distance", "Country", "Countries", "Journey origin", "Lieu d'arrivée", "Starting riders",
"Arriving riders", "Average speed", "Cost", "Stage results", "Winner", "Second", "Third", "Combative",
"General classification after stage", "Leader", "Second", "Third",
"Secondary classifications after stage", "Points", "Mountain", "Sprints", "Young", "Combativity", "Combinated", "Metas volantes", "Regularity",
"Team", "Team by points",
"Image", "Legend", "Card", "Sectional view", "Documentation", "Cima Coppi", "Cima Pantani", "Azzurri d'Italia", "Fuga Pinarello"}
l10nDef["ca"] = {"Detalls de la cursa", "Cursa", "Tipus", "Data", "Dates", "Distància", "País", "Països", "Origen de la cursa", "Lloc d’arribada", "Corredors sortits",
"Corredors arrivats", "Velocitat mitjana", "Duració", "Resultats de l’etapa", "Guanyador", "Segon", "Tercer", "Combatiu",
"Classificació general després de l'etapa", "Líder", "Segon", "Tercer",
"Classificacions secundàries després de l'etapa ", "Punts", "Muntanya", "Esprints ", "Jove", "Combativitat", "Combinada", "Metes volants", "Regularitat",
"Equip", "Equip per punts",
"Image", "Legend", "Card", "Sectional view", "Documentation", "Cima Coppi", "Cima Pantani", "Azzurri d'Italia", "Fuga Pinarello"}
l10nDef["da"] = {"Etapedetaljer", "Rute", "Type", "Dato", "Datoer", "Distance", "Land", "Lande", "Startby", "Målby", "Startende ryttere",
"Fuldførende ryttere", "Gennemsnitlig fart", "Omkostninger", "Etaperesultat", "Vinder", "Toer", "Treer", "Mest angrebsivrige",
"Samlede stilling efter etapen", "Førende rytter", "Toer", "Treer",
"Klassementerne efter etapen", "Point", "Bjerg", "Sprint", "Ungdom", "Mest angrebsivrige", "Kombination", "Indlagt spurt", "Regularitet",
"Hold", "Hold efter point",
"Billede", "Billedtekst", "Kort", "Profil", "Dokumentation", "Cima Coppi", "Cima Pantani", "Azzurri d'Italia", "Fuga Pinarello"}
l10nDef["es"] = {"Detalles de la carrera", "Carrera", "Tipo", "Fecha", "Fechas", "Distancia", "País", "Países", "Lugar de inicio", "Lugar de llegada", "Ciclistas participantes",
"Ciclistas finalizados", "Velocidad media", "Duración", "Resultados de la etapa", "Ganador", "Segundo", "Tercero", "Combativo",
"Clasificación general después de la etapa", "Líder", "Segundo", "Tercero",
"Clasificaciones secundarias despúes de la etapa", "Puntos", "Montaña", "Esprint", "Joven", "Combatividad", "Combinada", "Metas volantes", "Regularidad",
"Equipo", "Equipo por puntos",
"Imagen", "Leyenda", "Card", "Sectional view", "Documentation", "Cima Coppi", "Cima Pantani", "Azzurri d'Italia", "Fuga Pinarello"}
l10nDef["no"] = {"Etappedetaljer", "Etappe", "Type", "Dato", "Datoer", "Distanse", "Land", "Land", "Startby", "Målby", "Startende ryttere",
"Fullførende ryttere", "Snittfart", "Omkostninger", "Etapperesultat", "Vinner", "Toer", "Treer", "Mest offensive rytter",
"Sammenlagtstilling etter etappen", "Sammenlagtleder", "Toer", "Treer",
"Klassifisering etter etappen", "Poengtrøye", "Klatretrøye", "Sprinttrøye", "Ungdomstrøye", "Mest offensive rytter", "Kombinasjonstrøye", "Étapes volantes", "Régularité",
"Lagkonkurranse", "Lagkonkurranse etter poeng",
"Bilde", "Bildetekst", "Kart", "Profil", "Dokumentasjon", "Cima Coppi", "Cima Pantani", "Azzurri d'Italia", "Fuga Pinarello"}
l10nDef["pt"] = {"Detalhes da corrida", "Corrida", "Tipo", "Data", "Datas", "Distância", "País", "Países", "Origem da viagem", "Local de chegada", "Partida dos ciclistas",
"Chegada dos ciclistas", "Velocidade média", "Custo", "Resultados da etapa", "Vencedor", "Segundo", "Terceiro", "Combativo",
"Classificação geral após a etapa", "Líder", "Segundo", "Terceiro",
"Classificação secundária após a etapa", "Pontos", "Montanha", "Corridas de velocidade", "Jovem", "Combatividade", "Combinados", "Metas volantes", "Regularidade",
"Equipe", "Equipe por pontos",
"Imagem", "Legenda", "Ficha", "Vista secional", "Documentação", "Cima Coppi", "Cima Pantani", "Azzurri d'Italia", "Fuga Pinarello"}
l10nDef["nl"] = {"Race details", "Wedstrijd", "Soort", "Datum", "Datums", "Afstand", "Land", "Landen", "Start van de etappe", "Aankomstplaats", "Coureurs aan de start",
"Coureurs bij de finish", "Gemiddelde snelheid", "Kosten", "Etappeuitslag", "Winnaar", "Tweede", "Derde", "Combative",
"Algemeen klassement na de etappe", "Leider", "Tweede", "Derde",
"Bijkomende uitslagen na de wedstrijd", "Punten", "Berg", "Sprints", "Jongeren", "Combativity", "Combinatie", "Metas volantes", "Regularity",
"Team", "Team by points",
"Afbeelding", "Legend", "Card", "Sectional view", "Documentation", "Cima Coppi", "Cima Pantani", "Azzurri d'Italia", "Fuga Pinarello"}
 
local l10n = l10nDef[wiki]
if not l10n then l10n = l10nDef["fr"] end -- default
return l10n[x]
end
 
function headoftableIII(wiki,x) -- En-tête du tableau listant les équipes participantes (P1923)
local l10nDef = { }
l10nDef["fr"] = {"Nom de l'équipe", "Pays", "Code", "WorldTeam", "WorldTeams", "ProTeam", "ProTeams", "Équipe continentale professionnelle", "Équipes continentales professionnelles", "Équipe continentale", "Équipes continentales", "Équipe nationale", "Équipes nationales", "Équipe régionale et de club", "Équipes régionales et de clubs", "Équipe cycliste professionnelle", "Équipes cyclistes professionnelles", "Équipe cycliste amateur", "Équipes cyclistes amateurs", "Groupe sportif I", "Groupes sportifs I", "Groupe sportif II", "Groupes sportifs II", "Groupe sportif III", "Groupes sportifs III", "Équipe mixte", "Équipes mixtes", "Équipe féminine professionnelle", "Équipes féminines professionnelles"}
l10nDef["en"] = {"Team name", "Country", "Code", "WorldTeam", "WorldTeams", "ProTeam", "ProTeams", "Professional continental team", "Professional continental teams", "Continental team", "Continental teams", "National team", "National teams", "Regional and club team", "Regional and club teams", "Professional cycling team", "Professional cycling teams", "Amateur cycling team", "Amateur cycling teams", "Groupe sportif I", "Groupes sportifs I", "Groupe sportif II", "Groupes sportifs II", "Groupe sportif III", "Groupes sportifs III", "Mixt team", "Mixt teams", "Professional woman team", "Professional women teams"}
l10nDef["br"] = {"Anv skipailh", "Bro", "Kod", "WorldTeam", "WorldTeams", "ProTeam", "ProTeams", "Skipailh kevandir a-vicher", "Skipailhoù kevandir a-vicher", "Skipailh kevandir", "Skipailhoù kevandir", "Skipailh bro", "Skipailhoù bro", "Skipailh rannvro ha klub", "Skipailhoù rannvro ha club", "Skipailh marc'h-houarn a-vicher", "Skipailhoù marc'h-houarn a-vicher", "Skipailh marc'h-houarn amatour", "Skipailhoù marc'h-houarn amatour", "Strollad sport I", "Strolladoù sport I", "Strollad sport II", "Strolladoù sport II", "Strollad sport III", "Strolladoù sport III", "Skipailh kemmesk", "Skipailhoù kemmesk", "Skipailh merc'hed", "Skipailhoù merc'hed"}
l10nDef["ca"] = {"Nom de l'equip", "País", "Codi", "WorldTeam", "WorldTeams", "ProTeam", "ProTeams", "Equip continental professional", "Equips continentals professionals", "Equip continental", "Equips continentals", "Equip nacional", "Equips nacionals", "Equip regional i de club", "Equips regionals i de clubs", "Equip ciclista professional", "Equips ciclistes professionals", "Equip ciclista amateur", "Equips ciclistes amateurs", "Grup esportiu I", "Grups esportius I", "Grup esportiu II", "Grups esportius II", "Grup esportiu III", "Grups esportius III", "Equip mixt", "Equips mixtos", "Equip femení", "Equips femenins"}
l10nDef["da"] = {"Holdnavn", "Land", "Kode", "WorldTeam", "WorldTeams", "ProTeam", "ProTeams", "Professionelt kontinentalhold", "Professionelle kontinentalhold", "Kontinentalhold", "Kontinentalhold", "Landshold", "Landshold", "Regional- og klubhold", "Regional- og klubhold", "Prohold", "Prohold", "Amatørhold", "Amatørhold", "Sportsgruppe I", "Sportsgruppe I", "Sportsgruppe II", "Sportsgruppe II", "Sportsgruppe III", "Sportsgruppe III", "Mix-hold", "Mix-hold", "Kvindehold", "Kvindehold"}
l10nDef["de"] = {"Team", "Land", "Code", "WorldTeam", "WorldTeams", "ProTeam", "ProTeams", "Professional Continental Team", "Professional Continental Teams", "Continental Team", "Continental Teams", "Nationalmannschaft", "Nationalmannschaften", "Regionale Teams und Vereine", "Regionale Teams und Vereine", "Profi-Radsportteam", "Profi-Radsportteams", "Amateurmannschaft", "Amateurmannschaften", "Groupe Sortif I", "Groupes Sportifs I", "Groupe Sportif II", "Groupes Sportifs II", "Groupe Sportif III", "Groupes Sportifs III", "Mixed Team", "Mixed Teams", "Profi-Radsportteam der Frauen", "Profi-Radsportteams der Frauen"}
l10nDef["eo"] = {"Nomo de la teamo", "Lando", "Kodo", "Monda teamo", "Mondaj teamoj", "ProTeamo", "ProTeamoj", "Profesiista kontinenta teamo", "Profesiistaj kontinentaj teamoj", "Kontinenta teamo", "Kontinentaj teamoj", "Nacia teamo", "Naciaj teamoj", "Regiona aux kluba teamo", "Regionaj aux klubaj teamoj", "Profesiista bicikla teamo", "Profesiistaj biciklaj teamoj", "Amatora bicikla teamo", "Amatoraj biciklaj teamoj", "Sporta grupo 1", "Sportaj grupoj 1", "Sporta grupo 2", "Sportaj grupoj 2", "Sporta grupo 3", "Sportaj grupoj 3", "Miksa teamo", "Miksaj teamoj", "Ina teamo", "Inaj teamoj"}
l10nDef["es"] = {"Nombre del equipo", "País", "Código", "WorldTeam", "WorldTeams", "ProTeam", "ProTeams", "Equipo continental profesional", "Equipos continentales profesionales", "Equipo continental", "Equipos continentales", "Equipo nacional", "Equipos nacionales", "Equipo regional y de club", "Equipos regionales y de clubes", "Equipo ciclista profesional", "Equipos ciclistas profesionales", "Equipo ciclista aficionado", "Equipos ciclistas aficionados", "Grupo deportivo I", "Grupos deportivos I", "Grupo deportivo II", "Grupos deportivos II", "Grupo deportivo III", "Grupos deportivos III", "Equipo mixto", "Equipos mixtos", "Equipo femenino", "Equipos femeninos"}
l10nDef["eu"] = {"Taldearen izena", "Herrialdea", "Kodea", "Munduko taldea", "Munduko taldeak", "Pro taldea", "Pro taldeak", "Kontinenteko talde profesionala", "Kontinenteko talde profesionala", "Kontinenteko taldea", "Kontinenteko taldeak", "Estatuko taldea", "Estatuko taldeak", "Eskualdeko eta klubeko taldea", "Eskualdeko eta klubeko taldeak", "Txirrindulari talde profesionala", "Txirrindulari talde profesionalak", "Txirrindulari talde amateurra", "Txirrindulari talde amateurrak", "I. mailako kirol taldea", "I. mailako kirol taldeak", "II. mailako kirol taldea", "II. mailako kirol taldeak", "III. mailako kirol taldea", "III. mailako kirol taldeak", "Talde mistoa", "Talde mistoak", "Emakume taldea", "Emakume taldeak"}
l10nDef["fi"] = {"Joukkueen nimi", "Maa", "Koodi", "WorldTeam", "WorldTeams", "ProTeam", "ProTeams", "Professional continental -joukkue", "Professional continental -joukkueet", "Continental-joukkue", "Continental-joukkueet", "Maajoukkue", "Maajoukkueet", "Alue- ja seurajoukkue", "Alue- ja seurajoukkueet", "Ammattilaispyöräilytalli", "Ammattilaispyöräilytallit", "Amatööripyöräilytalli", "Amatööripyöräilytallit", "Groupe sportif I", "Groupes sportifs I", "Groupe sportif II", "Groupes sportifs II", "Groupe sportif III", "Groupes sportifs III", "Mixt team", "Mixt teams", "Naisten ammattilaisjoukkue", "Naisten ammattilaisjoukkueet"}
l10nDef["fo"] = {"Liðnavn", "Land", "Kota", "WorldTeam", "WorldTeams", "ProTeam", "ProTeams", "Professionelt kontinentallið", "Professionel kontinentallið", "Kontinentallið", "Kontinental lið", "Landslið", "Landslið", "Regional- og klublið", "Regional- og felagslið", "Prolið", "Prolið", "Amatørlið", "Amatørlið", "Ítróttarbólkur I", "Ítróttarbólkur I", "Ítróttarbólkur II", "Ítróttarbólkur II", "Ítróttarbólkur III", "Ítróttarbólkur III", "Blandaðlið", "Blandaðlið", "Kvinulið", "Kvinnulið"}
l10nDef["lb"] = {"Equippennumm", "Land", "Code", "WorldTeam", "WorldTeams", "ProTeam", "ProTeams", "Professionell Kontinentalequipe", "Professionell Kontinentalequippen", "Kontinentalequipe", "Kontinentalequippen", "Nationalequipe", "Nationalequippen", "Regional- a Klubequipe", "Regional- a Klubequippen", "Professionell Vëlosequipe", "Professionell Vëlosequippen", "Amateursequipe", "Amateursequippen", "Sportsgrupp I", "Sportsgruppen I", "Sportsgrupp II", "Sportsgruppen II", "Sportsgrupp III", "Sportsgruppen III", "Gemëscht Equipe", "Gemëscht Equippen", "Dammenequipe", "Dammenequippen"}
l10nDef["nl"] = {"Teamnaam", "Land", "Code", "WorldTeam", "WorldTeams", "ProTeam", "ProTeams", "Professional continental team", "Professional continental teams", "Continental team", "Continental teams", "National team", "National teams", "Regional and club team", "Regional and club teams", "Professional cycling team", "Professional cycling teams", "Amateurteam", "Amateurteams", "Groupe sportif I", "Groupes sportifs I", "Groupe sportif II", "Groupes sportifs II", "Groupe sportif III", "Groupes sportifs III", "Gemengd team", "Gemengde teams", "Professioneel vrouwenteam", "Professionele vrouwenteams"}
l10nDef["no"] = {"Lagnavn", "Land", "Kode", "WorldTeam", "WorldTeams", "ProTeam", "ProTeams", "Profesjonelt kontinentallag", "Profesjonelle kontinentallag", "Kontinentallag", "Kontinentale lag", "Nasjonallag", "Nasjonale lag", "Équipe régionale et de club", "Équipes régionales et de clubs", "Profflag", "Profflag", "Amatørlag", "Amatørlag", "Sportsgruppe I", "Sportsgruppe I", "Sportsgruppe II", "Sportsgruppe II", "Sportsgruppe III", "Sportsgruppe III", "Mix-lag", "Mix-lag", "Kvinnelag", "Kvinnelag"}
l10nDef["pt"] = {"Nome da equipe", "País", "Código", "Equipe WorldTeam", "Equipes WorldTeam", "Equipe ProTeam", "Equipes ProTeam", "Equipe profissional Continental", "Equipes profissionais Continentais", "Equipe Continental", "Equipes Continentais", "Equipe nacional", "Equipes nacionais", "Equipe regional e clube", "Equipes regionais e clubes", "Equipe profissional de ciclismo", "Equipes profissionais de ciclismo", "Equipe amadora de ciclismo", "Equipes amadoras de ciclismo", "Grupo esportivo I", "Grupos esportivos I", "Grupo esportivo II", "Grupos esportivos II", "Grupo esportivo III", "Grupos esportivos III", "Equipe mista", "Equipes mistas", "Equipe feminina profissional", "Equipes femininas profissionais"}
l10nDef["ro"] = {"Numele echipei", "Țară", "Cod", "WorldTeam", "WorldTeams", "ProTeam", "ProTeams", "Echipă continentală profesionistă", "Echipe continentale profesioniste", "Echipă continentală", "Echipe continentale", "Echipă națională", "Echipe naționale", "Echipă regională și de club", "Echipe regionale și de club", "Echipă ciclistă profesionistă", "Echipe cicliste profesioniste", "Echipă ciclistă de amatori", "Echipe cicliste de amatori", "Grup sportiv I", "Grupuri sportive I", "Grup sportiv II", "Grupuri sportive II", "Grup sportiv III", "Grupuri sportive III", "Echipă mixtă", "Echipe mixte", "Echipă feminină", "Echipe feminine"}
l10nDef["ru"] = {"Команда", "Страна", "Код", "WorldTeam", "WorldTeams", "ProTeam", "ProTeams", "Профессиональная континентальная команда", "Профессиональные континентальные команды", "Континентальная команда", "Континентальные команды", "Национальная команда", "Национальные команды", "Региональная команда или клуб", "Региональные команды и клубы", "Профессиональная велокоманда", "Профессиональные велокоманды", "Любительская велокоманда", "Любительские велокоманды", "Groupe sportif I", "Groupes sportifs I", "Groupe sportif II", "Groupes sportifs II", "Groupe sportif III", "Groupes sportifs III", "Смешанная велокоманда", "Смешанные велокоманды", "Профессиональная женская велокоманда", "Профессиональные женские велокоманды"}
l10nDef["www"] = l10nDef["fr"]
 
return l10nDef[wiki][x]
end
 
function jersey(wiki, winner_classification, item, timeofrace)
local jersey, jersey_name = '', ''
local jerseyWPID = ''
local starttime, endtime = '', '+2500'
local a1, b1
if wiki == 'www' then wiki = 'fr' end
 
-- 1. Item of race, e.g. Tour de France = 'Q33881'
-- 2. type of winner, names are the ones in variable t_s
-- 3. and 4. start and end time. '+2500' means year 2500. Always beginning with a '+'
-- 5. item of the jersey
-- 6. item of the Wikipedia article of that jersey
local data={{'Q33881', 'montagne', '+1975', '+2500', 'Q25265958', 'Q927157'}, -- Tour de France
{'Q33881', 'leader', '+1919', '+2500', 'Q24257871', 'Q738903'},
{'Q33881', 'points', '+1953', '+1967', 'Q24645209', 'Q175399'}, -- Jersey green.svg
{'Q33881', 'points', '+1968', '+1968', 'Q26919974', 'Q175399'}, -- Jersey red.svg
{'Q33881', 'points', '+1969', '+2500', 'Q24645209', 'Q175399'}, -- Jersey green.svg
{'Q33881', 'jeune', '+1975', '+2500', 'Q24645383', 'Q2254180'}, -- Jersey white.svg
{'Q33881', 'winner_fighting', '+2003', '+2500', 'Q27644113', 'Q2094179'}, -- Jersey red number.svg
{'Q33881', 'winner_fighting2', '+2003', '+2500', 'Q27644113', 'Q2094179'}, -- Jersey red number.svg
{'Q33881', 'equipe', '+2006', '+2500', 'Q27644112', 'Q1436680'}, -- Jersey yellow number.svg
{'Q33861', 'leader', '+1931', '+2500', 'Q24257763', 'Q1164275'}, -- Giro d'Italia, Jersey pink.svg
{'Q33861', 'points', '+1967', '+1968', 'Q26919974', 'Q641083'}, -- Jersey red.svg
{'Q33861', 'points', '+1969', '+2009', 'Q26945272', 'Q641083'}, -- Jersey violet.svg
{'Q33861', 'points', '+2010', '+2500', 'Q26919974', 'Q641083'}, -- Jersey red.svg
{'Q33861', 'montagne', '+1974', '+2011', 'Q24645209', 'Q641060'}, -- Jersey green.svg
{'Q33861', 'montagne', '+2012', '+2500', 'Q24687409', 'Q641060'}, -- Jersey blue.svg
{'Q33861', 'jeune', '+1976', '+2500', 'Q24645383', 'Q641662'}, -- Jersey white.svg
{'Q33937', 'leader', '+1935', '+1936', 'Q24258056', 'Q3278226'}, -- Vuelta a España, Jersey orange.svg
{'Q33937', 'leader', '+1941', '+1941', 'Q26696171', 'Q640430'}, -- Jersey white.svg
{'Q33937', 'leader', '+1942', '+1942', 'Q24258056', 'Q3278226'}, -- Jersey orange.svg
{'Q33937', 'leader', '+1945', '+1945', 'Q24257872', 'Q2534046'}, -- Jersey red.svg
{'Q33937', 'leader', '+1946', '+1950', 'Q26696171', 'Q640430'}, -- Jersey white.svg
{'Q33937', 'leader', '+1955', '+1976', 'Q24257871', 'Q738903'}, -- Jersey yellow.svg
{'Q33937', 'leader', '+1977', '+1977', 'Q24258056', 'Q3278226'}, -- Jersey orange.svg
{'Q33937', 'leader', '+1978', '+1998', 'Q24257871', 'Q738903'}, -- Jersey yellow.svg
{'Q33937', 'leader', '+1999', '+2009', 'Q24257991', 'Q27665179'}, -- Jersey gold.svg
{'Q33937', 'leader', '+2010', '+2500', 'Q24257872', 'Q2534046'}, -- Jersey red.svg
{'Q33937', 'points', '+1945', '+1986', 'Q24687409', 'Q2746711'}, -- Jersey blue.svg
{'Q33937', 'points', '+1987', '+1989', 'Q24645209', 'Q11638007'}, -- Jersey green.svg
{'Q33937', 'points', '+1990', '+2009', 'Q24687409', 'Q2746711'}, -- Jersey blue.svg
{'Q33937', 'points', '+2010', '+2500', 'Q24645209', 'Q11638007'}, -- Jersey green.svg
{'Q33937', 'montagne', '+1935', '+1985', 'Q27670182', 'Q11638007'}, -- Jersey green.svg
{'Q33937', 'montagne', '+1986', '+1986', 'Q27670174', 'Q3278226'}, -- Jersey orange.svg
{'Q33937', 'montagne', '+1987', '+1987', 'Q27670178', 'Q2534046'}, -- Jersey red.svg
{'Q33937', 'montagne', '+1988', '+1989', 'Q27670105', 'Q27670115'}, -- Jersey blackdots.png
{'Q33937', 'montagne', '+1990', '+2005', 'Q27670182', 'Q11638007'}, -- Jersey green.svg
{'Q33937', 'montagne', '+2006', '+2008', 'Q27670174', 'Q3278226'}, -- Jersey orange.svg
{'Q33937', 'montagne', '+2009', '+2009', 'Q27670126', 'Q27670163'}, -- Jersey granate.svg
{'Q33937', 'montagne', '+2010', '+2500', 'Q25265959', 'Q27670167'}} -- Jersey bluedots.svg
--timeofrace = '+1968-07-01T00:00:00Z'
timeofrace = string.sub(timeofrace, string.find(timeofrace, "+%d%d%d%d"))
for k, v in pairs(item) do
for key, value in pairs(data) do
if v == value[1] then
if winner_classification == value[2] then
if (timeofrace >= value[3]) and (timeofrace <= value[4]) then
jersey = value[5]
jerseyWPID = value[6]
end
end
end
end
end
 
if jersey~='' then --and (timeofrace > starttime) and (timeofrace < endtime) then
local entity_jersey = mw.wikibase.getEntity(jersey)
jersey = entity_jersey.claims['P18'][1].mainsnak.datavalue.value
jersey_name = entity_jersey:getLabel(wiki) or entity_jersey:getLabel('en') or ''
if jerseyWPID~= '' then
local entity = mw.wikibase.getEntity( jerseyWPID )
local Sitelink = entity:getSitelink(wiki..'wiki') -- link to WParticle
if Sitelink~= nil then jerseyWPID = wiki..':'..Sitelink else jerseyWPID = '' end
end
return jersey, jersey_name, jerseyWPID
else return '', '', ''
end
end
 
function p.stageinfobox(frame)
local vvv= ''
local tab
local wiki = string.match(mw.site.server, "%a+")
local entityId = frame.args[1]
local lang = mw.language.getContentLanguage()
local timeofrace
local a1, b1, c1, a2, b2, a3, b3
local jerseyWPID, jersey_name
local t_g = {show=true, name='', icon='', picture='', caption='', course= '', race={}, is_a='', startplace='', endplace='', time='',
length='', length_unit='', speed='', speed_unit='', nr_participants_start="", nr_participants_end='', country={},
series_ordinal_previous="", series_ordinal_next="", map='', sectional_view='',previous="", next=""}
local t_s = {order={'results', 'classement_gen', 'classement_annex'},
results={show=false, header=15, order = {'first','second','third','winner_fighting','winner_fighting2','cima_coppi','cima_pantani'},
-- name rider, stageinfobox_translate number, gender, jersey, team name, time, time gap, points, speed, rank
first={"", 16, "", '', "", "", '', '', '', ''},
second={"", 17, "", '', '', "", '', '', '', ''},
third={"", 18, "", '', '', "", '', '', '', ''},
winner_fighting={"", 19, "", '', '', '', '', '', '', ''},
winner_fighting2={"", 19, "", '', '', '', '', '', '', ''}, -- two winner_fighting possible
cima_coppi={"", 40, "", '', '', '', '', '', '', ''},
cima_pantani={"", 41, "", '', '', '', '', '', '', ''}},
classement_gen={show=false, header=20, order = {"leader", "deuxieme", "troisieme"},
-- name rider, stageinfobox_translate number, gender, jersey, team name, time, time gap, points, speed, rank
leader={"", 21, "", '', "", "", '', '', '', ''},
deuxieme={"", 22, "", '', '', "", '', '', '', ''},
troisieme={"", 23, "", '', '', "", '', '', '', ''}},
 
classement_annex={show=false, header=24, order={"points","montagne","sprints","jeune","super_combatif","combine",
"stage_volantes","regularite","azzurri_ditalia","fuga_pinarello","equipe","equipe_points"},
-- name rider, stageinfobox_translate number, gender, jersey, team name, time, time gap, points, speed, rank
points={"", 25, "", '', "", '', "", '', '', ''},
montagne={"", 26, "", '', '', '', "", '', '', ''},
sprints={"", 27, "", '', '', '', "", '', '', ''},
jeune={"", 28, "", '', '', '', '', '', '', ''},
super_combatif={"", 29, "", '', "", "", '', '', '', ''},
combine={"", 30, "", '', '', "", '', '', '', ''},
stage_volantes={"",31,'','','','','','', '', ''},
regularite={"",32,'','','','','','', '', ''},
azzurri_ditalia={"",42,'','','','','','', '', ''},
fuga_pinarello={"",43,'','','','','','', '', ''},
equipe={"", 33, "", '', '', "", '', '', '', ''},
equipe_points={"", 34, "", '', '', '', '', '', '', ''}}
}
 
if type( entityId ) ~= 'string' then error( 'parameter must be a string') end
if not entityId:match( 'Q%d+' ) then error ( 'parameter must be a valid Wikidata item (ex: Q42)' ) end
local entity = mw.wikibase.getEntity( entityId )
 
if entity:getLabel() ~= nil then t_g.name = entity:getLabel()
else t_g.name = entity:getLabel() or entity:getLabel('en') or '' end
if wiki == 'fr' and t_g.name ~= '' then t_g.name= mw.ustring.gsub(t_g.name, "^(%d+)([re]+)", "%1<sup>%2</sup> ") end
t_g.name= mw.ustring.gsub(t_g.name, "^(%a)",function (x) return mw.ustring.upper(x) end)
a1, b1 = pcall(fooA, 'numeric-id', entity, 'P31', 1) -- If stage is a "stage" or a timetrial stage
if a1 == true and b1~=18131152 then t_g.is_a = 'Q'.. b1 end
 
if t_g.is_a=='Q2266066' or t_g.is_a=='Q2348250' or t_g.is_a=='Q485321' then t_g.icon = " [[File:Cycling (track) pictogram.svg|35px]]"
else t_g.icon = " [[File:Cycling (road) pictogram.svg|35px]]" end
 
a1, b1 = pcall(fooA, 'value', entity, 'P18', 1) -- picture, legende
if a1 == true and t_g.picture == "" then
local v
t_g.picture = b1
if pcall(foo3, entity, "P18", 1, "P2096", 1) then
for _, v in pairs(entity.claims["P18"]) do
pcall(function()
for num=1,#v.qualifiers["P2096"] do -- find right language
if v.qualifiers["P2096"][num].datavalue.value.language == lang:getCode() then
t_g.caption = v.qualifiers["P2096"][num].datavalue.value.text end
end
end)
end
end
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_g.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_g.startplace = "Q" .. b1
end
-- Function that give the finishing place of a race
a1, b1, c1 = pcall(fooA, 'numeric-id', entity, 'P1444', 1)
if a1 == true and t_g.endplace == "" then i = 1
while a1 == true and c1 == 'deprecated' do
i = i + 1
a1, b1, c1 = pcall(fooA, 'numeric-id', entity, 'P1444', i)
end
t_g.endplace = "Q" .. b1
end
 
-- This function give a format to dates when P585 (date) is used in a single day race
a1, b1, c1 = pcall(fooA, 'time', entity, 'P585', 1)
if a1 == true and t_g.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_g.time = func_date (b1, wiki, 'long')
timeofrace = b1
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_g.nr_participants_start == "" and t_g.nr_participants_end == "" then i = 1
while a1 == true and c1 == 'deprecated' do
i = i + 1
a1, b1, c1 = pcall(fooA, 'amount', entity, 'P1132', i)
end
local v
for _, v in pairs(entity.claims["P1132"]) do
if pcall(function()
if v.qualifiers["P276"][1].datavalue.value["numeric-id"] == 529711 then
t_g.nr_participants_start = string.gsub(v.mainsnak.datavalue.value.amount, "+", "") end
end
) then else t_g.nr_participants_start = "" end
if pcall(function()
if v.qualifiers["P276"][1].datavalue.value["numeric-id"] == 12769393 then
t_g.nr_participants_end = string.gsub(v.mainsnak.datavalue.value.amount, "+", "") end
end
) then else t_g.nr_participants_end = "" end
end
end
 
-- 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_g.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_g.length = b1
a1, b1, _ = pcall(fooA, 'unit', entity, 'P2043', 1)
if b1 == "http://www.wikidata.org/entity/Q828224" then
t_g.length_unit = 'km'
if wiki == "mk" then t_g.length_unit = 'км' end
if wiki == "ru" then t_g.length_unit = 'км' end
if wiki == "ja" then t_g.length_unit = 'キロメートル' end
end
end
-- This function permits to display an unity (the kilometer per hour) for an average speed, with exceptions for macedionan, russian and japanese
-- that have other symbols
a1, b1, c1 = pcall(fooA, 'amount', entity, 'P2052', 1)
if a1 == true and t_g.speed == "" then i = 1
while a1 == true and c1 == 'deprecated' do
i = i + 1
a1, b1, c1 = pcall(fooA, 'amount', entity, 'P2052', i)
end
t_g.speed = b1
a1, b1 = pcall(fooA, 'unit', entity, 'P2052', 1)
if b1 == "http://www.wikidata.org/entity/Q180154" then
t_g.speed_unit = 'km/h'
if wiki == "da" then t_g.speed_unit = 'km/t' end
if wiki == "nl" then t_g.speed_unit = 'km/u' end
if wiki == "no" then t_g.speed_unit = 'km/t' end
if wiki == "mk" then t_g.speed_unit = 'км/ч' end
if wiki == "ru" then t_g.speed_unit = 'км/ч' end
if wiki == "ja" then t_g.speed_unit = 'キロメートル毎時' end
end
end -- if a1
 
a1, b1 = pcall(fooA, 'numeric-id', entity, 'P17', 1) -- This function gives countries where the race take place
if a1 == true then
for i, v in pairs(entity.claims["P17"]) do
t_g.country[i] = "Q" .. v.mainsnak.datavalue.value["numeric-id"]
end
end
 
a1, b1 = pcall(fooA, 'value', entity, 'P242', 1) -- locator map image
if a1 == true and t_g.map == "" then t_g.map = b1 end
a1, b1 = pcall(fooA, 'value', entity, 'P2713', 1) -- sectional view
if a1 == true and t_g.sectional_view == "" then t_g.sectional_view = b1 end
 
a1, b1 = pcall(fooA, 'numeric-id', entity, 'P155', 1)
if a1 == true and t_g.previous == "" then
t_g.previous = "Q"..b1
a2, b2 = pcall(fooA, 'value', mw.wikibase.getEntity( t_g.previous ), 'P1545', 1)
if a2 == true then t_g.series_ordinal_previous = b2 end
end
a1, b1 = pcall(fooA, 'numeric-id', entity, 'P156', 1)
if a1 == true and t_g.next == "" then
t_g.next = "Q"..b1
a2, b2 = pcall(fooA, 'value', mw.wikibase.getEntity( t_g.next ), 'P1545', 1)
if a2 == true then t_g.series_ordinal_next = b2 end
end
 
local t_P642 = {[20882747]={'results', 'first'}, [20882748]={'results', 'second'}, [20882749]={'results', 'third'}, [21686770]={'results', 'winner_fighting'},
[2250962]={'results', 'cima_coppi'}, [10452933]={'results', 'cima_pantani'},
[20882763]={'classement_gen', 'leader'}, [20882764]={'classement_gen', 'deuxieme'}, [20882765]={'classement_gen', 'troisieme'},
[20883213]={'classement_annex', 'montagne'}, [20883140]={'classement_annex', 'jeune'}, [20883008]={'classement_annex', 'points'},
[20883329]={'classement_annex', 'sprints'}, [20893984]={'classement_annex', 'super_combatif'}, [20965880]={'classement_annex', 'combine'},
[27104688]={'classement_annex', 'stage_volantes'}, [27104684]={'classement_annex', 'regularite'}, [20882922]={'classement_annex', 'equipe'},
[27104271]={'classement_annex', 'equipe_points'},
[20882667]={'classement_gen', 'leader'}, [20882668]={'classement_gen', 'deuxieme'}, [20882669]={'classement_gen', 'troisieme'},
[20883212]={'classement_annex', 'montagne'}, [20883139]={'classement_annex', 'jeune'}, [20883007]={'classement_annex', 'points'},
[20883328]={'classement_annex', 'sprints'}, [20893983]={'classement_annex', 'super_combatif'}, [20893979]={'classement_annex', 'combine'},
[27067359]={'classement_annex', 'stage_volantes'}, [27067170]={'classement_annex', 'regularite'},
[27907747]={'classement_annex', 'azzurri_ditalia'}, [27907748]={'classement_annex', 'azzurri_ditalia'},
[27907714]={'classement_annex', 'fuga_pinarello'}, [27907715]={'classement_annex', 'fuga_pinarello'},
[20882921]={'classement_annex', 'equipe'}, [27104269]={'classement_annex', 'equipe_points'}
}
 
a1, b1 = pcall(fooA, 'numeric-id', entity, "P1346", 1)
if a1 == true then
local deprecated, qual, id, id_team, id_time, id_time_gap, id_speed, id_points_a, id_points_b
for k, v in pairs(entity.claims["P1346"]) do
id_team, id_speed, id_time, id_time_gap, id_points_a, id_points_b = '', '', '', '', '', ''
a, b = pcall(fooC, 'numeric-id', entity, 'P1346', k, 'P54', 1)
if a == true then id_team = 'Q'..b end
 
if pcall(function()
id=v.mainsnak.datavalue.value['numeric-id'] -- id = rider id
deprecated = entity.claims["P1346"][k].rank
end) then
else id=nil end
if id ~= nil then
--timeofrace = "+2016-03-00T00:00:00Z"
-- function timeStartEnd finds the team of the rider at the time (timeofrace) of the race
if id_team == '' and timeofrace ~= nil and timeofrace ~= '' then
a, b = timeStartEnd('Q'..id, 'P54', 'numeric-id', timeofrace)
if a == true and b ~= nil then id_team = 'Q' .. b end
end
 
-- looks into race item if the winner has a P54 statement for beeng a member of a national team
pcall(function()
for _, vv in pairs(entity.claims["P1346"][k].qualifiers['P54']) do
id_team = national_team(wiki, 'Q'..id, timeofrace, entity, 'P1346', k) -- timeofrace -> startOfSeason ?????
if id_team == nil then id_team = '' end
end
end)
 
pcall(function() -- for property 'race time'
for _, v in pairs(entity.claims['P1346'][k].qualifiers['P2781']) do
id_time = tonumber(v.datavalue.value.amount)
end
end)
 
pcall(function() -- for property 'time gap'
for _, v in pairs(entity.claims['P1346'][k].qualifiers['P2911']) do
id_time_gap = tonumber(v.datavalue.value.amount)
end
end)
 
pcall(function() -- for property 'speed'
for _, v in pairs(entity.claims['P1346'][k].qualifiers['P2052']) do
id_speed = tonumber(v.datavalue.value.amount)
end
end)
 
pcall(function() -- for property 'points for'
for _, v in pairs(entity.claims['P1346'][k].qualifiers['P1358']) do
id_points_a = tonumber(v.datavalue.value.amount)
end
end)
 
pcall(function() -- for property 'number of points/goals/set scored'
for _, v in pairs(entity.claims['P1346'][k].qualifiers['P1351']) do
id_points_b = tonumber(v.datavalue.value.amount)
end
end)
 
-- looks into race item if the winner has a P642 statement for showing the type of winner (points, mountain, ..)
pcall(function()
for _, vv in pairs(entity.claims["P1346"][k].qualifiers['P642']) do
qual=vv.datavalue.value['numeric-id']
 
if id~=nil and qual~=nil and v.rank~='deprecated' then
if qual==21686770 and t_s['results']['winner_fighting'][1] ~= '' then t_P642[qual][2] = 'winner_fighting2' end
pcall(function() -- inserts WD data into table t_s
t_s[t_P642[qual][1]][t_P642[qual][2]][1]='Q'..id
t_s[t_P642[qual][1]][t_P642[qual][2]][5]=id_team
t_s[t_P642[qual][1]][t_P642[qual][2]][10]=deprecated
if id_time~='' then t_s[t_P642[qual][1]][t_P642[qual][2]][6]=id_time end
if id_time_gap~='' then t_s[t_P642[qual][1]][t_P642[qual][2]][7]=id_time_gap end
if id_points_a~='' then t_s[t_P642[qual][1]][t_P642[qual][2]][8]=id_points_a end
if id_points_b~='' then t_s[t_P642[qual][1]][t_P642[qual][2]][8]=id_points_b end
if id_speed~='' then t_s[t_P642[qual][1]][t_P642[qual][2]][9]=id_speed end
end)
if qual==27104271 and t_s.classement_annex.equipe_points[1]=='' then t_s.classement_annex.equipe_points[1]='Q'..id end
if qual==20882922 and t_s.classement_annex.equipe[1]=='' then t_s.classement_annex.equipe[1]='Q'..id end
 
a1, b1 = pcall(fooA, 'numeric-id', mw.wikibase.getEntityObject('Q'..id), 'P21', 1) -- detect gender
if a1 == true then
if b1 == 6581097 then t_s[t_P642[qual][1]][t_P642[qual][2]][3] = 'm' -- men
elseif b1 == 6581072 then t_s[t_P642[qual][1]][t_P642[qual][2]][3] = 'f' -- female
end
else t_s[t_P642[qual][1]][t_P642[qual][2]][3] = 'f' -- female
end
end
end
end)
end
end
end
local rank, deprecated
local order = {'first', 'second', 'third'}
local property = 'P2417'
a1, b1 = pcall(fooA, 'numeric-id', entity, property, 1)
if a1 == true then
for k, _ in pairs(entity.claims[property]) do -- look into P2417, stage classification
for _, v in pairs(entity.claims[property][k].qualifiers['P1352']) do -- for property 'rank'
rank = tonumber(v.datavalue.value.amount)
deprecated = entity.claims[property][k].rank
end
if rank == 1 or rank == 2 or rank == 3 then
t_s.results[order[rank]][10] = deprecated
if t_s.results[order[rank]][1] == '' or t_s.results[order[rank]][10] == 'normal' then -- name or rider / team
t_s.results[order[rank]][1] = 'Q' .. entity.claims[property][k].mainsnak.datavalue.value['numeric-id']
if t_s.results[order[rank]][7] == '' and t_s.results[order[rank]][6] == '' then
pcall(function()
for _, v in pairs(entity.claims[property][k].qualifiers['P2911']) do -- for property 'time gap'
t_s.results[order[rank]][7] = tonumber(v.datavalue.value.amount)
end
end)
end
if t_s.results[order[rank]][7] == '' and t_s.results[order[rank]][6] == '' then
pcall(function()
for _, v in pairs(entity.claims[property][k].qualifiers['P2781']) do -- for property 'race time'
t_s.results[order[rank]][6] = tonumber(v.datavalue.value.amount)
end
end)
end
if t_s.results[order[rank]][9] == '' then
pcall(function()
for _, v in pairs(entity.claims[property][k].qualifiers['P2052']) do -- for property 'speed'
t_s.results[order[rank]][9] = tonumber(v.datavalue.value.amount)
end
end)
end
a1, b1 = pcall(fooA, 'numeric-id', mw.wikibase.getEntityObject(t_s.results[order[rank]][1]), 'P21', 1) -- detect gender
if a1 == true then
if b1 == 6581097 then t_s.results[order[rank]][3] = 'm' -- men
elseif b1 == 6581072 then t_s.results[order[rank]][3] = 'f' -- female
end
else t_s.results[order[rank]][3] = 'f' -- female
end
end
end
end
end
order = {'leader', 'deuxieme', 'troisieme'}
property = 'P2321'
a1, b1 = pcall(fooA, 'numeric-id', entity, property, 1)
if a1 == true then
for k, _ in pairs(entity.claims[property]) do -- look into P2321, stage classification
for _, v in pairs(entity.claims[property][k].qualifiers['P1352']) do -- for property 'rank'
rank = tonumber(v.datavalue.value.amount)
deprecated = entity.claims[property][k].rank
end
if rank == 1 or rank == 2 or rank == 3 then
t_s.classement_gen[order[rank]][10] = deprecated
if t_s.classement_gen[order[rank]][1] == '' or t_s.classement_gen[order[rank]][10] == 'normal' then -- name or rider / team
t_s.classement_gen[order[rank]][1] = 'Q' .. entity.claims[property][k].mainsnak.datavalue.value['numeric-id']
if t_s.classement_gen[order[rank]][7] == '' and t_s.classement_gen[order[rank]][6] == '' then
pcall(function()
for _, v in pairs(entity.claims[property][k].qualifiers['P2911']) do -- for property 'time gap'
t_s.classement_gen[order[rank]][7] = tonumber(v.datavalue.value.amount)
end
end)
end
if t_s.classement_gen[order[rank]][7] == '' and t_s.classement_gen[order[rank]][6] == '' then
pcall(function()
for _, v in pairs(entity.claims[property][k].qualifiers['P2781']) do -- for property 'race time'
t_s.classement_gen[order[rank]][6] = tonumber(v.datavalue.value.amount)
end
end)
end
if t_s.classement_gen[order[rank]][9] == '' then
pcall(function()
for _, v in pairs(entity.claims[property][k].qualifiers['P2052']) do -- for property 'speed'
t_s.classement_gen[order[rank]][9] = tonumber(v.datavalue.value.amount)
end
end)
end
a1, b1 = pcall(fooA, 'numeric-id', mw.wikibase.getEntityObject(t_s.classement_gen[order[rank]][1]), 'P21', 1) -- detect gender
if a1 == true then
if b1 == 6581097 then t_s.classement_gen[order[rank]][3] = 'm' -- men
elseif b1 == 6581072 then t_s.classement_gen[order[rank]][3] = 'f' -- female
end
else t_s.classement_gen[order[rank]][3] = 'f' -- female
end
end
end
end
end
 
if t_g.length ~= "" then
t_g.length, _ = string.gsub(t_g.length, "[+]", "") -- delets "+" sign
t_g.length = lang:formatNum(tonumber(t_g.length)) -- formats t_g.length in the way it is done in the local Wiki
end
if t_g.speed ~= "" then
t_g.speed, _ = string.gsub(t_g.speed, "[+]", "")
t_g.speed = lang:formatNum(tonumber(t_g.speed))
end
 
local a, b
local span1, span2 = "<span style='color:#3366CC'>&#x25C0; </span>", "<span style='color:#3366CC'> &#x25B6;</span>"
 
if t_g.series_ordinal_previous ~= '' then
a, _ = string.gsub(t_g.series_ordinal_previous, "%a", "") -- 20, not 20a
if string.find(t_g.series_ordinal_previous, "%a") then b = string.sub(t_g.series_ordinal_previous, string.find(t_g.series_ordinal_previous, "%a"))
else b = "" end
local label_previous = stageLink(t_g.series_ordinal_previous, a, b)
if t_g.series_ordinal_previous == "0" then label_previous = func_prologue() end
if mw.wikibase.sitelink( t_g.previous ) ~= nil then
local k = transform(t_g.previous,'Q', timeofrace)
local i, _ = string.find(k, "|")
local j, _ = string.find(k, "]")
if i ~= nil and j ~= nil then
t_g.previous = string.sub(k, 1, i) .. span1 .. label_previous .. string.sub(k, j)
else t_g.previous = span1 .. label_previous end
else t_g.previous = span1 .. label_previous end
if wiki == 'www' then t_g.previous = span1 .. label_previous end
else t_g.previous = ''
end
 
if t_g.series_ordinal_next~= '' then
a, _ = string.gsub(t_g.series_ordinal_next, "%a", "") -- 20, not 20a
if string.find(t_g.series_ordinal_next, "%a") then b = string.sub(t_g.series_ordinal_next, string.find(t_g.series_ordinal_next, "%a"))
else b = "" end
local label_next = stageLink(t_g.series_ordinal_next, a, b)
if t_g.series_ordinal_next == "0" then label_next = func_prologue() end
if mw.wikibase.sitelink( t_g.next ) ~= nil then
local k = transform(t_g.next,'Q', timeofrace)
local i, _ = string.find(k, "|")
local j, _ = string.find(k, "]")
if i ~= nil and j ~= nil then
t_g.next = string.sub(k, 1, i) .. label_next.. span2 .. string.sub(k, j)
else t_g.next = label_next.. span2 end
else t_g.next = label_next.. span2 end
if wiki == 'www' then t_g.next = label_next .. span2 end
else t_g.next = ''
end
 
if t_g.course== '' then
a1, b1 = pcall(fooA, 'value', entity, 'P1545', 1)
if a1 == true then
a, _ = string.gsub(b1, "%a", "") -- 20, not 20a
if string.find(b1, "%a") then b = string.sub(b1, string.find(b1, "%a")) else b = "" end
local label = stageLink(b1, a, b)
if b1 == "0" then label = func_prologue() end
t_g.course = label
a2, b2 = pcall(fooA, 'numeric-id', entity, 'P361', 1)
if a2 == true then
t_g.course = t_g.course .. ', '.. WPlink('Q'..b2,'pure')
--t_g.race = 'Q'..b2
local entity_race = mw.wikibase.getEntity('Q'..b2)
a3, b3 = pcall(fooA, 'numeric-id', entity_race, 'P31', 1)
if a3 == true then
for k, v in pairs(entity_race.claims["P31"]) do
t_g.race[k] = 'Q'..v.mainsnak.datavalue.value["numeric-id"]
end
end
end
end
end
 
if t_s.results.first[1]~='' or t_s.results.second[1]~='' or t_s.results.third[1]~='' or t_s.results.winner_fighting[1]
then t_s.results.show = true end
if t_s.classement_gen.leader[1]~='' or t_s.classement_gen.deuxieme[1]~='' or t_s.classement_gen.troisieme[1]~=''
then t_s.classement_gen.show = true end
if t_s.classement_annex.points[1]~='' or t_s.classement_annex.montagne[1]~='' or t_s.classement_annex.sprints[1]~='' or t_s.classement_annex.jeune[1]~='' or
t_s.classement_annex.super_combatif[1]~='' or t_s.classement_annex.combine[1]~='' or t_s.classement_annex.stage_volantes[1]~='' or
t_s.classement_annex.regularite[1]~='' or t_s.classement_annex.azzurri_ditalia[1]~='' or t_s.classement_annex.fuga_pinarello[1]~='' or
t_s.classement_annex.equipe[1]~='' or t_s.classement_annex.equipe_points[1]~='' then t_s.classement_annex.show = true end
 
function stage_icon(x)
if x=='Q20646667' then return "[[File:Plainstage.svg|20px]] " end
if x=='Q20646670' then return "[[File:Hillystage.svg|20px]] " end
if x=='Q20680270' then return "[[File:Mediummountainstage.svg|20px]] " end
if x=='Q20646668' then return "[[File:Mountainstage.svg|20px]] " end
if x=='Q20679712' then return "[[File:Mountain Time Trial Stage.svg|20px]] " end
if x=='Q2348250' then return "[[File:Team Time Trial Stage.svg|20px]] " end
if x=='Q2266066' then return "[[File:Time Trial.svg|20px]] " end
if x=='Q485321' then return "[[File:Time Trial.svg|20px]] " end
return ''
end
 
local width= '320px' -- size standard 320px, special 340px
if t_s.classement_annex.show == true and (wiki == 'no' or wiki == '..') then width= '340px' end
tab = "<table border='0' cellpadding='4' cellspacing='0' style='float:right; max-width:"..width.."; border:1px solid rgb(200,200,200);"
tab = tab .. "margin:0 0 0.5em 0.5em; background-color:rgb(255, 255, 255); color:black; padding:5px; clear:left; "
tab = tab .. "text-align:left; font-size:85%; line-height:1.6em;'>"
tab = tab .. "<tr><td colspan='2' style='border-bottom:5px solid white; font-size:175%; background:#FFE7A0; text-align:center'>"
tab = tab .. "<table style='width:100%'><tr><td>" .. t_g.name .."</td><td>" .. t_g.icon .. "</td></tr></table></td></tr>"
 
if t_g.picture ~= "" then tab = tab .. "<tr><td colspan='2' style='text-align:center'>".." [[File:".. t_g.picture .."|center|300px]]</td></tr>" end
if t_g.picture ~= "" and t_g.caption ~= "" then tab = tab .. "<tr><td colspan='2' style='text-align:center; font-size:80%'>"..t_g.caption.."</td></tr>" end
if t_g.course~="" or t_g.is_a~="" or t_g.time~="" or t_g.length~="" or t_g.startplace~="" or t_g.endplace~="" then
tab=tab.."<tr><td colspan='2' style='background-color:#FFE7A0; text-align:center'>'''"..stageinfobox_translate(wiki,1).."'''</td></tr>" end
if t_g.course ~= "" then tab = tab.."<tr><td>'''"..stageinfobox_translate(wiki,2).."'''</td><td>" .. t_g.course .. "</td></tr>" end
if t_g.is_a ~= "" then tab = tab.."<tr><td>'''"..stageinfobox_translate(wiki,3).."'''</td><td>" ..stage_icon(t_g.is_a).. WPlink(t_g.is_a,'pure').. "</td></tr>" end
if t_g.time~="" then tab = tab.."<tr><td>'''"..stageinfobox_translate(wiki,4).."'''</td><td>" .. t_g.time.."</td></tr>" end
if t_g.length ~= "" then tab = tab.."<tr><td>'''"..stageinfobox_translate(wiki,6).."'''</td><td>" .. t_g.length.." "..t_g.length_unit.."</td></tr>" end
if t_g.startplace ~= "" then tab = tab.."<tr><td>'''"..stageinfobox_translate(wiki,9).."'''</td><td>" .. WPlink(t_g.startplace,'pure').. "</td></tr>" end
if t_g.endplace ~= "" then tab = tab.."<tr><td>'''"..stageinfobox_translate(wiki,10).."'''</td><td>" .. WPlink(t_g.endplace,'pure').. "</td></tr>" end
if t_g.country ~= nil then for i=1,#t_g.country do t_g.country[i] = flag(t_g.country[i], timeofrace).." ".. WPlink( t_g.country[i],'pure') end end
if t_g.country[1] ~= nil then tab = tab.."<tr><td style= 'vertical-align:top'>'''"
if #t_g.country == 1 then tab = tab..stageinfobox_translate(wiki,7).."'''</td><td>" else tab = tab..stageinfobox_translate(wiki,8).."'''</td><td>" end
for i=1,#t_g.country-1 do tab = tab .. t_g.country[i].."<br>" end tab = tab .. t_g.country[#t_g.country].."</td></tr>" end
if t_g.nr_participants_start ~= "" then tab = tab.."<tr><td>'''"..stageinfobox_translate(wiki,11).."'''</td><td>" .. t_g.nr_participants_start .. "</td></tr>" end
if t_g.nr_participants_end ~= "" then tab = tab.."<tr><td>'''"..stageinfobox_translate(wiki,12).."'''</td><td>" .. t_g.nr_participants_end .. "</td></tr>" end
if t_g.speed ~= "" then tab = tab.."<tr><td>'''"..stageinfobox_translate(wiki,13).."'''</td><td>" .. t_g.speed .. " "..t_g.speed_unit.."</td></tr>" end
 
for _, value_order in ipairs(t_s.order) do
if t_s[value_order].show == true then -- if a section of the stageinfobox should be shown
tab=tab.."<tr><td colspan='2'>"
tab=tab.."<table border='0' cellpadding='0' cellspacing='0' style='width:100%'>"
tab=tab.."<tr><td colspan='3' style='border-bottom:5px solid #fff2cc; background-color:#FFE7A0; text-align:center'>'''"..
stageinfobox_translate(wiki,t_s[value_order].header).."'''</td></tr>"
 
for key, value in ipairs(t_s[value_order].order) do
if t_s[value_order][value][1]~="" then
a1, jersey_name, jerseyWPID = jersey(wiki, value, t_g.race, timeofrace)
if a1~='' then t_s[value_order][value][4] = a1 end
if t_s[value_order][value][9] ~= '' then t_s[value_order][value][9] = '('.. lang:formatNum(t_s[value_order][value][9])..unit(wiki,5)..')' end
if t_s[value_order][value][8] ~= '' then
if t_s[value_order][value][8] > 1 then t_s[value_order][value][8] = t_s[value_order][value][8]..unit(wiki,7)
else t_s[value_order][value][8] = t_s[value_order][value][8]..unit(wiki,6) end end
local title, k =mw.ustring.gsub(stageinfobox_translate(wiki,t_s[value_order][value][2]), " ", "&nbsp;")
if k > 0 then title=mw.ustring.gsub(title, "&nbsp;", "<br>", 1) end --&#32;
if t_s[value_order][value][5]=="" and t_s[value_order][value][9] =="" then
tab=tab.."<tr style='vertical-align:top;'><td nowrap style='width:1%;background-color:#fff2cc;text-align:left;padding:0 2px 0 2px'>'''"
else tab=tab.."<tr style='vertical-align:top;'><td nowrap rowspan='2' style='width:1%;background-color:#fff2cc;text-align:left;padding:0 2px 0 2px'>'''"
end
if value_order~='classement_annex' and t_s[value_order][value][2]~=40 and t_s[value_order][value][2]~=41 then -- Cima Coppi, Cima Pantani with a line break
if t_s[value_order][value][4] == "" then
if (value_order=='results') and (value=='winner_fighting' or value=='winner_fighting2' or value=='cima_coppi' or value=='cima_pantanii') then
tab=tab..stageinfobox_translate(wiki,t_s[value_order][value][2])
else tab=tab..number(t_s[value_order][value][3], key, wiki) end
else
if jerseyWPID=='' then tab=tab.."[[File:"..t_s[value_order][value][4].."|20px|"..title.."]]"
else tab=tab.."[[File:"..t_s[value_order][value][4].."|20px|"..title.."|link="..jerseyWPID.."]]" end
end
else
if t_s[value_order][value][4] == "" then tab=tab..title
else
if jerseyWPID=='' then
if jersey_name ~= '' then tab=tab.."[[File:"..t_s[value_order][value][4].."|20px|"..jersey_name.."]]" .. title
else tab=tab.."[[File:"..t_s[value_order][value][4].."|20px]]" .. title end
else tab=tab.."[[File:"..t_s[value_order][value][4].."|20px|link="..jerseyWPID.."]]" .. title end end
end
if t_s[value_order][value][10] == 'deprecated' then
tab=tab.."</span>".. "'''</td><td style='padding:0 0.5em 0 0.5em'>".. '<s>' .. transform(t_s[value_order][value][1],'f', timeofrace) .. '</s>'
else tab=tab.."</span>".. "'''</td><td style='padding:0 0.5em 0 0.5em'>".. transform(t_s[value_order][value][1],'f', timeofrace) end
tab=tab.."</td><td nowrap style='text-align:right;font-size:85%;'>"
if t_s[value_order][value][6]~='' then tab=tab.. calculate_time(wiki,t_s[value_order][value][6]) end
if t_s[value_order][value][7]~='' then tab=tab..'+ '.. calculate_time(wiki,t_s[value_order][value][7]) end
tab= tab.. t_s[value_order][value][8].. "</td></tr>"
end
 
if t_s[value_order][value][5]~="" and t_s[value_order][value][9] ~="" then -- team row
tab=tab.."<tr><td colspan='2'>"
tab = tab.. "<table border='0' cellpadding='0' cellspacing='0' style='width:100%'>"
tab = tab.. "<tr><td style='width:100%;text-align:left;padding-left:2px'>("..transform(t_s[value_order][value][5],'t', timeofrace)..
")</td><td nowrap style='font-size:85%;vertical-align:top'>"..t_s[value_order][value][9] .. "</td></tr></table>"
else
if t_s[value_order][value][5]~="" or t_s[value_order][value][9] ~="" then -- team row
tab=tab.."<tr><td colspan='2' style='text-align:left;padding-left:2px'>"
if t_s[value_order][value][5] ~= '' then tab=tab..'('..transform(t_s[value_order][value][5],'t', timeofrace)..')' end
tab = tab.. '<span style="float:right;font-size:85%;">'.. t_s[value_order][value][9].."</span></td></tr>"
end
end
end
tab=tab.. "</table></td></tr>"
end
end
 
if t_g.map ~= "" then tab = tab .. "<tr><td colspan='2' style='text-align:center'>".." [[File:".. t_g.map .."|center|300px]]".."</td></tr>" end
if t_g.sectional_view ~= "" then tab = tab .. "<tr><td colspan='2' style='text-align:center'>".." [[File:".. t_g.sectional_view .."|center|300px]]".."</td></tr>" end
tab = tab.."<tr><td>"..t_g.previous.."</td><td style='text-align:right'>" .. t_g.next .. "</td></tr>"
local s = "d:Wikidata:WikiProject Cycling/Documentation/stageinfobox"
tab = tab .. "<tr><td colspan='2' style='text-align:right; border-top:3px solid #FFDF80; font-size:75%'>".. --infobox_bottom(1)
"[[" .. s .. "|" .. stageinfobox_translate(wiki,39).. "]] [[File:Wikidata-logo S.svg|12px|link=d:".. frame.args[1] .. "]]"
tab = tab .. "</span></td></tr>"
tab= tab.."</table>"
return tab
end
 
function transform(q_number, command, timeofrace)
-- transforms Q/q-number into flag / WPlink / WDlink
local wd = " [[File:Wikidata-logo S.svg|12px|link=d:"
if not string.find(q_number, "^Q%d+") then return q_number end -- test if q_number is an item
if command == "Q" then return WPlink( q_number ) end -- find variables with an item as value
if command == 'q' then -- with WDitem icon
--look into P27 (country of citizenship) to get the Qnumber of that country
a, b = timeStartEnd(q_number, "P27", 'numeric-id', timeofrace)
if a == true then return flag('Q'..b, timeofrace).." "..WPlink( q_number )..wd..q_number.."]]"
else
--look into P17 (country) to get the Qnumber of that country
a, b = pcall(fooA, 'numeric-id', mw.wikibase.getEntity( q_number ), 'P17', 1)
if a == true then return flag("Q"..b, timeofrace).." "..WPlink( q_number )..wd..q_number.."]]"
else return WPlink( q_number )..wd..q_number.."]]" end
end
end
if command == "f" then -- no WDitem icon
--look into P27 (country of citizenship) to get the Qnumber of that country
a, b = timeStartEnd(q_number, "P27", 'numeric-id', timeofrace)
if a == true then return flag('Q'..b, timeofrace).." "..WPlink( q_number )
else
--look into P17 (country) to get the Qnumber of that country
a, b = pcall(fooA, 'numeric-id', mw.wikibase.getEntity( q_number ), 'P17', 1)
if a == true then return flag("Q"..b, timeofrace).." "..WPlink( q_number, 'winner_team', timeofrace )
else return WPlink( q_number, 'winner_team', timeofrace ) end
end
end
if command == "c" then return WPlink( q_number, "Q22348500" ) end -- find "class"-items
if command == "t" then return WPlink( q_number, 'team', timeofrace ) end
if command =="2t" then return q_number end
return q_number
end
 
function p.listofteams(frame)
--frame.args[1] = 'Q19753550'
local entity = mw.wikibase.getEntityObject( frame.args[1] )
local mt = {}
local tempID, k, u, v, v1, w, new, teamcategory, entity2, len, len2
local wiki = string.match(mw.site.server, "%a+")
 
local startOfSeason = '' --'+2016-01-01T00:00:00Z'
pcall(function() startOfSeason = entity.claims["P580"][1].mainsnak.datavalue.value.time end)
if startOfSeason == '' then
if pcall(function() startOfSeason = entity.claims["P585"][1].mainsnak.datavalue.value.time end) then
else
local Sitelink = entity:getSitelink('enwiki') or entity:getSitelink('frwiki') or entity:getSitelink('dewiki') or ''
if Sitelink == '' then return '> Wikidata is missing data about the start time (P580) and end time (P582) of the season'
else startOfSeason = '+'..string.match(Sitelink, '%d%d%d%d' ) ..'-01-01T00:00:00Z'
end
end
end
 
v = ''
mt[1] = {}
mt[1][1], mt[1][2], mt[1][3] = '', 0, ''
local mu = {}
local a, b
 
if pcall(fooA, 'numeric-id', entity, 'P1923', 1) == true then
for k, v1 in pairs(entity.claims['P1923']) do
new = true
teamcategory, tempID, len = '', '', 0
tempID = 'Q'.. v1.mainsnak.datavalue.value['numeric-id']
entity2 = mw.wikibase.getEntityObject( tempID )
 
a, b = timeStartEnd(tempID, "P31", 'numeric-id', startOfSeason)
if a == true then teamcategory = 'Q'..b else new = false end
 
for w in pairs(mt) do
len = table.getn(mt[w])
if mt[w][1] == teamcategory then new=false mt[w][2]=mt[w][2]+1 len=len+1 mt[w][len]=tempID len2=len-2 end
end
if new == true then
local size = table.getn(mt)
mt[size+1] = {}
mt[size+1][1] = teamcategory
mt[size+1][2] = 1
mt[size+1][3] = tempID
end
end
end -- if pcall(fooA
 
local list = { -- c:d:e c = singular team type, d = plural team type, e = print order of the team types
["Q6154783"] = "4:5:1", -- WorldTeam
["Q20638319"] = "6:7:2", -- ProTeam
["Q382927"] = "8:9:3", -- UCI Professional Continental Team
["Q1756006"] = "10:11:4", -- UCI Continental Team
["Q23726798"] = "12:13:6", -- national cycling team
["Q20738667"] = "12:13:6", -- national cycling team U23
["Q20639848"] = "14:15:7", -- club cycling team
["Q20639847"] = "16:17:8", -- professional cycling team
["Q20652655"] = "18:19:9", -- amateur cycling team
["Q20653563"] = "20:21:10", -- Groupe Sportif I
["Q20653564"] = "22:23:11", -- Groupe Sportif II
["Q20653566"] = "24:25:12", -- Groupe Sportif III
["Q2466826"] = "28:29:5" -- UCI Women’s Team
}
local a, b, c, d, e, ii, jj
for i=1, table.getn(mt) do
mu[i] = {}
mu[i]['index']= 100 mu[i]['val'] = ''
if mt[i][1] ~= '' then
if list[mt[i][1]] ~= nil then
_, _, c, d, e = string.find(list[mt[i][1]], "(%d+):(%d+):(%d+)")
mu[i]['index'] = tonumber( e )
if mt[i][2] == 1 then mu[i]['val'] = mu[i]['val'] .. '<span style="font-size:1.2em;font-weight:bold">'..headoftableIII(wiki,tonumber( c ))..'</span>'
else mu[i]['val'] = mu[i]['val'] .. '<span style="font-size:1.2em;font-weight:bold">'..headoftableIII(wiki,tonumber( d )).. '</span>'
end
else -- fall back headings (ProTeam, ...) in case no value in function headoftableIII
mu[i]['val'] = mu[i]['val'] .. '<span style="font-size:1.2em;font-weight:bold;text-transform: capitalize;">' .. WPlink(mt[i][1])..'</span>'
end
mu[i]['val'] = mu[i]['val'] .. ' <small>('..mt[i][2]..')</small>'
 
mu[i]['val'] = mu[i]['val'].. '<ol>'
for w in pairs(mt[i]) do
if w > 2 then
mu[i]['val'] = mu[i]['val'] .. '<li style="text-indent:-1.5em;width:20em;display:inline-block;">'
a, b = timeStartEnd(mt[i][w], "P17", 'numeric-id', startOfSeason)
if a == true then mu[i]['val'] = mu[i]['val'].. flag('Q'..b, startOfSeason).. ' ' end
if mt[i][1] ~= 'Q23726798' and mt[i][1] ~= 'Q20738667' then mu[i]['val'] = mu[i]['val'].. WPlink(mt[i][w],'winner_team', startOfSeason).. '</li>'
else
national_team = mw.wikibase.getEntity( mt[i][w] )
-- calculate s for national team item
a, b = pcall(fooA, 'numeric-id', national_team, 'P31', 1) -- test if country
if a == true and b == 20738667 then -- Q20738667 = national cycling team U23
if wiki == 'fr' or wiki == 'www' then s = ' espoirs' else s = ' U23' end
elseif a == true and b == 23726798 then s = '' end -- Q23726798 = national cycling team
 
a, b = pcall(fooA, 'numeric-id', national_team, 'P17', 1) -- test if country
if a == true then
local nation = mw.wikibase.getEntityObject( 'Q'..b )
nationality = nation:getLabel() or nation:getLabel('en') or nation:getLabel('fr') or nation:getLabel('de')
end
 
if national_team:getSitelink() == nil then
team = nationality.. s
else
team = WPlink(mt[i][w], 'team', startOfSeason)
ii, jj = mw.ustring.find(team, "|")
if ii ~= nil and jj ~= nil then
jj=jj+1
team = mw.ustring.sub(team,1,ii).. nationality..s.. ']]'
end
end
mu[i]['val'] = mu[i]['val'] .. team ..'</li>'
end
end
end
mu[i]['val'] = mu[i]['val'] .. '</ol>'
end --if mt[i][1] ~= ''
end
 
table.sort(mu, function(a,b) return a.index<b.index end)
 
for i=1, table.getn(mu) do
if mu[i].val ~= nil then v = v .. mu[i].val end
end
 
v = v .. '<table border="0" cellspacing="0" cellpadding="0" style="line-height:0em;width:20em;margin:0.5em 0em;border-top:2px solid #FFDF80;"><th>'..
'<span style="float:left">[[File:Wikidata-logo S.svg|12px|link=d:'.. frame.args[1].. '#P1923]]</span></th></table>'
 
return '<table style="max-width:95%; padding:0.5em; margin-right:1em; border:1px solid rgb(200,200,200)"><tr><td>'..
v.. '</td></tr></table>'
end
 
function getSquadTableColumn(x)
local l10nDef = { } -- note (in the table), note (below the table)
l10nDef["fr"] = {"Cycliste", "Date de naissance", "Équipe précédente", "note", "note", "Pays"}
l10nDef["en"] = {"Rider", "Date of birth", "Previous team", "note", "note", "Country"}
l10nDef["br"] = {"Reder", "Deiziad genel", "Previous team", "note", "note", "Bro"}
l10nDef["ca"] = {"Ciclista", "Data de naixement", "Equip previ", "Nota", "Nota", "Pais"}
l10nDef["cs"] = {"Cyklista", "Datum narození", "Previous team", "note", "note", "Stát"}
l10nDef["da"] = {"Rytter", "Fødselsdag", "Seneste hold", "note", "note", "Land"}
l10nDef["de"] = {"Name", "Geburtsdatum", "Vorheriges Team", "Anm.", "Anmerkung", "Land"}
l10nDef["eo"] = {"Antaŭnomo Nomo", "Naskiĝtago", "Previous team", "note", "note", "Lando"}
l10nDef["es"] = {"Corredor", "Fecha de nacimiento", "Equipo previo", "Nota", "Nota", "Pais"}
l10nDef["eu"] = {"Izena", "Jaiotze-data", "Previous team", "note", "note", "Herrialde"}
l10nDef["fi"] = {"Ajaja", "Syntymäaika", "Edellinen joukkue", "huomio", "huomio", "Maa"}
l10nDef["fo"] = {"Súkklari", "Føðingardagur", "Previous team", "note", "note", "Country"}
l10nDef["hu"] = {"Név", "Születésnap", "Previous team", "note", "note", "Ország"}
l10nDef["it"] = {"Ciclista", "Data di nascita", "Previous team", "Nota", "Nota", "Paese"}
l10nDef["ja"] = {"選手名", "生年月日", "Previous team", "脚注", "脚注", "国"}
l10nDef["lb"] = {"Coureur", "Gebuertsdatum", "Previous team", "note", "note", "Staat"}
l10nDef["lv"] = {"Braucējs", "Dzimšanas datums", "Iepriekšējā komanda", "piezīme", "piezīme", "Valsts"}
l10nDef["mk"] = {"Велосипедист", "Датум на раѓање", "Previous team", "Фуснота", "Фуснота", "Држава"}
l10nDef["nl"] = {"Naam", "Geboortedatum", "Previous team", "noot", "noot", "Land"}
l10nDef["no"] = {"Rytter", "Fødselsdato", "Tidligere lag", "note", "note", "Stat"}
l10nDef["pl"] = {"Imię i nazwisko", "Data urodzenia", "Previous team", "Przypis", "Przypis", "Państwo"}
l10nDef["pt"] = {"Ciclista", "Data de nascimento", "Equipe anterior", "Nota", "Nota", "Pais"}
l10nDef["ro"] = {"Ciclist", "Data nașterii", "Previous team", "note", "note", "Țară"}
l10nDef["ru"] = {"Гонщик", "Дата рождения", "Предыдущая команда", "Примечание", "Примечание", "Страна"}
l10nDef["sv"] = {"Namn", "Födelsedatum", "Previous team", "not", "not", "Land"}
l10nDef["zh"] = {"車手", "出生日期", "Previous team", "脚注", "脚注", "国家"}
 
local wiki,l10n=mw.site.server
if wiki=='//www.wikidata.org' then l10n=l10nDef["fr"]
else l10n=l10nDef[string.sub(wiki,string.find(wiki,"%a+"))] end
return l10n[x]
end
 
function infobox_translate(x)
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.
-- This function permits to translate fields of the infobox, take the line below, give a Wikipedia (ex : mk), and translate all fields. By default, English values are taken.
-- l10nDef["//??.wikipedia.org"] = {"RACE DETAILS", "COURSE", "COMPETITION", "COMPETITIONS", "STAGES", "DATE", "DATES", "DISTANCE", "COUNTRY", "COUNTRIES",
-- "JOURNEY ORIGIN", "JOURNEY DESTINATION", "TEAMS", "STARTING RIDERS", "ARRIVING RIDERS", "AVERAGE SPEED", "COST", "PALMARES", "WINNER", "SECOND", "THIRD",
-- "POINTS", "MOUNTAINS", "SPRINTS", "YOUTH", "COMBATIVITY", "COMBINATION", "TEAM", "Picture", "Caption", "Map", "Special 1", "Special 2"}, "Documentation",
-- "METAS VOLANTES", "REGULARIDAD", "TEAM POINTS"}
local l10nDef = { }
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", "Image",
"Image", "Légende", "Carte", "Special 1", "Special 2"}, "Documentation", "Étapes volantes", "Régularité", "Meilleure équipe aux points",
"Fuga Pinarello", "Azzurri d'Italia"}
l10nDef["//en.wikipedia.org"] = {"Race details", "Course", "Competition", "Competitions", "Stages", "Date", "Dates", "Distance", "Country", "Countries",
"Journey origin", "Journey destination", "Teams", "Starting riders", "Arriving riders", "Average speed", "Cost", "Palmares", "Winner", "Second",
"Third", "Points", "Mountains", "Sprints", "Youth", "Combativity", "Combination", "Team", "Picture", "Caption", "Map", "Special 1", "Special 2"},
"Documentation", "Metas volantes", "Regularidad", "Team points", "Fuga Pinarello", "Azzurri d'Italia"}
l10nDef["//br.wikipedia.org"] = {"Hollegezhioù", "Redadeg", "Kevezadeg", "Kevezadegoù", "Tennadoù", "Deiziad", "Deiziadoù", "Hed", "Bro", "Broioù",
"Lec'h loc'hañ", "Lec'h degouezhout", "Skipailhoù", "Loc'herien", "Erruerien", "Tizh keitat", "Koust", "Disoc'hoù", "Gounezer", "Eil", "Trede",
"Renkadur a-boentoù", "Kraper gwellañ", "Sprinter gwellañ", "Yaouank gwellañ", "Stourmer meur", "Gwellañ el liesrenkadur", "Skipailh gwellañ", "Picture", "Caption", "Map", "Special 1", "Special 2"}
"Picture", "Caption", "Map", "Special 1", "Special 2", "Documentation", "Metas volantes", "Regularidad", "Team points", "Fuga Pinarello", "Azzurri d'Italia"}
l10nDef["//ca.wikipedia.org"] = {"Detalls de la cursa", "Cursa", "Competició", "Competicions", "Etapes", "Data", "Dates", "Distància", "País", "Països",
"Sortida", "Arribada", "Equips", "Inscrits", "Finalitzen", "Velocitat mitjana", "Cost", "Palmarès", "Vencedor", "Segon", "Tercer", "Punts", "Muntanya",
"Esprints", "Joves", "Combativitat", "Combinada", "Equip", "Picture", "Caption", "Map", "Special 1", "Special 2"}, "Documentació", "Metas volantes",
"Regularidad", "Team points", "Fuga Pinarello", "Azzurri d'Italia"}
l10nDef["//cs.wikipedia.org"] = {"Přehled", "Závod", "Soutěž", "Soutěže", "Počet etap", "Datum", "Datum", "Celková délka", "Země", "Země", "Start", "Cíl",
"Týmy", "Běžci", "Příjezdy", "Rychlostní průměr", "Náklady", "Konečné pořadí", "Celkový vítěz", "2. místo", "3. místo", "Vítěz bodovací soutěže", "Nejlepší vrchař",
"Nejlepší vrchař", "Nejlepší sprinter", "Nejlepší mladý jezdec", "Nejaktivnější jezdec", "Nejlepší kombinovaná", "Nejlepší družstvo", "Picture", "Caption", "Map", "Special 1", "Special 2"}
l10nDef["//da.wikipedia.orgCaption"] =, {"LøbsdetaljerMap", "RuteSpecial 1", "KonkurrenceSpecial 2", "KonkurrencerDokumentace", "EtaperMetas volantes", "DatoRegularidad", "Datoer",Team "Distancepoints", "Land",Fuga "LandePinarello", "StartAzzurri på turd'Italia", }
l10nDef["Destination på tur//da.wikipedia.org",] "Hold",= {"Startende ryttereLøbsdetaljer", "Sluttende ryttereRute", "Gennemsnitlig fartKonkurrence", "PrisKonkurrencer", "ResultaterEtaper", "VinderDato", "ToerDatoer", "TreerDistance", "PointLand", "BjergtrøjeLande",
"PointtrøjeStartby", "UngdomstrøjeMålby", "Mest angrebsivrigeHold", "KombinationStartende ryttere", "HoldkonkurrenceFuldførende ryttere", "PictureGennemsnitlig fart", "CaptionPris", "MapResultater", "Special 1Vinder", "SpecialToer", 2"}Treer",
"Pointtrøje", "Bjergtrøje", "Sprinttrøje", "Ungdomstrøje", "Mest angrebsivrige", "Kombinationstrøje", "Holdkonkurrence", "Billede", "Billedtekst",
l10nDef["//de.wikipedia.org"] = {"Allgemeines", "Ausgabe", "Rennserie", " Wettbewerb", "Etappen", "Datum", "Datum", "Gesamtlänge", "Austragungsland", "Austragungsländer",
"Kort", "Special 1", "Special 2", "Dokumentation", "Metas volantes", "Regularidad", "Holdkonkurrence efter point", "Fuga Pinarello", "Azzurri d'Italia"}
"Start", "Ziel", "Teams", "Fahrer am Start", "Fahrer im Ziel", "Durchschnitts-geschwindigkeit", "Kosten", "Sieger", "Gesamtwertung", "Zweiter",
l10nDef["//de.wikipedia.org"] = {"Allgemeines", "Ausgabe", "Rennserie", " Wettbewerb", "Etappen", "Datum", "Datum", "Gesamtlänge", "Austragungsland",
"Dritter", "Punktewertung", "Bergwertung", "Sprintwertung", "Nachwuchswertung", "Kämpferischster Fahrer", "Kombinationswertung", "Teamwertung", "Bild", "Beschriftung",
"Austragungsländer", "Start", "Ziel", "Teams", "Fahrer am Start", "Fahrer im Ziel", "Durchschnitts&#173;geschwindigkeit", "Kosten", "Sieger",
"Karte", "Special 1", "Special 2"}
"Gesamtwertung", "Zweiter", "Dritter", "Punktewertung", "Bergwertung", "Sprintwertung", "Nachwuchswertung", "Kämpferischster Fahrer", "Kombinationswertung",
"Teamwertung", "Bild", "Beschriftung", "Karte", "Special 1", "Special 2", "Dokumentation", "Metas volantes", "Regularidad", "Teamwertung (Punkte)",
"Fuga Pinarello", "Azzurri d'Italia"}
l10nDef["//eo.wikipedia.org"] = {"Gxeneralajxo", "Bicikla konkurso", "Konkuro", "Konkuroj", "Etapoj", "Dato", "Datoj", "Longo", "Lando", "Landoj",
"Komencloko", "Alvenloko", "Teamoj", "Startantoj", "Alvenantoj", "Averagxa rapido", "Kosto", "Rezultoj", "Venkinto", "Dua pozicio", "Tria pozicio",
"Klasifiko laux poentoj", "Plej bona grimpanto", "Plej bona sprinto", "Plej bona juno", "Superbatalema", "Plej bona por kombino", "Plej bona teamo", "Picture", "Caption", "Map", "Special 1", "Special 2"}
l10nDef["//es.wikipedia.orgPicture"] =, {"DetallesCaption", "CarreraMap", "VálidaSpecial para1", "VálidaSpecial para2", "EtapasDokumentado", "FechaMetas volantes", "FechasRegularidad", "DistanciaTeam totalpoints", "PaísFuga Pinarello", "PaísesAzzurri d'Italia", }
l10nDef["//es.wikipedia.org"] = {"Detalles", "Carrera", "Competición", "Competiciones", "Etapas", "Fecha", "Fechas", "Distancia total", "País", "Países",
"Lugar de inicio", "Lugar de llegada", "Equipos", "Ciclistas que iniciaron", "Ciclistas que finalizaron", "Velocidad media", "Costo", "Clasificación final",
"Ganador",Lugar "Segundo",de "Terceroinicio", "Puntos",Lugar "Montañade llegada", "SprintsEquipos", "Jóvenes",Ciclistas "Combatividadparticipantes", "Combinación",Ciclistas "Equipofinalizados", "Picture",Velocidad "Captionmedia", "MapCosto", "SpecialClasificación 1final", "Special 2"}
l10nDef["//eu.wikipedia.orgGanador"], ="Segundo", {"LasterketarenTercero", xehetasunak"Puntos", "IbilbideaMontaña", "LehiaketaMetas volantes", "LehiaketakJóvenes", "EtapakCombatividad", "DataCombinada", "DatakEquipo", "DistantziaImagen", "HerrialdeaLeyenda", "HerrialdeakMapa",
"Especial 1", "Especial 2", "Documentación", "Metas volantes", "Regularidad", "Team points", "Fuga Pinarello", "Azzurri d'Italia"}
"Jardunaldiko abiapuntua", "Jardunaldiko helmuga", "Taldeak", "Abiatutako txirrindulariak", "Iritsitako txirrindulariak", "Batez besteko abiadura", "Kostua", "Azken sailkapena",
l10nDef["//eu.wikipedia.org"] = {"Lasterketaren xehetasunak", "Ibilbidea", "Lehiaketa", "Lehiaketak", "Etapak", "Data", "Datak", "Distantzia",
"Irabazlea", "Bigarrena", "Hirugarrena", "Puntuak", "Mendiak", "Esprintak", "Gazteak", "Saiatuena", "Konbinatua", "Taldeak", "Picture", "Caption", "Map", "Special 1", "Special 2"}
"Herrialdea", "Herrialdeak", "Jardunaldiko abiapuntua", "Jardunaldiko helmuga", "Taldeak", "Abiatutako txirrindulariak", "Iritsitako txirrindulariak",
"Batez besteko abiadura", "Kostua", "Azken sailkapena", "Irabazlea", "Bigarrena", "Hirugarrena", "Puntuak", "Mendiak", "Esprintak", "Gazteak",
"Saiatuena", "Konbinatua", "Taldeak", "Picture", "Caption", "Map", "Special 1", "Special 2", "Dokumentazioa", "Metas volantes", "Regularidad",
"Team points", "Fuga Pinarello", "Azzurri d'Italia"}
l10nDef["//fi.wikipedia.org"] = {"Kilpailun tiedot", "Nimi", "Kilpailu", "Kilpailut", "Etapit", "Päivä", "Päivät", "Matka", "Maa", "Maat",
"Lähtöpaikka", "Saapumispaikka", "Joukkueet", "Osallistuneet pyöräilijät", "Maaliin saapuneet pyöräilijät", "Keskinopeus", "Kustannukset", "Lopputilanne", "Voittaja", "Toinen",
"Voittaja", "Toinen", "Kolmas", "Pistekilpailu", "Mäkikirikilpailu", "Sprintit", "Nuoret", "Yritteliäin", "Yhdistelmä", "Joukkue", "Kuva", "Kuvateksti", "Kartta", "Special 1", "Special 2"}
"Kartta", "Special 1", "Special 2", "Ohjesivu", "Metas volantes", "Regularidad", "Team points", "Fuga Pinarello", "Azzurri d'Italia"}
l10nDef["//fo.wikipedia.org"] = {"Smálutir", "Leið", "Kapping", "Kappingar", "Teinar", "Dagfesting", "Dagfestingar", "Strekki", "Land", "Lond", "Byrjunarbýur",
"Málbýur", "Lið", "Byrjandi súkklarar", "Fullførandi súkklarar", "Miðalferð", "Virðisløn", "Palmares", "Vinnari", "Nr. 2", "Nr. 3", "Stig", "Fjøll",
"Spurtar", "Ungdómur", "Mest álopssinnaður", "Kombinatión", "Lið", "Picture", "Caption", "Map", "Special 1", "Special 2"}, "Dokumentation", "Metas volantes",
"Regularidad", "Team points", "Fuga Pinarello", "Azzurri d'Italia"}
l10nDef["//lb.wikipedia.org"] = {"Detailer", "Course", "Kompetitioun", "Kompetitiounen", "Etappen", "Datum", "Datumer", "Distanz", "Land", "Länner",
"Depart", "Arrivée", "Equippen", "Um Depart", "Ukomm", "Vitesse-Moyenne", "Käschten", "Palmarès", "Gewënner", "Zweeten", "Drëtten", "Beschte Sprinter", "Biergpräis",
"Biergpräis", "Sprinter", "Beschte Jonken", "Kombativitéit", "Kombinatioun", "Equipe", "Picture", "Caption", "Map", "Special 1", "Special 2"},
"Dokumentatioun", "Étapes volantes", "Regularidad", "Team points", "Fuga Pinarello", "Azzurri d'Italia"}
l10nDef["//lv.wikipedia.org"] = {"Sacensību informācija", "Maršruts", "Sacensība", "Sacensības", "Posmi", "Datums", "Datumi", "Distance", "Valsts",
"Valstis", "Starts", "Finišs", "Komandas", "Braucēji startā", "Braucēji finišā", "Vidējais ātrums", "Izmaksas", "Rezultāti", "Uzvarētājs", "Otrais",
"Trešais", "Punkti", "Kalnu karalis", "Sprints", "Jaunais braucējs", "Cīnītājs", "Kombinācija", "Komanda", "Atēls", "Paraksts", "Karte", "Papildinformācija 1",
"Papildinformācija 2", "Dokumentācija", "Metas volantes", "Regularidad", "Team points", "Fuga Pinarello", "Azzurri d'Italia"}
l10nDef["//mk.wikipedia.org"] = {"Детали за трката", "Издание", "Натпреварување", "Натпреварувања", "Етапи", "Датум", "Датуми", "Растојание",
"Држава", "Држави", "Поаѓалиште", "Одредиште", "Екипи", "Возачи на почеток", "Возачи на крај", "Просечна брзина", "Трошоци", "Добитници на наградите",
"Победник", "Второпласиран", "Третопласиран", "Бодовен", "Планински", "Спринтерски", "Младински", "Борбеност", "Комбиниран", "Екипен", "слика", "опис", "местоположбена карта", "Special 1", "Special 2"}
"местоположбена карта", "Special 1", "Special 2", "Документација", "Metas volantes", "Regularidad", "Team points", "Fuga Pinarello", "Azzurri d'Italia"}
l10nDef["//nl.wikipedia.org"] = {"Wedstrijddetails", "Koers", "Wedstrijd", "Wedstrijden", "Etappes", "Datum", "Datums", "Afstand", "Land", "Landen", "Startplaats",
l10nDef["//nl.wikipedia.org"] = {"Wedstrijddetails", "Koers", "Wedstrijd", "Wedstrijden", "Etappes", "Datum", "Datums", "Afstand", "Land", "Landen",
"Finishplaats", "Teams", "Aantal coureurs aan de start", "Aantal coureurs bij de aankomst", "Gemiddelde snelheid", "Kosten", "Palmares", "Winnaar", "Tweede",
"DerdeStartplaats", "PuntenFinishplaats", "BergenTeams", "Sprints",Aantal "Jeugd",coureurs aan de "Aanvalsluststart", "Combinatie",Aantal coureurs bij "Teamde aankomst", "Picture",Gemiddelde "Captionsnelheid", "MapKosten", "Special 1Palmares", "Special 2"}
l10nDef["//no.wikipedia.orgWinnaar"], ="Tweede", {"DetaljerDerde", "RittPunten", "TurneringBergen", "TurneringerSprints", "EtapperJeugd", "DatoAanvalslust", "DatoerCombinatie", "DistanseTeam", "LandPicture", "LandCaption", "Map", "Special 1",
"Special 2", "Documentatie", "Metas volantes", "Regularidad", "Teampunten", "Fuga Pinarello", "Azzurri d'Italia"}
"Startby", "Målby", "Lag", "Startende ryttere", "Fullførende ryttere", "Gjennomsnittsfart", "Kostnad", "Resultater", "Vinner", "2. plass", "3. plass",
l10nDef["Poeng//no.wikipedia.org",] = {"KlatreDetaljer", "SprintRitt", "UngdomKonkurranse", "Mest offensiveKonkurranser", "KombinasjonEtapper", "LagkonkurranseDato", "PictureDatoer", "CaptionDistanse", "MapLand", "Special 1Land", "Special 2Startby"},
l10nDef["//pl.wikipedia.orgMålby"], = {"Wyrażenia ogólneLag", "WyścigStartende ryttere", "KonkurencjaFullførende ryttere", "KonkursyGjennomsnittsfart", "EtapówKostnad", "DataResultater", "DatyVinner", "Dystans2. plass", "Państwo",3. "Państwyplass", "OdejściePoeng",
"PrzyjazdKlatre", "ZespołySprint", "ZgłoszeniaUngdom", "UkończyłoMest wyścigoffensive", "Średnia prędkośćKombinasjon", "KosztLagkonkurranse", "PodiumBilde", "PierwszeBildetekst", miejsce"Kart", "DrugieSpecial miejsce1", "TrzecieSpecial miejsce2", "PunktowaDokumentasjon",
"Metas volantes", "Regularidad", "Team points", "Fuga Pinarello", "Azzurri d'Italia"}
"Górska", "Sprinterska", "Młodzieżowa", "Najaktywniejszych", "Kombinowana", "Drużynowa", "Picture", "Caption", "Map", "Special 1", "Special 2"}
l10nDef["//ropl.wikipedia.org"] = {"DetaliiWyrażenia cursăogólne", "CursăWyścig", "CompetițieKonkurencja", "CompetițiiKonkursy", "EtapeEtapów", "DatăData", "DateDaty", "DistanțăDystans", "ȚarăPaństwo", "Țări", "Start", "SosirePaństwy",
"EchipeOdejście", "Cicliști la startPrzyjazd", "Cicliști la sosireZespoły", "Viteză medieZgłoszenia", "CostUkończyło wyścig", "PalmaresŚrednia prędkość", "CâștigătorKoszt", "Al doileaPodium", "AlPierwsze treileamiejsce", "Clasament peDrugie punctemiejsce",
"CelTrzecie mai bun cățărătormiejsce", "Cel mai bun sprinterPunktowa", "Cel mai bun tânărGórska", "CombativitateSprinterska", "CombinatMłodzieżowa", "EchipăNajaktywniejszych", "PictureKombinowana", "CaptionDrużynowa", "MapPicture", "Special 1Caption", "Special 2Map"},
"Special 1", "Special 2", "Dokumentacja", "Metas volantes", "Regularidad", "Team points", "Fuga Pinarello", "Azzurri d'Italia"}
l10nDef["//pt.wikipedia.org"] = {"Detalhes", "Corrida", "Válida para", "Válida para", "Etapas", "Data", "Data", "Distância", "País", "Países",
"Partida", "Chegada", "Nº de equipes", "Ciclistas que iniciaram", "Ciclistas que finalizaram", "Velocidade média", "Custo", "Classificação final",
"Vencedor", "Segundo", "Terceiro", "Prêmio por pontos", "Prêmio de montanha", "Sprints", "Juventude", "Disputa", "Combinação", "Equipes", "Imagem",
"Legenda", "Mapa", "Special 1", "Special 2", "Documentação", "Metas volantes", "Regularidad", "Team points", "Fuga Pinarello", "Azzurri d'Italia"}
l10nDef["//ro.wikipedia.org"] = {"Detalii cursă", "Cursă", "Competiție", "Competiții", "Etape", "Dată", "Date", "Distanță", "Țară", "Țări", "Start",
"Sosire", "Echipe", "Cicliști la start", "Cicliști la sosire", "Viteză medie", "Cost", "Palmares", "Câștigător", "Al doilea", "Al treilea", "Clasament pe puncte",
"Cel mai bun cățărător", "Cel mai bun sprinter", "Cel mai bun tânăr", "Combativitate", "Combinat", "Echipă", "Picture", "Caption", "Map", "Special 1",
"Special 2", "Documentație", "Metas volantes", "Regularidad", "Team points", "Fuga Pinarello", "Azzurri d'Italia"}
l10nDef["//ru.wikipedia.org"] = {"Детали гонки", "Маршрут", "Соревнование", "Соревнования", "Этапы", "Дата", "Даты", "Дистанция", "Страна", "Страны",
"Место старта", "Пункт назначения", "Команды", "Вышло на старт гонщиков", "Финишировало гонщиков", "Средняя скорость", "Призовые", "Призёры", "Победитель",
"Второй", "Третий", "Очковая", "Горная", "Спринтерская", "Молодёжная", "Бойцовская", "Комбинированная", "Командная", "PictureВид", "CaptionОписание", "MapКарта", "Special 1", "Special 2"}
"Special 2", "Документация", "Metas volantes", "Regularidad", "Team points", "Fuga Pinarello", "Azzurri d'Italia"}
l10nDef["//sv.wikipedia.org"] = {"Race details", "Course", "Competition", "Competitions", "Stages", "Date", "Dates", "Distance", "Country", "Countries",
"Journey origin", "Journey destination", "Teams", "Starting riders", "Arriving riders", "Average speed", "Cost", "Palmares", "Winner", "Second",
"Third", "Points", "Mountains", "Sprints", "Youth", "Combativity", "Combination", "Team", "Picture", "Caption", "Map", "Special 1", "Special 2",
"Documentation", "Metas volantes", "Regularidad", "Team points", "Fuga Pinarello", "Azzurri d'Italia"}
l10nDef["//www.wikidata.org"] = l10nDef["//en.wikipedia.org"]
local l10n = l10nDef[mw.site.server]
Ред 71 ⟶ 1.073:
end
 
function unit(wiki,x)
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"] = {"en", " h ", " min ", " s", ' km/h', " pt", " pts"}
l10nDef["//fr.wikipedia.org"] = {"[[d:Wikidata:WikiProject Cycling/Documentation/infobox|Documentation]]", "In Wikidata missing:"}
l10nDef["br"] = {"", "e ", "' ", '"', ' km/h', " pt", " pts"}
l10nDef["//en.wikipedia.org"] = {"[[d:Wikidata:WikiProject Cycling/Documentation/infobox|Documentation]]", "In Wikidata missing:"}
l10nDef["da"] = {"", "t ", "' ", '"', ' km/t', " point", " point"}
l10nDef["//br.wikipedia.org"] = {"[[d:Wikidata:WikiProject Cycling/Documentation/infobox|Documentation]]", "In Wikidata missing:"}
l10nDef["de"] = {"", " h ", " min ", " s", ' km/h', " P.", " P."}
l10nDef["//ca.wikipedia.org"] = {"[[d:Wikidata:WikiProject Cycling/Documentation/infobox|Documentació]]", "In Wikidata missing:"}
l10nDef["es"] = {"", " h ", " min ", " s", ' km/h', "pt", " pts"}
l10nDef["//cs.wikipedia.org"] = {"[[d:Wikidata:WikiProject Cycling/Documentation/infobox|Dokumentace]]", "In Wikidata missing:"}
l10nDef["eu"] = {"", " o ", " min ", " s", ' km/h', " pt", " pts"}
l10nDef["//da.wikipedia.org"] = {"[[d:Wikidata:WikiProject Cycling/Documentation/infobox|Dokumentation]]", "In Wikidata missing:"}
l10nDef["fo"] = {"", "t ", "' ", '"', ' km/h', " pt", " pts"}
l10nDef["//de.wikipedia.org"] = {"[[d:Wikidata:WikiProject Cycling/Documentation/infobox|Dokumentation]]", "In Wikidata missing:"}
l10nDef["fi"] = {"", ".", ".", "", ' km/h', " pt", " pts"}
l10nDef["//eo.wikipedia.org"] = {"[[d:Wikidata:WikiProject Cycling/Documentation/infobox|Dokumentado]]", "In Wikidata missing:"}
l10nDef["it"] = {"", "h", "'", '"', ' km/h', " pt", " pts"}
l10nDef["//es.wikipedia.org"] = {"[[d:Wikidata:WikiProject Cycling/Documentation/infobox|Documentación]]", "In Wikidata missing:"}
l10nDef["lb"] = {"", " h ", " min ", " s", ' km/h', " pt", " pts"}
l10nDef["//eu.wikipedia.org"] = {"[[d:Wikidata:WikiProject Cycling/Documentation/infobox|Dokumentazioa]]", "In Wikidata missing:"}
l10nDef["mk"] = {"", "ч ", "' ", "", ' км/ч', " pt", " pts"}
l10nDef["//fi.wikipedia.org"] = {"[[d:Wikidata:WikiProject Cycling/Documentation/infobox|Ohjesivu]]", "In Wikidata missing:"}
l10nDef["nl"] = {"", "u", "'", '"', ' km/u', " pt", " pts"}
l10nDef["//fo.wikipedia.org"] = {"[[d:Wikidata:WikiProject Cycling/Documentation/infobox|Dokumentation]]", "In Wikidata missing:"}
l10nDef["no"] = {"", "t ", "' ", '"', ' km/t', " pt", " pts"}
l10nDef["//hu.wikipedia.org"] = {"[[d:Wikidata:WikiProject Cycling/Documentation/infobox|Dokumentáció]]", "In Wikidata missing:"}
l10nDef["pt"] = {"", "h", "m", "s", ' km/h', " pt", " pts"}
l10nDef["//lb.wikipedia.org"] = {"[[d:Wikidata:WikiProject Cycling/Documentation/infobox|Dokumentatioun]]", "In Wikidata missing:"}
l10nDef["ru"] = {"", "ч ", "' ", "", ' км/ч', " очко", " очко"}
l10nDef["//mk.wikipedia.org"] = {"[[d:Wikidata:WikiProject Cycling/Documentation/infobox|Документација]]", "In Wikidata missing:"}
l10nDef["www"] = {"", "h ", "' ", '"', ' km/h', " pt", " pts"} -- wikidata
l10nDef["//nl.wikipedia.org"] = {"[[d:Wikidata:WikiProject Cycling/Documentation/infobox|Documentatie]]", "In Wikidata missing:"}
 
l10nDef["//no.wikipedia.org"] = {"[[d:Wikidata:WikiProject Cycling/Documentation/infobox|Dokumentasjon]]", "In Wikidata missing:"}
local l10n = l10nDef[wiki]
l10nDef["//pl.wikipedia.org"] = {"[[d:Wikidata:WikiProject Cycling/Documentation/infobox|Dokumentacja]]", "In Wikidata missing:"}
if not l10n then l10n = l10nDef["www"] end -- default for lv,cs,en,ca,hu,ro,pt,pl,sv
l10nDef["//pt.wikipedia.org"] = {"[[d:Wikidata:WikiProject Cycling/Documentation/infobox|Documentação]]", "In Wikidata missing:"}
l10nDef["//ro.wikipedia.org"] = {"[[d:Wikidata:WikiProject Cycling/Documentation/infobox|Documentație]]", "In Wikidata missing:"}
l10nDef["//ru.wikipedia.org"] = {"[[d:Wikidata:WikiProject Cycling/Documentation/infobox|Документация]]", "In Wikidata missing:"}
l10nDef["//sv.wikipedia.org"] = {"[[d:Wikidata:WikiProject Cycling/Documentation/infobox|Dokumentation]]", "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 number(gender, b, wiki)
local str
if b=="" then return "" end
str = b .. ". "
if wiki == "ca" then
if b==1 then str = b.."r" end
if b==2 then str = b.."n" end
if b==3 then str = b.."r" end
if b==4 then str = b.."t" end
if b>4 then str = b.."è" end
end
if wiki=="es" then str = b..".º" end
if wiki=="fr" or wiki=="www" then
if b==1 then
if gender == 'm' then str="1<sup>er</sup>"
elseif gender == 'f' then str="1<sup>re</sup>"
else str="1<sup>e</sup>" end
else str=b.."<sup>e</sup>" end
end
if wiki=="nl" then str=b.."e" end
if wiki=="ru" then str=b.."-й" end
if wiki=="eo" then str=b.."-a" end
return str
end
 
function calculate_time(wiki, t)
local time = tonumber(t)
local h, m, s = 0, 0, 0
local str=''
 
if time == nil then return '' end
if time < 60 then s = time
elseif time < 3600 then m = math.modf(time/60) s = time - m*60
else h = math.modf(time/3600) m = math.modf((time - h*3600)/60) s = time - h*3600 - m*60
end
 
if h>0 then str = str..mw.ustring.format ('%i'..unit(wiki,2), h) end
if m>0 and h>0 then str = str.. mw.ustring.format('%02i'..unit(wiki,3), m) end
if m>0 and h==0 then str = str.. mw.ustring.format('%i'..unit(wiki,3), m) end
if s>=0 and (h>0 or m>0) then str = str.. mw.ustring.format('%02i'..unit(wiki,4), s) end
if s>=0 and h==0 and m==0 then str = str.. mw.ustring.format('%i'..unit(wiki,4), s) end
return str --time..': '..h..' '..m..' '..s
end
 
function p.teamtimetrialclassification(frame)
local entity = mw.wikibase.getEntityObject( frame.args[1] )
local WDlink_on
local wiki = string.match(mw.site.server, "%a+")
local cont = {nr={}, teamIDs={}, teamNames={}, flags={}, country={}, time={}, time_gap={}, speed={}, time_date=false, no_country=true }
local startOfSeason = '' --'+2016-01-01T00:00:00Z'
 
if wiki == "mk" or wiki == "ja" or wiki == "lv" or wiki == "ru" then WDlink_on = true else WDlink_on = false end
 
pcall(function() startOfSeason = entity.claims["P580"][1].mainsnak.datavalue.value.time end)
if startOfSeason == '' then
if pcall(function() startOfSeason = entity.claims["P585"][1].mainsnak.datavalue.value.time end) then
else
local Sitelink = entity:getSitelink('enwiki') or entity:getSitelink('frwiki') or entity:getSitelink('dewiki') or ''
if Sitelink == '' then return '> Wikidata is missing data about the start time (P580) and end time (P582) of the season'
else startOfSeason = '+'..string.match(Sitelink, '%d%d%d%d' ) ..'-01-01T00:00:00Z'
end
end
end
 
local k, v, a, b, rank
local max_rank = 0
pcall(function()
for k, _ in pairs(entity.claims['P2417']) do -- look into all statements
for _, v in pairs(entity.claims['P2417'][k].qualifiers['P1352']) do -- for property 'rank'
rank = tonumber(v.datavalue.value.amount) break
end
if rank > max_rank then max_rank = rank end
cont.nr[rank] = rank
 
cont.teamIDs[rank] = 'Q' .. entity.claims['P2417'][k].mainsnak.datavalue.value['numeric-id']
cont.teamNames[rank] = WPlink(cont.teamIDs[rank], 'winner_team', startOfSeason)
 
a, b = pcall(fooA, 'numeric-id', mw.wikibase.getEntityObject( cont.teamIDs[rank] ), 'P17', 1)
if a == true then
if available == true then
if type( translations ) == "table" then cont.country[rank] = translations.list('Q'..b) end
if cont.country[rank] == '' then
local country = mw.wikibase.getEntityObject( 'Q'..b )
cont.country[rank] = country:getLabel() or country:getLabel('en') .. ' (en)'
end
--else cont.country[rank] = mw.wikibase.label( 'Q'..b ) end
end
else cont.country[rank] = '' end
 
a, b = timeStartEnd(cont.teamIDs[rank], "P17", 'numeric-id', startOfSeason)
if a == true then
cont.flags[rank] = flag('Q'..b, startOfSeason)
else cont.flags[rank] = '' end
if pcall(function()
for _, v in pairs(entity.claims['P2417'][k].qualifiers['P2781']) do -- for property 'race time'
cont.time[rank] = tonumber(v.datavalue.value.amount)
end
end) then else cont.time[rank] = '' end
if pcall(function()
for _, v in pairs(entity.claims['P2417'][k].qualifiers['P2911']) do -- for property 'time gap'
cont.time_gap[rank] = tonumber(v.datavalue.value.amount)
end
end) then else cont.time_gap[rank] = '' end
if pcall(function()
for _, v in pairs(entity.claims['P2417'][k].qualifiers['P2052']) do -- for property 'speed'
cont.speed[rank] = tonumber(v.datavalue.value.amount)
end
end) then else cont.speed[rank] = '' end
end
end)
 
for i= 1,max_rank do
if cont.nr[i] == nil then cont.nr[i]='' end
if cont.teamNames[i] == nil then cont.teamNames[i]='' end
end
 
local time_headoftable = '' -- if there is time data in the classification, print the column time
local tableStart = '<table border="0" cellspacing="0" cellpadding="0"><th colspan="6" style="padding:2px 2px; text-align:center; background-color:#FFDF80">'
local tableHeader1 = ''
if WDlink_on == false then tableHeader1 = tableHeader1 .. '<span style="float:left">[[File:Wikidata-logo S.svg|12px|link=d:'.. frame.args[1].. '#P2417]]</span>' end
tableHeader1 = tableHeader1 .. headoftableII(wiki,8)
local tableHeader2 = '<tr><th colspan="2" style="text-align:center;padding:2px 2px">'..headoftableII(wiki,3)
if available==true then tableHeader2 = tableHeader2..'<th nowrap style="text-align:center;padding:2px 2px">'..headoftableII(wiki,2) end
tableHeader2 = tableHeader2..'</th><th style="text-align:center;padding:2px 2px">'..headoftableII(wiki,4)..
'</th><th style="text-align:center;padding:2px 2px">'..headoftableII(wiki,5)..
'</th><th style="text-align:center;padding:2px 2px">'..headoftableII(wiki,6).. '</th></tr>'
 
local tableBody = ''
local tableEnd = '</th></table>'
 
local unit = ' km/h'
if wiki == 'da' then unit = ' km/t' end
if wiki == 'nl' then unit = ' km/u' end
if wiki == 'no' then unit = ' km/t' end
if wiki == 'mk' or wiki == 'ru' then unit = ' км/ч' end
local i = 1
while cont.nr[i] do
tableBody = tableBody.. '<tr><td nowrap style="text-align:center;padding:2px 0.5em 2px 0.5em">'.. number('f', cont.nr[i], wiki)
if available==true then tableBody = tableBody..'</td><td style="text-align:left;padding:0 0.2em 0 0.2em">'.. cont.teamNames[i].. '</td>'
else tableBody = tableBody.. '</td><td style="text-align:left;padding:0 0.2em 0 0.2em">'.. cont.flags[i].. ' '..cont.teamNames[i].. '</td>'
end
if available==true then tableBody = tableBody.. '</td><td style="text-align:left;padding:0 0.2em 0 0.2em">'.. cont.flags[i].. ' '.. cont.country[i].. '</td>' end
tableBody = tableBody.. '</td><td style="text-align:right;padding:0 0.2em 0 0.2em">'.. calculate_time(wiki,cont.time[i]).. '</td>'
if i == 1 then tableBody = tableBody.. '</td><td style="text-align:right;padding:0 0.2em 0 0.2em">'.. calculate_time(wiki,cont.time_gap[i]).. '</td>'
else
if cont.time_gap[i] ~= '' then tableBody = tableBody.. '</td><td style="text-align:right;padding:0 0.2em 0 0.2em">'.. '+ '.. calculate_time(wiki,cont.time_gap[i]).. '</td>'
else tableBody = tableBody.. '</td><td></td>' end
end
if cont.speed[i] ~= '' then tableBody = tableBody.. '</td><td style="text-align:center;padding:0 0.2em 0 0.2em">'..
mw.ustring.format('%.3f', cont.speed[i]).. '<span style="font-size:80%">'.. unit.. '</span>'.. '</td></tr>'
else tableBody = tableBody.. '</td><td></td></tr>' end
i = i + 1
end
 
return '<table style="float:left; margin-right:0.5em; border:1px solid rgb(200,200,200)"><tr><td>'..
tableStart.. tableHeader1.. tableHeader2.. tableBody.. tableEnd.. '</td></tr></table>'
end
 
function classification(item, property, wiki)
local entity = mw.wikibase.getEntityObject( item )
local g = {nr={}, riderIDs={}, riderNames={}, riderGender={}, jersey={}, jerseyIDs={}, jersey_name={}, flags={}, country={},
team={}, time={}, time_gap={}, time_date=false, no_country=true }
local startOfSeason = '' --'+2016-01-01T00:00:00Z'
 
pcall(function() startOfSeason = entity.claims["P580"][1].mainsnak.datavalue.value.time end)
if startOfSeason == '' then
if pcall(function() startOfSeason = entity.claims["P585"][1].mainsnak.datavalue.value.time end) then
else
local Sitelink = entity:getSitelink('enwiki') or entity:getSitelink('frwiki') or entity:getSitelink('dewiki') or ''
if Sitelink == '' then return '> Wikidata is missing data about the start time (P580) and end time (P582) of the season'
else startOfSeason = '+'..string.match(Sitelink, '%d%d%d%d' ) ..'-01-01T00:00:00Z'
end
end
end
 
local k, v, a, b, rank
local max_rank = 0
local nr_jersey -- number of jerseys one rider has
 
pcall(function()
for k, _ in pairs(entity.claims[property]) do -- look into all statements
for _, v in pairs(entity.claims[property][k].qualifiers['P1352']) do -- for property 'rank'
rank = tonumber(v.datavalue.value.amount) break
end
if rank > max_rank then max_rank = rank end
 
nr_jersey = 1
g.jersey[rank], g.jersey_name[rank], g.jerseyIDs[rank] = {}, {}, {}
local entity_jersey
if pcall(function()
for _, v in pairs(entity.claims[property][k].qualifiers['P2912']) do -- for property 'distinctive jersey'
g.jerseyIDs[rank][nr_jersey] = 'Q'..v.datavalue.value['numeric-id']
entity_jersey = mw.wikibase.getEntityObject(g.jerseyIDs[rank][nr_jersey])
g.jersey[rank][nr_jersey] = 'File:'.. entity_jersey.claims['P18'][1].mainsnak.datavalue.value
g.jersey_name[rank][nr_jersey] = entity_jersey:getLabel() or entity_jersey:getLabel( 'fr' )
nr_jersey = nr_jersey + 1
end
end) then else g.jersey[rank][1] = '' end
 
g.riderIDs[rank] = 'Q' .. entity.claims[property][k].mainsnak.datavalue.value['numeric-id']
g.riderNames[rank] = WPlink(g.riderIDs[rank], 'pure')
 
a, b = pcall(fooA, 'numeric-id', mw.wikibase.getEntityObject( g.riderIDs[rank] ), 'P21', 1)
if a == true then
if b == 6581097 then g.riderGender[rank] = 'm' -- men
elseif b == 6581072 then g.riderGender[rank] = 'f' -- female
else g.riderGender[rank] = '' end
else g.riderGender[rank] = '' end
 
g.nr[rank] = rank
 
a, b = timeStartEnd(g.riderIDs[rank], "P27", 'numeric-id', startOfSeason)
if a == true then
g.flags[rank] = flag('Q'..b, startOfSeason)
if available == true then
if type( translations ) == "table" then g.country[rank] = translations.list('Q'..b) end
if g.country[rank] == '' then
local country = mw.wikibase.getEntityObject( 'Q'..b )
g.country[rank] = country:getLabel() or country:getLabel('en') .. ' (en)'
end
end
end
 
g.team[rank] = national_team(wiki, g.riderIDs[rank], startOfSeason, entity, property, k)
 
if pcall(function()
for _, v in pairs(entity.claims[property][k].qualifiers['P2781']) do -- for property 'race time'
g.time[rank] = tonumber(v.datavalue.value.amount)
end
end) then else g.time[rank] = '' end
if pcall(function()
for _, v in pairs(entity.claims[property][k].qualifiers['P2911']) do -- for property 'time gap'
g.time_gap[rank] = tonumber(v.datavalue.value.amount)
end
end) then else g.time_gap[rank] = '' end
end -- end for
end)
 
for i= 1,max_rank do
if g.nr[i] == nil then g.nr[i]='' end
if g.riderNames[i] == nil then g.riderNames[i]='' end
-- if g.jersey[i] == nil then g.jersey[i] ='' end
if g.flags[i] == nil then g.flags[i]='' end
if g.country[i] == nil then g.country[i]='' else g.no_country=false end
if g.team[i] == nil then g.team[i]='' end
if g.time[i] == nil then g.time[i] ='' end
if g.time[i] ~= '' then g.time_date = true end
if g.time_gap[i] == nil then g.time_gap[i] ='' end
end
return g
end
 
function p.generalclassification(frame)
local WDlink_on
local wiki = wiki
frame.args[1] = string.gsub(frame.args[1], "%c", "")
local item = frame.args[1]
local content = classification(item, 'P2321', wiki)
local time_headoftable = '' -- if there is time data in the classification, print the column time
if content.time_date == true then time_headoftable = headoftableII(wiki,4) end
 
if wiki == "mk" or wiki == "ja" or wiki == "lv" or wiki == "ru" then WDlink_on = true else WDlink_on = false end
 
local tableStart = '<table border="0" cellspacing="0" cellpadding="0"><th colspan="5" style="padding:2px 2px; text-align:center; background-color:#FFDF80">'
local tableHeader1 = ''
if WDlink_on == false then tableHeader1 = tableHeader1 .. '<span style="float:left">[[File:Wikidata-logo S.svg|12px|link=d:'.. frame.args[1].. '#P2321]]</span>' end
tableHeader1 = tableHeader1 .. headoftableII(wiki,9)
local tableHeader2 = '<tr><th colspan="2" nowrap style="text-align:center;padding:2px 2px">'..headoftableII(wiki,1)
if available==true then tableHeader2 = tableHeader2..'<th nowrap style="text-align:center">'..headoftableII(wiki,2) end
tableHeader2 = tableHeader2.. '<th nowrap style="text-align:center">'..headoftableII(wiki,3)..
'</th><th nowrap style="text-align:center">'..time_headoftable .. '</th></tr>' -- '' or 'temp', depending on available time data
local tableBody = ''
local tableEnd = '</th></table>'
 
local i = 1
local bg_color -- background color
while content.riderNames[i] do
tableBody = tableBody .. '<tr'
-- find the right background color if a rider has more then one jersey
-- see Wikidata:WikiProject Cycling/Kit to translate/Jerseys
if type(content.jersey[i]) == 'table' and content.jersey[i][1] ~= '' then
local num = 1 -- loop for more then one jersey per rider
while content.jerseyIDs[i][num] ~= nil do
if content.jerseyIDs[i][num] == "Q24257872" then bg_color="#FF8666" break end -- Jersey red.svg
if content.jerseyIDs[i][num] == "Q24257763" then bg_color="pink" -- Jersey pink.svg
if wiki == "ca" then bg_color="lightpink" end
break end
if content.jerseyIDs[i][num] == "Q24257871" then bg_color="#FFFF99" break end -- Jersey yellow.svg
if content.jerseyIDs[i][num] == "Q26696171" then bg_color="#FFFFFF" break end -- Jersey white.svg
if content.jerseyIDs[i][num] == "Q24687408" then bg_color="#99CBFF" break end -- Jersey blue.svg
if content.jerseyIDs[i][num] == "Q26945272" then bg_color="#BF80FF" break end -- Jersey violet.svg
if content.jerseyIDs[i][num] == "Q24257991" then bg_color="#FFD700" break end -- Jersey gold.svg
if content.jerseyIDs[i][num] == "Q24258056" then bg_color="#FFD030" break end -- Jersey orange.svg
if content.jerseyIDs[i][num] == "Q24258125" then bg_color="#BFFF80" break end -- Jersey green 2.svg
num = num + 1
end
end
 
if i == 1 then
tableBody = tableBody ..' style="font-weight:bold;' -- winner is formated bold
if type(content.jersey[i]) == 'table' and content.jersey[i][1] ~= '' and bg_color ~= nil then -- background color of winner depending on jersey
tableBody = tableBody ..'background-color:'..bg_color..'"'
else tableBody = tableBody ..'"' end
end
if available==true then tableBody = tableBody ..'><td nowrap style="padding:2px 0.5em 2px 0.5em;text-align:center">'.. number(content.riderGender[i], content.nr[i], wiki)..
'</td><td nowrap style="padding:0 0.2em 0 0.2em">'.. content.riderNames[i]
else tableBody = tableBody ..'><td nowrap style="padding:2px 0.5em 2px 0.5em;text-align:center">'.. number(content.riderGender[i], content.nr[i], wiki)..
'</td><td nowrap style="padding:0 0.2em 0 0.2em">'.. content.flags[i]..' '.. content.riderNames[i]
end
if type(content.jersey[i]) == 'table' and content.jersey[i][1] ~= '' then
tableBody = tableBody ..' '
local num = 1 -- loop for more then one jersey per rider
while content.jersey[i][num] ~= nil do
tableBody = tableBody ..'[['..content.jersey[i][num]..'|20px|'..content.jersey_name[i][num]..']]'
num = num + 1
end
end
 
if available==true then tableBody = tableBody.. '</td><td nowrap style="padding:0 0.2em 0 0.2em;">'.. content.flags[i].. ' '.. content.country[i]..
'</td><td style="padding:0 0.2em 0 0.2em">' .. content.team[i]
else tableBody = tableBody.. '</td><td style="padding:0 0.2em 0 0.2em">' .. content.team[i]
end
 
-- calculate time
if content.time[i] == '' and content.time_gap[i] == '' then tableBody = tableBody .. '</td><td>' else
if i == 1 and content.time[i]~='' then tableBody = tableBody..
'</td><td style="text-align:right;padding:0 0.2em 0 0.2em">'.. calculate_time(wiki,content.time[i]).. '</td>'
elseif content.time_gap[i]~= '' then tableBody = tableBody..
'</td><td style="text-align:right;padding:0 0.2em 0 0.2em">'.. '+ '.. calculate_time(wiki,content.time_gap[i]).. '</td>' end
end
i = i + 1
end -- end while
 
tableBody = tableBody.. '</td></tr>'
 
return '<table style="border:1px solid rgb(200,200,200)"><tr><td>'..
tableStart.. tableHeader1.. tableHeader2.. tableBody.. tableEnd.. '</td></tr></table><br style="clear:left;">'
end
 
function p.stageclassification(frame)
local WDlink_on
local wiki = wiki
frame.args[1] = string.gsub(frame.args[1], "%c", "")
local item = frame.args[1]
local content = classification(item, 'P2417', wiki)
local time_headoftable = '' -- if there is time data in the classification, print the column time
if content.time_date == true then time_headoftable = headoftableII(wiki,4) end
 
if wiki == "mk" or wiki == "ja" or wiki == "lv" or wiki == "ru" then WDlink_on = true else WDlink_on = false end
 
local tableStart = '<table border="0" cellspacing="0" cellpadding="0"><th colspan="5" style="padding:2px 2px; text-align:center; background-color:#FFDF80">'
local tableHeader1 = ''
if WDlink_on == false then tableHeader1 = tableHeader1 .. '<span style="float:left">[[File:Wikidata-logo S.svg|12px|link=d:'.. frame.args[1].. '#P2321]]</span>' end
tableHeader1 = tableHeader1 .. headoftableII(wiki,8)
local tableHeader2 = '<tr><th colspan="2" nowrap style="text-align:center;padding:2px 2px">'..headoftableII(wiki,1)
if available==true then tableHeader2 = tableHeader2..'<th nowrap style="text-align:center">'..headoftableII(wiki,2) end
tableHeader2 = tableHeader2.. '<th nowrap style="text-align:center">'..headoftableII(wiki,3)..
'</th><th nowrap style="text-align:center">'..time_headoftable .. '</th></tr>' -- '' or 'temp', depending on available time data
local tableBody = ''
local tableEnd = '</th></table>'
 
local i = 1
local bg_color -- background color
while content.riderNames[i] do
tableBody = tableBody .. '<tr'
if i == 1 then tableBody = tableBody ..' style="font-weight:bold;"' end -- winner is formated bold
 
if available==true then tableBody = tableBody ..'><td nowrap style="padding:2px 0.5em 2px 0.5em;text-align:center">'.. number(content.riderGender[i], content.nr[i], wiki)..
'</td><td nowrap style="padding:0 0.2em 0 0.2em">'.. content.riderNames[i]
else tableBody = tableBody ..'><td nowrap style="padding:2px 0.5em 2px 0.5em;text-align:center">'.. number(content.riderGender[i], content.nr[i], wiki)..
'</td><td nowrap style="padding:0 0.2em 0 0.2em">'.. content.flags[i]..' '.. content.riderNames[i]
end
 
if type(content.jersey[i]) == 'table' and content.jersey[i][1] ~= '' then
tableBody = tableBody ..' '
local num = 1 -- loop for more then one jersey per rider
while content.jersey[i][num] ~= nil do
tableBody = tableBody ..'[['..content.jersey[i][num]..'|20px|'..content.jersey_name[i][num]..']]'
num = num + 1
end
end
 
if available==true then tableBody = tableBody.. '</td><td nowrap style="padding:0 0.2em 0 0.2em;">'.. content.flags[i].. ' '.. content.country[i]..
'</td><td style="padding:0 0.2em 0 0.2em">' .. content.team[i]
else tableBody = tableBody.. '</td><td style="padding:0 0.2em 0 0.2em">' .. content.team[i]
end
 
-- calculate time
if content.time[i] == '' and content.time_gap[i] == '' then tableBody = tableBody .. '</td><td>' else
if i == 1 and content.time[i]~='' then tableBody = tableBody..
'</td><td style="text-align:right;padding:0 0.2em 0 0.2em">'.. calculate_time(wiki,content.time[i]).. '</td>'
elseif content.time_gap[i]~= '' then tableBody = tableBody..
'</td><td style="text-align:right;padding:0 0.2em 0 0.2em">'.. '+ '.. calculate_time(wiki,content.time_gap[i]).. '</td>' end
end
i = i + 1
end -- end while
 
tableBody = tableBody.. '</td></tr>'
 
return '<table style="float:left; margin-right:0.5em; border:1px solid rgb(200,200,200)"><tr><td>'..
tableStart.. tableHeader1.. tableHeader2.. tableBody.. tableEnd.. '</td></tr></table>'
end
 
function references(entity, property, var1)
local wiki = string.match(mw.site.server, "%a+")
local ref1, ref2, ref2b, ref3, ref4 = "", " ", "", "", ""
local url, ref
local lang = mw.language.getContentLanguage()
local a, b
 
if wiki == 'www' then wiki = 'fr' lang = mw.getLanguage('fr') end
 
a, b = pcall(fooB, 'value', entity, property, var1, 1, 'P854', 1) -- url
if a == true then ref1 = b end
a, b = pcall(fooB, 'text', entity, property, var1, 1, 'P1476', 1) -- Originaltitel der webpage, "language": "fr"
if a == true then
ref2 = b
ref2b= entity.claims[property][var1].references[1].snaks['P1476'][1].datavalue.value.language or ''
if ref2b == wiki then ref2b = '' else ref2b = '(' .. ref2b .. ') ' end
end
a, b = pcall(fooB, 'time', entity, property, var1, 1, 'P577', 1) -- publication date
if a == true then
local _, _, year, m, d = string.find(b,"(%d+)-(%d+)-(%d+)")
if d ~= '00' and m ~= '00' then
if wiki == "de" then ref3 = ', ' .. lang:formatDate( "j. F Y", b)
elseif wiki == "en" then ref3 = ', ' .. lang:formatDate( "Y F, j", b) .. '.'
elseif wiki == "fr" then ref3 = ', ' .. lang:formatDate( "j F Y", b)
else ref3 = ', ' .. func_date (b, wiki, 'long') .. '.' --lang:formatDate( "j n Y", b) .. '.'
end
elseif d == '00' and m ~= '00' then
d = '01'
if wiki == "de" then ref3 = ', ' .. lang:formatDate( "F Y", year..'-'..m..'-'..d )
elseif wiki == "en" then ref3 =', ' .. lang:formatDate( "Y F", year..'-'..m..'-'..d )..'.'
elseif wiki == "fr" then ref3 =', ' .. lang:formatDate( "F Y", year..'-'..m..'-'..d )
else ref3 = ', ' .. lang:formatDate( "F Y", year..'-'..m..'-'..d )..'.'
end
else ref3 = year
end
end
a, b = pcall(fooB, 'time', entity, property, var1, 1, 'P813', 1) -- Retrieved
if a == true then
if wiki == "de" then ref4 = ", (abgerufen am " .. lang:formatDate( "j. F Y", b).. ')'
elseif wiki == "en" then ref4 = " Retrieved " .. lang:formatDate( "Y F, j", b) .. '.'
elseif wiki == "fr" then ref4 = " (consulté le " .. lang:formatDate( "j F Y", b) .. ')'
else ref4 = " Retrieved " .. func_date (b, wiki, 'long').. '.' --lang:formatDate( "j n Y", b) .. '.'
end
end
 
if ref1~='' then --and ref2~='' then
local _, start = string.find( ref1, '//' )
local ende, _ = string.find( ref1, '/', start + 1 )
local s = string.sub(ref1, start + 1, ende - 1)
local s2 = string.gsub(s, "www.", "")
if wiki == "fr" then
-- fr: "(en) « Lloyd Mondory ... EPO », sur velonews.competitor.com (consulté le 30 april 2016), 30 octobre 2015."
if ref2~=' ' then url= ', sur <span style="font-style:italic;">' .. s2 .. '</span>' else url='' end
ref = ref2b .. '« ['.. ref1.. ' '.. ref2.. '] »' .. url .. ref4 .. ref3 ..'.'
elseif wiki == "en" then
-- en: "Inflation ... recession", Pittsburgh Post-Gazette, October 16, 2009. Retrieved 2010-01-21.
if ref2~=' ' then url= ', <span style="font-style:italic;">' .. s2 .. '</span>' else url='' end
ref = '"['.. ref1.. ' '.. ref2.. '"]'.. ref2b .. url .. ref3 .. ref4
elseif wiki == "de" then
if ref2~=' ' then url= ' In: <span style="font-style:italic;">' .. s2 .. '</span>' else url='' end
ref = '<span style="font-style:italic;">['.. ref1.. ' '.. ref2.. '.]</span> '.. url.. ref3 .. ref4 ..'.'
else
if ref2~=' ' then url= ' <span style="font-style:italic;">' .. s2 .. '</span>' else url='' end
ref = ref2b .. '['.. ref1.. ' '.. ref2.. '] ' .. url.. ref3 .. ref4
end
-- end-- end if wiki == 'www'
return ref or ''
else return ''
end
end
 
Ред 104 ⟶ 1.582:
local t = {is_a="", class="", stage="", starttime="", endtime="", time="", date="", dates="", length="", length_unit="",
startplace="", endplace="", nr_teams="", nr_participants_start="", nr_participants_end="", speed="", speed_unit="", cost="", cost_unit="",
first="", first_team="", second="", second_team="", third="", winner_pointthird_team="", winner_mountainwinner_point="", winner_sprintwinner_point_team="", winner_youngwinner_mountain="", winner_fightingwinner_mountain_team="",
winner_sprint="", winner_sprint_team="", winner_young="", winner_young_team="", winner_fighting="", winner_fighting_team="", winner_combination="",
winner_combination="", winner_team="", previous="", next=""}
winner_combination_team="", winner_metas_volantes="", winner_metas_volantes_team="", winner_regularity="", winner_regularity_team="",
winner_fuga_pinarello="", winner_fuga_pinarello_team="", winner_azzurri_ditalia="", winner_azzurri_ditalia_team="", winner_team="",
winner_team_points="", previous="", next=""}
local ref = {stage="", starttime="", endtime="", time="", date="", dates="", length="", nr_participants_start="", nr_participants_end="",
speed="", speed_unit="", cost="", first="", second="", third="", winner_point="", winner_mountain="", winner_sprint="", winner_young="",
winner_fighting="", winner_metas_volantes="", winner_regularity="", winner_combination="", winner_fuga_pinarello="", winner_azzurri_ditalia="",
winner_team="", winner_team_points=""}
local tt = {icon="", picture="", caption="", name="", nr="", map="" }
local ttt = {tour={}, country={}}
Ред 116 ⟶ 1.601:
local entityId = frame.args[1]
local lang = mw.language.getContentLanguage()
local wiki = string.match(mw.site.server, "%a+")
local results = false
local a1, b1, c1, a2, b2, c2
local timeofrace
 
if type( entityId ) ~= 'string' then error( 'parameter must be a string') end
Ред 128 ⟶ 1.614:
then localFrame = frame:getParent() else localFrame = frame end
 
if localFrame.args[infobox_leftinfobox_translate(29)] then tt.picture = localFrame.args[infobox_leftinfobox_translate(29)] end
if localFrame.args[infobox_leftinfobox_translate(30)] then tt.caption = localFrame.args[infobox_leftinfobox_translate(30)] end
if localFrame.args[infobox_leftinfobox_translate(31)] then tt.map = localFrame.args[infobox_leftinfobox_translate(31)] end
 
if entity:getLabel() ~= nil then tt.name = entity:getLabel()
Ред 144 ⟶ 1.630:
a, b = pcall(fooA, 'value', entity, 'P18', 1)
if a == true and tt.picture == "" then
local v
tt.picture = b
tt.picture = b
for _, v in pairs(entity.claims["P18"]) do
if pcall(foo3, entity, "P18", 1, "P2096", 1) then
for num=1,#v.qualifiers["P2096"] do
for _, v in pairs(entity.claims["P18"]) do
if v.qualifiers["P2096"][num].datavalue.value.language == lang:getCode() then
tt.captionfor num= 1,#v.qualifiers["P2096"][num].datavalue.value.text enddo
if v.qualifiers["P2096"][num].datavalue.value.language == lang:getCode() then
end
tt.caption = v.qualifiers["P2096"][num].datavalue.value.text end
end
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" or wiki == "//www.wikidata.org" then
if b == 1 then tt.nr = "1<sup>re</sup> " else tt.nr = b .."<sup>e</sup> " end end
if wiki == "//nl.wikipedia.org" then tt.nr = b .."e " end
if wiki == "//ru.wikipedia.org" then tt.nr = b .."-й " end
if wiki == "//eo.wikipedia.org" then tt.nr = b .."-a " end
if wiki == "//cs.wikipedia.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
Ред 180 ⟶ 1.669:
 
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
local i, v
for i, v in pairs(entity.claims["P361"]) do
ttt.tour[i] = "T" .. v.mainsnak.datavalue.value["numeric-id"]
Ред 216 ⟶ 1.706:
else t.starttime = lang:formatDate( "j", b1 )
end
if wiki == "//br.wikipedia.org" then
if y ~= y2 then t.starttime = lang:formatDate( "j", b1 ) .." a viz ".. lang:formatDate( "F Y", b1 )
elseif m ~= m2 then t.starttime = lang:formatDate( "j", b1 ) .." a viz ".. lang:formatDate( "F", b1 )
else t.starttime = lang:formatDate( "j", b1 ) .." "
end end
if wiki == "//ca.wikipedia.org" or wiki == "//es.wikipedia.org" then
if y ~= y2 then t.starttime = lang:formatDate( "j", b1 ) .." de ".. lang:formatDate( "F", b1 ) .." de ".. lang:formatDate( "Y", b1 )
elseif m ~= m2 then t.starttime = lang:formatDate( "j", b1 ) .." de ".. lang:formatDate( "F", b1 )
else t.starttime = lang:formatDate( "j", b1 ) .." "
end end
if wiki == "//cs.wikipedia.org" then
if y ~= y2 then t.starttime = lang:formatDate( "j. xg Y", b1 )
elseif m ~= m2 then t.starttime = lang:formatDate( "j. xg", b1 )
else t.starttime = lang:formatDate( "j", b1 )
end end
if wiki == "//de.wikipedia.org" or wiki == "//da.wikipedia.org" or wiki == "//fi.wikipedia.org" or wiki == "//fo.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 == "//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 == "//eo.wikipedia.org" then
if y ~= y2 then t.starttime = lang:formatDate( "j", b1 ) .."-a de ".. lang:formatDate( "F Y", b1 )
elseif m ~= m2 then t.starttime = lang:formatDate( "j", b1 ) .."-a de ".. lang:formatDate( "F", b1 )
else t.starttime = lang:formatDate( "j", b1 ) .."-a "
end end
if wiki == "//eu.wikipedia.org" then
if y ~= y2 then t.starttime = lang:formatDate( "Y", b1 ) ..".eko ".. lang:formatDate( "F", b1 ) .."k ".. lang:formatDate( "j", b1 )
elseif m ~= m2 then t.starttime = lang:formatDate( "F", b1 ) .."k ".. lang:formatDate( "j", b1 )
else t.starttime = lang:formatDate( "F", b1 ) .."k ".. lang:formatDate( "j", b1 )
end end
if wiki == "//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 == "//lv.wikipedia.org" then
if y ~= y2 then t.starttime = lang:formatDate( "Y. \\g\\a\\d\\a j. F", b1 )
elseif m ~= m2 then t.starttime = lang:formatDate( "Y. \\g\\a\\d\\a j. F", b1 )
else t.starttime = lang:formatDate( "Y. \\g\\a\\d\\a j.", b1 )
end end
if wiki == "//pl.wikipedia.org" then
local date_pl = {"stycznia", "lutego", "marca", "kwietnia", "maja", "czerwca", "lipca", "sierpnia", "września", "października", "listopada", "grudnia"}
if y ~= y2 then t.starttime = lang:formatDate( "j ", b1 ) .. date_pl[tonumber(lang:formatDate( "n", b1 ))] .. lang:formatDate( " Y", b1 )
Ред 270 ⟶ 1.760:
if a2 == true and t.endtime == "" then
t.endtime = lang:formatDate( "j F Y", b2 )
timeofrace = b2
if wiki == "//br.wikipedia.org" then
if wiki == "br" then t.endtime = lang:formatDate( "j", b2 ) .." a viz ".. lang:formatDate( "F Y", b1b2 ) end
if wiki == "ca" or wiki == "es" then t.endtime = lang:formatDate( "j", b2 ) .." de ".. lang:formatDate( "F", b2 ) .." de ".. lang:formatDate( "Y", b2 ) end
if wiki == "//ca.wikipedia.org" or wiki == "//es.wikipedia.org" then
t.endtimeif wiki == lang:formatDate( "jcs", b2 )then t.."endtime de "..= lang:formatDate( "F", b1 ) j.." dexg ".. lang:formatDate( "Y", b1b2 ) end
if wiki == "de" or wiki == "da" or wiki == "fi" or wiki == "fo" or wiki == "no" then t.endtime = lang:formatDate( "j. F Y", b2 ) end
if wiki == "//cs.wikipedia.org" then
if wiki == "en" then
t.endtime = lang:formatDate( "j. xg Y", b2 ) end
if wiki == "//de.wikipedia.org" or wiki == "//da.wikipedia.org" or wiki == "//fi.wikipedia.org" or wiki == "//fo.wikipedia.org" or wiki == "//no.wikipedia.org" then
t.endtime = lang:formatDate( "j. F Y", b2 ) 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 == "eo" then t.endtime = lang:formatDate( "j", b2 ) .."-a de ".. lang:formatDate( "F Y", b2 ) end
if wiki == "//eo.wikipedia.org" then
if wiki == "eu" then t.endtime = lang:formatDate( "jY", b2 ) .."-a de.eko ".. lang:formatDate( "F", Yb2 ) .."k ".. lang:formatDate( "j", b1b2 ) end
if wiki == "//eu.wikipedia.orgja" then
t.endtime = lang:formatDate( "Y", b1 ) ..".eko ".. lang:formatDate( "F", b1 ) .."k ".. lang:formatDate( "j", 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 == "//lv.wikipedia.org" then
if y ~= y2 then t.endtime = lang:formatDate( "Y. \\g\\a\\d\\a j. F", b2 )
elseif m ~= m2 then t.endtime = lang:formatDate( "j. F", b2 )
else t.endtime = lang:formatDate( "j. F", b2 )
end end
if wiki == "//pl.wikipedia.org" then
local date_pl = {"stycznia", "lutego", "marca", "kwietnia", "maja", "czerwca", "lipca", "sierpnia", "września", "października", "listopada", "grudnia"}
t.endtime = lang:formatDate( "j ", b2 ) .. date_pl[tonumber(lang:formatDate( "n", b2 ))] .. lang:formatDate( " Y", b2 ) end
Ред 309 ⟶ 1.794:
a1, b1, c1 = pcall(fooA, 'time', entity, 'P585', i)
end
t.time = lang:formatDatefunc_date (b1, "j F Y"wiki, b1 'long')
timeofrace = b1
if wiki == "//br.wikipedia.org" then
t.time = lang:formatDate( "j", b1 ) .." a viz ".. lang:formatDate( "F Y", b1 ) end
if wiki == "//ca.wikipedia.org" or wiki == "//es.wikipedia.org" then
t.time = lang:formatDate( "j", b1 ) .." de ".. lang:formatDate( "F", b1 ) .." de ".. lang:formatDate( "Y", b1 ) end
if wiki == "//cs.wikipedia.org" then
t.time = lang:formatDate( "j. xg Y", b1 ) end
if wiki == "//de.wikipedia.org" or wiki == "//da.wikipedia.org" or wiki == "//fi.wikipedia.org" or wiki == "//fo.wikipedia.org" or wiki == "//no.wikipedia.org" then
t.time = lang:formatDate( "j. F Y", b1 ) end
if wiki == "//en.wikipedia.org" then
t.time = lang:formatDate( "F d, Y", b1 ) end
if wiki == "//eo.wikipedia.org" then
t.time = lang:formatDate( "j", b1 ) .."-a de ".. lang:formatDate( "F Y", b1 ) end
if wiki == "//eu.wikipedia.org" then
t.time = lang:formatDate( "Y", b1 ) ..".eko ".. lang:formatDate( "F", b1 ) .."k ".. lang:formatDate( "j", b1 ) end
if wiki == "//ja.wikipedia.org" then
t.time = lang:formatDate( "Y年m月d日", b1 ) end
if wiki == "//lv.wikipedia.org" then
t.time = lang:formatDate( "Y. j. F", b1 ) end
if wiki == "//pl.wikipedia.org" then
local date_pl = {"stycznia", "lutego", "marca", "kwietnia", "maja", "czerwca", "lipca", "sierpnia", "września", "października", "listopada", "grudnia"}
t.time = lang:formatDate( "j ", b1 ) .. date_pl[tonumber(lang:formatDate( "n", b1 ))] .. lang:formatDate( " Y", b1 ) end
end
 
Ред 345 ⟶ 1.810:
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
Ред 353 ⟶ 1.818:
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
local i, v
for i, v in pairs(entity.claims["P17"]) do
ttt.country[i] = "C" .. v.mainsnak.datavalue.value["numeric-id"]
Ред 387 ⟶ 1.853:
i = i + 1
a1, b1, c1 = pcall(fooA, 'amount', entity, 'P1132', i)
end
local v
for _, v in pairs(entity.claims["P1132"]) do
if pcall(function()
if v.qualifiers["P276"][1].datavalue.value["numeric-id"] == 529711 then
if v.qualifiers["P276"][1].datavalue.value["numeric-id"] == 529711 then
if pcall(function()
t.nr_participants_start = string.gsub(v.mainsnak.datavalue.value.amount, "+", "") end
end
end
) then else t.nr_participants_start = "" end
if pcall(function()
end
if v.qualifiers["P276"][1].datavalue.value["numeric-id"] == 1505371612769393 then
t.nr_participants_end = string.gsub(v.mainsnak.datavalue.value.amount, "+", "") end
if pcall(function()
end
t.nr_participants_end = string.gsub(v.mainsnak.datavalue.value.amount, "+", "")
) then else t.nr_participants_end = "" end
end
end -- for
) 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
Ред 416 ⟶ 1.881:
if b1 == "http://www.wikidata.org/entity/Q180154" then
t.speed_unit = 'km/h'
if wiki == "//nl.wikipedia.orgda" then t.speed_unit = 'km/ut' end
if wiki == "//mk.wikipedia.orgnl" then t.speed_unit = 'кмkm/чu' end
if wiki == "//ru.wikipedia.orgno" then t.speed_unit = 'кмkm/чt' end
if wiki == "//ja.wikipedia.orgmk" then t.speed_unit = 'キロメートル毎時км/ч' end
if wiki == "ru" then t.speed_unit = 'км/ч' end
if wiki == "ja" then t.speed_unit = 'キロメートル毎時' end
end
end -- if a1
Ред 437 ⟶ 1.904:
a, b = pcall(fooA, 'numeric-id', entity, 'P156', 1)
if a == true and t.next == "" then t.next = "Q"..b end
local note, qual, id, id_team
-- By entering a value just below, the Wikipedia added will have Wikidata logos associated with cyclists in the infobox
if wiki == "www" or wiki == "mk" or wiki == "ja" or wiki == "lv" or wiki == "ru" then note = 'q' else note = 'f' end
-- By entering a value just below, the Wikipedia added will show the team of the winner
if pcall(foo3, entity, "P1346", 1, "P642", 1) then
local k, v, vv
for k, v in pairs(entity.claims["P1346"]) do
id_team = ''
--id_team = 't26973671'
a, b = pcall(fooC, 'numeric-id', entity, 'P1346', k, 'P54', 1)
if a == true then id_team = 't'..b end
if pcall(function() id=v.mainsnak.datavalue.value['numeric-id'] end) then else id=nil end -- id = rider id
if id ~= nil then
--timeofrace = "+2016-03-00T00:00:00Z"
-- function timeStartEnd finds the team of the rider at the time (timeofrace) of the race
if id_team == '' and timeofrace ~= nil and timeofrace ~= '' then
a, b = timeStartEnd('Q'..id, 'P54', 'numeric-id', timeofrace)
if a == true and b ~= nil then id_team = 't' .. b end
end
end
-- pcall(function() id=v.mainsnak.datavalue.value['numeric-id'] end) -- rider ID
-- looks into race item if the winner has a P54 statement for beeng a member of a national team
pcall(function()
for _, vv in pairs(entity.claims["P1346"][k].qualifiers['P54']) do
id_team = '2t'.. ' ('.. national_team(wiki, 'Q'..id, timeofrace, entity, 'P1346', k).. ')'
end
end)
 
-- looks into race item if the winner has a P642 statement for showing the type of winner (points, mountain, ..)
-- By entering a value just below, the Wikipedia added will not have Wikidata logos associated with cyclists in the infobox
pcall(function()
local note, qual, id
for _, vv in pairs(entity.claims["P1346"][k].qualifiers['P642']) do
if wiki == "//fr.wikipedia.org" or wiki == "//en.wikipedia.org" or wiki == "//br.wikipedia.org" or wiki == "//ca.wikipedia.org" or
qual=vv.datavalue.value['numeric-id']
wiki == "//cs.wikipedia.org" or wiki == "//da.wikipedia.org" or wiki == "//de.wikipedia.org" or wiki == "//eo.wikipedia.org" or
 
wiki == "//es.wikipedia.org" or wiki == "//eu.wikipedia.org" or wiki == "//fi.wikipedia.org" or wiki == "//fo.wikipedia.org" or
if id~=nil and qual~=nil and v.rank~='deprecated' then
wiki == "//hu.wikipedia.org" or wiki == "//it.wikipedia.org" or wiki == "//lb.wikipedia.org" or wiki == "//nl.wikipedia.org" or
if qual == 20882667 and t.first=="" then t.first=note..id t.first_team=id_team ref.first=references(entity,"P1346",k) results=true end
wiki == "//no.wikipedia.org" or wiki == "//pl.wikipedia.org" or wiki == "//pt.wikipedia.org" or wiki == "//ro.wikipedia.org" or
if qual == 20882668 and t.second=="" then t.second=note..id t.second_team=id_team ref.second=references(entity,"P1346",k) results=true end
wiki == "//sv.wikipedia.org" then
if qual == 20882669 and t.third=="" then t.third=note..id t.third_team=id_team ref.third=references(entity,"P1346",k) results=true end
note = 'f' else note = 'q' end
if qual == 20883007 and t.winner_point=="" then t.winner_point=note..id t.winner_point_team=id_team ref.winner_point=references(entity,"P1346",k) results=true end
if pcall(foo3, entity, "P1346", 1, "P642", 1) then
if qual == 20883212 and t.winner_mountain=="" then t.winner_mountain=note..id t.winner_mountain_team=id_team ref.winner_mountain=references(entity,"P1346",k) results=true end
for _, v in pairs(entity.claims["P1346"]) do
if qual == 20883328 and t.winner_sprint=="" then t.winner_sprint=note..id t.winner_sprint_team=id_team ref.winner_sprint=references(entity,"P1346",k) results=true end
if pcall(function() id=v.mainsnak.datavalue.value['numeric-id'] end) then else id=nil end
if qual == 20883139 and t.winner_young=="" then t.winner_young=note..id t.winner_young_team=id_team ref.winner_young=references(entity,"P1346",k) results=true end
if pcall(function() qual=v.qualifiers["P642"][1].datavalue.value["numeric-id"] end) then else qual=nil end
if qual == 20893983 and t.winner_fighting=="" then t.winner_fighting=note..id t.winner_fighting_team=id_team ref.winner_fighting=references(entity,"P1346",k) results=true end
if id~=nil and qual~=nil and v.rank~='deprecated' then
if qual == 2088266727067359 and t.first winner_metas_volantes== "" then t.first winner_metas_volantes= note .. id resultst.winner_metas_volantes_team=id_team ref.winner_metas_volantes=references(entity,"P1346",k) results=true end
if qual == 2088266827067170 and t.second winner_regularity== "" then t.second winner_regularity= note .. id resultst.winner_regularity_team=id_team ref.winner_regularity=references(entity,"P1346",k) results=true end
if qual == 2088266920893979 and t.third winner_combination== "" then t.third winner_combination= note .. id resultst.winner_combination_team=id_team ref.winner_combination=references(entity,"P1346",k) results=true end
if qual == 2088300727907715 and t.winner_point winner_fuga_pinarello== "" then t.winner_point winner_fuga_pinarello= note .. id resultst.winner_fuga_pinarello_team=id_team ref.winner_fuga_pinarello=references(entity,"P1346",k) results=true end
if qual == 2088321227907747 and t.winner_mountain winner_azzurri_ditalia== "" then t.winner_mountain winner_azzurri_ditalia= note .. id resultst.winner_azzurri_ditalia_team=id_team ref.winner_azzurri_ditalia=references(entity,"P1346",k) results=true end
if qual == 2088332820882921 and t.winner_sprintwinner_team == "" then t.winner_sprintwinner_team = note .. id ref.winner_team=references(entity,"P1346",k) results = true end
if qual == 2088313927104269 and t.winner_youngwinner_team_points == "" then t.winner_youngwinner_team_points = note .. id ref.winner_team_points=references(entity,"P1346",k) results = true end
end
if qual == 20893983 and t.winner_fighting == "" then t.winner_fighting = note .. id results = true end
end
if qual == 20893979 and t.winner_combination == "" then t.winner_combination = note .. id results = true end
end)
if qual == 20882921 and t.winner_team == "" then t.winner_team = note .. id results = true end
end end -- if idfor
end -- for
end -- end if pcall
 
-- code for references
local list = {} -- list[1][1] = value from ref.first, list [1][2] = 'first'
local k
for k in pairs(ref) do
if ref[k]~='' then table.insert(list, {ref[k], k}) end
end
local w, ww
num = #list
for w=num,1,-1 do
for ww=1,w do
-- mw.log ('w=',w,' ww= ', ww)
if w ~= ww then
if list[w][1] == list[ww][1] then list[w][1] = frame:extensionTag{name='ref', args={name=entityId..ww}} break end
else list[w][1] = frame:extensionTag{name='ref', content=list[w][1], args={name=entityId..ww}} end
end
end
for i=1,num do
ref[ list[i][2] ] = list[i][1] --list[num+1-i][1]
end
 
-- 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], datumtimeofrace).." ".. WPlink( ttt[k][i] ) end end
if ttt[k][1]~=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") ttt[k][i] = WPlink( ttt[k][i], 'race') end end
end
for k in pairs(t) do
Ред 487 ⟶ 1.998:
t[k] = mw.ustring.upper( t[k] )
--look into P27 (country of citizenship) to get the Qnumber of that country
a, b = pcalltimeStartEnd(fooA, 'numeric-id', mw.wikibase.getEntity( t[k], )"P27", 'P27numeric-id', 1timeofrace)
if a == true and pcall(foo1, t[k]) then t[k] = flag( getNationalityOnDate (t[k]'Q'..b, datum), datumtimeofrace).." "..WPlink( t[k] )..ref[k]..wd..t[k].."]]"
else
--look into P17 (country) to get the Qnumber of that country
a, b = pcall(fooA, 'numeric-id', mw.wikibase.getEntity( t[k] ), 'P17', 1)
if a == true and pcall(foo1, t[k]) then t[k] = flag("Q"..b, datumtimeofrace).." "..WPlink( t[k], team )..ref[k]..wd..t[k].."]]" end
end
end
Ред 498 ⟶ 2.009:
t[k] = string.gsub(t[k], "f", "Q")
--look into P27 (country of citizenship) to get the Qnumber of that country
a, b = pcalltimeStartEnd(fooA, 'numeric-id', mw.wikibase.getEntity( t[k], )"P27", 'P27numeric-id', 1timeofrace)
if a == true and pcall(foo1, t[k]) then t[k] = flag( getNationalityOnDate (t[k]'Q'..b, datum), datumtimeofrace).." "..WPlink( t[k] )..ref[k]
else
--look into P17 (country) to get the Qnumber of that country
a, b = pcall(fooA, 'numeric-id', mw.wikibase.getEntity( t[k] ), 'P17', 1)
if a == true and pcall(foo1, t[k]) then t[k] = flag("Q"..b, datumtimeofrace).." "..WPlink( t[k], team'winner_team', timeofrace )..ref[k] else t[k] = WPlink( t[k], 'winner_team', timeofrace )..ref[k] end
end
end
Ред 509 ⟶ 2.020:
t[k] = string.gsub(t[k], "c", "Q")
if pcall(foo1, t[k]) then t[k] = WPlink( t[k], "Q22348500" ) end
end
if string.find(t[k], "^t") then
t[k] = string.gsub(t[k], "t", "Q")
--timeofrace = "+2008-04-09T00:00:00Z"
if pcall(foo1, t[k]) then t[k] = " (" .. WPlink( t[k], 'team', timeofrace ) .. ")" end
end
if string.find(t[k], "^2t") then t[k] = string.gsub(t[k], "2t", "") end
end
 
--local nl ="&#10;"
-- 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 ="&#10;"
-- local tooltip = infobox_bottom(2) .. nl .. mw.text.encode( property(1) .. ' (P393)' ) .. nl .. mw.text.encode( property(2) ..' (P17)')
Ред 543 ⟶ 2.045:
end
local span1, span2 = "<span style='color:#3366CC'>&#x25C0; </span>", "<span style='color:#3366CC'> &#x25B6;</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.gsubmatch(string.sub(k, i+1, j-1), "%D", "d%d%d%d") .. string.sub(k, j)
else
if string.find(k, "%d%d%d%d") == nil then t.previous = ""'' else t.previous = string.sub(k, string.find(k, "%d%d%d%d")) end
if t.previous ~= "" then t.previous = span1 .. t.previous end
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
if string.find(k, "%d%d%d%d") == nil then t.next = "" else t.next = string.sub(k, string.find(k, "%d%d%d%d")) end
if t.next ~= "" then t.next = t.next .. span2 end
end
tt.caption = string.gsub(tt.caption, "{{(%w+)}}", function (n) return frame:expandTemplate{ title = n } end)
 
k = t.next
local z = {stage=5, date=6, dates=7, length=8, startplace=11, endplace=12, nr_teams=13, nr_participants_start=14, nr_participants_end=15,
i, _ = string.find(k, "|")
speed=16, cost=17, first=19, second=20, third=21, winner_point=22, winner_mountain=23, winner_sprint=24, winner_young=25, winner_fighting=26, winner_combination=27,
j, _ = string.find(k, "]")
winner_team=28}
if i ~= nil and j ~= nil then
t.next = string.sub(k, 1, i) .. string.match(string.sub(k, i+1, j-1), "%d%d%d%d") .. span2 .. string.sub(k,j)
else
if string.find(k, "%d%d%d%d") == nil then t.next = "" else t.next = string.sub(k, string.find(k, "%d%d%d%d")) end
if t.next ~= "" then t.next = t.next .. span2 end
end
 
tt.caption = string.gsub(tt.caption, "{{(%w+)}}", function (n) return frame:expandTemplate{ title = n } end)
for i,k in pairs(z) do
-- for overwriting Wikidata content with data in Wikipedia articles. numbers are from function infobox_translate
if localFrame.args[infobox_left(k)]~="" and localFrame.args[infobox_left(k)]~=nil then
local z = {stage=5, date=6, dates=7, length=8, startplace=11, endplace=12, nr_teams=13, nr_participants_start=14, nr_participants_end=15,
if k>=19 and k<=28 then t[i] = t[i] .. ' '.. localFrame.args[infobox_left(k)] else t[i] = localFrame.args[infobox_left(k)] end
speed=16, cost=17, first=19, second=20, third=21, winner_point=22, winner_mountain=23, winner_sprint=24, winner_young=25, winner_fighting=26,
if i=="length" then t.length_unit="" end
winner_combination=27, winner_team=28, winner_team_points=37, winner_metas_volantes=35, winner_regularity=36, winner_fuga_pinarello=38,
if i=="speed" then t.speed_unit="" end
winner_azzurri_ditalia=39}
local i, k, s
for i,k in pairs(z) do
s = localFrame.args[mw.ustring.gsub(infobox_translate(k), "&#173;", "")] -- filter soft hyphen out
if s~="" and s~=nil then
t[i] = s
if i=="length" then t.length_unit="" end
if i=="speed" then t.speed_unit="" end
if i=="cost" then t.cost_unit="" end
else
if k>=19 and k<=27 then t[i] = t[i].. t[i..'_team'] end
if k>=35 and k<=36 then t[i] = t[i].. t[i..'_team'] end
if k>=38 and k<=39 then t[i] = t[i].. t[i..'_team'] end
end
end
 
if localFrame.args[infobox_leftinfobox_translate(32)]~="" and localFrame.args[infobox_leftinfobox_translate(32)]~=nil then
i, k = string.find(localFrame.args[infobox_leftinfobox_translate(32)] , ":")
tttt.special_1a = string.sub(localFrame.args[infobox_leftinfobox_translate(32)], 1, i-1)
tttt.special_1b = string.sub(localFrame.args[infobox_leftinfobox_translate(32)], k+1)
end
if localFrame.args[infobox_leftinfobox_translate(33)]~="" and localFrame.args[infobox_leftinfobox_translate(33)]~=nil then
i, k = string.find(localFrame.args[infobox_leftinfobox_translate(33)] , ":")
tttt.special_2a = string.sub(localFrame.args[infobox_leftinfobox_translate(33)], 1, i-1)
tttt.special_2b = string.sub(localFrame.args[infobox_leftinfobox_translate(33)], k+1)
end
 
if wiki == "//fi.wikipedia.org" then
if t.starttime ~= "" then t.starttime = mw.ustring.gsub(t.starttime, "%a+", "%0ta") end
if t.endtime ~= "" then t.endtime = mw.ustring.gsub(t.endtime, "%a+", "%0ta") end
if t.time ~= "" then t.time = mw.ustring.gsub(t.time, "%a+", "%0ta") end
end
 
tab = "<table cellpadding='4' cellspacing='0' style='float:right; width:300px; border:1px solid rgb(200,200,200);"
tab = tab .. "margin:0 0 0.5em 0.5em; background-color:rgb(255, 255, 255); color:black; padding:5px; clear:left; "
tab = tab .. "text-align:left; font-size:85%; line-height:1.6em;'>"
if wiki == "//eo.wikipedia.org" then tab = "<table style='width:23em; border:1px solid rgb(200,200,200);"
tab = tab .. "margin:0 0 0.5em 0.5em; background-color:rgb(255, 255, 255); color:black; padding:5px; "
tab = tab .. "text-align:left; font-size:85%; line-height:1.6em;' class='infobox' >"
end
tab = tab .. "<tr><td colspan='2' style='border-bottom:5px solid white; font-size:175%; background:#FFDF80; text-align:center'>"
tab = tab .. "<table style='width:100%'><tr><td>[[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_leftinfobox_translate(1).."'''</td></tr>"
if tt.nr ~= "" and t.is_a ~= "" then tab = tab.."<tr><td style='width:40%'>'''"..infobox_leftinfobox_translate(2).."'''</td><td>" .. tt.nr .. " " .. t.is_a .. "</td></tr>" end
if ttt.tour[1] ~= nil then tab = tab.."<tr><td style= 'vertical-align:top'>'''"
if #ttt.tour == 1 then tab = tab..infobox_leftinfobox_translate(3).."'''</td><td>" else tab = tab..infobox_leftinfobox_translate(4).."'''</td><td>" end
for i=1,#ttt.tour do tab = tab .. ttt.tour[i] if i == 1 then tab = tab .. " " ..t.class end tab = tab .. "<br>" end
tab = tab.."</td></tr>" end
if t.stage ~= "" then tab = tab.."<tr><td>'''"..infobox_leftinfobox_translate(5).."'''</td><td>" .. t.stage.."</td></tr>" end
if (t.starttime~="" or t.endtime~="") and t.date=="" and t.dates=="" then tab = tab.."<tr><td>'''"..infobox_leftinfobox_translate(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~="" and t.date=="" and t.dates=="" then tab = tab.."<tr><td>'''"..infobox_leftinfobox_translate(6).."'''</td><td>" .. t.time.."</td></tr>" end
if t.date~="" then tab = tab.."<tr><td>'''"..infobox_leftinfobox_translate(6).."'''</td><td>" .. t.date.."</td></tr>" end
if t.dates~="" then tab = tab.."<tr><td>'''"..infobox_leftinfobox_translate(7).."'''</td><td>" .. t.dates.."</td></tr>" end
if t.length ~= "" then tab = tab.."<tr><td>'''"..infobox_leftinfobox_translate(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_leftinfobox_translate(9).."'''</td><td>" else tab = tab..infobox_leftinfobox_translate(10).."'''</td><td>" end
for i=1,#ttt.country-1 do tab = tab .. ttt.country[i].."<br>" end tab = tab .. ttt.country[#ttt.country].."</td></tr>" end
if t.startplace ~= "" then tab = tab.."<tr><td>'''"..infobox_leftinfobox_translate(11).."'''</td><td>" .. t.startplace .. "</td></tr>" end
if t.endplace ~= "" then tab = tab.."<tr><td>'''"..infobox_leftinfobox_translate(12).."'''</td><td>" .. t.endplace .. "</td></tr>" end
if t.nr_teams ~= "" then tab = tab.."<tr><td>'''"..infobox_leftinfobox_translate(13).."'''</td><td>" .. t.nr_teams .. "</td></tr>" end
if t.nr_participants_start ~= "" then tab = tab.."<tr><td>'''"..infobox_leftinfobox_translate(14).."'''</td><td>" .. t.nr_participants_start .. "</td></tr>" end
if t.nr_participants_end ~= "" then tab = tab.."<tr><td>'''"..infobox_leftinfobox_translate(15).."'''</td><td>" .. t.nr_participants_end .. "</td></tr>" end
if t.speed ~= "" then tab = tab.."<tr><td>'''"..infobox_leftinfobox_translate(16).."'''</td><td>" .. t.speed .. " "..t.speed_unit.."</td></tr>" end
if t.cost ~= "" then tab = tab.."<tr><td>'''"..infobox_leftinfobox_translate(17).."'''</td><td>" .. t.cost .. " "..t.cost_unit.. "</td></tr>" end
if tttt.special_1a ~= "" then tab = tab.."<tr><td>'''"..tttt.special_1a.."'''</td><td>" .. tttt.special_1b.. "</td></tr>" end
if tttt.special_2a ~= "" then tab = tab.."<tr><td>'''"..tttt.special_2a.."'''</td><td>" .. tttt.special_2b.. "</td></tr>" end
if results then tab = tab.."<tr><td colspan='2' style='border-bottom:5px solid white; background-color:#FFDF80; text-align:center'>'''"..infobox_leftinfobox_translate(18).."'''</td></tr>" end
if t.first ~= "" then tab = tab.."<tr><td>'''"..infobox_leftinfobox_translate(19).."'''</td><td>" .. t.first .. "</td></tr>" end
if t.second ~= "" then tab = tab.."<tr><td>'''"..infobox_leftinfobox_translate(20).."'''</td><td>" .. t.second .. "</td></tr>" end
if t.third ~= "" then tab = tab.."<tr><td>'''"..infobox_leftinfobox_translate(21).."'''</td><td>" .. t.third .. "</td></tr>" end
if t.winner_point ~= "" then tab = tab.."<tr><td>'''"..infobox_leftinfobox_translate(22).."'''</td><td>" .. t.winner_point .. "</td></tr>" end
if t.winner_mountain ~= "" then tab = tab.."<tr><td>'''"..infobox_leftinfobox_translate(23).."'''</td><td>" .. t.winner_mountain .. "</td></tr>" end
if t.winner_sprint ~= "" then tab = tab.."<tr><td>'''"..infobox_leftinfobox_translate(24).."'''</td><td>" .. t.winner_sprint .. "</td></tr>" end
if t.winner_young ~= "" then tab = tab.."<tr><td>'''"..infobox_leftinfobox_translate(25).."'''</td><td>" .. t.winner_young .. "</td></tr>" end
if t.winner_fighting ~= "" then tab = tab.."<tr><td>'''"..infobox_leftinfobox_translate(26).."'''</td><td>" .. t.winner_fighting .. "</td></tr>" end
if t.winner_combinationwinner_metas_volantes ~= "" then tab = tab.."<tr><td>'''"..infobox_leftinfobox_translate(2735).."'''</td><td>" .. t.winner_combinationwinner_metas_volantes .. "</td></tr>" end
if t.winner_teamwinner_regularity ~= "" then tab = tab.."<tr><td>'''"..infobox_leftinfobox_translate(2836).."'''</td><td>" .. t.winner_teamwinner_regularity .. "</td></tr>" end
if ttt.mapwinner_fuga_pinarello ~= "" then tab = tab .. "<tr><td colspan=>'2' style='text-align:center'>"..infobox_translate(38).." [[File:'''</td><td>" .. ttt.mapwinner_fuga_pinarello .."|center|300px]]".. "</td></tr>" end
if t.winner_azzurri_ditalia ~= "" then tab = tab.."<tr><td>'''"..infobox_translate(39).."'''</td><td>" .. t.winner_azzurri_ditalia .. "</td></tr>" end
if t.winner_combination ~= "" then tab = tab.."<tr><td>'''"..infobox_translate(27).."'''</td><td>" .. t.winner_combination .. "</td></tr>" end
if t.winner_team ~= "" then tab = tab.."<tr><td>'''"..infobox_translate(28).."'''</td><td>" .. t.winner_team .. "</td></tr>" end
if t.winner_team_points ~= "" then tab = tab.."<tr><td>'''"..infobox_translate(37).."'''</td><td>" .. t.winner_team_points .. "</td></tr>" end
if tt.map ~= "" then tab = tab .. "<tr><td colspan='2' style='text-align:center'>".." [[File:".. tt.map .."|center|300px]]".."</td></tr>" end
 
tab = tab.."<tr><td>"..t.previous.."</td><td style='text-align:right'>" .. t.next .. "</td></tr>"
local s = "d:Wikidata:WikiProject Cycling/Documentation/infobox"
tab = tab .. "<tr><td colspan='2' style='text-align:right; border-top:3px solid #FFDF80; font-size:75%'>" .. infobox_bottom(1)
tab = tab .. "<tr><td colspan='2' style='text-align:right; border-top:3px solid #FFDF80; font-size:75%'>" .. "[[" .. s .. "|" .. infobox_translate(34) .. "]] [[File:Wikidata-logo S.svg|12px|link=d:".. frame.args[1] .. "]]" --infobox_bottom(1)
--tab = tab .. "<span style='float:right' title='".. tooltip .. "'>[[File:High-contrast-help-browser.svg|10px|right|link=]]"
tab = tab .. "</span></td></tr>"
if wiki == "//eo.wikipedia.org" then tab = tab ..changetemplate() end
tab= tab.."</table>"
return tab
end
 
function national_team(wiki, riderID, startOfSeason, entity, property, k)
-- property: statement where the rider is the value
-- k: loop
local national_team, team, nationality, teamID
-- national team for U23 or older riders
if pcall(function()
local i,j, s
for _, v in pairs(entity.claims[property][k].qualifiers['P54']) do -- for property 'member of sports team'
teamID = 'Q'.. v.datavalue.value['numeric-id'] break
end
 
national_team = mw.wikibase.getEntity( teamID )
-- calculate s for national team item
a, b = pcall(fooA, 'numeric-id', national_team, 'P31', 1) -- test if country
if a == true and b == 20738667 then -- Q20738667 = national cycling team U23
if wiki == 'fr' or wiki == 'www' then s = ' espoirs' else s = ' U23' end
elseif a == true and (b == 1194951 or b == 23726798) then s = '' end
-- Q1194951 = national sports team, Q23726798 = national cycling team
 
a, b = timeStartEnd(riderID, "P27", 'numeric-id', startOfSeason)
if a == true then
local nation = mw.wikibase.getEntityObject( 'Q'..b )
nationality = nation:getLabel() or nation:getLabel('en') .. ' (en)'
if national_team:getSitelink() == nil then
team = nationality.. s
else
team = "[[".. national_team:getSitelink().. "|".. nationality.. s.. ']]'
end
end
 
end) then
else
--standard team
pcall(function()
a, b = timeStartEnd(riderID, 'P54', 'numeric-id', startOfSeason)
if a == true then
national_team = mw.wikibase.getEntity( 'Q'..b )
-- g.team[rank] = national_team:getLabel() or g.country[rank].. s
team = WPlink('Q'..b, 'team', startOfSeason)
end
-- guest team
if teamID ~= nil then team = WPlink(teamID, 'winner_team') end
end)
end
 
return team
end
 
function func_date (date, wiki, mode)
-- local wiki = 'cs'
-- local mode = 'small'
-- local date = '+2016-05-20'
local function standard(datum)
if mode=='long' then return mw.language.getContentLanguage():formatDate("j F Y", datum) end
if mode=='small' then return mw.language.getContentLanguage():formatDate("j M", datum) end
end
local function br(datum)
local lang = mw.getLanguage('br')
if mode=='long' then return lang:formatDate("j", datum ) .." a viz ".. lang:formatDate("F Y", datum) end
if mode=='small' then return lang:formatDate("j", datum ) .." a viz ".. lang:formatDate("M", datum) end
end
local function ca(datum, language)
local lang = mw.getLanguage(language)
if mode=='long' then return lang:formatDate("j", datum) .." de ".. lang:formatDate("F", datum) .." de ".. lang:formatDate("Y", datum) end
if mode=='small' then return lang:formatDate("j", datum) .." de ".. lang:formatDate("M", datum) end
end
local function cs(datum)
local lang = mw.getLanguage('cs')
if mode=='long' then return lang:formatDate("j. xg Y", datum) end
if mode=='small' then return lang:formatDate("j", datum) ..". xg ".. lang:formatDate("M", datum) end
end
local function de(datum, language)
if mode=='long' then return mw.getLanguage(language):formatDate("j. F Y", datum) end
if mode=='small' then return mw.getLanguage(language):formatDate("j. M", datum) end
end
local function eo(datum)
local lang = mw.getLanguage('eo')
if mode=='long' then return lang:formatDate("j", datum) .."-a de ".. lang:formatDate("F Y", datum) end
if mode=='small' then return lang:formatDate("j", datum) .."-a de ".. lang:formatDate("M", datum) end
end
local function en(datum)
if mode=='long' then return mw.getLanguage('en'):formatDate("F d, Y", datum) end
if mode=='small' then return mw.getLanguage('en'):formatDate("M d", datum) end
end
local function eu(datum)
local lang = mw.getLanguage('eu')
if mode=='long' then return lang:formatDate( "Y", datum) ..".eko ".. lang:formatDate("F", datum) .."k ".. lang:formatDate("j", datum) end
if mode=='small' then return lang:formatDate( "M", datum) .."k ".. lang:formatDate("j", datum) end
end
local function fi(datum) -- may be different
if mode=='long' then return mw.ustring.gsub(mw.getLanguage('fi'):formatDate("j. F Y", date), "%a+", "%0ta") end
if mode=='small' then return mw.getLanguage('fi'):formatDate("j. M", date) end
end
local function ja(datum)
if mode=='long' then return mw.getLanguage('ja'):formatDate("Y年m月d日", datum) end
if mode=='small' then return mw.getLanguage('ja'):formatDate("m月d日", datum) end
end
local function lv(datum)
local lang = mw.getLanguage('lv')
if mode=='long' then return lang:formatDate("Y.", datum) .." gada ".. lang:formatDate("j. F", datum) end
if mode=='small' then return lang:formatDate("Y. M", datum) end
end
local function pl(datum)
local lang = mw.getLanguage('pl')
local date_pl = {"stycznia", "lutego", "marca", "kwietnia", "maja", "czerwca", "lipca", "sierpnia", "września", "października", "listopada", "grudnia"}
if mode=='long' then return lang:formatDate("j ", datum) .. date_pl[tonumber(lang:formatDate("n", datum))] .. lang:formatDate(" Y", datum) end
if mode=='small' then return lang:formatDate("j M", datum) end
end
 
local x = {['']=standard(date), ['br']=br(date), ['ca']=ca(date,'ca'), ['cs']=cs(date), ['da']=de(date,'da'), ['de']=de(date,'de'), ['en']=en(date), ['eo']=eo(date),
['es']=ca(date,'es'), ['eu']=eu(date), ['fi']=fi(date), ['fo']=de(date,'fo'), ['ja']=ja(date), ['lv']=lv(date), ['no']=de(date,'no'), ['pl']=pl(date)}
 
--mw.log(b1, x['no'])
return x[wiki] or x['']
end
 
function p.teamroster(frame)
localif columnsframe.args[1] ~= tonumber(nil then frame.args.columns)[1] == 1 and tonumber string.gsub(frame.args.columns)[1], or"%c", 2 --defaults to two"") columnsend
local squadSeason = mw.wikibase.getEntityObject( frame.args[1] )
local flags, pays = {}, {}
local riderIds, riderNames, riderBirthdays, givenname, familyname, riderTeam, time = {}, {}, {}, {}, {}, {}, {}
local riderIds = {}
local riderStart, riderEnd, riderPosition, riderReason, riderRef = {}, {}, {}, {}, {}
local riderNames = {}
local index, riderNames_transl, riderNames_notransl = {}, {}, {}
local riderBirthdays = {}
local labelMissing = false
local wiki = string.match(mw.site.server, "%a+")
local lang = mw.language.getContentLanguage()
local WDlink_off = false
local WDlink_on
local team, rider, startOfSeason
local v = ''
 
local function trans(date, month, day)
-- WDlink_off is used to decide if a Wikidata flag will be shown
if date ~= '' then
if wiki == "//www.wikidata.org" or wiki == "//fr.wikipedia.org" or wiki == "//en.wikipedia.org" or wiki == "//br.wikipedia.org" or
local _, _, y, m, d = string.find(date, "(%d+)-(%d+)-(%d+)")
wiki == "//ca.wikipedia.org" or wiki == "//cs.wikipedia.org" or wiki == "//da.wikipedia.org" or wiki == "//de.wikipedia.org" or
if m == '00' then m = month end
wiki == "//eo.wikipedia.org" or wiki == "//es.wikipedia.org" or wiki == "//eu.wikipedia.org" or wiki == "//fi.wikipedia.org" or
if d == '00' then d = day end
wiki == "//fo.wikipedia.org" or wiki == "//hu.wikipedia.org" or wiki == "//it.wikipedia.org" or wiki == "//lb.wikipedia.org" or wiki == "//nl.wikipedia.org" or wiki == "//no.wikipedia.org" or
date = '+'..y..'-'..m..'-'..d..'T00:00:00Z'
wiki == "//pl.wikipedia.org" or wiki == "//pt.wikipedia.org" or wiki == "//ro.wikipedia.org" or wiki == "//sv.wikipedia.org" then WDlink_off = true end
return date
else return '' end
end
local function name(i, wiki, transl, names, givenname, familyname)
-- transform name "A B ..." into "B ... A"
local _, count = mw.ustring.gsub(names, " ", " ")
local a,b,c,d = '', '', '', ''
local done = false
if count ~= nil then count = count + 1 else count = 1 end
 
if count > 1 then
local startOfSeason = squadSeason.claims["P580"][1].mainsnak.datavalue.value.time
if count == 2 then
if names~='' then _, _, a, b = mw.ustring.find(names, "(%S+)%s+(%S+)") names=b..' '..a..":"..i end
else
local name_parts_lv = {'da', 'de', 'di', 'De', 'la', 'Le', 'ten', 'van', 'Van'}
local name_parts_mk = {'да', 'ди', 'де', 'Де', 'ла', 'Ле', 'тен', 'ван', 'Ван'}
local name_parts_ru = {'да', 'ди', 'де', 'Де', 'ла', 'Ле', 'тен', 'ван', 'Ван'}
local name_parts = {'da', 'de', 'di', 'De', 'la', 'Le', 'ten', 'van', 'Van'}
local v
if count == 3 and names~='' then
_, _, a, b, c = mw.ustring.find(names, "(%S+)%s+(%S+)%s+(%S+)")
if wiki == 'mk' then
for _,v in ipairs(name_parts_mk) do if b == v then names = b..' '..c..' '..a..":"..i done = true break end end
end
if wiki == 'lv' then
for _,v in ipairs(name_parts_lv) do if b == v then names = b..' '..c..' '..a..":"..i done = true break end end
end
if wiki == 'ru' then
for _,v in ipairs(name_parts_ru) do if b == v then names = b..' '..c..' '..a..":"..i done = true break end end
end
if wiki ~= 'lv' and wiki ~= 'mk' and wiki ~= 'ru' then
for _,v in ipairs(name_parts) do if b == v then names = b..' '..c..' '..a..":"..i done = true break end end
end
if transl == 'notransl' then --or (wiki~='lv' and wiki~='mk' and wiki~='ru' and wiki~='ja') then
for _,v in ipairs(name_parts) do if b == v then names = b..' '..c..' '..a..":"..i done = true break end end
end
if not done and familyname==2 then names = b..' '..c..' '..a..":"..i done = true end
if not done and familyname==1 then names = c..' '..a..' '..b..":"..i done = true end
if not done and familyname==0 then names = c..' '..a..' '..b..":"..i done = true end
end
if count > 3 and names~='' then
_, _, a, b, c, d = mw.ustring.find(names, "(%S+)%s+(%S+)%s+(%S+)%s+(%S+)")
if wiki == 'mk' then
for _,v in ipairs(name_parts_mk) do if c == v then names = c..' '..d..' '..a..' '..b..":"..i done = true break end end
for _,v in ipairs(name_parts_mk) do if b == v then names = b..' '..c..' '..d..' '..a..":"..i done = true break end end
end
if wiki == 'lv' then
for _,v in ipairs(name_parts_lv) do if c == v then names = c..' '..d..' '..a..' '..b..":"..i done = true break end end
for _,v in ipairs(name_parts_lv) do if b == v then names = b..' '..c..' '..d..' '..a..":"..i done = true break end end
end
if wiki == 'ru' then
for _,v in ipairs(name_parts_ru) do if c == v then names = c..' '..d..' '..a..' '..b..":"..i done = true break end end
for _,v in ipairs(name_parts_ru) do if b == v then names = b..' '..c..' '..d..' '..a..":"..i done = true break end end
end
if wiki ~= 'lv' and wiki ~= 'mk' and wiki ~= 'ru' then
for _,v in ipairs(name_parts) do if c == v then names = c..' '..d..' '..a..' '..b..":"..i done = true break end end
for _,v in ipairs(name_parts) do if b == v then names = b..' '..c..' '..d..' '..a..":"..i done = true break end end
end
if transl == 'notransl' then --or (wiki~='lv' and wiki~='mk' and wiki~='ru' and wiki~='ja') then
for _,v in ipairs(name_parts) do if c == v then names = c..' '..d..' '..a..' '..b..":"..i done = true break end end
for _,v in ipairs(name_parts) do if b == v then names = b..' '..c..' '..d..' '..a..":"..i done = true break end end
end
if not done then names = b..' '..c..' '..d..' '..a..":"..i end
end
end
end
return names
end
 
local i = 1localFrame
local sort
while squadSeason.claims["P527"][i] do
--[[
riderIds[i] = 'Q' .. squadSeason.claims["P527"][i].mainsnak.datavalue.value['numeric-id']
The word 'sort' is used to sort the riders after the surname. It could look like this in the Wikipedia article
local rider = mw.wikibase.getEntityObject(riderIds[i])
{{Cycling race/teamroster|Q21769847
| sort
local label = rider:getLabel()
}}
local link = rider:getSitelink()
A rider called 'Laurens De Vreese' is sorted after 'De Vreese Laurens'. If you want to sort after 'Vreese Laurens De'
change that in the code. In lvWiki, mkWiki and ruWiki sorting is standard, there is no need to switch sorting on in the article
if label == null then
]]
label = '\'\'' .. rider:getLabel('en') .. '&nbsp;(en)\'\''
if frame.args[2] ~= nil then
labelMissing = true
if string.match(frame:getParent():getTitle(), '%P+') == mw.site.namespaces.Template.name
end
then localFrame = frame:getParent() else localFrame = frame end
if mw.ustring.find(mw.ustring.lower(frame.args[2]), "sort") then sort = true else sort = false end
if link == null then
else sort = false
riderNames[i] = label
end
elseif label == link then
if wiki == "lv" or wiki == "mk" or wiki == "ru" then sort = true end
riderNames[i] = '[[' .. label .. ']]'
else
riderNames[i] = '[[' .. link .. '|' .. label .. ']]'
end
if pcall(function()
riderBirthdays[i] = rider.claims["P569"][1].mainsnak.datavalue.value.time
end
) then else riderBirthdays[i] = '' end
 
pcall(function() team = squadSeason.claims["P361"][1].mainsnak.datavalue.value['numeric-id'] end)
if pcall(function()
flags[i] = flag(getNationalityOnDate (riderIds[i], startOfSeason), startOfSeason)
end
) then else flags[i] = '' end
 
-- WDlink_on is used to decide if a Wikidata flag will be shown
i = i + 1
if wiki == "mk" or wiki == "ja" or wiki == "ru" then WDlink_on = true else WDlink_on = false end
end
 
if pcall(function() startOfSeason = squadSeason.claims["P580"][1].mainsnak.datavalue.value.time end) then
local tableBody = ''
else
local tableHeader = '<table border="0" cellspacing="0" cellpadding="2" width="100%">'
local Sitelink = squadSeason:getSitelink('enwiki') or squadSeason:getSitelink('frwiki') or squadSeason:getSitelink('dewiki') or ''
.. '<tr style="background-color:#FFDF80;"><th width="35%" style="text-align:left;">'
if Sitelink == '' then return '> Wikidata is missing data about the start time (P580) and end time (P582) of the season'
if WDlink_off == true then tableHeader = tableHeader .. '[[File:Wikidata-logo S.svg|12px|link=d:'.. frame.args[1].. '#P527]]&nbsp;&nbsp;' end
else startOfSeason = '+'..string.match(Sitelink, '%d%d%d%d' ) ..'-01-01T00:00:00Z'
tableHeader = tableHeader .. getSquadTableColumn(1) .. '</th><th width="42%" style="text-align:left;">' .. getSquadTableColumn(2) .. '</th></tr>'
end
local tableFoot = '</table>'
end
i = 1
local tableSize = table.getn(riderNames)
while riderNames[i] do
tableBody = tableBody ..'<tr><td nowrap >'..flags[i] .. ' '.. riderNames[i] .. ' '
if WDlink_off == false then tableBody = tableBody .. wdLink(riderIds[i]) end
tableBody = tableBody.. '</td><td nowrap >' ..getDateAndAgeOnDate(frame, startOfSeason, riderBirthdays[i]).. '</td></tr>'
 
local i = 1
if columns == 2 and math.floor((tableSize + 1)/2) == i then
pcall(function()
tableBody = tableBody .. tableFoot ..'</td><td width="1%"></td><td style="vertical-align:top;" width="44%">' .. tableHeader
while squadSeason.claims["P527"][i] do
end
riderIds[i] = 'Q' .. squadSeason.claims["P527"][i].mainsnak.datavalue.value['numeric-id']
i = i + 1
riderNames[i] = WPlink(riderIds[i])
end
local tableStart = '<table border="0"><tr><td style="vertical-align:top;" width="44%">'
local tableEnd = '</td></tr></table>'
if labelMissing then
tableEnd = tableEnd .. getMissingLabelTrackingCategory()
end
 
rider = mw.wikibase.getEntityObject(riderIds[i])
return '<table style="border:1px solid rgb(200,200,200)"><tr><td>'..
if pcall(function() riderBirthdays[i] = rider.claims["P569"][1].mainsnak.datavalue.value.time end
tableStart.. tableHeader.. tableBody.. tableFoot.. tableEnd.. '</td></tr></table>'
) then else riderBirthdays[i] = '' end
if pcall(function() local k for k, _ in pairs(rider.claims["P735"]) do givenname[i] = k end end
) then else givenname[i] = 0 end
if pcall(function() local k for k, _ in pairs(rider.claims["P734"]) do familyname[i] = k end end
) then else familyname[i] = 0 end
 
pcall(function()
local language
if wiki == "www" then language = 'en' else language = wiki end
local entity=mw.wikibase.getEntity(riderIds[i])
if wiki == 'mk' or wiki == 'ru' then
if entity:getLabel(language) ~= nil and (mw.ustring.byte(entity:getLabel(language), 1, 1) > 127 and mw.ustring.byte(entity:getLabel(language), 3, 3) > 127)
then riderNames_transl[i] = entity.labels[language].value riderNames_notransl[i] = ''
else riderNames_notransl[i] = entity.labels['en'].value or entity.labels['fr'].value or entity.labels['de'].value riderNames_transl[i] = ''
end
end
if wiki ~= 'mk' and wiki ~= 'ru' then
if entity:getLabel(language) ~= nil then riderNames_transl[i] = entity.labels[language].value riderNames_notransl[i] = ''
else riderNames_notransl[i] = entity.labels['en'].value or entity.labels['fr'].value or entity.labels['de'].value riderNames_transl[i] = ''
end
end
end)
 
if sort == true then
riderNames_transl[i] = name(i, wiki, 'transl', riderNames_transl[i], givenname[i], familyname[i])
riderNames_notransl[i] = name(i, wiki, 'notransl', riderNames_notransl[i], givenname[i], familyname[i])
else index[i] = i
end
 
if pcall(function()
local date = squadSeason.claims["P527"][i].qualifiers["P580"][1].datavalue.value.time or ''
riderStart[i] = func_date(trans(date,'01', '01'), wiki, 'small')
end
) then else riderStart[i] = '' end
 
if pcall(function()
local date = squadSeason.claims["P527"][i].qualifiers["P582"][1].datavalue.value.time
riderEnd[i] = func_date(trans(date,'12', '31'), wiki, 'small')
end
) then else riderEnd[i] = '' end
 
if pcall(function()
riderPosition[i] = 'Q' .. squadSeason.claims["P527"][i].qualifiers["P39"][1].datavalue.value['numeric-id']
local entity = mw.wikibase.getEntity( riderPosition[i] )
local label = string.gsub(entity:getLabel(), "%b()", "") or entity:getLabel( 'en' )
--if label == null then label = entity:getLabel( 'en' ) end
riderPosition[i] = ', ' .. label end
) then else riderPosition[i] = '' end
 
riderReason[i] = ''
pcall(function() riderReason[i] = 'Q'.. squadSeason.claims["P527"][i].qualifiers["P1643"][1].datavalue.value['numeric-id'] end)
if riderReason[i] == '' then pcall(function() riderReason[i] = 'Q'.. squadSeason.claims["P527"][i].qualifiers["P1642"][1].datavalue.value['numeric-id'] end) end
if riderReason[i] == '' then pcall(function() riderReason[i] = 'Q'.. squadSeason.claims["P527"][i].qualifiers["P1534"][1].datavalue.value['numeric-id'] end) end
if riderReason[i] ~= '' then
local entity = mw.wikibase.getEntity( riderReason[i] )
local label = string.gsub(entity:getLabel(), "%b()", "") or entity:getLabel('en')
--if label == null then label = entity:getLabel( 'en' ) end
riderRef[i] = references(squadSeason, 'P527', i)
riderReason[i] = ', ' .. label
end
 
local a, b
local timeofrace
local changedTime = '+0000-00-00'
local changedTeam = ''
local entity, label
local stagiaire
time[i]='' riderTeam[i] = ''
if pcall(function() timeofrace = squadSeason.claims["P527"][i].qualifiers["P580"][1].datavalue.value.time end)
then else timeofrace = startOfSeason end
if team ~= nil then a = true b = team -- if team known, don´t search for team
else a, b = timeStartEnd(riderIds[i], 'P54', 'numeric-id', timeofrace) team = b
end
if a == true and b ~= nil then
pcall(function()
local v
for _, v in pairs(rider.claims["P54"]) do -- look into all P54 teams
pcall(function() -- get trainee data from rider item
if v.mainsnak.datavalue.value['numeric-id'] == b then -- print riderStart[i], riderEnd[i], riderPosition[i], riderReason[i]
if riderReason[i] == '' then pcall(function() riderReason[i] = 'Q'.. v.qualifiers["P1643"][1].datavalue.value['numeric-id'] end) end
if riderReason[i] == '' then pcall(function() riderReason[i] = 'Q'.. v.qualifiers["P1642"][1].datavalue.value['numeric-id'] end) end
if riderReason[i] == '' then pcall(function() riderReason[i] = 'Q'.. v.qualifiers["P1534"][1].datavalue.value['numeric-id'] end) end
if string.sub(riderReason[i],1,1)=='Q' then -- only for these pcall-functions, not for those at line 970
local entity = mw.wikibase.getEntity( riderReason[i] )
local label = string.gsub(entity:getLabel(), "%b()", "") or entity:getLabel('en')
if pcall(function() riderRef[i] = references(squadSeason, 'P527', i) end) then else riderRef[i]='' end
-- riderRef[i] = references(squadSeason, 'P527', i)
riderReason[i] = ', ' .. label
end
 
local date1 = v.qualifiers["P580"][1].datavalue.value.time
date1 = trans(date1,'01','01')
local _, _, y1, m1, d1 = string.find(date1, "(%d+)-(%d+)-(%d+)")
local date2
if pcall(function() date2 = v.qualifiers["P582"][1].datavalue.value.time end) then else date2='+'..y1..'-12-31T00:00:00Z' end
date2 = trans(date2,'12','31')
local _, _, y2, m2, d2 = string.find(date2, "(%d+)-(%d+)-(%d+)")
local _, _, y3, m3, d3 = string.find(startOfSeason, "(%d+)-(%d+)-(%d+)")
 
if (y1 == y3 or y2 == y3) and ((y1 == y3 and (m1 ~= '01' or d1 ~= '01')) or (y2 == y3 and (m2 ~= '12' or d2 ~= '31'))) then
-- riders who start after 1 January or end earlier then 31 December in the season
riderStart[i] = func_date(date1, wiki,'small')
if pcall(function()
local date = v.qualifiers["P582"][1].datavalue.value.time
riderEnd[i] = func_date(date2, wiki,'small')
end
) then else riderEnd[i] = func_date('+'..y1..'-12-31T00:00:00Z', wiki,'small') end
 
if riderPosition[i] == '' then -- find the 'position' (P39) of a rider
pcall(function() riderPosition[i] ='Q' ..v.qualifiers["P39"][1].datavalue.value['numeric-id']
local entity = mw.wikibase.getEntity( riderPosition[i] )
local label = string.gsub(entity:getLabel(), "%b()", "") or entity:getLabel( 'en' )
riderPosition[i] = ', ' .. label
end)
end
end
end
end)
stagiaire = ''
pcall(function() stagiaire = v.qualifiers["P39"][1].datavalue.value['numeric-id'] end)
if v.mainsnak.datavalue.value['numeric-id'] ~= b and stagiaire == '' then -- find previous team and end time for the rider at that team
local date1 = v.qualifiers["P580"][1].datavalue.value.time
date1 = trans(date1,'01','01')
local _, _, y1, m1, d1 = string.find(date1, "(%d+)-(%d+)-(%d+)")
local date2
if pcall(function() date2 = v.qualifiers["P582"][1].datavalue.value.time end) then else date2='+'..y1..'-12-31T00:00:00Z' end
date2 = trans(date2,'12','31')
local _, _, y2, m2, d2 = string.find(date2, "(%d+)-(%d+)-(%d+)")
local _, _, y3, m3, d3 = string.find(startOfSeason, "(%d+)-(%d+)-(%d+)")
if y1 <= y3 then -- start time < season time
pcall(function()
local timeP582 = v.qualifiers["P582"][1].datavalue.value.time
timeP582 = trans(timeP582,'12', '31')
if timeP582 >= changedTime then -- find maximum end time
-- Case Pierre-Roger Latour: Chambéry CF (2012 - 2014), time season at 2013
-- Task: changedTime should be after start time, but before startOfSeason
local _, _, y4, m4, d4 = string.find(timeP582, "(%d+)-(%d+)-(%d+)")
if y4 > y3 then changedTime = '+'..y3..'-12-31T00:00:00Z' else changedTime = timeP582 end
changedTeam = v.mainsnak.datavalue.value['numeric-id']
end -- end if
end) -- end function
-- print riderTeam[i], time[i]
if changedTime ~= '+0000-00-00' then
pcall(function() riderTeam[i] = WPlink( 'Q'..changedTeam , 'team', changedTime ) end)
local _, _, y1, _, _ = string.find(changedTime, "(%d+)-(%d+)-(%d+)")
time[i] = ' ('..y1..')'
end
end
end -- end if
end -- end for
end) -- end function
end -- end if
 
if pcall(function()
local a, b = timeStartEnd(riderIds[i], "P27", 'numeric-id', startOfSeason)
flags[i] = flag('Q'..b, startOfSeason)
if available==true then
pays[i] = translations.list('Q'..b)
if pays[i] == '' then
local country = mw.wikibase.getEntityObject( 'Q'..b )
pays[i] = country:getLabel() or country:getLabel('en') .. ' (en)'
end
end
end
) then else flags[i] = '' end
 
i = i + 1
end
end)
 
-- sorting names after surname
function getDateAndAgeOnDate (frame, onDate, date)
if sort == true then
local lang = mw.language.getContentLanguage()
if language~='ja' then
local wiki = mw.site.server
table.sort(riderNames_transl, function(a,b) return a<b end)
table.sort(riderNames_notransl, function(a,b) return a<b end)
end
local ii, v1, v2, name1, name2, number
i = 1
-- sorting riders with a translation
for ii,name1 in ipairs(riderNames_transl) do
if name1 ~= '' then
v1, v2 = mw.ustring.find(name1, ":")
number = mw.ustring.sub(name1, v2+1)
name2, _ = mw.ustring.gsub(name1, ":%d+", "")
index[i] = tonumber(number)
i = i + 1
end
end
-- sorting riders without a translation
for ii,name1 in ipairs(riderNames_notransl) do
if name1 ~= '' then
v1, v2 = mw.ustring.find(name1, ":")
number = mw.ustring.sub(name1, v2+1)
name2, _ = mw.ustring.gsub(name1, ":%d+", "")
index[i] = tonumber(number)
i = i + 1
end
end
end
 
local tableBody= ''
time = lang:formatDate( "j F Y", date )
local tableHeader = '<table border="0" cellspacing="0" cellpadding="2">'
if wiki == "//br.wikipedia.org" then
.. '<tr style="background-color:#FFDF80;line-height:1.8em;"><th nowrap style="text-align:left;">'
time = lang:formatDate( "j", date ) .." a viz ".. lang:formatDate( "F Y", date ) end
if WDlink_on == false then tableHeader = tableHeader .. '[[File:Wikidata-logo S.svg|12px|link=d:'.. frame.args[1].. '#P527]]&nbsp;&nbsp;&nbsp;' end
if wiki == "//ca.wikipedia.org" or wiki == "//es.wikipedia.org" then
tableHeader = tableHeader..getSquadTableColumn(1)..'</th><th nowrap style="text-align:right">'..getSquadTableColumn(2)
time = lang:formatDate( "j", date ) .." de ".. lang:formatDate( "F", date ) .." de ".. lang:formatDate( "Y", date ) end
if available==true then tableHeader = tableHeader.. '</th><th nowrap style="text-align:left;padding:0 0.5em">'..getSquadTableColumn(6) .. '&nbsp;' end
if wiki == "//de.wikipedia.org" or wiki == "//da.wikipedia.org" or wiki == "//fo.wikipedia.org" or wiki == "//no.wikipedia.org" then
tableHeader = tableHeader.. '&nbsp;</th><th nowrap style="text-align:left;padding:0 0.5em">'..getSquadTableColumn(3) .. '&nbsp;</th></tr>'
time = lang:formatDate( "j. F Y", date ) end
local tableFoot = '</table>'
if wiki == "//en.wikipedia.org" then
local tableEndText = ''
time = lang:formatDate( "F d, Y", date ) end
local tableSize = table.getn(riderNames)
if wiki == "//eo.wikipedia.org" then
local iii = 1
time = lang:formatDate( "j", date ) .."-a de ".. lang:formatDate( "F Y", date ) end
i = 1
if wiki == "//eu.wikipedia.org" then
while index[i] do
time = lang:formatDate( "Y", date ) ..".eko ".. lang:formatDate( "F", date ) .."k ".. lang:formatDate( "j", date ) end
tableBody = tableBody.. '<tr style="line-height:1.8em"><td nowrap style="padding:0 1em 0 0">'
if wiki == "//ja.wikipedia.org" then
if available==false then tableBody=tableBody.. flags[index[i]]..' '..riderNames[index[i]] else tableBody = tableBody.. riderNames[index[i]] end
time = lang:formatDate( "Y年m月d日", date ) end
if WDlink_on == true then tableBody = tableBody.. ' '.. wdLink(riderIds[index[i]]) end
if wiki == "//lv.wikipedia.org" then
if riderStart[index[i]]~='' or riderEnd[index[i]]~='' then
local _, _, y1, m1, d1 = string.find(onDate, "(%d+)-(%d+)-0*(%d+)")
tableBody=tableBody..'<span style="font-size:80%; color:#686868"> ('..riderStart[index[i]]..'–'..riderEnd[index[i]].. riderPosition[index[i]]
local _, _, y2, m2, d2 = string.find(date, "(%d+)-(%d+)-0*(%d+)")
if riderReason[index[i]] ~= '' then tableBody=tableBody.. ', [[#tr_'..i..frame.args[1]..'|'..getSquadTableColumn(4)..']]' end
time = frame:expandTemplate{ title = 'Template:Birth date and age2', args = { y1, m1, d1, y2, m2, d2 } } end
tableBody=tableBody .. ')</span>'
if wiki == "//fi.wikipedia.org" then
elseif riderReason[index[i]]~='' then
time = mw.ustring.gsub(lang:formatDate( "j. F Y", date ), "%a+", "%0ta") end
tableBody=tableBody.. '<span style="font-size:80%; color:#686868"> ([[#tr_'..i..frame.args[1]..'|'..getSquadTableColumn(4)..']]'.. ')</span>'
if wiki == "//pl.wikipedia.org" then
end
local date_pl = {"stycznia", "lutego", "marca", "kwietnia", "maja", "czerwca", "lipca", "sierpnia", "września", "października", "listopada", "grudnia"}
tableBody = tableBody.. '</td><td nowrap style="text-align:right">'
time = lang:formatDate( "d ", date ) .. date_pl[tonumber(lang:formatDate( "n", date ))] .. lang:formatDate( " Y", date ) end
if wiki == 'lv' then
return time
local _, _, y1, m1, d1 = string.find(startOfSeason,"(%d+)-(%d+)-0*(%d+)")
local _, _, y2, m2, d2 = string.find(riderBirthdays[index[i]],"(%d+)-(%d+)-0*(%d+)")
tableBody = tableBody.. frame:expandTemplate{ title = 'Template:Birth date and age2', args = { y1, m1, d1, y2, m2, d2 } }.. '</td>'
else
tableBody = tableBody.. func_date (riderBirthdays[index[i]], wiki, 'long')
if available==false then tableBody=tableBody..'</td>' else tableBody=tableBody..'</td><td>'.. flags[index[i]].. ' '..pays[i].. '</td>' end
end
tableBody = tableBody.. '<td style="padding:0 0.5em; text-align:left">'
if riderTeam[index[i]] ~= nil then tableBody = tableBody.. riderTeam[index[i]].. time[index[i]] end
tableBody = tableBody..'</td></tr>'
if riderReason[index[i]] ~= '' then
if iii == 1 then tableEndText = tableEndText.. getSquadTableColumn(5)..': '.. riderNames[index[i]].. riderReason[index[i]]
else tableEndText = tableEndText.. '<span style="color:white">'.. getSquadTableColumn(5)..': </span>'.. riderNames[index[i]].. riderReason[index[i]] end
iii = iii + 1
if riderRef[index[i]] ~= '' then tableEndText = tableEndText..
frame:extensionTag{name='ref', content=riderRef[index[i]], args = {name='tr_'..i..frame.args[1]}} end
tableEndText = tableEndText.. '<br>'
end
i = i + 1
end
 
--if tableEndText ~= '' then tableEndText = getSquadTableColumn(5)..': <span style="font-size:80%; color:#686868">'.. tableEndText .. '</span>' 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 borderStyle = 'border:1px solid rgb(200,200,200); padding: 4px'
if wiki == 'lv' then
borderStyle = 'border:0'
end
local tableStart = '<table style="'.. borderStyle.. '"><tr><td style="vertical-align:top;">'
local tableEnd = '</td></tr></table>'
 
if labelMissing then tableEnd = tableEnd .. getMissingLabelTrackingCategory() end
 
return tableStart.. tableHeader.. tableBody.. tableFoot.. tableEnd.. tableEndText
end
 
function timeStartEnd(Qid, property, mode, timeofrace)
-- mode = 'numeric-id', property = 'P54', Qid = 'Q123'
local entity = mw.wikibase.getEntity(Qid)
local a, b = pcall(fooA, mode, entity, property, 1)
local starttime, endtime
 
if a == true then
local timeStartEnd = {}
local num = 1
local v
for _, v in pairs(nationalities) do
for _, v in pairs(entity.claims[property]) do
if pcall(function () local test = v.mainsnak.datavalue.value[mode] end) then -- test if not 'unnown value'
if pcall(function () starttime = v.qualifiers["P580"][1].datavalue.value.time end) then
starttime = v.qualifiers["P580"][1].datavalue.value.time
local _,_,year,m,d = string.find(starttime,"(%d+)-(%d+)-(%d+)")
if m == '00' and d == '00' then starttime = '+'..year..'-01-01T00:00:00Z' end
end
if pcall(function () endtime = v.qualifiers["P582"][1].datavalue.value.time end) then
endtime = v.qualifiers["P582"][1].datavalue.value.time
local _,_,year,m,d = string.find(endtime,"(%d+)-(%d+)-(%d+)")
if m == '00' and d == '00' then endtime = '+'..year..'-12-31T00:00:00Z' end
if m == '01' and d == '01' then endtime = '+'..year..'-12-31T00:00:00Z' end
end
if v.qualifiers then
if (not v.qualifiers["P580"] or v.qualifiers["P580"][1].datavalue.value.timestarttime <= datetimeofrace)
and
(not v.qualifiers["P582"] or v.qualifiers["P582"][1].datavalue.value.timeendtime >= datetimeofrace)
then
possibleNationalitiestimeStartEnd[num] = "Q" .. v.mainsnak.datavalue.value['numeric-id'mode]
num = num + 1
end
else
possibleNationalitiestimeStartEnd[num] = "Q" .. v.mainsnak.datavalue.value['numeric-id'mode]
num = num + 1
end
end
end
return possibleNationalities[1]
return a, timeStartEnd[1]
else return false, '' end
end
 
function black_list(wiki, Label)
-- List of Wikipedia articles with the same lemma as the non existing rider article. Those lemmas are printed as text "black" in the tables,
-- not "blue" or "red". This way there will be no false wikilinks at the WhatLinksHere entry. List should be updated maybe once a year.
local black_list = {}
if wiki=='de' then black_list={ ["Ryan Anderson"]=true, ["Chris Butler"]=true, ["Josef Černý"]=true, ["Brad Evans"]=true, ["Robert Fontaine"]=true,
["Carlos Giménez"]=true, ["George Harper"]=true, ["Mathias Jørgensen"]=true, ["Luis Lemus"]=true, ["David Lozano"]=true, ["Jan Maas"]=true,
["James McLaughlin"]=true, ["Nikolaj Michajlow"]=true, ["Antonio Molina"]=true, ["Ben O'Connor"]=true, ["Andrea Peron"]=true, ["Cristian Rodríguez"]=true,
["Nick Schultz"]=true, ["Adam Stachowiak"]=true, ["Michel Vermote"]=true, ["Johannes Weber"]=true, ["Martin Weiss"]=true, ["Christopher Williams"]=true,
["Samuel Williams"]=true, ["Peter Williams"]=true, ['Stephen Williams']=true, ["Michael Woods"]=true, ["Michael Wright"] = true, ["Edoardo Zardini"]=true,
["Georg Zimmermann"]=true } end
if wiki=='en' then black_list={ ["Tiago da Silva"]=true, ["Jan Maas"]=true, ["Alexander Meier"]=true, ["James McLaughlin"]=true, ["Andrea Nencini"]=true,
["Johannes Weber"]=true } end
if wiki=='fr' then black_list={['Pierre Barbier']=true, ['Jessica Cutler']=true, ['Fernanda da Silva']=true, ['Guillaume Delvaux']=true, ['Willy De Waele']=true,
['Jules Dubois']=true, ['Jean Dupont']=true, ['Robert Fontaine']=true, ['René Fournier']=true, ['Pierre Gauthier']=true, ['Marc Goossens']=true,
['Claude Guyot']=true, ['Amy Hill']=true, ['Liang Hongyu']=true, ['Marcus Johansson']=true, ['Mathias Jørgensen']=true, ['José Mendoza']=true,
['Daniel Müller']=true, ['Henri Parmentier']=true, ['Jean Raynal']=true, ['Pascal Robert']=true, ['Jean-Yves Roy']=true, ['Michael Shermer']=true,
['Juris Silovs']=true, ['Jacques Simon']=true, ['Guy Thomas']=true, ['Ryan Thomas']=true, ['Hans Vonk']=true, ['Jan Wijnants']=true } end
return black_list[Label]
end
 
Ред 799 ⟶ 2.742:
local entity = mw.wikibase.getEntity( Qnumber )
local Sitelink = entity:getSitelink() -- link to WParticle
local LabelSitelink2 = entity:getLabel()Sitelink
local Label_frLabel = entity:getLabel() or 'fr' )
local Label_fr = entity:getLabel( 'fr' ) or ''
local Sitelink_claas = mw.wikibase.getEntity( 'Q22348500' ):getSitelink()
local a, b
local official_name = ""
local wiki = string.match(mw.site.server, "%a+")
 
if arg[1] == nil then
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 then
if Sitelink ~= nil and official_name == b then link = "[[" .. Sitelink .. "|" .. official_name .. "]]" else link = official_name end
if wiki=="en" then --delete string ", ..." from e.g. "Unley, South Australia"
local i, _ = string.find(Sitelink, ",")
if i ~= nil then Sitelink2 = string.sub(Sitelink, 1, i-1) end
end
link = "[[" .. Sitelink .. "|" .. mw.text.trim(string.gsub(Sitelink2, "%b()", "")..' ') .. "]]"
if wiki == "de" then -- ru riders get label as alias, to shorten the name
local a, b = pcall(fooA, 'numeric-id', entity, 'P27', 1)
if a == true and (b==159 or b==184 or b==212 or b==232) then link = "[[" .. Sitelink .. "|" .. Label .. "]]" end
end
elseif Label ~= '' then
if wiki ~= 'www' then
if black_list(wiki, Label) == true then
link = Label -- function black_list: articles that are printed as text, not wikilinks
else -- detect if there is a different local article with the same name
local title = mw.title.new(Label)
if title.exists then link = Label else link = "[[" .. Label.. "]]" end
end
else link = Label end
else link = Label end
else return "unknown ID in function WPlink" end
if link == '' then
link = entity:getLabel('fr') or entity:getLabel('en') or entity:getLabel('de') or ''
if link ~= '' then link = string.gsub(link, "%b()", "")
else link = "(label missing)" end
end
end -- if arg[1] == nil
if arg[1] == 'winner_team' then -- Qnumber of a team
a, b = pcall(fooA, 'text', entity, 'P1448', 2) -- test if more then two official names
if a == true then
a, b = timeStartEnd(Qnumber, 'P1448', 'text', arg[2]) --officialName(entity)
if a == true then official_name = b end
else
a, b = pcall(fooA, 'text', entity, 'P1448', 1)
if a == true then official_name = b end
end
if pcall(foo1, Qnumber) then
if Sitelink ~= nil and official_name == b and official_name ~= nil then link = "[[".. Sitelink.. "|".. official_name.. "]]"
else -- if there is no saison article, then print team article (if available)
a, b = pcall(fooA, 'numeric-id', entity, 'P361', 1)
if a == true then
local entity = mw.wikibase.getEntity( 'Q'.. b ) -- Qnumber of team
local Sitelink = entity:getSitelink() -- link to WParticle
if Sitelink ~= nil and official_name ~= nil and official_name ~='' then link = "[[".. Sitelink.. "|".. official_name.. "]]"
elseif Sitelink ~= nil then
if wiki=="en" then --delete string ", ..." from e.g. "Unley, South Australia"
local i, _ = string.find(Sitelink, ",")
if i ~= nil then Sitelink2 = string.sub(Sitelink, 1, i-1) end
end
link = "[[".. Sitelink.. "|".. mw.text.trim(string.gsub(Sitelink2,"%b()","").. ' ').. "]]"
else link = official_name end
else link = Sitelink end
end
else return "unknown ID in function WPlink" end
if link == nil then
link = Label_fr entity:getLabel()
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] == 'team' then -- add '(team of the winner)'
a, b = timeStartEnd(Qnumber, 'P1448', 'text', arg[2]) --officialName(entity)
if a == true then official_name = b end
if wiki=="en" then --delete string ", ..." from e.g. "Unley, South Australia"
local i, _ = string.find(Sitelink, ",")
if i ~= nil then Sitelink = string.sub(Sitelink, 1, i-1) end
end
if Sitelink ~= nil and official_name ~= nil and official_name ~='' then link = "[[" .. Sitelink .. "|" .. official_name .. "]]" end
if Sitelink == nil and official_name ~= nil and official_name ~='' then link = official_name end
end -- end arg[1]
if arg[1] == 'pure' then
if pcall(foo1, Qnumber) then
if wiki=="en" or wiki=="www" then --delete string ", ..." from e.g. "Unley, South Australia"
local i, _ = string.find(Sitelink, ",")
if i ~= nil then Sitelink2 = string.sub(Sitelink, 1, i-1) end
end
if Sitelink ~= nil then link = "[[" .. Sitelink .. "|" .. mw.text.trim(string.gsub(Sitelink2, "%b()", "")..' ') .. "]]"
else link = mw.ustring.gsub(Label, "^(%a)", function (x) return mw.ustring.upper(x) end)
end
end
end
if arg[1] == 'race' then -- for infobox "Competitions"
local a, b = pcall(fooA, 'numeric-id', entity, 'P31', 1)
if a == true and b == 1137352 then
local entity_race = mw.wikibase.getEntity( 'Q'..b )
local Label_race = entity_race:getLabel() or ''
local Sitelink_race = entity_race:getSitelink() or ''
if Label_race ~= '' and Sitelink ~= nil then link = '[['..Sitelink..'|'..Label_race..']]'
elseif Sitelink ~= nil then link = "[[".. Sitelink.. "]]"
else if Sitelink_race ~= '' then link = '[['..Sitelink_race.."|".. mw.text.trim(string.gsub(Sitelink_race,"%b()","").. ' ').. "]]"
else link = Label_race or Label end
end
if wiki == 'www' then link = '[['..entity:getSitelink( 'frwiki')..'|'..entity_race:getLabel('fr')..']]' end
 
else if Sitelink ~= nil then link = "[[".. Sitelink.. "]]" else link = Label end
end
end
if arg[1] == "Q22348500" then -- add weblink from item "Q22348500" if available
if pcall(foo1, Qnumber) then --Sitelink_claas
Ред 848 ⟶ 2.873:
end
return l10n
end
 
function getSquadTableColumn(x)
local l10nDef = { }
l10nDef["//fr.wikipedia.org"] = {"Cycliste", "Date de naissance"}
l10nDef["//en.wikipedia.org"] = {"Rider", "Date of birth"}
l10nDef["//br.wikipedia.org"] = {"Reder", "Deiziad genel"}
l10nDef["//ca.wikipedia.org"] = {"Ciclista", "Data de naixement"}
l10nDef["//cs.wikipedia.org"] = {"Cyklista", "Datum narození"}
l10nDef["//da.wikipedia.org"] = {"Rytter", "Fødselsdag"}
l10nDef["//de.wikipedia.org"] = {"Name", "Geburtsdatum"}
l10nDef["//es.wikipedia.org"] = {"Corredor", "Fecha de nacimiento"}
l10nDef["//eu.wikipedia.org"] = {"Izena", "Jaiotze-data"}
l10nDef["//fi.wikipedia.org"] = {"Ajaja", "Syntymäaika"}
l10nDef["//fo.wikipedia.org"] = {"Súkklari", "Føðingardagur"}
l10nDef["//hu.wikipedia.org"] = {"Név", "Születésnap"}
l10nDef["//it.wikipedia.org"] = {"Ciclista", "Data di nascita"}
l10nDef["//ja.wikipedia.org"] = {"選手名", "生年月日"}
l10nDef["//lb.wikipedia.org"] = {"Coureur", "Gebuertsdatum"}
l10nDef["//lv.wikipedia.org"] = {"Braucējs", "Dzimšanas datums"}
l10nDef["//mk.wikipedia.org"] = {"Велосипедист", "Датум на раѓање"}
l10nDef["//nl.wikipedia.org"] = {"Naam", "Geboortedatum"}
l10nDef["//no.wikipedia.org"] = {"Rytter", "Fødselsdato"}
l10nDef["//pl.wikipedia.org"] = {"Imię i nazwisko", "Data urodzenia"}
l10nDef["//pt.wikipedia.org"] = {"Ciclista", "Data de Nascimento"}
l10nDef["//ro.wikipedia.org"] = {"Ciclist", "Data nașterii"}
l10nDef["//ru.wikipedia.org"] = {"Гонщик", "Дата рождения"}
l10nDef["//sv.wikipedia.org"] = {"Namn", "Födelsedatum"}
l10nDef["//zh.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
return l10n[x]
end
 
Ред 898 ⟶ 2.887:
end
return snak, entity.claims[property][var].rank
end
 
function fooB (mode, entity_var, property, var1, var2, ref, var3)
local snak
if mode == 'value' then snak = entity_var.claims[property][var1].references[var2].snaks[ref][var3].datavalue.value
else snak = entity_var.claims[property][var1].references[var2].snaks[ref][var3].datavalue.value[mode]
end
return snak
end
 
function fooC (mode, entity_var, property, var1, quali, var2)
local snak
if mode == 'value' then snak = entity_var.claims[property][var1].references[var2].snaks[ref][var3].datavalue.value
else snak = entity_var.claims[property][var1].qualifiers[quali][var2].datavalue.value[mode]
end
return snak
end
 
Ред 912 ⟶ 2.917:
end
 
function foo12winner (entity_varwiki, propertyt, var1, var2, ref, var3winner_id)
local number = t.number
local snak = entity_var.claims[property][var1].references[var2].snaks[ref][var3].datavalue
local wiki = wiki
end
local winner_id = winner_id
local tt = {}
for num=1,number do table.insert(tt, "") end
local WDlink_on
 
-- WDlink_on is used to decide if a Wikidata flag will be shown
function winner (t, winner_id)
if wiki == "mk" or wiki == "ja" or wiki == "lv" or wiki == "ru" then WDlink_on = true else WDlink_on = false end
tt = {}
for num=1,t.main.number do
local entity_race = mw.wikibase.getEntityObject(t.race[num][1])
table.insert(tt, "")
if pcall(fooA, 'numeric-id', entity_race, 'P1346', 1) == true then
end
for k, v1 in pairs(entity_race.claims['P1346']) do
local wiki = mw.site.server
if pcall(fooC, 'numeric-id', entity_race, 'P1346', k, 'P642', 1) == true and v1.qualifiers.P642[1].datavalue.value['numeric-id'] == winner_id then
local winner, time_var, sitelink, nationality
local gotime_var, a, b
local winner = "Q"..v1.mainsnak.datavalue.value['numeric-id']
local WDlink_off = false
 
-- WDlink_off is used to decide if a Wikidata flag will be shown
if wiki == "//fr.wikipedia.org" or wiki == "//en.wikipedia.org" or wiki == "//br.wikipedia.org" or wiki == "//ca.wikipedia.org" or
wiki == "//cs.wikipedia.org" or wiki == "//da.wikipedia.org" or wiki == "//de.wikipedia.org" or wiki == "//eo.wikipedia.org" or
wiki == "//es.wikipedia.org" or wiki == "//eu.wikipedia.org" or wiki == "//fi.wikipedia.org" or wiki == "//fo.wikipedia.org" or wiki == "//hu.wikipedia.org" or wiki == "//it.wikipedia.org" or
wiki == "//lb.wikipedia.org" or wiki == "//nl.wikipedia.org" or wiki == "//no.wikipedia.org" or wiki == "//pl.wikipedia.org" or
wiki == "//pt.wikipedia.org" or wiki == "//ro.wikipedia.org" or wiki == "//sv.wikipedia.org" then WDlink_off = true end
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 wiki == "//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 = mw.wikibase.getEntity( winner ):getLabel()
elseif mw.wikibase.getEntity(winner):getLabel('fr')~=nil then sitelink=mw.wikibase.getEntity(winner):getLabel('fr').. " (fr)"
elseif mw.wikibase.getEntity(winner):getLabel('en')~=nil then sitelink=mw.wikibase.getEntity(winner):getLabel('en').. " (en)"
elseif mw.wikibase.getEntity(winner):getLabel('de')~=nil then sitelink=mw.wikibase.getEntity(winner):getLabel('de').. " (de)"
else sitelink = "—" 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)
ifa, b = pcall(foo2fooA, t.main.race[num][2]'time', "entity_race, 'P585"', 1) then
if a == true then time_var = b
time_var = t.main.race[num][2].claims["P585"][1].mainsnak.datavalue.value.time
else
elseif pcall(foo2, t.main.race[num][2], "P580", 1) then
a, b = pcall(fooA, 'time', entity_race, 'P580', 1)
time_var = t.main.race[num][2].claims["P580"][1].mainsnak.datavalue.value.time
else if a == true then time_var = b end
end
 
-- get nationality of the winner, nationality could have changed, therefore look for qualifiers p580 and p582
ifa, b = pcall(foo2fooA, 'numeric-id', mw.wikibase.getEntity( winner ), "'P27"', 1) then -- standard: only one nationality
if a == true then
nationality = "Q"..mw.wikibase.getEntity( winner ).claims["P27"][1].mainsnak.datavalue.value['numeric-id']
tt[num] = flag(nationality"Q"..b, time_var) .. " " .. sitelinkWPlink(winner) .. " "
if WDlink_offWDlink_on == falsetrue then tt[num] = tt[num].. wdLink(winner) end
else if WDlink_on == true then tt[num] = " " .. sitelink .. " " .. wdLink(winner) else tt[num] = "" 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 .. " "
if WDlink_off == false then tt[num] = tt[num].. wdLink(winner) end
end
 
end -- end if
-- if person has more than one nationality calculate tt[num] again
i = i + 1
a, b = pcall(fooA, 'numeric-id', mw.wikibase.getEntity( winner ), 'P27', 2)
end -- end while
if a == true then
else end -- end if pcall
local _, bb = timeStartEnd(winner, "P27", 'numeric-id', time_var)
end -- end for
tt[num] = flag('Q'..bb, time_var) .. " " .. WPlink(winner) .. " "
if WDlink_on == true then tt[num] = tt[num].. wdLink(winner) end
end
end -- if v1.
end -- for k, v1
end -- if
end -- for num=
return tt
end
 
function p.listofwinners(frame)
local t = {main={entity0=""number, race={}}, year={}, vainqueur={}, second={}, troisieme={}}
frame.args[1] = string.gsub(frame.args[1], "%c", "")
 
iflocal pcall(foo1, frame.args[1]) then t.main.entity0entity = mw.wikibase.getEntity( frame.args[1] ) end
local tt, k, sitelinkWDlink_on
local numwiki = 1string.match(mw.site.server, "%a+")
local goWPcontent = {}
local wiki = mw.site.server
local WDlink_off = false
local localFrame
-- WDlink_off is used to decide if a Wikidata flag will be shown
if string.match(frame:getParent():getTitle(), '%P+') == mw.site.namespaces.Template.name
if wiki == "//fr.wikipedia.org" or wiki == "//en.wikipedia.org" or wiki == "//br.wikipedia.org" or wiki == "//ca.wikipedia.org" or
then localFrame = frame:getParent() else localFrame = frame end
wiki == "//cs.wikipedia.org" or wiki == "//da.wikipedia.org" or wiki == "//de.wikipedia.org" or wiki == "//eo.wikipedia.org" or
if localFrame.args[1] ~= nil then localFrame.args[1] = string.gsub(localFrame.args[1], "%c", "") end
wiki == "//es.wikipedia.org" or wiki == "//eu.wikipedia.org" or wiki == "//fi.wikipedia.org" or wiki == "//fo.wikipedia.org" or wiki == "//hu.wikipedia.org" or wiki == "//it.wikipedia.org" or
--[=[
wiki == "//lb.wikipedia.org" or wiki == "//nl.wikipedia.org" or wiki == "//no.wikipedia.org" or wiki == "//pl.wikipedia.org" or
It is possible to give the table listofwinners in the article commands. It could look like this:
wiki == "//pt.wikipedia.org" or wiki == "//ro.wikipedia.org" or wiki == "//sv.wikipedia.org" then WDlink_off = true end
{{Cycling race/listofwinners|Q18574623
| above row 1: '''[[aaa bbb ccc]]''' xxx
}}
"above row x" inserts a new row above row x into the table. Content is what is behind the ":".
]=]
if localFrame.args[2] ~= nil then
for num,var in pairs(localFrame.args) do
if num > 1 and mw.ustring.find(mw.ustring.lower(localFrame.args[num]), 'row') then
local _, _, key1, val = mw.ustring.find(localFrame.args[num], "([^:]+)%s*:%s*(%C+)")
local _, _, key01, key11, key12 = mw.ustring.find(key1, "(%a+)%s*(%a+)%s*(%d+)")
key12 = tonumber(key12) key11 = mw.ustring.lower(key01..key11)
if key11 == 'aboverow' then WPcontent[key12] = val end
end
end
end
 
-- WDlink_on is used to decide if a Wikidata flag will be shown
if pcall(foo2, t.main.entity0, "P527", num) then go = true else go = false end
if wiki == "mk" or wiki == "ja" or wiki == "lv" or wiki == "ru" then WDlink_on = true else WDlink_on = 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
 
ttlocal num = {}0
if pcall(fooA, 'numeric-id', entity, 'P527', 1) == true then
for num=1,t.main.number do -- build first column with link to wikipedia article and to wikidata item
for k, v1 in pairs(entity.claims['P527']) do
if wiki == "//www.wikidata.org" then sitelink = t.main.race[num][2]:getSitelink( 'frwiki' )
local year, race, entity_race, a, b
else sitelink = mw.wikibase.sitelink( t.main.race[num][1] )
race = 'Q'..v1.mainsnak.datavalue.value['numeric-id'] -- Qnumbers of the parts of a tour
end
entity_race = mw.wikibase.getEntityObject(race)
if sitelink == nil then sitelink = t.main.race[num][3]
 
else sitelink = "[[" .. sitelink .. "|" .. t.main.race[num][3] .. "]]"
-- P585(point in time for a single day race) or P580(start time for a stage race)
a, b = pcall(fooA, 'time', entity_race, 'P585', 1)
if a == true then year = b
else
a, b = pcall(fooA, 'time', entity_race, 'P580', 1)
if a == true then year = b end
end
 
if WDlink_off == true then table.insert(tt, sitelink) else table.insert(tt, sitelink.. " " .. wdLink(t.main.race[num][1]) ) end
if year ~= nil then _, _, year, _, _ = string.find(year, "(%d+)-(%d+)-(%d+)") end
table.insert(t.race, { race, year} )
table.sort(t.race, function(a,b) return a[2] < b[2] end) -- t.race is sorted after year
num = num + 1
end
end -- for k, v1
t.number = num
 
for num=1,t.number do -- build year column with link to wikipedia article and to wikidata item
local sitelink = mw.wikibase.sitelink( t.race[num][1] )
if sitelink == nil then sitelink = t.race[num][2] else sitelink = "[[" .. sitelink .. "|" .. t.race[num][2] .. "]]" end
if WDlink_on == false then table.insert(t.year, sitelink) else table.insert(t.year, sitelink.. " " .. wdLink(t.race[num][1]) ) end
end
table.insert(t.year, tt)
table.insert(t.vainqueur, winner(t, 20882667))
table.insert(t.second, winner(t, 20882668))
table.insert(t.troisieme, winner(t, 20882669))
 
t.vainqueur = winner(wiki, t, 20882667) -- build vainqueur column
local table_first, table_proto, table_last, table_center
t.second = winner(wiki, t, 20882668) -- build second column
table_first = "<table cellpadding='4' cellspacing='0' style='border:1px solid rgb(200,200,200); color:black;"
t.troisieme = winner(wiki, t, 20882669) -- build troisiem column
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;'>"
 
local table_first = "<table cellpadding='4' cellspacing='0' style='border:1px solid rgb(200,200,200); color:black;"..
table_proto = "<tr style='background:#FFDF80; text-align:center;'><th>"
"margin:0 0 0.5em 0; background-color:rgb(255, 255, 255); padding:5px; clear:left; "..
if WDlink_off == true then table_proto = table_proto .. "[[File:Wikidata-logo S.svg|12px|link=d:".. frame.args[1].. "#P527]]" end
"text-align:left; vertical-align:top; font-size:85%; line-height:1.6em;'>"
table_proto = table_proto.. headoftableIV(1).. "</th><th>"..
local table_proto = "<tr style='background:#FFDF80; text-align:center'><th>"
headoftableIV(2).. "</th><th>".. headoftableIV(3).. "</th><th>".. headoftableIV(4).. "</th></tr>"
if WDlink_on == false then table_proto = table_proto .. '<span style="float:left">[[File:Wikidata-logo S.svg|12px|link=d:'.. frame.args[1].. '#P527]]</span>' end
table_center = ""
table_proto = table_proto.. headoftableIV(wiki,1).. "</th><th>".. headoftableIV(wiki,2).. "</th><th>".. headoftableIV(wiki,3).. "</th><th>".. headoftableIV(wiki,4).. "</th></tr>"
table_last = "</table>"
local table_center, table_last = "", "</table>"
 
local table_center = ""
for var=1, t.main.number do -- t.main.race[var][3]
if type(WPcontent) == 'table' and WPcontent[var] ~= nil then table_center = table_center..
table_center = table_center .. "<tr><td style='text-align:center'>".. t.year[table.getn(t.year)][var].."</td>"
"<tr><td colspan='4' style='text-align:center'>".. WPcontent[var].. "</td></tr>" end
table_center = table_center .. "<td>"..t.vainqueur[table.getn(t.vainqueur)][var].."</td>"
 
table_center = table_center .. "<td>"..t.second[table.getn(t.second)][var].."</td>"
table_center = table_center .. "<tr><td style='text-align:center'>".. t.troisieme[table.getn(t.troisieme)]year[var].."</td></tr>"
table_center = table_center .. "<td>"..t.vainqueur[var].."</td>"
table_center = table_center .. "<td>"..t.second[var].."</td>"
table_center = table_center .. "<td>"..t.troisieme[var].."</td></tr>"
end
return table_first .. table_proto .. table_center .. table_last
end
 
function p.listofstages(frame)
if frame.args[1] ~= nil then frame.args[1] = string.gsub(frame.args[1], "%c", "") end
local i, v, uu, ii, nationality
local entityi, etapek, stage =v, {}uu, {}ii, {}nationality
local series_ordinalentity, point_of_timeetape, lengthstage = {}, {}, {}
local series_ordinal, point_of_time, length = {}, {}, {}
local sitelinks_etape, sitelinks1, sitelinks2, sitelinks3, sitelinks4 = {}, {}, {}, {}, {}
local y, m, d = {}, {}, {}
local flag1, flag2 = {}, {}
local number0, number1, number2 = {}, {}, {}
local level = false
local a, b, num, var
local wiki = string.match(mw.site.server, "%a+")
local num, var
local wikientity0 = mw.sitewikibase.server getEntityObject( frame.args[1] )
local WDlink_on
local entity0 = mw.wikibase.getEntityObject( frame.args[1] ) -- Q18589873 (Quatre jours de Dunkerque 2015)
local _, _, key1, key01, key11, key12, key2, key21, key22, val
local WDlink_off = false
local teamWPcontent = true{}
-- if there is one 'P527' then level = 2
a, b = pcall(fooA, 'numeric-id', entity0, 'P527', 1)
if a == true then level = true 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 parts =localFrame {}
if string.match(frame:getParent():getTitle(), '%P+') == mw.site.namespaces.Template.name
for num, v in pairs(entity0.claims["P527"]) do
then localFrame = frame:getParent() else localFrame = frame end
etape[num] = 'Q'..v.mainsnak.datavalue.value['numeric-id']
if localFrame.args[1] ~= nil then localFrame.args[1] = string.gsub(localFrame.args[1], "%c", "") end
entity[num] = mw.wikibase.getEntityObject( etape[num] )
--[=[ It is possible to give the table listofstages in the article commands which overwrites data from Wikidata. It could look like this:
a, b = pcall(fooA, 'value', entity[num], 'P1545', 1)
{{Cycling race/listofstages|Q18574623
if a == true then series_ordinal[num] = b else series_ordinal[num] = " " end
| RoW 1: locaTION Ab : [[1a1b]]
table.insert(parts, num, {nr = series_ordinal[num], Qnum = etape[num]})
| after row 1 : date : 99 août
| after row 1 : icon : [[File:Stage rest day.svg|vbght frthzt fdgtr]]
| after row 1: text : rest day at [[aaa bbb ccc]]
|row 4: location A : [[4a4a]]abc
| row 3 : winner a : <sup>tzhgt<sup/>
| row 4 : winner b : kjuzhgt<br />bbjje
| row 4 : icon : [[File:Mediummountainstage.svg|xcvbbgf fgtr]]
| row 4 : distance : <s>141.8</s> 122<ref>test</ref>
}}
The first paramer is "row x" or "after row x". "after row" adds a new row after row x into the table to print e.g. a rest day. The second parameters are
"location [a/b/ab]", "date", "icon", "text", "winner [a/b]" and "distance". "a" and "b" means the first and the second location or winner. "ab" could be used if
start location and end location are the same. The file data for the icon looks this way: [[File:Stage rest day.svg|any text]]
]=]
if localFrame.args[2] ~= nil then
-- local WProw, WPcourse, WPwinner = mw.ustring.lower(headoftable(1)), mw.ustring.lower(headoftable(3)), mw.ustring.lower(headoftable(5))
local WProw, WPnew_row, WPcourse, WPtext, WPdate, WPwinner, WPicon, WPdistance = 'row', 'afterrow', 'location', 'text', 'date', 'winner', 'icon', 'distance'
for num,var in pairs(localFrame.args) do
if num > 1 and mw.ustring.find(mw.ustring.lower(localFrame.args[num]), WProw) then
_, _, key1, key2, val = mw.ustring.find(localFrame.args[num], "([^:]+)%s*:?%s*([^:]*)%s*:%s*(%C+)")
_, _, key01, key11, key12 = mw.ustring.find(key1, "(%a+)%s*(%a+)%s*(%d+)")
key12 = tonumber(key12) key11 = mw.ustring.lower(key01..key11)
key2 = mw.ustring.lower(mw.text.trim(key2))
_, _, key21, key22 = mw.ustring.find(key2, "(%a+)%s*(%a*)")
key21 = mw.ustring.lower(key21) key22 = mw.ustring.lower(key22)
 
if type(WPcontent[key12]) ~= 'table' then WPcontent[key12] = {} end
if key11 == WProw and key21 == WPcourse then WPcontent[key12][key22] = val end
if key11 == WPnew_row and key2 == WPdate then
WPcontent[key12]['date'] = val
WPcontent[key12]['text'] = WPcontent[key12]['text'] or ''
WPcontent[key12]['icon (new row)'] = WPcontent[key12]['icon (new row)'] or ''
end
if key11 == WPnew_row and key2 == WPtext then
WPcontent[key12]['text'] = val
WPcontent[key12]['date'] = WPcontent[key12]['date'] or ''
WPcontent[key12]['icon (new row)'] = WPcontent[key12]['icon (new row)'] or ''
end
if key11 == WPnew_row and key2 == WPicon then
val = mw.ustring.gsub(val, "|", "|border|right|20px|", 1)
WPcontent[key12]['icon (new row)'] = val
WPcontent[key12]['date'] = WPcontent[key12]['date'] or ''
WPcontent[key12]['text'] = WPcontent[key12]['text'] or ''
end
if key11 == WProw and key21 == WPwinner and key22 == 'a' then WPcontent[key12]['stage winner'] = val end
if key11 == WProw and key21 == WPwinner and key22 == 'b' then WPcontent[key12]['general winner'] = val end
if key11 == WProw and key21 == WPicon then
val = mw.ustring.gsub(val, "|", "|border|right|20px|", 1) WPcontent[key12]['icon'] = val end
if key11 == WProw and key21 == WPdistance then WPcontent[key12]['distance'] = val end
end
end
end
-- if there is one 'P527' then level = true
-- sort parts after nr = series_ordinal[num], not Qnum
a, b = pcall(fooA, 'numeric-id', entity0, 'P527', 1)
table.sort(parts, function(a, b)
if a == true then level = true end
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
 
-- read series_ordinal and the Qnumber and sort them after series_ordinal, eg: 1 2a 2b 3 4 5
local comp
local parts = {}
if char1 == "" and char2 == "" then comp = tonumber(num1) < tonumber(num2) end
for num, v in pairs(entity0.claims["P527"]) do
if char1 ~= "" and char2 == "" then comp = tonumber(num1) < tonumber(num2) end
etape[num] = 'Q'..v.mainsnak.datavalue.value['numeric-id']
if char1 == "" and char2 ~= "" then comp = tonumber(num1) < tonumber(num2) end
entity[num] = mw.wikibase.getEntityObject( etape[num] )
if char1 ~= "" and char2 ~= "" then comp = char1 < char2 end
a, b = pcall(fooA, 'value', entity[num], 'P1545', 1)
return comp end)
if a == true then series_ordinal[num] = b else series_ordinal[num] = " " end
--return a.nr < b.nr end)
table.insert(parts, num, {nr = series_ordinal[num], Qnum = etape[num]})
end
 
-- sort parts after nr = series_ordinal[num], not Qnum
-- WDlink_off is used to decide if a Wikidata flag will be shown
table.sort(parts, function(a, b)
if wiki == "//fr.wikipedia.org" or wiki == "//en.wikipedia.org" or wiki == "//br.wikipedia.org" or wiki == "//ca.wikipedia.org" or
local num1 = string.sub(a.nr, string.find(a.nr, "%d+"))
wiki == "//cs.wikipedia.org" or wiki == "//da.wikipedia.org" or wiki == "//de.wikipedia.org" or wiki == "//eo.wikipedia.org" or
local num2 = string.sub(b.nr, string.find(b.nr, "%d+"))
wiki == "//es.wikipedia.org" or wiki == "//eu.wikipedia.org" or wiki == "//fi.wikipedia.org" or wiki == "//fo.wikipedia.org" or wiki == "//hu.wikipedia.org" or wiki == "//it.wikipedia.org" or
local char1, char2
wiki == "//lb.wikipedia.org" or wiki == "//nl.wikipedia.org" or wiki == "//no.wikipedia.org" or wiki == "//pl.wikipedia.org" or
if string.find(a.nr, "%a") then char1 = string.sub(a.nr, string.find(a.nr, "%a")) else char1 = "" end
wiki == "//pt.wikipedia.org" or wiki == "//ro.wikipedia.org" or wiki == "//sv.wikipedia.org" then WDlink_off = true end
if string.find(b.nr, "%a") then char2 = string.sub(b.nr, string.find(b.nr, "%a")) else char2 = "" end
 
var = #entity0.claims["P527"]
local comp
for num=1,var do
if char1 == "" and char2 == "" then comp = tonumber(num1) < tonumber(num2) end
if char1 ~= "" or char2 ~= "" then comp = tonumber(num1) < tonumber(num2) end
if char1 ~= "" and char2 ~= "" then
if num1 == num2 then comp = char1 < char2
else comp = tonumber(num1) < tonumber(num2)
end
end
return comp end)
 
-- WDlink_on is used to decide if a Wikidata flag will be shown
if wiki == "mk" or wiki == "ja" or wiki == "lv" or wiki == "ru" then WDlink_on = true else WDlink_on = false end
 
var = #entity0.claims["P527"]
for num=1,var do
-- collect data from Wikidata in tables
entity[num] = mw.wikibase.getEntityObject( parts[num].Qnum )
if WDlink_offWDlink_on == truefalse then number0[num]= " " else number0[num] = " &nbsp;" .. wdLink(parts[num].Qnum) end
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
 
flag1[num] = ' '
Ред 1.126 ⟶ 3.184:
number1[num] = ' '
local id, qual
-- find the vainqueur d'étape, Q20882747
if pcall(foo3, entity[num], "P1346", 1, "P642", 1) then
local v
for _, v in pairs(entity[num].claims["P1346"]) do
if pcall(function() id = v.mainsnak.datavalue.value['numeric-id'] end) then else id = nil end
qual = v.qualifiers["P642"][1].datavalue.value["numeric-id"]
if id ~= nil and v.rank ~= 'deprecated' then
if qual == 20882747 then
number1[num] = 'Q' .. id
-- flag1[num]a, b = flag(getNationalityOnDatetimeStartEnd(number1[num], point_of_time[num])"P27", 'numeric-id', point_of_time[num])
if a == true then
a, b = pcall(fooA, 'numeric-id', mw.wikibase.getEntityObject(number1[num]), 'P27', 1)
flag1[num] = flag('Q'..b, point_of_time[num])
if a == true then
flag1sitelinks3[num] = flagWPlink( getNationalityOnDate (number1[num], point_of_time[num]), point_of_time[num])
else
sitelinks3[num] = WPlink( number1[num] )
a, b = pcall(fooA, 'numeric-id', mw.wikibase.getEntityObject(number1[num]), 'P17', 1)
else
if a == true then
a, b = pcall(fooA, 'numeric-id', mw.wikibase.getEntityObject(number1[num]), 'P17', 1)
flag1[num] = flag('Q'..b, point_of_time[num])
if a == true then
flag1sitelinks3[num] = flagWPlink( 'Q'..b, point_of_timenumber1[num]), 'winner_team' )
sitelinks3[num] = WPlink( number1[num], team )
end
end
if WDlink_offWDlink_on == truefalse then number1[num]="" else number1[num]= =
"<span style='white-space:nowrap'>&nbsp;[[File:Wikidata-logo S.svg|12px|link=d:".. number1[num] .. ']]</span>' end
end
end -- if id
Ред 1.156 ⟶ 3.215:
number2[num] = ' '
local id, qual
-- find the leader du classement général à l'issue de l'étape, Q20882763
if pcall(foo3, entity[num], "P1346", 1, "P642", 1) then
local v
for _, v in pairs(entity[num].claims["P1346"]) do
if pcall(function() id = v.mainsnak.datavalue.value['numeric-id'] end) then else id = nil end
qual = v.qualifiers["P642"][1].datavalue.value["numeric-id"]
if id ~= nil and v.rank ~= 'deprecated' then
if qual == 20882763 or qual == 20882667 then
number2[num] = 'Q' .. id
-- flag2[num]a, b = flag( getNationalityOnDate timeStartEnd(number2[num], point_of_time[num])"P27", 'numeric-id', point_of_time[num])
if a == true then
a, b = pcall(fooA, 'numeric-id', mw.wikibase.getEntityObject(number2[num]), 'P27', 1)
flag2[num] = flag( 'Q'..b, point_of_time[num])
if a == true then
flag2sitelinks4[num] = flagWPlink( getNationalityOnDate(number2[num], point_of_time[num]), point_of_time[num])
else
sitelinks4[num] = WPlink( number2[num] )
a, b = pcall(fooA, 'numeric-id', mw.wikibase.getEntityObject(number2[num]), 'P17', 1)
else
if a == true then
a, b = pcall(fooA, 'numeric-id', mw.wikibase.getEntityObject(number2[num]), 'P17', 1)
flag2[num] = flag( 'Q'..b, point_of_time[num])
if a == true then
flag2sitelinks4[num] = flagWPlink( 'Q'..b, point_of_timenumber2[num]), 'winner_team' )
sitelinks4[num] = WPlink( number2[num], team )
end
end
if WDlink_offWDlink_on == truefalse then number2[num]="" else number2[num]= =
"<span style='white-space:nowrap'>&nbsp;[[File:Wikidata-logo S.svg|12px|link=d:"..number2[num] .. ']]</span>' end
end
end -- if id
Ред 1.182 ⟶ 3.242:
end -- end if 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') break end
if uu == 20646670 then stage[num] = typeofstage('hilly stage') break end
if uu == 20680270 then stage[num] = typeofstage('intermediate stage') break end
if uu == 20646668 then stage[num] = typeofstage('mountain stage') break end
if uu == 485321 then stage[num] = typeofstage('time trial stage', 485321) break end -- prologue
if uu == 2266066 then stage[num] = typeofstage('time trial stage', 2266066) break end -- individual time trial
if uu == 2348250 then stage[num] = typeofstage('time trial stage', 2348250) break end -- team time trial
if uu == 20679712 then stage[num] = typeofstage('uphill time trial stage') break end
i = i + 1
end
end)
end
) then else stage[num] = " " end
 
_, _, y[num], m[num], d[num] = string.find(point_of_time[num], "(%d+)-(%d+)-(%d+)") -- d = day, m = month
Ред 1.206 ⟶ 3.266:
 
local table_first, table_proto, table_last
table_first = "<table border='0' cellpadding='4' cellspacing='0' style='border:1px solid rgb(200,200,200); color:black; "
table_first = table_first .. "margin:0 0 0.5em 0; background-color:rgb(255, 255, 255); padding:5px; clear:left; "
table_first = table_first .. "text-align:left; vertical-align:top; font-size:85%; line-height:1.6em;'>"
table_proto = "<tr style='background:#FFDF80; text-align:center;'><th nowrap>"
if WDlink_offWDlink_on == truefalse then table_proto = table_proto .. "[[File:Wikidata-logo S.svg|12px|link=d:".. framelocalFrame.args[1].. "#P527]]" end
table_proto = table_proto.. headoftable(1) .."</th><th>" .. headoftable(2) .."</th><th>".. headoftable(3)..
"</th>".. "<th style='color:#FFDF80'>type</th>" .."<th>".. headoftable(4).. "</th><th>".. headoftable(5).."</th><th>".. headoftable(6).. "</th></tr>"
table_last = "</table>"
 
-- build table for output
local table_center = ""
var = #entity0.claims["P527"]
for num=1, var do
local a, b
a, _ = string.gsub(series_ordinal[num], "%a", "") -- 20, not 20a
if string.find(series_ordinal[num], "%a") then b = string.sub(series_ordinal[num], string.find(series_ordinal[num], "%a"))
else b = "" end
local ee, er = stageLink(series_ordinal[num], a, b)
if series_ordinal[num] == "0" then
er = "#"..func_prologue()
ee = func_prologue()
end
local stageNr -- if there is a wikipedia article of that stage show it or show the section
if sitelinks_etape[num] == nil then stageNr = "[["..er.."|"..ee.."]]" else stageNr = "[["..sitelinks_etape[num].."|"..ee.."]]" end
 
local day = tostring(tonumber(d[num]))
if day == "1" and (wiki == "//fr.wikipedia.org") then day = "1<sup>er</sup>" end
if wiki == "lv" then stageNr = series_ordinal[num] end
else if wiki == "//fr.wikipedia.org" or wiki == "//eo.wikipedia.org" or wiki == "//de.wikipedia.org" then day = day .. "." end end
if wiki == "//lv.wikipedia.org" then stageNr = series_ordinal[num] end
local month = func_month(m[num])
local date = day..' ' .. month
if wiki == "//br.wikipedia.org" then date = day .. " a viz ".. month end
if wiki == "//ca.wikipedia.org" or wiki == "//es.wikipedia.org" then date = day .. " de ".. month end
if wiki == "//eo.wikipedia.org" then date = day .. "-a de ".. month end
if wiki == "//eu.wikipedia.org" then date = month .. "k ".. day end
if wiki == "//ja.wikipedia.org" then date = month .. day .. "日" end
if wiki == "de" or wiki == "da" or wiki == "fi" or wiki == "fo" or wiki == "no" or wiki == "lv" then date = day.. ". ".. month end
if wiki == "cs" then date = day.. ". xg ".. month end
if wiki == "en" then date = month.. " ".. day end
 
if pcall(function()
length[num] = mw.language.getContentLanguage():formatNum(tonumber(length[num]))
end
) then else length[num] = " " end
 
if type(WPcontent[num]) == 'table' and WPcontent[num]['a'] ~= nil then sitelinks1[num] = WPcontent[num]['a'] end
table_center = table_center.. "<tr style='vertical-align:top'><td nowrap style='text-align:right'>".. stageNr .. number0[num]..
"</td><tdif nowraptype(WPcontent[num]) style='text-align:right;= padding-right:0px'>"..date..table' "</td><td>"..and sitelinks1WPcontent[num].."['b'] ~= nil then "..sitelinks2[num]..stage = WPcontent[num]..['b'] end
if type(WPcontent[num]) == 'table' and WPcontent[num]['ab'] ~= nil then sitelinks1[num] = WPcontent[num]['ab'] sitelinks2[num] = '' end
"</td><td style='text-align:center'>".. length[num].. " </td><td nowrap>".. flag1[num].. ' '.. sitelinks3[num].. number1[num].. "</td><td nowrap>"..
if type(WPcontent[num]) == 'table' and WPcontent[num]['icon'] ~= nil then stage[num] = WPcontent[num]['icon'] end
flag2[num]..' ' ..sitelinks4[num].. number2[num].. "</td></tr>"
if type(WPcontent[num]) == 'table' and WPcontent[num]['distance'] ~= nil then length[num] = WPcontent[num]['distance'] end
if type(WPcontent[num]) == 'table' and WPcontent[num]['stage winner'] ~= nil then
flag1[num] = '' sitelinks3[num] = WPcontent[num]['stage winner'] number1[num]= '' end
if type(WPcontent[num]) == 'table' and WPcontent[num]['general winner'] ~= nil then
flag2[num] = '' sitelinks4[num] = WPcontent[num]['general winner'] number2[num]= '' end
 
table_center = table_center.. "<tr><td style='text-align:center; white-space:nowrap'>".. stageNr .. "<span style='white-space:nowrap'>&nbsp;".. number0[num].."</span>"..
"</td><td style='white-space:nowrap; text-align:right; padding-right:0px'>"..date.. "</td><td style='padding-right:0px'>".. sitelinks1[num]
if sitelinks2[num] ~= '' then table_center = table_center.. " – " end
table_center = table_center.. sitelinks2[num].."</td><td style='padding-top:10px'>".. stage[num].. "</td><td style='text-align:center'>".. length[num].. "</td>"
if type(WPcontent[num]) == 'table' and WPcontent[num]['stage winner'] ~= nil then
table_center = table_center.. "<td style='text-align:center'>".. flag1[num].. ' '.. sitelinks3[num].. number1[num]
else table_center = table_center.. "<td>".. flag1[num].. ' '.. sitelinks3[num].. number1[num] end
if type(WPcontent[num]) == 'table' and WPcontent[num]['general winner'] ~= nil then
table_center = table_center.. "<td style='text-align:center'>".. flag2[num].. ' '.. sitelinks4[num].. number2[num].. "</td></tr>"
else table_center = table_center.. "<td>".. flag2[num].. ' '.. sitelinks4[num].. number2[num].. "</td></tr>" end
 
if type(WPcontent[num]) == 'table' and (WPcontent[num]['date'] ~= nil or WPcontent[num]['text'] ~= nil or WPcontent[num]['icon (new row)'] ~= nil)
then table_center = table_center.. "<tr><td></td>"
if WPcontent[num]['icon (new row)'] == '' then table_center = table_center.."<td nowrap style='text-align:right; padding:3px 0px 10px 0px'>".. WPcontent[num]['date']
else table_center = table_center.."<td style='text-align:right; padding-right:0px'>".. WPcontent[num]['date'] end
if WPcontent[num]['icon (new row)'] == '' then table_center = table_center.."</td><td style='text-align:left; padding:3px 4px 10px'>"..WPcontent[num]['text']
else table_center = table_center.."</td><td style='text-align:left'>"..WPcontent[num]['text'] end
table_center = table_center.."</td><td style='padding-top:10px'>".. WPcontent[num]['icon (new row)'].. "</td><td colspan='3' ></td></tr>"
end
end
 
local tabl = table_first .. table_proto
if level == true then tabl = tabl .. table_center .. table_last else tabl = tabl .. table_last end
return tabl
end
 
function func_prologue() -- returns the word "Prologue"
local l10nDef = { ["fr"]="Prologue", ["en"]="Prologue", ["br"]="Prolog", ["ca"]="Pròleg", ["cs"]="Prolog", ["de"]="PProlog", ["da"]="Prolog", ["eo"]="Prologo",
["es"]="Prólogo", ["eu"]="Aitzinetapa", ["fi"]="Prologi", ["fo"]="Forteinur", ["hu"]="Prolog", ["it"]="Prologo", ["ja"]="プロローグ", ["la"]="Incipit prologus", ["lb"]="Prolog", ["lv"]="Prologs",
["mk"]="Пролог", ["nl"]="Proloog", ["no"]="Prolog", ["pl"]="Prologu", ["pt"]="Prólogo", ["ro"]="Prolog", ["ru"]="Пролог", ["sk"]="Prológ", ["sv"]="Prolog" }
 
local wiki,word=mw.site.server
if wiki=='//www.wikidata.org' then return l10nDef["fr"]
else return l10nDef[string.sub(wiki,string.find(wiki,"%a+"))] end
end
 
function stageLink(x, a, b) -- x= 10a: a = 10, b = a. x = 5: a = 5, b = ""
local l10nDef = {["fr"]="étape", ["en"]="Stage", ["br"]="Tennad", ["ca"]="Etapa", ["cs"]="Etapa", ["de"]="Etappe", ["da"]="Etapeetape", ["eo"]="Etapo",
["es"]="Etapa", ["eu"]="Etapa", ["fi"]="Etappi", ["fo"]="Teinur", ["hu"]="Szakasz", ["it"]="Tappa", ["ja"]="ステージ", ["la"]="Statio", ["lb"]="Etapp", ["lv"]="Posms", ["mk"]="Етапа",
["nl"]="Etappe", ["no"]="Etappe", ["pl"]="Etap", ["pt"]="Etapa", ["ro"]="Etapa", ["ru"]="Этап", ["sk"]="Etapa", ["sv"]="Etapp" }
 
local wiki,l10n=mw.site.server
local word1, word2
if wiki=='//www.wikidata.org' then word2=l10nDef["fr"]
else word2=l10nDef[string.sub(wiki,string.find(wiki,"%a+"))] end
Ред 1.281 ⟶ 3.368:
 
-- 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
end
if mw.site.server == "//de.wikipedia.org" or mw.site.server == "//da.wikipedia.org" then return a..". "..b.." "..word, "#"..a..". "..b.." "..word end
-- default
 
word1 = x -- table text = 1, 2a, 3
-- default
word2 = "#"..word.." ".. x -- text of section header = #Etappe 2a, #Stage 4
word1 = x -- table text = 1, 2a, 3
word2 = "#"..word.." ".. x --return table text, text of section header = #Etappe 2a, #Stage 4
return word1, word2
end
 
function func_month(x)
Ред 1.331 ⟶ 3.418:
l10nDef["nl"] = {"jan.", "feb.", "maart", "apr.", "mei", "juni", "juli", "aug.", "sept.", "okt.", "nov.", "dec."}
l10nDef["pl"] = {"stycznia", "lutego", "marca", "kwietnia", "maja", "czerwca", "lipca", "sierpnia", "września", "października", "listopada", "grudnia"}
l10nDef["pt"] = {"jan.", "fev.", "marçomar", "abrilabr", "maiomai", "junhojun", "julhojul", "agostoago", "set.", "out.", "nov.", "dez."}
l10nDef["ro"] = {"Ian.", "Feb.", "Mar.", "Apr.", "Mai", "Iun.", "Iul.", "Aug.", "Sep.", "Oct.", "Nov.", "Dec."}
l10nDef["ru"] = {"Января", "Февраля", "Марта", "Апреля", "Мая", "Июня", "Июля", "Августа", "Сентября", "Октября", "Ноября", "Декабря"}
Ред 1.352 ⟶ 3.439:
l10nDef["ca"]={"Etapa", "Data", "Ciutats d'etapa", "Distància (km)", "Vencedor de l'etapa", "Líder de la general"}
l10nDef["cs"]={"Etapa", "Datum", "Trasa", "Vzdálenost (km)", "Vítěz", "Průběžný lídr"}
l10nDef["da"]={"Etape", "Dato", "Start – Mål", "Afstand (km)", "Etapevinder", "DenFørende gule trøjerytter"}
l10nDef["de"]={"Etappe", "Datum", "Etappenorte", "Länge (km)", "EtappensiegerEtappen&shy;sieger", "GesamtführenderGesamt&shy;führender"}
l10nDef["eo"]={"Etapo", "Dato", "Etapa urbo", "Longo (km)", "Venkinto de la etapo", "Estro de la gxeneralo klasado"}
l10nDef["es"]={"Etapa", "Fecha", "Recorrido", "Distancia (km)", "Ganador", "Líder"}
l10nDef["eu"]={"Etapa", "Data", "Ibilbidea", "Distantzia (km)", "Irabazlea", "Liderra"}
l10nDef["fi"]={"Etappi", "Päivä", "Reitti", "Pituus (km)", "Voittaja", "Kokonaiskilpailun johtaja"}
l10nDef["fo"]={"Etape", "Dagur", "Byrjan – Mál", "Vegalongd (km)", "TeinavinnariTeina&shy;vinnari", "Gula troyggjan"}
l10nDef["hu"]={"Szakasz", "Időpont", "Végpontok", "Hossz (km)", "SzakaszgyőztesSzakasz&shy;győztes", "Általános vezető"}
l10nDef["it"]={"Tappa", "Data", "Percorso", "Distanza (km)", "Vincitore di tappa", "Leader cl. generale"}
l10nDef["ja"]={"ステージ", "開催日", "コース", "距離 (km)", "ステージ勝者", "全体リーダー"}
l10nDef["la"]={"Statio", "Dies", "Iter", "Distantia (km)", "Victor", "Altiore princeps"}
l10nDef["lb"]={"Etapp", "Datum", "Etappestied", "Längt (km)", "Gewënner", "GeneralklassementGeneral&shy;klassement"}
l10nDef["lv"]={"Posms", "Datums", "Maršruts", "Posma garums (km)", "Uzvarētājs", "Kopvērtējuma līderis"}
l10nDef["mk"]={"Етапа", "Датум", "Тек", "Растојание (км)", "Победник", "Cевкупен лидер"}
l10nDef["nl"]={"Etappe", "Datum", "Start – Finish", "Afstand (km)", "Winnaar", "KlassementsleiderKlassements&shy;leider"}
l10nDef["no"]={"Etappe", "Dato", "Start – Målgang", "Lengde (km)", "EtappevinnerEtappe&shy;vinner", "SammenlagtlederSammenlagt&shy;leder"}
l10nDef["pl"]={"Etap", "Data", "Start – Meta", "Dystans (km)", "Zwycięzca etapu", "Lider"}
l10nDef["pt"]={"Etapa", "Data", "Percurso", "Distância (km)", "Vencedor", "Líder geral"}
Ред 1.374 ⟶ 3.461:
l10nDef["sk"]={"Etapa", "Dátum", "Trasa", "Vzdialenosť (km)", "Víťaz", "Priebežný líder"}
l10nDef["sv"]={"Etapp", "Datum", "Start – mål", "Distans (km)", "Skede vinnare", "Övergripande ledare"}
l10nDef["als"]=l10nDef["defr"]
 
local wiki,l10n=mw.site.server
Ред 1.380 ⟶ 3.467:
else l10n=l10nDef[string.sub(wiki,string.find(wiki,"%a+"))] end
 
-- local l10n = l10nDef[mw.site.server]
-- if not l10n then l10n = l10nDef["//fr.wikipedia.org"] end -- default
return l10n[x]
end
 
function headoftableII(wiki,x) -- En-têtes des tableaux générant les classements
local l10nDef = { }
l10nDef["//fr.wikipedia.org"] = {"Coureur", "Pays", "Équipe", "Temps", "Écart de temps", "Vitesse moy.", "Points", "Classement de l'étape", "Classement général", "Classement par points", "Classement de la montagne", "Classement des sprints", "Classement du meilleur jeune", "Classement par équipes"}
l10nDef["//br.wikipedia.orgen"] = {"RederRider", "BroCountry", "SkipailhTeam", "AmzerTime", "PoentoùTime Gap", "RenkadurSpeed", an tennad"Points", "RenkadurStage hollekclassification", "RenkadurGeneral a-boentoùclassification", "RenkadurPoints ar menezclassification", "RenkadurMountains ar sprintoùclassification", "RenkadurSprints arclassification", "Best yaouankyoung gwellañclassification", "RenkadurTeams a-skipailhclassifications"}
l10nDef["//ca.wikipedia.orgbr"] = {"CorredorReder", "PaísBro", "EquipSkipailh", "TempsAmzer", "PuntsTime Gap", "Classificació deSpeed", l'etapa"Poentoù", "ClassificacióRenkadur generalan tennad", "ClassificacióRenkadur per puntshollek", "ClassificacióRenkadur dea-boentoù", "Renkadur laar muntanyamenez", "ClassificacióRenkadur delsar esprintssprintoù", "ClassificacióRenkadur delar milloryaouank jovegwellañ", "Classificació perRenkadur equipsa-skipailh"}
l10nDef["//eo.wikipedia.orgca"] = {"KurantoCorredor", "LandoPaís", "TeamoEquip", "TempoTemps", "PoentojTime Gap", "Etapa klasifikoVelocitat", "Gxenerala klasifikoPunts", "KlasifikoClassificació lauxde poentojl'etapa", "KlasifikoClassificació porgeneral", la"Classificació per montaropunts", "KlasifikoClassificació porde la sprintojmuntanya", "KlasifikoClassificació dedels laesprints", "Classificació plejdel bonamillor junojove", "KlasifikoClassificació poper teamoequips"}
l10nDef["//eu.wikipedia.orgda"] = {"TxirrindulariaRytter", "HerrialdeaLand", "TaldeaHold", "DenboraTid", "PuntuaTidsforskel", "EtapakoGns. sailkapenafart", "Sailkapen orokorraPoint", "Puntukako sailkapenaEtaperesultat", "MendikoSamlede sailkapenastilling", "Esprinetako sailkapenaPointkonkurrence", "GazteBjergkonkurrence", onenaren sailkapena"Sprintkonkurrence", "TaldekakoUngdomskonkurrence", sailkapena"Holdkonkurrence"}
l10nDef["//lb.wikipedia.orgde"] = {"CoureurFahrer", "Land", "EquipeTeam", "ZäitZeit", "PunktenZeitabstand", "EtappeklassementGeschw.", "GeneralklassementPunkte", "Klassement noEtappenergebnis", Punkten"Gesamtwertung", "BiergpräisPunktewertung", "SprintklassementBergwertung", "BeschteSprintwertung", Jonken"Nachwuchswertung", "EquippeklassementMannschaftswertung"}
l10nDef["//ro.wikipedia.orgeo"] = {"CiclistKuranto", "ȚarăLando", "EchipăTeamo", "TimpTempo", "PuncteTime Gap", "ClasamentulRapido", etapei"Poentoj", "ClasamentEtapa generalklasifiko", "ClasamentGxenerala peklasifiko", "Klasifiko laux punctepoentoj", "ClasamentKlasifiko cățărătoripor la montaro", "ClasamentKlasifiko sprinteripor la sprintoj", "ClasamentulKlasifiko de celuila maiplej bunbona tânărjuno", "ClasamentKlasifiko pepo echipeteamo"}
l10nDef["es"] = {"Ciclista", "País", "Equipo", "Tiempo", "Intervalo de tiempo", "Velocidad media", "Puntos", "Clasificación de la etapa", "Clasificación general", "Clasificación por puntos", "Clasificación de la montaña", "Clasificación de los sprints", "Clasificación del mejor joven", "Clasificación por equipos"}
l10nDef["//www.wikidata.org"] = l10nDef["//fr.wikipedia.org"]
l10nDef["eu"] = {"Txirrindularia", "Herrialdea", "Taldea", "Denbora", "Time Gap", "Speed", "Puntua", "Etapako sailkapena", "Sailkapen orokorra", "Puntukako sailkapena", "Mendiko sailkapena", "Esprinetako sailkapena", "Gazte onenaren sailkapena", "Taldekako sailkapena"}
local l10n = l10nDef[mw.site.server]
l10nDef["fi"] = {"Pyöräilijä", "Maa", "Joukkue", "Aika", "Aikaero", "Nopeus", "Pisteet", "Etapin tulokset", "Kokonaistilanne", "Pistekilpailu", "Vuoristokilpailu", "Sprinttikilpailu", "Nuorten kilpailu", "Joukkuekilpailu"}
if not l10n then l10n = l10nDef["//fr.wikipedia.org"] end -- default
l10nDef["fo"] = {"Súkklari", "Land", "Lið", "Tíð", "Time Gap", "Ferð", "Stig", "Teinaplasering", "Samlað plasering", "Stigkappingin", "Fjallakappingin", "Spurtkappingin", "Ungdómskappingin", "Liðkappingin"}
return l10n[x]
l10nDef["lb"] = {"Coureur", "Land", "Equipe", "Zäit", "Time Gap", "Vitesse", "Punkten", "Etappeklassement", "Generalklassement", "Klassement no Punkten", "Biergpräis", "Sprintklassement", "Beschte Jonken", "Equippeklassement"}
end
l10nDef["no"] = {"Rytter", "Land", "Lag", "Tid", "Tidsforskjell", "Fart", "Poeng", "Etappeplassering", "Sammenlagtplassering", "Poengkonkurranse", "Klatrekonkurranse", "Sprintkonkurranse", "Ungdomskonkurranse", "Lagkonkurranse"}
l10nDef["nl"] = {"Renner", "Land", "Ploeg", "Tijd", "Tijdsverschil", "Snelheid", "Punten", "Etappeklassement", "Algemeen Klassement", "Puntenklassement", "Bergklassement", "Sprintklassement", "Jongerenklassement", "Ploegenklassement"}
l10nDef["pt"] = {"Ciclista", "País", "Equipe", "Tempo", "Intervalo de tempo", "Rapidez", "Pontos", "Classificação por etapas", "Classificação geral", "Classificação por pontos", "Classificação de montanha", "Classificação por velocidade", "Classificação de juventude", "Classificação coletiva"}
l10nDef["ro"] = {"Ciclist", "Țară", "Echipă", "Timp", "Time Gap", "Viteză", "Puncte", "Clasamentul etapei", "Clasament general", "Clasament pe puncte", "Clasament cățărători", "Clasament sprinteri", "Clasamentul celui mai bun tânăr", "Clasament pe echipe"}
l10nDef["ru"] = {"Гонщик", "Страна", "Команда", "Время", "Отставание", "Скорость", "Очки", "Результаты этапа", "Генеральная классификация", "Очковая классификация", "Горная классификация", "Спринтерская классификация", "Молодёжная классификация", "Командная классификация"}
l10nDef["www"] = l10nDef["fr"]
local l10n = l10nDef[wiki]
if not l10n then l10n = l10nDef["en"] end -- default
return l10n[x]
end
 
function headoftableIIIheadoftableIV(wiki,x) -- En-tête du tableau listantdu lespalmarès équipesd'une participantescourse (P1923)cycliste
local l10nDef = { }
l10nDef["fr"] = {"Année", "Vainqueur", "Deuxième", "Troisième"}
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["en"] = {"Year", "Winner", "Second", "Third"}
l10nDef["//br.wikipedia.org"] = {"Anv skipailh", "Bro", "Kod", "WorldTeam", "WorldTeams", "ProTeam", "ProTeams", "Skipailh kevandir a-vicher", "Skipailhoù kevandir a-vicher", "Skipailh kevandir", "Skipailhoù kevandir", "Skipailh bro", "Skipailhoù bro", "Skipailh rannvro ha klub", "Skipailhoù rannvro ha club", "Skipailh marc'h-houarn a-vicher", "Skipailhoù marc'h-houarn a-vicher", "Skipailh marc'h-houarn amatour", "Skipailhoù marc'h-houarn amatour", "Strollad sport I", "Strolladoù sport I", "Strollad sport II", "Strolladoù sport II", "Strollad sport III", "Strolladoù sport III", "Skipailh kemmesk", "Skipailhoù kemmesk", "Skipailh merc'hed", "Skipailhoù merc'hed"}
l10nDef["br"] = {"Bloavezh", "1añ", "2l", "3de"}
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["ca"] = {"Any", "Vencedor", "Segon", "Tercer"}
l10nDef["//eo.wikipedia.org"] = {"Nomo de la teamo", "Lando", "Kodo", "Monda teamo", "Mondaj teamoj", "ProTeamo", "ProTeamoj", "Profesiista kontinenta teamo", "Profesiistaj kontinentaj teamoj", "Kontinenta teamo", "Kontinentaj teamoj", "Nacia teamo", "Naciaj teamoj", "Regiona aux kluba teamo", "Regionaj aux klubaj teamoj", "Profesiista bicikla teamo", "Profesiistaj biciklaj teamoj", "Amatora bicikla teamo", "Amatoraj biciklaj teamoj", "Sporta grupo 1", "Sportaj grupoj 1", "Sporta grupo 2", "Sportaj grupoj 2", "Sporta grupo 3", "Sportaj grupoj 3", "Miksa teamo", "Miksaj teamoj", "Ina teamo", "Inaj teamoj"}
l10nDef["cs"] = {"Ročník", "Vítěz", "Druhý", "Třetí"}
l10nDef["//eu.wikipedia.org"] = {"Taldearen izena", "Herrialdea", "Kodea", "Munduko taldea", "Munduko taldeak", "Pro taldea", "Pro taldeak", "Kontinenteko talde profesionala", "Kontinenteko talde profesionala", "Kontinenteko taldea", "Kontinenteko taldeak", "Estatuko taldea", "Estatuko taldeak", "Eskualdeko eta klubeko taldea", "Eskualdeko eta klubeko taldeak", "Txirrindulari talde profesionala", "Txirrindulari talde profesionalak", "Txirrindulari talde amateurra", "Txirrindulari talde amateurrak", "I. mailako kirol taldea", "I. mailako kirol taldeak", "II. mailako kirol taldea", "II. mailako kirol taldeak", "III. mailako kirol taldea", "III. mailako kirol taldeak", "Talde mistoa", "Talde mistoak", "Emakume taldea", "Emakume taldeak"}
l10nDef["da"] = {"År", "Vinder", "Toer", "Treer"}
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["de"] = {"Jahr", "Sieger", "Zweiter", "Dritter"}
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["eo"] = {"Jaro", "Venkinto", "Dua pozicio", "Tria pozicio"}
l10nDef["//www.wikidata.org"] = l10nDef["//fr.wikipedia.org"]
l10nDef["es"] = {"Año", "Ganador", "Segundo", "Tercero"}
local l10n = l10nDef[mw.site.server]
l10nDef["eu"] = {"Urtea", "Irabazlea", "Bigarrena", "Hirugarrena"}
if not l10n then l10n = l10nDef["//fr.wikipedia.org"] end -- default
l10nDef["fi"] = {"Vuosi", "Voittaja", "Toinen", "Kolmas"}
return l10n[x]
l10nDef["fo"] = {"Ár", "Vinnari", "Nr. 2", "Nr. 3"}
end
l10nDef["hu"] = {"Év", "Versenyző", "Második", "Harmadik"}
 
l10nDef["it"] = {"Anno", "Vincitore", "Secondo", "Terzo"}
function headoftableIV(x) -- En-tête du tableau du palmarès d'une course cycliste
local l10nDef["ja"] = {"年", "優勝", "準優勝", "3位"}
l10nDef["//fr.wikipedia.orglb"] = {"AnnéeJoer", "VainqueurGewënner", "DeuxièmeZweeten", "TroisièmeDrëtten"}
l10nDef["//en.wikipedia.orglv"] = {"YearGads", "WinnerUzvarētājs", "SecondOtrais", "ThirdTrešais"}
l10nDef["//br.wikipedia.orgmk"] = {"BloavezhГодина", "1añПобедник", "2lВторопласиран", "3deТретопласиран"}
l10nDef["//ca.wikipedia.orgnl"] = {"AnyJaar", "VencedorWinnaar", "SegonTweede", "TercerDerde"}
l10nDef["//cs.wikipedia.orgno"] = {"RočníkÅr", "VítězVinner", "DruhýAndreplass", "TřetíTredjeplass"}
l10nDef["//da.wikipedia.orgpl"] = {"ÅrRok", "VinderPierwsze", "ToerDrugie", "TreerTrzecie"}
l10nDef["//de.wikipedia.orgpt"] = {"JahrAno", "SiegerVencedor", "ZweiterSegundo", "DritterTerceiro"}
l10nDef["//eo.wikipedia.orgro"] = {"JaroAn", "VenkintoCâștigător", "DuaLocul poziciodoi", "TriaLocul poziciotrei"}
l10nDef["//es.wikipedia.orgru"] = {"AñoГод", "GanadorПобедитель", "SegundoВторой", "TerceroТретий"}
l10nDef["//eu.wikipedia.orgsr"] = {"UrteaГодина", "IrabazleaПобедник", "BigarrenaДруги", "HirugarrenaТрећи"}
l10nDef["//fi.wikipedia.orgsv"] = {"VuosiÅr", "VoittajaVinnare", "ToinenAndra", "KolmasTredje"}
l10nDef["//fo.wikipedia.orgwww"] = {l10nDef["Árfr", "Vinnari", "Nr. 2", "Nr. 3"}]
l10nDef["//hu.wikipedia.org"] = {"Év", "Versenyző", "Második", "Harmadik"}
return l10nDef[wiki][x]
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["//sv.wikipedia.org"] = {"År", "Vinnare", "Andra", "Tredje"}
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
 
Ред 1.458 ⟶ 3.538:
l10nDef["ca"] = {plain = "etapa plana", hilly="etapa accidentada", inter='etapa de mitja muntanya', mount='etapa de muntanya', time_prologue='pròleg', time_team='contrarellotge per equips', time_indiv='contrarellotge individual', uphill='', rest='etapa de descans'}
l10nDef["cs"] = {plain = "rovinatá etapa", hilly="", inter='kopcovitá etapa', mount='horská etapa', time_prologue='prolog', time_team='týmová časovka', time_indiv='individuální časovka', uphill='', rest=''}
l10nDef["da"] = {plain = "Fladflad etape", hilly="Fladkuperet med brostenetape", inter='Kuperetmiddel bjergetape', mount='Bjergetapebjergetape', time_prologue='prolog', time_team='Holdkørselholdtidskørsel', time_indiv='Enkeltstartenkeltstart', uphill='bjergenkeltstart', rest='hviledag'}
l10nDef["de"] = {plain = "Flachetappe", hilly="Hügelige Etappe", inter='Mittelschwere Etappe', mount='HochgebiergsetappeHochgebirgsetappe', time_prologue='Prolog', time_team='Teamzeitfahren', time_indiv='Einzelzeitfahren', uphill='Bergzeitfahren', rest='Ruhetag'}
l10nDef["eo"] = {plain = "ebena etapo", hilly="malebena etapo", inter='mezgranda montaro etapo', mount='montara etapo', time_prologue='prologo', time_team='teama kontraux-la-kronometro', time_indiv='individua kontraux-la-kronometro', uphill='malebena kontraux-la-kronometro', rest='ripoza etapo'}
l10nDef["es"] = {plain = "etapa llana", hilly="etapa escarpada", inter='etapa de media montaña', mount='etapa de montaña', time_prologue='prólogo', time_team='contrarreloj por equipos', time_indiv='contrarreloj individual', uphill='cronoescalada', rest='jornada de descanso'}
l10nDef["eu"] = {plain = "etapa laua", hilly="etapa gorabeheratsua", inter='bitarteko etapa', mount='mendiko etapa', time_prologue='aitzinetapa', time_team='taldekako erlojupekoa', time_indiv='banakako erlojupekoa', uphill='erlojupeko igoera', rest='atseden eguna'}
l10nDef["fi"] = {plain = "Tasamaaetappi", hilly="Mäkietappi", inter='Keskivaikea vuorietappi', mount='Vuorietappi', time_prologue='', time_team='Joukkueaika-ajo', time_indiv='Henkilökohtainen aika-ajo', uphill='mäkiaika-ajo', rest='välipäivä'}
l10nDef["fo"] = {plain = "Slætt", hilly="Slætt við brúgvasteinum", inter='Óslætt', mount='Fjallateinur', time_prologue='Forteinur', time_team='Liðsúkkling', time_indiv='Einkultstartur', uphill='', rest='Hvílidagur'}
l10nDef["ja"] = {plain = "平坦ステージ", hilly="丘陵ステージ", inter='中間ステージ', mount='山岳ステージ', time_prologue='タイムトライアルステージ', time_team='チームタイムトライアルステージ', time_indiv='個人タイムトライアルステージ', uphill='アップヒルタイムトライアルステージ', rest='休養日'}
Ред 1.472 ⟶ 3.552:
l10nDef["no"] = {plain = "flat etappe", hilly="kupert etappe", inter='middels klatreetappe', mount='klatreetappe', time_prologue='prolog', time_team='lagtempo', time_indiv='temporitt', uphill='klatretempoetappe', rest='hviledag'}
l10nDef["pl"] = {plain = "płaski", hilly="", inter='pagórkowaty', mount='górski', time_prologue='prologu', time_team='jazda drużynowa na czas', time_indiv='jazda indywidualna na czas', uphill='', rest=''}
l10nDef["pt"] = {plain = "etapa plana", hilly="", inter='média montanha', mount='alta montanha', time_prologue='prólogo', time_team='contrarrelógio por equipes', time_indiv='contrarrelógio individual', uphill='', rest=''}
l10nDef["ro"] = {plain = "etapă de plat", hilly="etapă valonată", inter='etapă intermediară', mount='etapă de munte', time_prologue='prolog', time_team='contratimp pe echipe', time_indiv='contratimp individual', uphill='', rest='zi de repaus'}
l10nDef["ru"] = {plain = "равнинный", hilly="холмистый", inter='горный', mount='высокогорный', time_prologue='пролог', time_team='командная разделка', time_indiv='индивидуальная разделка', uphill='горная разделка', rest='день отдыха'}
Ред 1.484 ⟶ 3.565:
if x=='intermediate stage' then return "[[File:Mediummountainstage.svg|right|border|20px|"..l10n.inter.."]]" end
if x=='mountain stage' then return "[[File:Mountainstage.svg|border|right|20px|"..l10n.mount.."]]" end
if x=='uphill time trial stage' then return "[[File:MountainstageMountain Time Trial Stage.svg|border|right|20px|"..l10n.uphill.."]]" end
if x=='rest day' then return "[[File:Stage rest day.svg|border|right|20px|"..l10n.rest.."]]" end
if x=='time trial stage' then
if typ==2348250 then return "[[File:Team Time Trial Stage.svg|right|20px|"..l10n.time_team.."]]" end
if typ==2266066 then return "[[File:Time Trial.svg|right|20px|"..l10n.time_indiv.."]]" end
if typ==485321 then return "[[File:Time Trial.svg|right|20px|"..l10n.time_prologue.."]]" end
end
end
 
function 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
 
Ред 1.506 ⟶ 3.578:
end
 
function flag (x, date)
local year,m,d
if date==nil then date = '+'..os.date('%Y-%m-%d') end
-- _,_,year,m,d = string.find(date,"(%d+)-(%d+)-(%d+)") -- year, m = month, d = day
--year="1940"
--x = "Q145"
local flag1 = { -- Q..a current flag, Q..b, Q..c older flag. date: "+2016", "+2016-01-30", ..
Q29a={"[[File:Flag of Spain.svg|border|20px|ESP]]","+1982",""},
Ред 1.519 ⟶ 3.588:
Q38a={"[[File:Flag of Italy.svg|border|20px|ITA]]","+1947",""},
Q38b={"[[File:Flag of Italy (1861-1946) crowned.svg|border|20px|ITA]]","+1861","+1946"},
Q39="[[File:Flag of Switzerland (Pantone).svg|border|15px|SUI]]",
Q55= "[[File:Flag of the Netherlands.svg|border|20px|NED]]",
Q142="[[File:Flag of France.svg|border|20px|FRA]]",
Q145="[[File:Flag of the United Kingdom.svg|border|20px|GBR]]",
Q183Q183a={"[[File:Flag of Germany.svg|border|20px|GER]]","+1949-05-23",""},
Q183b={"[[File:Flag of German Reich (1935–1945).svg|border|20px|GER]]","+1935","+1945"},
Q183c={"[[File:Flag of the NSDAP (1920–1945).svg|border|20px|GER]]","+1933","+1935"},
Q183d={"[[File:Flag of Germany (3-2 aspect ratio).svg|border|20px|GER]]","+1919","+1933"},
Q183e={"[[File:Flag of the German Empire.svg|border|20px|GER]]","+1866","+1918"},
Q218a={"[[File:Flag of Romania.svg|border|20px|ROU]]","+1989-12-27",""},
Q218b={"[[File:Flag of Romania (1965-1989).svg|border|20px|ROU]]","+1965","+1989-12-26"},
Ред 1.540 ⟶ 3.613:
if flag1[x]~=nil then return flag1[x] end
 
local flag2 = { Q16={'Q80110','CAN'}, Q17={'Q43175','JPN'}, Q20={'Q83149','NOR'}, Q27={'Q82205','IRL'}, Q35Q32={'Q60149Q133022','DENLUX'}, Q36Q33={'Q42436Q47891','POLFIN'},
Q37Q34={'Q81477Q81286','LTUSWE'}, Q39Q35={'Q124020Q60149','SUIDEN'}, Q77Q36={'Q171103Q42436','URUPOL'}, Q145Q37={'Q83278Q81477','GBRLTU'}, Q159Q39={'Q16611Q124020','RUSSUI'}, Q191Q77={'Q81471Q171103','ESTURU'}, Q211={'Q130449','LAT'},
Q212Q96={'Q127974Q122462','UKRMEX'}, Q214Q145={'Q160861Q83278','SVKGBR'}, Q232Q159={'Q131650Q16611','KAZRUS'}, Q408Q191={'Q81676Q81471','AUSEST'}, Q739Q211={'Q160425Q130449','COLLAT'}, Q212={'Q127974','UKR'},
Q213={'Q127155','CZE'}, Q214={'Q160861','SVK'}, Q232={'Q131650','KAZ'}, Q262={'Q83392','DZA'}, Q408={'Q81676','AUS'}, Q414={'Q130774','ARG'},
Q664={'Q160260','NZL'}, Q717={'Q165538','VEN'}, Q739={'Q160425','COL'} }
 
local xx
if flag2[x]~=nil then x = flag2[x] end -- transform x to new x
if flag_table[x] ~= nil then return flag_table[x] end
 
if flag2[x]~=nil then xx = x x = flag2[x] end -- transform x to new x
if type(x)=='table' and pcall(foo1,x[1]) then -- for transformed x
local entity=mw.wikibase.getEntity(x[1])
local a,b=pcall(fooA,'value',entity,'P18',1) -- P18 (image)
if a==true then return
flag_table[xx] = "[[File:"..b.."|border|20px|"..x[2].."]]" end
return "[[File:"..b.."|border|20px|"..x[2].."]]"
end
end
if type(x)=='string' and pcall(foo1,x) then -- reading the flag data from untransformed items, e.g. Q29
Ред 1.555 ⟶ 3.636:
local possible_flag = {}
local num = 1
if pcall(fooA, 'numeric-id', entity, 'P41', 1) then
local v
for _, v in pairs(flags) do
if v.qualifiers then
Ред 1.561 ⟶ 3.644:
then possible_flag[num]=v.mainsnak.datavalue.value num=num+1 end
else possible_flag[num]=v.mainsnak.datavalue.value num=num+1 end
end
local file="[[File:"..possible_flag[1].."|border|20px"
local a2,b2=pcall(fooA,'value',entity,'P984',1) -- P984 (country code by the International Olympic Committee)
if a2==true then file=file.."|"..b2.."]]" else file=file.."]]" end
flag_table[x] = file
return file
end
end
return " "
end
 
return p