Wikipedia gvwiki https://gv.wikipedia.org/wiki/Ard-ghuillag MediaWiki 1.47.0-wmf.19 first-letter Meanyn Er lheh Resooney Ymmydeyr Resooney ymmydeyr Wikipedia Resooney Wikipedia Coadan Resooney coadan MediaWiki Resooney MediaWiki Clowan Resooney clowan Cooney Resooney cooney Ronney Resooney ronney TimedText TimedText talk Module Module talk Event Event talk Rolley eaghtyraneyn ny Steatyn Unnaneysit 0 2320 393009 389619 2026-09-10T02:42:16Z Ziv 21344 ([[c:GR|GR]]) [[File:Bharrison.gif]] → [[File:Eastman Johnson - Benjamin Harrison - Google Art Project.jpg]] File replacement. 393009 wikitext text/x-wiki [[Coadan:Seal_Of_The_President_Of_The_United_States_Of_America.svg|thumb|200px|Seal yn Eaghtyrane]] She '''Eaghtyrane ny Steaytyn Unnaneysit''' toshiagh [[ny Steaytyn Unnaneysit]]. Ren y chied eaghtyrane goaill toshiaght ayns 1789. == Coontey Eaghtyraneyn ny Steatyn Unnaneysit == {{ogher2|#E6E6AA|[[Partee Conastagh (Ny Steatyn Unnaneysit)|Conastagh]]|border=1px solid #AAAAAA}} {{ogher2|#AACC99|[[Partee Deynlagh-Pobblaghtagh (Ny Steatyn Unnaneysit)|Deynlagh-Pobblaghtagh]]|border=1px solid #AAAAAA}} {{ogher2|#CCEEFF|[[Partee Deynlagh (Ny Steatyn Unnaneysit)|Deynlagh]]|border=1px solid #AAAAAA}} {{ogher2|#FFFFCC|[[Partee Feoiltagh (Ny Steatyn Unnaneysit)|Feoiltagh]]|border=1px solid #AAAAAA}} {{ogher2|#FFB6B6|[[Partee Pobblaghtagh (Ny Steatyn Unnaneysit)|Pobblaghtagh]]|border=1px solid #AAAAAA}} <onlyinclude> {| class="wikitable" style="text-align:center" |- style="background:#cccccc" ! #{{ref label|Note00|*|*}} ! colspan=2 | Eaghtyrane ! Oik y ghoaill ! Oik y 'aagail ! Partee ! Lhiass-eaghtyrane ! Traa{{ref label|Note00|*|*}} |- {{daah partee/Gyn partee}} | rowspan=2 | '''[[Eaghtyraneys George Washington|1]]''' | rowspan=2 | [[George Washington]] | rowspan=2 | [[Coadan:Washington (3).jpg|100px]] | rowspan=2 | 30 Averil, 1789 | rowspan=2 | 4 Mart, 1797 | rowspan=2 | [[Partee Rish-Reiltys (Ny Steatyn Unnaneysit)|Gyn partee]] | rowspan=2 | [[John Adams]] | align=center | 1 |- {{daah partee/Gyn partee}} | align=center | 2 |- {{daah partee/Conastagh}} | '''2''' | [[John Adams]] | [[Coadan:Adamstrumbull.jpg|100px]] | 4 Mart, 1797 | 4 Mart, 1801 | [[Partee Conastagh (Ny Steatyn Unnaneysit)|Conastagh]] | {{daah partee/Deynlagh-Pobblaghtagh}} | [[Thomas Jefferson]] | align=center | 3 |- {{daah partee/Deynlagh-Pobblaghtagh}} |- {{daah partee/Deynlagh-Pobblaghtagh}} | rowspan=2 | '''[[Eaghtyraneys Thomas Jefferson|3]]''' | rowspan=2 | [[Thomas Jefferson]] | rowspan=2 | [[Coadan:Thomas_Jefferson_by_Rembrandt_Peale,_1800.jpg|100px]] | rowspan=2 | 4 Mart, 1801 | rowspan=2 | 4 Mart, 1809 | rowspan=2 | [[Partee Deynlagh-Pobblaghtagh (Ny Steatyn Unnaneysit)|Deynlagh-Pobblaghtagh]] | [[Aaron Burr]] | align=center | 4 |- {{daah partee/Deynlagh-Pobblaghtagh}} | rowspan=2 | [[George Clinton (lhiass-eaghtyrane)|George Clinton]]{{ref label|Note01|D|D}}<br /><small>''follym''</small> | align=center | 5<includeonly> |}</includeonly></onlyinclude> |- {{daah partee/Deynlagh-Pobblaghtagh}} | rowspan=2 | '''4''' | rowspan=2 | [[James Madison]] | rowspan=2 | [[Coadan:James Madison (cropped 3x4 close).jpg|100px]] | rowspan=2 | 4 Mart, 1809 | rowspan=2 | 4 Mart, 1817 | rowspan=2 | [[Partee Deynlagh-Pobblaghtagh (Ny Steatyn Unnaneysit)|Deynlagh-Pobblaghtagh]] | align=center | 6 |- {{daah partee/Deynlagh-Pobblaghtagh}} |[[Elbridge Gerry]]{{ref label|Note01|D|D}}<br /><small>''follym''</small> | align=center | 7 |- {{daah partee/Deynlagh-Pobblaghtagh}} | rowspan=2 | '''5''' | rowspan=2 | [[James Monroe]] | rowspan=2 | [[Coadan:James Monroe White House portrait 1819.jpg|100px]] | rowspan=2 | 4 Mart, 1817 | rowspan=2 | 4 Mart, 1825 | rowspan=2 | [[Partee Deynlagh-Pobblaghtagh (Ny Steatyn Unnaneysit)|Deynlagh-Pobblaghtagh]] | rowspan=2 | [[Daniel D. Tompkins]] | align=center | 8 |- {{daah partee/Deynlagh-Pobblaghtagh}} | align=center | 9 |- {{daah partee/Deynlagh-Pobblaghtagh}} | '''6''' | [[John Quincy Adams]] | [[Coadan:John_Quincy_Adams_by_GPA_Healy,_1858.jpg|100px]] | 4 Mart, 1825 | 4 Mart, 1829 | [[Partee Deynlagh-Pobblaghtagh (Ny Steatyn Unnaneysit)|Deynlagh-Pobblaghtagh]]<br />[[Partee Pobblaghtagh Ashoonagh (Ny Steatyn Unnaneysit)|Pobblaghtagh Ashoonagh]] | [[John C. Calhoun]] | align=center | 10 |- {{daah partee/Deynlagh}} | rowspan=2 | '''7''' | rowspan=2 | [[Andrew Jackson]] | rowspan=2 | [[Coadan:Andrew jackson head.jpg|100px]] | rowspan=2 | 4 Mart, 1829 | rowspan=2 | 4 Mart, 1837 | rowspan=2 | [[Partee Deynlagh (Ny Steatyn Unnaneysit)|Deynlagh]] | [[John C. Calhoun]]{{ref label|Note02|R|R}}<br /><small>''follym''</small> | align=center | 11 |- {{daah partee/Deynlagh}} | [[Martin Van Buren]] | align=center | 12 |- {{daah partee/Deynlagh}} | '''8''' | [[Martin Van Buren]] | [[Coadan:mb8.gif|100px]] | 4 Mart, 1837 | 4 Mart, 1841 | [[Partee Deynlagh (Ny Steatyn Unnaneysit)|Deynlagh]] | [[Richard Mentor Johnson]] | align=center | 13 |- {{daah partee/Feoiltagh}} | '''9''' | [[William Henry Harrison]] | [[Coadan:William_Henry_Harrison_by_James_Reid_Lambdin,_1835.jpg|100px]] | 4 Mart, 1841 | 4 Averil, 1841{{ref label|Note01|D|D}} | [[Partee Feoiltagh (Ny Steatyn Unnaneysit)|Feoiltagh]] | [[John Tyler]] | rowspan=2 align=center | 14 |- {{daah partee/Feoiltagh}} | '''10''' | [[John Tyler]] | [[Coadan:WHOportTyler.jpg|100px]] | 4 Averil, 1841 | 4 Mart, 1845 | [[Partee Feoiltagh (Ny Steatyn Unnaneysit)|Feoiltagh]]<br />[[John Tyler#Roonaghtyn|Gyn partee]]{{ref label|Note04|N|N}} |<small>''follym''</small> |- {{daah partee/Deynlagh}} | '''11''' | [[James K. Polk]] | [[Coadan:James_Knox_Polk_by_GPA_Healy,_1858.jpg|100px]] | 4 Mart, 1845 | 4 Mart, 1849 | [[Partee Deynlagh (Ny Steatyn Unnaneysit)|Deynlagh]] | [[George M. Dallas]] | align=center | 15 |- {{daah partee/Feoiltagh}} | '''12''' | [[Zachary Taylor]] | [[Coadan:Zachary_Taylor_by_Joseph_Henry_Bush,_c1848.jpg|100px]] | 4 Mart, 1849 | 9 Jerrey Souree, 1850{{ref label|Note01|D|D}} | [[Partee Feoiltagh (Ny Steatyn Unnaneysit)|Feoiltagh]] | [[Millard Fillmore]] | rowspan=2 align=center | 16 |- {{daah partee/Feoiltagh}} | '''13''' | [[Millard Fillmore]] | [[Coadan:Millard Fillmore White House portrait.png|100px]] | 9 Jerrey Souree, 1850 | 4 Mart, 1853 | [[Partee Feoiltagh (Ny Steatyn Unnaneysit)|Feoiltagh]] | <small>''follym''</small> |- {{daah partee/Deynlagh}} | '''14''' | [[Franklin Pierce]] | [[Coadan:Franklin_Pierce_by_GPA_Healy,_1858.jpg|100px]] | 4 Mart, 1853 | 4 Mart, 1857 | [[Partee Deynlagh (Ny Steatyn Unnaneysit)|Deynlagh]] | [[William R. King]]{{ref label|Note01|D|D}}<br /><small>''follym''</small> | align=center | 17 |- {{daah partee/Deynlagh}} | '''15''' | [[James Buchanan]] | [[Coadan:Jb15.gif|100px]] | 4 Mart, 1857 | 4 Mart, 1861 | [[Partee Deynlagh (Ny Steatyn Unnaneysit)|Deynlagh]] | [[John C. Breckinridge]] | align=center | 18 |- {{daah partee/Pobblaghtagh}} | rowspan=2 | '''16''' | rowspan=2 | [[Abraham Lincoln]] | rowspan=2 | [[Coadan:Abraham_Lincoln_by_George_Peter_Alexander_Healy.jpg|100px]] | rowspan=2 | 4 Mart, 1861 | rowspan=2 | 15 Averil, 1865{{ref label|Note03|A|A}} | rowspan=2 | [[Partee Pobblaghtagh (Ny Steatyn Unnaneysit)|Pobblaghtagh]]<br />[[Partee Ashoonagh yn Unnaneys (Ny Steatyn Unnaneysit)|Ashoonagh yn Unnaneys]]{{ref label|Note05|U|U}} | [[Hannibal Hamlin]] | align=center | 19 |- {{daah partee/Deynlagh}} | [[Andrew Johnson]] | rowspan=2 align=center | 20 |- {{daah partee/Deynlagh}} | '''17''' | [[Andrew Johnson]] | [[Coadan:aj17.gif|100px]] | 15 Averil, 1865 | March 4, 1869 | [[Partee Deynlagh (Ny Steatyn Unnaneysit)|Deynlagh]]<br />[[Partee Ashoonagh yn Unnaneys (Ny Steatyn Unnaneysit)|Ashoonagh yn Unnaneys]]{{ref label|Note05|U|U}} | <small>''follym''</small> |- {{daah partee/Pobblaghtagh}} | rowspan=2 | '''18''' | rowspan=2 | [[Ulysses S. Grant]] | rowspan=2 | [[Coadan:Ugrant.jpeg|100px]] | rowspan=2 | 4 Mart, 1869 | rowspan=2 | 4 Mart, 1877 | rowspan=2 | [[Partee Pobblaghtagh (Ny Steatyn Unnaneysit)|Pobblaghtagh]] | [[Schuyler Colfax]] | align=center | 21 |- {{daah partee/Pobblaghtagh}} | [[Henry Wilson]]{{ref label|Note01|D|D}}<br /><small>''follym''</small> | align=center | 22 |- {{daah partee/Pobblaghtagh}} | '''19''' | [[Rutherford B. Hayes]] | [[Coadan:Rhayes.png|100px]] | 4 Mart, 1877 | 4 Mart, 1881 | [[Partee Pobblaghtagh (Ny Steatyn Unnaneysit)|Pobblaghtagh]] | [[William A. Wheeler]] | align=center | 23 |- {{daah partee/Pobblaghtagh}} | '''20''' | [[James A. Garfield]] | [[Coadan:James Garfield portrait.jpg|100px]] | 4 Mart, 1881 | 19 Mean Fouyir, 1881{{ref label|Note03|A|A}} | [[Partee Pobblaghtagh (Ny Steatyn Unnaneysit)|Pobblaghtagh]] | [[Chester A. Arthur]] | rowspan=2 align=center | 24 |- {{daah partee/Pobblaghtagh}} | '''21''' | [[Chester A. Arthur]] | [[Coadan:Chester A Arthur by Daniel Huntington.jpeg|100px]] | 19 Mean Fouyir, 1881 | 4 Mart, 1885 | [[Partee Pobblaghtagh (Ny Steatyn Unnaneysit)|Pobblaghtagh]] | <small>''follym''</small> |- {{Daah partee/Deynlagh}} | '''22''' | [[Grover Cleveland]] | [[Coadan:Grover Cleveland portrait2.jpg|100px]] | 4 Mart, 1885 | 4 Mart, 1889 | [[Partee Deynlagh (Ny Steatyn Unnaneysit)|Deynlagh]] | [[Thomas A. Hendricks]]{{ref label|Note01|D|D}}<br /><small>''follym''</small> | align=center | 25 |- {{daah partee/Pobblaghtagh}} | '''23''' | [[Benjamin Harrison]] | [[Coadan:Eastman Johnson - Benjamin Harrison - Google Art Project.jpg|100px]] | 4 Mart, 1889 | 4 Mart, 1893 | [[Partee Pobblaghtagh (Ny Steatyn Unnaneysit)|Pobblaghtagh]] | [[Levi P. Morton]] | align=center | 26 |- {{Daah partee/Deynlagh}} | '''24''' | [[Grover Cleveland]]<br /><small>''(nah traa)''</small> | [[Coadan:Grover Cleveland, painting by Anders Zorn.jpg|100px]] | 4 Mart, 1893 | 4 Mart, 1897 | [[Partee Deynlagh (Ny Steatyn Unnaneysit)|Deynlagh]] | [[Adlai E. Stevenson I]] | align=center | 27 |- {{daah partee/Pobblaghtagh}} | rowspan=2 | '''25''' | rowspan=2 | [[William McKinley]] | rowspan=2 | [[Coadan:Official White House portrait of William McKinley.jpg|100px]] | rowspan=2 | 4 Mart, 1897 | rowspan=2 | 14 Mean Fouyir, 1901{{ref label|Note03|A|A}} | rowspan=2 | [[Partee Pobblaghtagh (Ny Steatyn Unnaneysit)|Pobblaghtagh]] | [[Garret Hobart]]{{ref label|Note01|D|D}}<br /><small>''follym''</small> | align=center | 28 |- {{daah partee/Pobblaghtagh}} | [[Theodore Roosevelt]] | rowspan=2 align=center | 29 |- style="background:#ffc2e1" |- {{daah partee/Pobblaghtagh}} | rowspan=2 | '''[[Eaghtyraneys Theodore Roosevelt|26]]''' | rowspan=2 | [[Theodore Roosevelt]] | rowspan=2 | [[Coadan:John Singer Sargent - Theodore Roosevelt - Google Art Project.jpg|100px]] | rowspan=2 | 14 Mean Fouyir, 1901 | rowspan=2 | 4 Mart, 1909 | rowspan=2 | [[Partee Pobblaghtagh (Ny Steatyn Unnaneysit)|Pobblaghtagh]] | <small>''follym''</small> |- {{daah partee/Pobblaghtagh}} | [[Charles W. Fairbanks]] | align=center | 30 |- {{daah partee/Pobblaghtagh}} | '''27''' | [[William Howard Taft]] | [[Coadan:Anders Zorn - Portrait of William Howard Taft (1911).jpg|100px]] | 4 Mart, 1909 | 4 Mart, 1913 | [[Partee Pobblaghtagh (Ny Steatyn Unnaneysit)|Pobblaghtagh]] | [[James S. Sherman]]{{ref label|Note01|D|D}}<br /><small>''follym''</small> | align=center | 31 |- {{Daah partee/Deynlagh}} | rowspan=2 | '''28''' | rowspan=2 | [[Woodrow Wilson]] | rowspan=2 | [[Coadan:Ww28.jpg|100px]] | rowspan=2 | 4 Mart, 1913 | rowspan=2 | 4 Mart, 1921 | rowspan=2 | [[Partee Deynlagh (Ny Steatyn Unnaneysit)|Deynlagh]] | rowspan=2 | [[Thomas R. Marshall]] | align=center | 32 |- {{Daah partee/Deynlagh}} | align=center | 33 |- {{daah partee/Pobblaghtagh}} | '''29''' | [[Warren G. Harding]] | [[Coadan:wh29.gif|100px]] | 4 Mart, 1921 | 2 Luanistyn, 1923{{ref label|Note01|D|D}} | [[Partee Pobblaghtagh (Ny Steatyn Unnaneysit)|Pobblaghtagh]] | [[Calvin Coolidge]] | rowspan=2 align=center | 34 |- {{daah partee/Pobblaghtagh}} | rowspan=2 | '''30''' | rowspan=2 | [[Calvin Coolidge]] | rowspan=2 | [[Coadan:Calvin Coolidge.jpg|100px]] | rowspan=2 | 2 Luanistyn, 1923 | rowspan=2 | 4 Mart, 1929 | rowspan=2 | [[Partee Pobblaghtagh (Ny Steatyn Unnaneysit)|Pobblaghtagh]] | <small>''follym''</small> |- {{daah partee/Pobblaghtagh}} | [[Charles G. Dawes]] | align=center | 35 |- {{daah partee/Pobblaghtagh}} | '''31''' | [[Herbert Hoover]] | [[Coadan:Herbert_Clark_Hoover_by_Greene,_1956.jpg|100px]] | 4 Mart, 1929 | 4 Mart, 1933 | [[Partee Pobblaghtagh (Ny Steatyn Unnaneysit)|Pobblaghtagh]] | [[Charles Curtis]] | align=center | 36 |- {{Daah partee/Deynlagh}} | rowspan=4 | '''32''' | rowspan=4 | [[Franklin D. Roosevelt]] | rowspan=4 | [[Coadan:FDR in 1933.jpg|100px]] | rowspan=4 | 4 Mart, 1933 | rowspan=4 | 12 Averil, 1945{{ref label|Note01|D|D}} | rowspan=4 | [[Partee Deynlagh (Ny Steatyn Unnaneysit)|Deynlagh]] | rowspan=2 | [[John Nance Garner]] | align=center | 37 |- {{Daah partee/Deynlagh}} | align=center | 38 |- {{Daah partee/Deynlagh}} | [[Henry A. Wallace]] | align=center |39 |- {{Daah partee/Deynlagh}} | [[Harry S. Truman]] | rowspan=2 align=center | 40 |- {{Daah partee/Deynlagh}} | rowspan=2 | '''33''' | rowspan=2 | [[Harry S. Truman]] | rowspan=2 | [[Coadan:HarryTruman.jpg|100px]] | rowspan=2 | 12 Averil, 1945 | rowspan=2 | 20 Jerrey Geuree, 1953 | rowspan=2 | [[Partee Deynlagh (Ny Steatyn Unnaneysit)|Deynlagh]] | <small>''follym''</small> |- {{Daah partee/Deynlagh}} | [[Alben W. Barkley]] | align=center | 41 |- {{daah partee/Pobblaghtagh}} | rowspan=2 | '''[[Eaghtyraneys Dwight D. Eisenhower|34]]''' | rowspan=2 | [[Dwight D. Eisenhower]] | rowspan=2 | [[Coadan:Dwight D. Eisenhower, official Presidential portrait.jpg|100px]] | rowspan=2 | 20 Jerrey Geuree, 1953 | rowspan=2 | 20 Jerrey Geuree, 1961 | rowspan=2 | [[Partee Pobblaghtagh (Ny Steatyn Unnaneysit)|Pobblaghtagh]] | rowspan=2 | [[Richard Nixon]] | align=center | 42 |- {{daah partee/Pobblaghtagh}} | align=center | 43 |- {{Daah partee/Deynlagh}} | '''35''' | [[John F. Kennedy]] | [[Coadan:John_F_Kennedy_Official_Portrait.jpg|100px]] | 20 Jerrey Geuree, 1961 | 22 Sauin, 1963{{ref label|Note03|A|A}} | [[Partee Deynlagh (Ny Steatyn Unnaneysit)|Deynlagh]] | [[Lyndon B. Johnson]] | rowspan=2 align=center | 44 |- {{Daah partee/Deynlagh}} | rowspan=2 | '''36''' | rowspan=2 | [[Lyndon B. Johnson]] | rowspan=2 | [[Coadan:37_Lyndon_Johnson_3x4.jpg|100px]] | rowspan=2 | 22 Sauin, 1963 | rowspan=2 | 20 Jerrey Geuree, 1969 | rowspan=2 | [[Partee Deynlagh (Ny Steatyn Unnaneysit)|Deynlagh]] | <small>''follym''</small> |- {{Daah partee/Deynlagh}} | [[Hubert Humphrey]] | align=center | 45 |- {{daah partee/Pobblaghtagh}} | rowspan=2 | '''37''' | rowspan=2 | [[Richard Nixon]] | rowspan=2 | [[Coadan:rn37.gif|100px]] | rowspan=2 | 20 Jerrey Geuree, 1969 | rowspan=2 | 9 Luanistyn, 1974{{ref label|Note02|R|R}} | rowspan=2 | [[Partee Pobblaghtagh (Ny Steatyn Unnaneysit)|Pobblaghtagh]] | [[Spiro Agnew]] | align=center | 46 |- {{daah partee/Pobblaghtagh}} | [[Spiro Agnew]]{{ref label|Note02|R|R}}<br /><small>''follym''</small><br />[[Gerald Ford]] | rowspan=2 align=center | 47 |- {{daah partee/Pobblaghtagh}} | '''[[Eaghtyraneys Gerald Ford|38]]''' | [[Gerald Ford]] | [[Coadan:Gerald_Ford_presidential_portrait_(cropped).jpg|100px]] | 9 Luanistyn, 1974 | 20 Jerrey Geuree, 1977 | [[Partee Pobblaghtagh (Ny Steatyn Unnaneysit)|Pobblaghtagh]] | <small>''follym''</small><br />[[Nelson Rockefeller]] |- {{Daah partee/Deynlagh}} | '''39''' | [[Jimmy Carter]] | [[Coadan:JimmyCarterPortrait_(cropped).jpg|100px]] | 20 Jerrey Geuree, 1977 | 20 Jerrey Geuree, 1981 | [[Partee Deynlagh (Ny Steatyn Unnaneysit)|Deynlagh]] | [[Walter Mondale]] | align=center | 48 |- {{daah partee/Pobblaghtagh}} | rowspan=2 | '''[[Eaghtyraneys Ronald Reagan|40]]''' | rowspan=2 | [[Ronald Reagan]] | rowspan=2 | [[Coadan:Ronald Reagan 1981 presidential portrait.jpg|100px]] | rowspan=2 | 20 Jerrey Geuree, 1981 | rowspan=2 | 20 Jerrey Geuree, 1989 | rowspan=2 | [[Partee Pobblaghtagh (Ny Steatyn Unnaneysit)|Pobblaghtagh]] | rowspan=2 | [[George H. W. Bush]] | align=center | [[Ronald Reagan#Kied traa, 1981–1985|49]] |- {{daah partee/Pobblaghtagh}} | align=center | [[Ronald Reagan#Nah traa, 1985–1989|50]] |- {{daah partee/Pobblaghtagh}} | '''41''' | [[George H. W. Bush]] | [[Coadan:George_H._W._Bush_presidential_portrait_(cropped).jpg|100px]] | 20 Jerrey Geuree, 1989 | 20 Jerrey Geuree, 1993 | [[Partee Pobblaghtagh (Ny Steatyn Unnaneysit)|Pobblaghtagh]] | [[Dan Quayle]] | align=center | [[George H. W. Bush#Eaghtyraneys (1989–1993)|51]] |- {{Daah partee/Deynlagh}} | rowspan=2 | '''[[Eaghtyraneys Bill Clinton|42]]''' | rowspan=2 | [[Bill Clinton]] | rowspan=2 | [[Coadan:Bill_Clinton.jpg|100px]] | rowspan=2 | 20 Jerrey Geuree, 1993 | rowspan=2 | 20 Jerrey Geuree, 2001 | rowspan=2 | [[Partee Deynlagh (Ny Steatyn Unnaneysit)|Deynlagh]] | rowspan=2 | [[Al Gore]] | align=center | [[Bill Clinton#Kied traa, 1993–1997|52]] |- {{Daah partee/Deynlagh}} | align=center | [[Bill Clinton#Nah traa, 1997–2001|53]] |- {{daah partee/Pobblaghtagh}} | rowspan=2 | '''[[Eaghtyraneys George W. Bush|43]]''' | rowspan=2 | [[George W. Bush]] | rowspan=2 | [[Coadan:George-W-Bush.jpeg|100px]] | rowspan=2 | 20 Jerrey Geuree, 2001 | rowspan=2 | 20 Jerrey Geuree, 2009 | rowspan=2 | [[Partee Pobblaghtagh (Ny Steatyn Unnaneysit)|Pobblaghtagh]] | rowspan=2 | [[Dick Cheney]] | align=center | [[Eaghtyraneys George W. Bush#Kied traa|54]] |- {{daah partee/Pobblaghtagh}} | align=center | [[Eaghtyraneys George W. Bush#Nah traa|55]] |- {{daah partee/Pobblaghtagh}} |- {{Daah partee/Deynlagh}} | rowspan=2 | '''[[Eaghtyraneys Barack Obama|44]]''' | rowspan=2 | [[Barack Obama]] | rowspan=2 | [[Coadan:BarackObama2005portrait.jpg|100px]] | rowspan=2 | 20 Jerrey Geuree, 2009 | rowspan=2 | 20 Jerrey Geuree 2017 | rowspan=2 | [[Partee Deynlagh (Ny Steatyn Unnaneysit)|Deynlagh]] | rowspan=2 | [[Joe Biden]] | align=center | 56 |- {{daah partee/Deynlagh}} | align=center | 57 |- {{daah partee/Deynlagh}} |- {{Daah partee/Pobblaghtagh}} | rowspan=1 | '''[[Eaghtyraneys Donald Trump|45]]''' | rowspan=1 | [[Donald Trump]] | rowspan=1 | [[Coadan:Donald_Trump_official_portrait.jpg|100px]] | rowspan=1 | 20 Jerrey Geuree 2017 | rowspan=1 | 20 Jerrey Geuree 2021 | rowspan=1 | [[Partee Pobblaghtagh (Ny Steatyn Unnaneysit)|Pobblaghtagh]] | rowspan=1 | [[Mike Pence]] | align=center | 58 |- {{daah partee/Pobblaghtagh}} |- {{Daah partee/Deynlagh}} | rowspan=2 | '''[[Eaghtyraneys Joe Biden|46]]''' | rowspan=2 | [[Joe Biden]] | rowspan=2 | [[Coadan:Joe_Biden_presidential_portrait.jpg|100px]] | rowspan=2 | 20 Jerrey Geuree 2021 | rowspan=2 | Ayns shelloo oik | rowspan=2 | [[Partee Deynlagh (Ny Steatyn Unnaneysit)|Deynlagh]] | rowspan=2 | [[Kamala Harris]] | align=center | 59 |- {{daah partee/Deynlagh}} |} {{USPresidents}} <!-- interwiki --> [[Ronney:Ny Steatyn Unnaneysit]] [[Ronney:Eaghtyraneyn ny Steatyn Unnaneysit| ]] de8fa3hz9skh123tqg2n9hkm85i3ixe Yn Choonceil Slattyssagh (Mannin) 0 20453 393007 300938 2026-09-10T02:36:38Z MacTire02 219 MacTire02 moved page [[Coonseil Slattyssagh Vannin]] to [[Yn Choonceil Slattyssagh (Mannin)]] 300938 wikitext text/x-wiki {{Politickaght Vannin}} She thie eaghtyragh jeh'n [[Tinvaal]] eh yn '''Choonceil Slattyssagh''' ({{lang-en|Legislative Council}} ny {{lang|en|''LegCo''}}). ==OCSyn (Mean Arree 2020)== *[[Steve Rodan]] (Eaghtyrane) *[[Peter Eagles]] ([[Aspickys Vannin|Aspick Sodor as Vannin]]) *[[John Quinn]] (Yn Turneyr Theayagh) *[[Robert Henderson]] *[[Jane Poole-Wilson]] *[[Kate Lord-Brennan]] *[[Tanya August-Hanson]] *[[Marlene Maska]] *[[Kerry Sharpe]] *Peter Greenhill *Robert Mercer [[Ronney:Reiltys Vannin]] [[Ronney:Politickaght Vannin]] [[Ronney:Thieyn eaghtyragh ashoonagh]] [[Ronney:Tinvaal]] czjyh630qnuviun64dg3ychpz3acekw Oltey yn Choonseil Slattyssagh 0 28139 393012 319803 2026-09-10T09:10:06Z EmausBot 2954 Fixing double redirect from [[Coonseil Slattyssagh Vannin]] to [[Yn Choonceil Slattyssagh (Mannin)]] 393012 wikitext text/x-wiki #REDIRECT [[Yn Choonceil Slattyssagh (Mannin)]] iftztpkfzv8t118j1xuhh1kgnycc740 Gurneil eaghtyrys 0 36600 392993 347592 2026-09-09T13:47:57Z MacTire02 219 yl-rey 392993 wikitext text/x-wiki Ayns [[oaylleeaght lioarlann]] as [[oaylleeaght fysseree]], ta '''gurneil eaghtyrys''' çheet er ymmyd as freayll cummaghyn enmyn, bun-chooishyn, enmyssyn cadjinit as stundayrtit, as reddyn elley ta ymmydit ayns kione-linnaghyn ayns [[catalog]]yn as ayndaghyn. Er-yn-oyr dy vel eh shoh croo kiangley eddyr ny recortyssyn [[Claare lioaragh|lioaragh]] as y coadan eaghtyrys, ta'n ghurneil eaghtyrys kiarail stughtoor bunneydagh y chatalog. ==Ynnydyn-eggey elley== * [https://web.archive.org/web/20150906062421/https://library.fiu.edu/about-us/cataloging/authority-control Lioarlannyn FIU] {{Webarchive|url=https://web.archive.org/web/20150906062421/https://library.fiu.edu/about-us/cataloging/authority-control |date=2015-09-06 }} {{Gurneil eaghtyrys}} [[Ronney:Catalogey as rang-oardraghey lioarlann]] [[Ronney:Çhiarrymeeaght oaylleeaght lioarlann]] jj5mamwxjtzomkdmr8hcl7drenjcr0r Module:Enmyn çheerey 828 55828 393000 392778 2026-09-10T01:45:07Z MacTire02 219 +cheeraghyn 393000 Scribunto text/plain local p = {} -- Enmyn çheerey as ny lhiegganyn gienneydagh oc. -- Cur lhimmaghyn ayns shoh my vel feme orroo. local country_names = { ["Bretyn"] = "Bretyn", ["Yn Chanadey"] = "Yn Chanadey", ["Yn Chroit"] = "Yn Chroit", ["Finnlynn"] = "Finnlynn", ["Yn Ghermaan"] = "Yn Ghermaan", ["Greenlynn"] = "Greenlynn", ["Yn Iddaal"] = "Yn Iddaal", ["Jersee"] = "Jersee", ["Kosovo"] = "Kosovo", ["Nalbin"] = "Nalbin", ["Nerin"] = "Nerin", ["Mannin"] = "Mannin", ["Meksico"] = "Meksico", ["Yn Ookraan"] = "Yn Ookraan", ["Yn Pholynn"] = "Yn Pholynn", ["Yn Phortiugal"] = "Yn Phortiugal", ["Yn Rank"] = "Yn Rank", ["Yn Reeriaght Unnaneysit"] = "Yn Reeriaght Unnaneysit", ["Yn Roosh"] = "Yn Roosh", ["Yn Serb"] = "Yn Serb", ["Sostyn"] = "Sostyn", ["Yn Spaainey"] = "Yn Spaainey", ["Ny Steatyn Unnaneysit"] = "Ny Steatyn Unnaneysit", ["Yn Toolynn"] = "y Toolynn" } local genitive = { ["Bretyn"] = "Vretyn", ["Yn Chanadey"] = "y Chanadey", ["Yn Chroit"] = "y Chroit", ["Finnlynn"] = "Innlynn", ["Yn Ghermaan"] = "y Ghermaan", ["Greenlynn"] = "Ghreenlynn", ["Yn Iddaal"] = "yn Iddaal", ["Jersee"] = "Jersee", ["Kosovo"] = "Chosovo", ["Nalbin"] = "ny h-Albey", ["Nerin"] = "Nerin", ["Mannin"] = "Vannin", ["Meksico"] = "Veksico", ["Yn Ookraan"] = "yn Ookraan", ["Yn Pholynn"] = "y Pholynn", ["Yn Phortiugal"] = "y Phortiugal", ["Yn Rank"] = "y Rank", ["Yn Reeriaght Unnaneysit"] = "y Reeriaght Unnaneysit", ["Yn Roosh"] = "y Roosh", ["Yn Serb"] = "y Terb", ["Sostyn"] = "Hostyn", ["Yn Spaainey"] = "y Spaainey", ["Ny Steatyn Unnaneysit"] = "ny Steatyn Unnaneysit", ["Yn Toolynn"] = "y Toolynn", } function p.name(name) if not name or name == "" then return name end return country_names[name] or name end function p.genitive(name) if not name or name == "" then return name end return genitive[name] or name end return p 7q2ieiyhdduv0voi9ovvupkwlat701o 393002 393000 2026-09-10T01:50:07Z MacTire02 219 ++ 393002 Scribunto text/plain local p = {} -- Enmyn çheerey as ny lhiegganyn gienneydagh oc. -- Cur lhimmaghyn ayns shoh my vel feme orroo. local country_names = { ["Yn Austrail"] = "Yn Austrail", ["Bretyn"] = "Bretyn", ["Yn Chanadey"] = "Yn Chanadey", ["Yn Chroit"] = "Yn Chroit", ["Finnlynn"] = "Finnlynn", ["Yn Ghermaan"] = "Yn Ghermaan", ["Greenlynn"] = "Greenlynn", ["Yn Iddaal"] = "Yn Iddaal", ["Jersee"] = "Jersee", ["Kosovo"] = "Kosovo", ["Nalbin"] = "Nalbin", ["Nerin"] = "Nerin", ["Mannin"] = "Mannin", ["Meksico"] = "Meksico", ["Yn Ookraan"] = "Yn Ookraan", ["Yn Pholynn"] = "Yn Pholynn", ["Yn Phortiugal"] = "Yn Phortiugal", ["Yn Phroosh"] = "Yn Phroosh", ["Yn Rank"] = "Yn Rank", ["Yn Reeriaght Unnaneysit"] = "Yn Reeriaght Unnaneysit", ["Yn Roosh"] = "Yn Roosh", ["Yn Serb"] = "Yn Serb", ["Sostyn"] = "Sostyn", ["Yn Spaainey"] = "Yn Spaainey", ["Ny Steatyn Unnaneysit"] = "Ny Steatyn Unnaneysit", ["Yn Toolynn"] = "y Toolynn" } local genitive = { ["Yn Austrail"] = "yn Austrail", ["Bretyn"] = "Vretyn", ["Yn Chanadey"] = "y Chanadey", ["Yn Chroit"] = "y Chroit", ["Finnlynn"] = "Innlynn", ["Yn Ghermaan"] = "y Ghermaan", ["Greenlynn"] = "Ghreenlynn", ["Yn Iddaal"] = "yn Iddaal", ["Jersee"] = "Jersee", ["Kosovo"] = "Chosovo", ["Nalbin"] = "ny h-Albey", ["Nerin"] = "Nerin", ["Mannin"] = "Vannin", ["Meksico"] = "Veksico", ["Yn Ookraan"] = "yn Ookraan", ["Yn Pholynn"] = "y Pholynn", ["Yn Phortiugal"] = "y Phortiugal", ["Yn Phroosh"] = "y Phroosh", ["Yn Rank"] = "y Rank", ["Yn Reeriaght Unnaneysit"] = "y Reeriaght Unnaneysit", ["Yn Roosh"] = "y Roosh", ["Yn Serb"] = "y Terb", ["Sostyn"] = "Hostyn", ["Yn Spaainey"] = "y Spaainey", ["Ny Steatyn Unnaneysit"] = "ny Steatyn Unnaneysit", ["Yn Toolynn"] = "y Toolynn", } function p.name(name) if not name or name == "" then return name end return country_names[name] or name end function p.genitive(name) if not name or name == "" then return name end return genitive[name] or name end return p 733n8xfcth1rlglm2fm1b1zs8pjp8wx Module:Kishtey fys çheer/reiltys 828 55837 392995 392987 2026-09-10T00:19:46Z MacTire02 219 ++ 392995 Scribunto text/plain local p = {} -- Module:Wd is gv.wiki's actual working Wikidata-fetch-and-cite module -- (confirmed by its localized /i18n submodule) — used instead of -- Module:WikidataIB, which has no working reference-building of its own. -- pcall so a wiki state where Wd (or its own Module:Wd/i18n) isn't set up -- degrades to "no Wikidata fallback" instead of breaking the infobox. local wdOK, Wd = pcall(require, "Module:Wd") -- Safely get manual parameters from priority list local function getManual(args, names) for _, name in ipairs(names) do local value = args[name] if value and mw.text.trim(value) ~= "" then return mw.text.trim(value) end end return nil end local function isNone(value) return value ~= nil and mw.text.trim(value):lower() == "none" end -- Append a manual reference (<ref>) and/or note ({{efn}}) to a value. This -- is the manual imraa_*/noteyn_* channel, same as Module:Kishtey fys -- çheer/çhengaghyn uses. It layers on top of a Wikidata-sourced value too -- (which already carries its own auto-built citation from getWdProperty -- below) in case an editor wants to add an extra citation or clarifying -- footnote of their own. local function applyRefNote(value, ref, note, frame) if not value then return value end if note and note ~= "" and frame then value = value .. frame:expandTemplate{ title = "efn", args = { note } } end if ref and ref ~= "" then value = value .. "<ref>" .. ref .. "</ref>" end return value end -- Fetch+format a single Wikidata property value via Module:Wd's "property" -- command, combined with its "reference" command so that, when the -- Wikidata statement itself carries references, Wd builds a real <ref> -- citation (Cite web / Cite Q) from them automatically — the same way -- gv.wiki's other Wd-based infoboxes already cite Wikidata data. `flags` -- is an optional array of extra Wd flags (e.g. {"linked"}). Returns nil -- when Wd isn't available, or the property has no value. local function getWdProperty(property, flags) if not wdOK or not Wd or not Wd._property then return nil end local callArgs = {} for _, f in ipairs(flags or {}) do table.insert(callArgs, f) end table.insert(callArgs, "reference") -- request an auto-built citation alongside the value table.insert(callArgs, "best") -- single best-ranked value, mirroring the old template's behaviour table.insert(callArgs, property) local ok, result = pcall(Wd._property, callArgs) if ok and result and result ~= "" then return result end return nil end -- Same as getWdProperty, but via Module:Wd's plural "properties" command, -- which joins EVERY matching value together (comma-separated by default) -- instead of just the single best one. Used for government type (P122 -- "basic form of government"), which Wikidata typically records as several -- separate statements on one country (e.g. "unitary state", "parliamentary -- system", "constitutional monarchy") rather than one combined phrase. local function getWdProperties(property, flags) if not wdOK or not Wd or not Wd._properties then return nil end local callArgs = {} for _, f in ipairs(flags or {}) do table.insert(callArgs, f) end table.insert(callArgs, "reference") table.insert(callArgs, property) local ok, result = pcall(Wd._properties, callArgs) if ok and result and result ~= "" then return result end return nil end -- Module:Wd's "linked" flag only produces a wikilink when the entity -- already has a gv sitelink (Config:getLabel returns the bare label, -- un-bracketed, otherwise — see Module:Wd source). For a leader whose -- article doesn't exist on gv.wiki yet, that means no link at all. Since -- an editor should still be able to click through (or see a redlink -- inviting the article to be written), this forces a wikilink around the -- label text when Wd didn't already supply one — without touching a -- trailing auto-built <ref>...</ref> citation, which Wd appends directly -- after the label/link text. local function ensureLinked(value) if not value or value == "" then return value end local label, refSuffix = value:match("^(.-)(<ref.*)$") if not label then label = value refSuffix = "" end if label:find("%[%[") then return value -- already a real link via a gv sitelink end label = mw.text.trim(label) if label == "" then return value end return "[[" .. label .. "]]" .. refSuffix end -- Label of the Wikidata PROPERTY itself (e.g. P35 -> "head of state"), used -- as a Wikidata-sourced fallback for a leader's title when no manual -- title/override is supplied. Deliberately uses getLabelByLang(property, -- "gv") rather than mw.wikibase.label(property): plain label() follows -- Wikidata's language-fallback chain and will happily hand back the -- English label when no Manx one exists (which is the common case for -- properties on Wikidata) — silently leaking English text like "head of -- state" into the Manx infobox. getLabelByLang only returns a value when a -- Manx label genuinely exists, so an untranslated property correctly falls -- through to the hardcoded Manx text below instead. local function getWikidataPropertyLabel(property) local ok, label = pcall(mw.wikibase.getLabelByLang, property, "gv") if ok and label and label ~= "" then return label end return nil end -- Raw QID (no linking/label formatting) of an entity-valued property on the -- CURRENT page's Wikidata item — e.g. P35's value (the head of state person) -- as a bare "Q..." id, so it can be used as the `eid` for a follow-up -- lookup on THAT person's own item (see getWdPositionTitle below). Uses -- Module:Wd's "raw" flag, which for an entity-id-valued statement returns -- the plain id instead of a formatted link/label. local function getWdRawPropertyId(property) if not wdOK or not Wd or not Wd._property then return nil end local ok, result = pcall(Wd._property, {"raw", "best", property}) if ok and result and type(result) == "string" and result:match("^Q%d+$") then return result end return nil end -- Raw QIDs of EVERY value of an entity-valued property on a FOREIGN -- Wikidata item (`eid`), not the current page's — e.g. the leader's own -- P39 ("position held") statements, which a real politician very often has -- several of at once (a parliamentary seat, a party leadership, AND a head- -- of-government office can all be simultaneously "current" -- see -- getWdPositionTitle below for why that matters). Uses Module:Wd's PLURAL -- "properties" command (not "property"), which -- unlike the singular -- command -- does not stop at a single "best" value, so every matching -- claim is returned, joined together; this extracts each "Q..." token from -- that joined string rather than relying on a specific separator, since -- Wd's separator choice isn't part of its documented contract. `eid` is -- passed the same way Module:Wd's own code does internally -- (`p._property{..., [p.args.eid] = id}`). `qualifiers` is an optional -- table of {qualifierPropertyId = requiredValue} pairs -- Module:Wd's -- claimCommand treats any hash key matching "P%d+" as a qualifier filter -- (see its `qualifierIDsAndValues`/`qualifierMatches` logic), letting a -- caller narrow the claims returned to just those with a matching -- qualifier (see getWdPositionTitle below, which uses this for P1001 -- "applies to jurisdiction"). Returns an empty table on any failure. local function getWdRawForeignPropertyIds(eid, property, extraFlags, qualifiers) if not wdOK or not Wd or not Wd._properties or not eid then return {} end local callArgs = {} for _, f in ipairs(extraFlags or {}) do table.insert(callArgs, f) end table.insert(callArgs, "raw") table.insert(callArgs, property) callArgs[Wd.args and Wd.args.eid or "eid"] = eid for qid, value in pairs(qualifiers or {}) do callArgs[qid] = value end local ok, result = pcall(Wd._properties, callArgs) if not ok or not result or type(result) ~= "string" or result == "" then return {} end local ids = {} for id in result:gmatch("Q%d+") do table.insert(ids, id) end return ids end -- The QID of the entity connected to the CURRENT page (e.g. the country the -- article is about), used to disambiguate a multi-realm head of state's P39 -- statements (see getWdPositionTitle below). Returns nil when the current -- page has no connected Wikidata item. local function getCurrentCountryQid() local ok, id = pcall(mw.wikibase.getEntityIdForCurrentPage) if ok and id and id ~= "" then return id end return nil end -- Manx country-specific office titles on gv.wiki follow the pattern -- "<role> y <country>" ("y" = "of the") -- e.g. "Monark y Reeriaght -- Unnaneysit", "Ard-vinishter y Reeriaght Unnaneysit". There is no separate -- short-form property reliably populated on Wikidata for these items, so -- rather than depending on one, this detaches the "y <country>" tail -- itself and keeps just the leading role word(s) -- "Monark", inserted as -- the display text of a link that still points at the full title. A title -- with no " y " in it (already just a bare role name) is returned as-is. local function shortManxForm(title) if not title or title == "" then return title end local short = title:match("^(.-)%sy%s") if short and short ~= "" then return short end return title end -- Capitalizes the first letter the way the wiki itself would (respecting -- Manx-specific case folding, e.g. digraphs like "çh"), via the content -- language object's own ucfirst -- NOT a plain Lua upper() on byte 1, which -- would mangle multi-byte UTF-8 and wouldn't match gv.wiki's own title- -- capitalization rules. Needed because a raw Wikidata LABEL (unlike a real -- page title/sitelink) is conventionally stored all-lowercase (e.g. -- "monark"), but both a link's display text and a red-linked target should -- read the way an actual Manx Wikipedia article title would. local function wikiUcfirst(text) if not text or text == "" then return text end local ok, result = pcall(function() return mw.language.getContentLanguage():ucfirst(text) end) if ok and result and result ~= "" then return result end return text end -- Given a Wikidata item ID for a specific office/position (e.g. "King of -- the United Kingdom"), build a wikilink using the gv sitelink (when one -- exists) or, failing that, a verified gv LABEL as the link target -- ALWAYS -- as a real wikilink, even when that means a redlink inviting the article to -- be written (per explicit instruction: an unlinked office title is -- indistinguishable from an unsourced one, same reasoning as ensureLinked() -- above for leader names). The display text has the "y <country>" tail -- detached (see shortManxForm above), e.g. "[[Monark y Reeriaght -- Unnaneysit|Monark]]". Never uses mw.wikibase.label's English-fallback- -- prone version -- same leak this module already had to fix once for -- property labels. Returns nil only when NEITHER a sitelink nor a gv label -- exists at all, so callers fall through to the generic hardcoded Manx text. local function getWdItemManxLink(qid) if not qid then return nil end local okSite, sitelinkTitle = pcall(mw.wikibase.sitelink, qid) if not okSite then sitelinkTitle = nil end local title = (sitelinkTitle and sitelinkTitle ~= "") and sitelinkTitle or nil if not title then local okLabel, gvLabel = pcall(mw.wikibase.getLabelByLang, qid, "gv") if okLabel and gvLabel and gvLabel ~= "" then -- Wikidata labels are conventionally lowercase; capitalize so the -- redlink reads (and will resolve/redirect) like a real title. title = wikiUcfirst(gvLabel) end end if not title then return nil end local short = shortManxForm(title) if short ~= title then return "[[" .. title .. "|" .. short .. "]]" end return "[[" .. title .. "]]" end -- The leader's own specific office title (e.g. "Monark y Reeriaght -- Unnaneysit" / "Ard-vinishter y Reeriaght Unnaneysit"), NOT the generic -- property description ("head of state"/"kione steat"). Wikidata attaches -- the country-specific title to the position-HOLDER's own "position held" -- (P39) statement, not to the country's P35/P6 statement — so this chains -- through the person: P35/P6 -> person's raw QID -> that person's current -- P39 value -> a Manx link/label for it. -- -- A head of state/government very often holds MULTIPLE simultaneous "current" -- P39 positions -- not just the classic shared-monarch case ("King of the -- United Kingdom", "King of Canada", "King of Australia", ... all current at -- once), but just as commonly a head of government who is ALSO, right now, a -- sitting member of their legislature AND the leader of their party. A brand -- new statement (e.g. someone who became PM only weeks ago) frequently has -- NO qualifier at all yet distinguishing "this is the state office" from -- "this is the party/parliamentary one" -- P1001 ("applies to jurisdiction") -- is the qualifier Wikidata uses for the shared-monarch case specifically, -- but isn't reliably present on every fresh statement, so it can't be -- trusted as the only signal. -- -- So rather than committing to a single "best" P39 value (which could just -- as easily be "Member of Parliament for ..." or "Leader of the ... Party" -- as the actual head-of-government office), this collects EVERY current P39 -- candidate -- ones matching a P1001 filter for this article's own country -- first (when the data has that qualifier, which correctly resolves a -- shared monarch to the right realm), then every other current candidate -- -- and tries each in turn, using the FIRST one that actually resolves to a -- real Manx sitelink or label via getWdItemManxLink. In practice an -- ancillary role (a parliamentary seat, a party leadership) is very unlikely -- to have a dedicated gv.wiki article of its own, while the formal head-of- -- state/government office is exactly the kind of article gv.wiki is likely -- to have -- so this reliably lands on the right one without needing -- Wikidata's qualifiers to be perfectly curated. -- -- Returns nil only when NONE of the current P39 candidates resolves to -- anything on gv.wiki (or Module:Wd is unavailable, or there's no current -- P39 at all), so callers fall back to the property-label / hardcoded rungs -- below. local function getWdPositionTitle(headProperty) local personQid = getWdRawPropertyId(headProperty) if not personQid then return nil end local countryQid = getCurrentCountryQid() local candidates = {} if countryQid then for _, id in ipairs(getWdRawForeignPropertyIds(personQid, "P39", {"current"}, {["P1001"] = countryQid})) do table.insert(candidates, id) end end for _, id in ipairs(getWdRawForeignPropertyIds(personQid, "P39", {"current"})) do table.insert(candidates, id) end local tried = {} for _, qid in ipairs(candidates) do if not tried[qid] then tried[qid] = true local link = getWdItemManxLink(qid) if link then return link end end end return nil end -- Row templates. Every row in this table is a plain 2-cell -- `<th>label</th><td>value</td>` row — exactly the grid every OTHER -- submodule in this system uses (Module:Kishtey fys çheer/çhengaghyn, -- /balley, /bratteeyn). The old HTML template used a 3-column grid instead -- (a narrow indent-spacer <td>, a label <td>, a value <td>, with -- colspan="2"/colspan="3" on label-only/header rows) — mixing that 3-column -- convention into a 2-column table was the actual cause of the reported -- "bunching"/"enormous gap" distortion: rows with different physical cell -- counts in the same table force the browser to reconcile column widths -- unpredictably. Sub-items (individual leaders/houses/founding events under -- one shared label) are distinguished with a "•" bullet + reduced font -- weight on the label cell instead of a separate spacer column — matching -- how English Wikipedia's infobox marks up a list of leaders under one -- "Leader" heading. local ROW = '<tr%s><th style="vertical-align:top; white-space:nowrap; text-align:left; font-weight:bold;">%s</th><td style="vertical-align:top;">%s</td></tr>' local SUBROW = '<tr%s><th style="vertical-align:top; white-space:nowrap; text-align:left; font-weight:normal; padding-left:0.5em;">•&nbsp;%s</th><td style="vertical-align:top;">%s</td></tr>' local HEADER = '<tr class="mergedtoprow"><th colspan="2">%s</th></tr>' -- Builds a `class="..."` attribute (or an empty string), for the -- mergedrow/mergedbottomrow/mergedtoprow classes the old template uses to -- remove the double border between a header/label row and the indented -- sub-rows that visually belong under it. local function trClass(name) if name and name ~= "" then return ' class="' .. name .. '"' end return "" end -- Formats a run of bullet-prefixed sub-rows (leader pairs, house names, -- establishment events, ...) with the old template's merged-border -- convention: every row but the last is "mergedrow", the last is -- "mergedbottomrow" — so the whole run reads as one visually joined block -- under its header/label row. local function appendIndentRun(rows, items) for idx, item in ipairs(items) do local class = (idx == #items) and "mergedbottomrow" or "mergedrow" table.insert(rows, string.format(SUBROW, trClass(class), item[1], item[2])) end end -- Same divider the dispatcher module (Module:Kishtey fys çheer) uses BETWEEN -- whole submodules (see its own `dividerLine`/`appendModule`). Reused here, -- identically, to separate this module's own three internal sections -- (leaders/government, legislature, founding) the same visual way -- a -- divider is only inserted BETWEEN two sections that both actually produced -- rows, never before the first section or after the last, and never next to -- an empty/suppressed section (mirrors appendModule's own conditional). local dividerLine = '<tr><td colspan="2" style="border-top:1px solid #a2a9b1; padding:0; height:0px;"></td></tr>' local function appendSection(rows, sectionRows) if sectionRows and #sectionRows > 0 then if #rows > 0 then table.insert(rows, dividerLine) end for _, row in ipairs(sectionRows) do table.insert(rows, row) end end end function p.main(frame, args) -- Fallback verification to catch argument slots accurately if frame context shifts if not args then args = frame frame = mw.getCurrentFrame() end local rows = {} local govRows = {} local quaiylRows = {} local foundingRows = {} ---------------------------------------------------------------- -- 1-2. REILTYS (Government type) + FIR HOSHEE / TOSHEE (Leaders: -- head of state / head of government / etc.) -- `enmysN_fer-toshee` / `ennymN_fer-toshee` are the old, gendered -- param names, kept for backward compatibility with existing -- articles. `enmys_toshiaghN` / `ennym_toshiaghN` are the -- gender-neutral synonyms going forward ("toshiagh" = leader); -- either spelling works, and the new one takes priority when both -- are supplied for the same slot. Leaders are computed BEFORE the -- government-type row is emitted so that row can carry the right -- merged-border class when leader rows are going to follow it. ---------------------------------------------------------------- local govTypeRaw = getManual(args, {"sorçh_reiltys", "government_type"}) local govRef = getManual(args, {"imraa_reiltys"}) local govNote = getManual(args, {"noteyn_reiltys"}) if not govTypeRaw then -- Wikidata fallback via Module:Wd: basic form of government (P122), -- e.g. "unitary state, parliamentary system, constitutional -- monarchy" -- joins every value Wikidata records rather than just -- one, since this is normally split across several statements. -- Skipped entirely when the field was explicitly suppressed -- (`|sorçh_reiltys=none`), same as every other Wikidata-fallback -- field in this module. govTypeRaw = getWdProperties("P122", {"linked"}) end local govShown = govTypeRaw and not isNone(govTypeRaw) local leaderPairs = {} local manualLeaderGiven = false for i = 1, 5 do local title = getManual(args, {"enmys_toshiagh" .. i, "enmys" .. i .. "_fer-toshee"}) local name = getManual(args, {"ennym_toshiagh" .. i, "ennym" .. i .. "_fer-toshee"}) if title or name then manualLeaderGiven = true if not isNone(name) then table.insert(leaderPairs, {title = title or "", name = name or ""}) end end end local leaderRef = getManual(args, {"imraa_toshiagh", "imraa_fer-toshee"}) local leaderNote = getManual(args, {"noteyn_toshiagh", "noteyn_fer-toshee"}) local leadersSuppressed = isNone(getManual(args, {"fir_hoshee", "toshiaghyn"})) if not manualLeaderGiven and not leadersSuppressed then -- Wikidata fallback via Module:Wd: head of state (P35) / head of -- government (P6). Names are ALWAYS forced into a link (a redlink -- when gv.wiki has no article for that person yet) via -- ensureLinked, since an unlinked plain name is easy to mistake for -- a manual/unsourced value and gives editors nothing to click -- through to create the article. Titles try, in order: a manual -- override, the leader's own country-specific office (e.g. "Monark -- y Reeriaght Unnaneysit"), the Wikidata property's own label, then -- a hardcoded Manx fallback. local hos = ensureLinked(getWdProperty("P35", {"linked"})) local hog = ensureLinked(getWdProperty("P6", {"linked"})) if hos then local hosTitle = getManual(args, {"sorçh_kione_steat"}) or getWdPositionTitle("P35") or getWikidataPropertyLabel("P35") or "Kione steat" table.insert(leaderPairs, {title = hosTitle, name = hos}) end if hog then local hogTitle = getManual(args, {"sorçh_kione_reiltys"}) or getWdPositionTitle("P6") or getWikidataPropertyLabel("P6") or "Kione reiltys" table.insert(leaderPairs, {title = hogTitle, name = hog}) end end if govShown then local govClass = (#leaderPairs > 0) and "mergedtoprow" or "" table.insert(govRows, string.format(ROW, trClass(govClass), "[[Reiltys]]", applyRefNote(govTypeRaw, govRef, govNote, frame))) elseif #leaderPairs > 0 then table.insert(govRows, string.format(HEADER, "[[Reiltys]]")) end if #leaderPairs > 0 then -- The shared manual ref/note for the whole leaders block is -- attached to the last row, same convention as a single footnote -- covering a list. (A Wikidata-sourced name already carries its own -- auto-built citation from getWdProperty.) local last = leaderPairs[#leaderPairs] last.name = applyRefNote(last.name, leaderRef, leaderNote, frame) local items = {} for _, leader in ipairs(leaderPairs) do table.insert(items, {leader.title, leader.name}) end appendIndentRun(govRows, items) end ---------------------------------------------------------------- -- 3. QUAIYL / ÇHIONNAL (Legislature) -- `çhionnal` is a synonym for `quaiyl`; `thie_heose` / `thie_heese` -- are synonyms for `quaiyl_syrjey` / `quaiyl_s'inshley` (upper / -- lower house). New spellings take priority when both are given. ---------------------------------------------------------------- local quaiyl = getManual(args, {"çhionnal", "quaiyl"}) local quaiylSyrjey = getManual(args, {"thie_heose", "quaiyl_syrjey"}) local quaiylInshley = getManual(args, {"thie_heese", "quaiyl_s'inshley", "quaiyl_sinshley"}) local quaiylRef = getManual(args, {"imraa_çhionnal", "imraa_quaiyl"}) local quaiylNote = getManual(args, {"noteyn_çhionnal", "noteyn_quaiyl"}) if not quaiyl and not quaiylSyrjey and not quaiylInshley then -- "short" asks Module:Wd for the item's short name (Wikidata -- P1813) first, e.g. "Parliament" instead of the full official -- "Parliament of the United Kingdom of Great Britain and Northern -- Ireland" -- matching enwiki's own concise style. Falls back to -- the item's normal label when no short name is set. quaiyl = getWdProperty("P194", {"linked", "short"}) end if quaiyl and not isNone(quaiyl) then local houseItems = {} if quaiylSyrjey and not isNone(quaiylSyrjey) then table.insert(houseItems, {"[[Thie heose]]", quaiylSyrjey}) end if quaiylInshley and not isNone(quaiylInshley) then table.insert(houseItems, {"[[Thie heese]]", quaiylInshley}) end local quaiylClass = (#houseItems > 0) and "mergedtoprow" or "" table.insert(quaiylRows, string.format(ROW, trClass(quaiylClass), "[[Çhionnal slattyssagh]]", applyRefNote(quaiyl, quaiylRef, quaiylNote, frame))) appendIndentRun(quaiylRows, houseItems) end ---------------------------------------------------------------- -- 4. BUNNEEAGHT / KIONDEEAGHT (Founding / constitution) and -- historical establishment events — manual-only, ported -- directly from the old template's numbered slots (1-9). -- `kionedeeaght` is a synonym for `kiondeeaght` in the label/note -- param names. ---------------------------------------------------------------- local foundingLabel = getManual(args, {"sorçh_kionedeeaght", "sorçh_kiondeeaght"}) or "Bunneeaght" local foundingValue = getManual(args, {"bunnit"}) local foundingNote = getManual(args, {"note_kionedeeaght", "note_kiondeeaght"}) local foundingRef = getManual(args, {"imraa_kionedeeaght", "imraa_kiondeeaght"}) local establishmentRows = {} for i = 1, 9 do local event = getManual(args, {"taghyrt" .. i .. "_bunnit"}) local date = getManual(args, {"date" .. i .. "_bunnit"}) if event then table.insert(establishmentRows, {event, date or ""}) end end if foundingValue or #establishmentRows > 0 then if foundingValue and not isNone(foundingValue) then local foundingClass = (#establishmentRows > 0) and "mergedtoprow" or "" table.insert(foundingRows, string.format(ROW, trClass(foundingClass), "[[" .. foundingLabel .. "]]", applyRefNote(foundingValue, foundingRef, foundingNote, frame))) elseif #establishmentRows > 0 then table.insert(foundingRows, string.format(HEADER, "[[" .. foundingLabel .. "]]")) end appendIndentRun(foundingRows, establishmentRows) elseif not isNone(getManual(args, {"bunnit"})) then -- Wikidata fallback via Module:Wd: inception (P571) — only when the -- whole establishment block was left unset (not explicitly |bunnit=none). -- NOTE on date precision: Module:Wd's own time-value formatting (see -- Config:getValue's `datatype == 'time'` branch) already renders a -- FULL day-month-year date whenever the underlying Wikidata statement -- itself is stored at day precision -- there is no flag this call is -- missing, and no truncation happens on our side (confirmed by the -- test harness, which feeds a day-precision value straight through -- unchanged). When only a year is shown on a real article, that is -- because THAT COUNTRY's P571 statement on Wikidata itself is only -- recorded at year precision (very common for older founding dates) -- -- not a bug here. The manual |bunnit= override remains the fix for -- any article where the Wikidata precision isn't good enough. local inception = getWdProperty("P571") if inception then table.insert(foundingRows, string.format(ROW, "", "[[" .. foundingLabel .. "]]", applyRefNote(inception, foundingRef, foundingNote, frame))) end end appendSection(rows, govRows) appendSection(rows, quaiylRows) appendSection(rows, foundingRows) if #rows == 0 then return nil end return table.concat(rows) end return p lim6959q2u3b3w2burv0kicrq6ua4yq 392996 392995 2026-09-10T00:27:14Z MacTire02 219 ++ 392996 Scribunto text/plain local p = {} -- Module:Wd is gv.wiki's actual working Wikidata-fetch-and-cite module -- (confirmed by its localized /i18n submodule) — used instead of -- Module:WikidataIB, which has no working reference-building of its own. -- pcall so a wiki state where Wd (or its own Module:Wd/i18n) isn't set up -- degrades to "no Wikidata fallback" instead of breaking the infobox. local wdOK, Wd = pcall(require, "Module:Wd") -- Safely get manual parameters from priority list local function getManual(args, names) for _, name in ipairs(names) do local value = args[name] if value and mw.text.trim(value) ~= "" then return mw.text.trim(value) end end return nil end local function isNone(value) return value ~= nil and mw.text.trim(value):lower() == "none" end -- Append a manual reference (<ref>) and/or note ({{efn}}) to a value. This -- is the manual imraa_*/noteyn_* channel, same as Module:Kishtey fys -- çheer/çhengaghyn uses. It layers on top of a Wikidata-sourced value too -- (which already carries its own auto-built citation from getWdProperty -- below) in case an editor wants to add an extra citation or clarifying -- footnote of their own. local function applyRefNote(value, ref, note, frame) if not value then return value end if note and note ~= "" and frame then value = value .. frame:expandTemplate{ title = "efn", args = { note } } end if ref and ref ~= "" then value = value .. "<ref>" .. ref .. "</ref>" end return value end -- Fetch+format a single Wikidata property value via Module:Wd's "property" -- command, combined with its "reference" command so that, when the -- Wikidata statement itself carries references, Wd builds a real <ref> -- citation (Cite web / Cite Q) from them automatically — the same way -- gv.wiki's other Wd-based infoboxes already cite Wikidata data. `flags` -- is an optional array of extra Wd flags (e.g. {"linked"}). Returns nil -- when Wd isn't available, or the property has no value. local function getWdProperty(property, flags) if not wdOK or not Wd or not Wd._property then return nil end local callArgs = {} for _, f in ipairs(flags or {}) do table.insert(callArgs, f) end table.insert(callArgs, "reference") -- request an auto-built citation alongside the value table.insert(callArgs, "best") -- single best-ranked value, mirroring the old template's behaviour table.insert(callArgs, property) local ok, result = pcall(Wd._property, callArgs) if ok and result and result ~= "" then return result end return nil end -- Same as getWdProperty, but via Module:Wd's plural "properties" command, -- which joins EVERY matching value together (comma-separated by default) -- instead of just the single best one. Used for government type (P122 -- "basic form of government"), which Wikidata typically records as several -- separate statements on one country (e.g. "unitary state", "parliamentary -- system", "constitutional monarchy") rather than one combined phrase. local function getWdProperties(property, flags) if not wdOK or not Wd or not Wd._properties then return nil end local callArgs = {} for _, f in ipairs(flags or {}) do table.insert(callArgs, f) end table.insert(callArgs, "reference") table.insert(callArgs, property) local ok, result = pcall(Wd._properties, callArgs) if ok and result and result ~= "" then return result end return nil end -- Module:Wd's "linked" flag only produces a wikilink when the entity -- already has a gv sitelink (Config:getLabel returns the bare label, -- un-bracketed, otherwise — see Module:Wd source). For a leader whose -- article doesn't exist on gv.wiki yet, that means no link at all. Since -- an editor should still be able to click through (or see a redlink -- inviting the article to be written), this forces a wikilink around the -- label text when Wd didn't already supply one — without touching a -- trailing auto-built <ref>...</ref> citation, which Wd appends directly -- after the label/link text. local function ensureLinked(value) if not value or value == "" then return value end local label, refSuffix = value:match("^(.-)(<ref.*)$") if not label then label = value refSuffix = "" end if label:find("%[%[") then return value -- already a real link via a gv sitelink end label = mw.text.trim(label) if label == "" then return value end return "[[" .. label .. "]]" .. refSuffix end -- Label of the Wikidata PROPERTY itself (e.g. P35 -> "head of state"), used -- as a Wikidata-sourced fallback for a leader's title when no manual -- title/override is supplied. Deliberately uses getLabelByLang(property, -- "gv") rather than mw.wikibase.label(property): plain label() follows -- Wikidata's language-fallback chain and will happily hand back the -- English label when no Manx one exists (which is the common case for -- properties on Wikidata) — silently leaking English text like "head of -- state" into the Manx infobox. getLabelByLang only returns a value when a -- Manx label genuinely exists, so an untranslated property correctly falls -- through to the hardcoded Manx text below instead. local function getWikidataPropertyLabel(property) local ok, label = pcall(mw.wikibase.getLabelByLang, property, "gv") if ok and label and label ~= "" then return label end return nil end -- Raw QID (no linking/label formatting) of an entity-valued property on the -- CURRENT page's Wikidata item — e.g. P35's value (the head of state person) -- as a bare "Q..." id, so it can be used as the `eid` for a follow-up -- lookup on THAT person's own item (see getWdPositionTitle below). Uses -- Module:Wd's "raw" flag, which for an entity-id-valued statement returns -- the plain id instead of a formatted link/label. local function getWdRawPropertyId(property) if not wdOK or not Wd or not Wd._property then return nil end local ok, result = pcall(Wd._property, {"raw", "best", property}) if ok and result and type(result) == "string" and result:match("^Q%d+$") then return result end return nil end -- Raw QIDs of EVERY value of an entity-valued property on a FOREIGN -- Wikidata item (`eid`), not the current page's — e.g. the leader's own -- P39 ("position held") statements, which a real politician very often has -- several of at once (a parliamentary seat, a party leadership, AND a head- -- of-government office can all be simultaneously "current" -- see -- getWdPositionTitle below for why that matters). Uses Module:Wd's PLURAL -- "properties" command (not "property"), which -- unlike the singular -- command -- does not stop at a single "best" value, so every matching -- claim is returned, joined together; this extracts each "Q..." token from -- that joined string rather than relying on a specific separator, since -- Wd's separator choice isn't part of its documented contract. `eid` is -- passed the same way Module:Wd's own code does internally -- (`p._property{..., [p.args.eid] = id}`). `qualifiers` is an optional -- table of {qualifierPropertyId = requiredValue} pairs -- Module:Wd's -- claimCommand treats any hash key matching "P%d+" as a qualifier filter -- (see its `qualifierIDsAndValues`/`qualifierMatches` logic), letting a -- caller narrow the claims returned to just those with a matching -- qualifier (see getWdPositionTitle below, which uses this for P1001 -- "applies to jurisdiction"). Returns an empty table on any failure. local function getWdRawForeignPropertyIds(eid, property, extraFlags, qualifiers) if not wdOK or not Wd or not Wd._properties or not eid then return {} end local callArgs = {} for _, f in ipairs(extraFlags or {}) do table.insert(callArgs, f) end table.insert(callArgs, "raw") table.insert(callArgs, property) callArgs[Wd.args and Wd.args.eid or "eid"] = eid for qid, value in pairs(qualifiers or {}) do callArgs[qid] = value end local ok, result = pcall(Wd._properties, callArgs) if not ok or not result or type(result) ~= "string" or result == "" then return {} end local ids = {} for id in result:gmatch("Q%d+") do table.insert(ids, id) end return ids end -- The QID of the entity connected to the CURRENT page (e.g. the country the -- article is about), used to disambiguate a multi-realm head of state's P39 -- statements (see getWdPositionTitle below). Returns nil when the current -- page has no connected Wikidata item. local function getCurrentCountryQid() local ok, id = pcall(mw.wikibase.getEntityIdForCurrentPage) if ok and id and id ~= "" then return id end return nil end -- Manx country-specific office titles on gv.wiki follow the pattern -- "<role> y <country>" ("y" = "of the") -- e.g. "Monark y Reeriaght -- Unnaneysit", "Ard-vinishter y Reeriaght Unnaneysit". There is no separate -- short-form property reliably populated on Wikidata for these items, so -- rather than depending on one, this detaches the "y <country>" tail -- itself and keeps just the leading role word(s) -- "Monark", inserted as -- the display text of a link that still points at the full title. A title -- with no " y " in it (already just a bare role name) is returned as-is. local function shortManxForm(title) if not title or title == "" then return title end local short = title:match("^(.-)%sy%s") if short and short ~= "" then return short end return title end -- Capitalizes the first letter the way the wiki itself would (respecting -- Manx-specific case folding, e.g. digraphs like "çh"), via the content -- language object's own ucfirst -- NOT a plain Lua upper() on byte 1, which -- would mangle multi-byte UTF-8 and wouldn't match gv.wiki's own title- -- capitalization rules. Needed because a raw Wikidata LABEL (unlike a real -- page title/sitelink) is conventionally stored all-lowercase (e.g. -- "monark"), but both a link's display text and a red-linked target should -- read the way an actual Manx Wikipedia article title would. local function wikiUcfirst(text) if not text or text == "" then return text end local ok, result = pcall(function() return mw.language.getContentLanguage():ucfirst(text) end) if ok and result and result ~= "" then return result end return text end -- Given a Wikidata item ID for a specific office/position (e.g. "King of -- the United Kingdom"), build a wikilink using the gv sitelink (when one -- exists) or, failing that, a verified gv LABEL as the link target -- ALWAYS -- as a real wikilink, even when that means a redlink inviting the article to -- be written (per explicit instruction: an unlinked office title is -- indistinguishable from an unsourced one, same reasoning as ensureLinked() -- above for leader names). The display text has the "y <country>" tail -- detached (see shortManxForm above), e.g. "[[Monark y Reeriaght -- Unnaneysit|Monark]]". Never uses mw.wikibase.label's English-fallback- -- prone version -- same leak this module already had to fix once for -- property labels. Returns nil only when NEITHER a sitelink nor a gv label -- exists at all, so callers fall through to the generic hardcoded Manx text. local function getWdItemManxLink(qid) if not qid then return nil end local okSite, sitelinkTitle = pcall(mw.wikibase.sitelink, qid) if not okSite then sitelinkTitle = nil end local title = (sitelinkTitle and sitelinkTitle ~= "") and sitelinkTitle or nil if not title then local okLabel, gvLabel = pcall(mw.wikibase.getLabelByLang, qid, "gv") if okLabel and gvLabel and gvLabel ~= "" then -- Wikidata labels are conventionally lowercase; capitalize so the -- redlink reads (and will resolve/redirect) like a real title. title = wikiUcfirst(gvLabel) end end if not title then return nil end local short = shortManxForm(title) if short ~= title then return "[[" .. title .. "|" .. short .. "]]" end return "[[" .. title .. "]]" end -- Wikidata has two properties made specifically to solve this exact office- -- title problem, set directly on the COUNTRY's own item rather than on the -- office-holder: P1313 "office held by head of state" and P1906 "office held -- by head of government". Their value is the generic OFFICE item itself -- (e.g. "Chief Minister of the Isle of Man" / "Ard-hirveishagh Vannin") -- -- not a person, and not one of several roles a particular office-holder -- happens to hold right now. When a country's item has this property set, -- it sidesteps the multi-role-P39 ambiguity entirely (see getWdPositionTitle -- below): there's no need to guess which of a person's several concurrent -- "position held" statements is the right one, because Wikidata already -- names the office directly. Tried FIRST, before the person-chain fallback. local function getWdOfficeItemTitle(officeProperty) local officeQid = getWdRawPropertyId(officeProperty) if not officeQid then return nil end return getWdItemManxLink(officeQid) end -- FALLBACK ONLY (see getWdOfficeItemTitle above, tried first): the leader's -- own specific office title (e.g. "Monark y Reeriaght Unnaneysit" / -- "Ard-vinishter y Reeriaght Unnaneysit"), NOT the generic property -- description ("head of state"/"kione steat"), derived by chaining through -- the CURRENT OFFICE-HOLDER instead of a dedicated country-level property -- -- used only for a country whose Wikidata item doesn't have P1313/P1906 set. -- Wikidata attaches the country-specific title to the position-HOLDER's own -- "position held" (P39) statement, not to the country's P35/P6 statement — -- so this chains through the person: P35/P6 -> person's raw QID -> that -- person's current P39 value -> a Manx link/label for it. -- -- A head of state/government very often holds MULTIPLE simultaneous "current" -- P39 positions -- not just the classic shared-monarch case ("King of the -- United Kingdom", "King of Canada", "King of Australia", ... all current at -- once), but just as commonly a head of government who is ALSO, right now, a -- sitting member of their legislature AND the leader of their party. A brand -- new statement (e.g. someone who became PM only weeks ago) frequently has -- NO qualifier at all yet distinguishing "this is the state office" from -- "this is the party/parliamentary one" -- P1001 ("applies to jurisdiction") -- is the qualifier Wikidata uses for the shared-monarch case specifically, -- but isn't reliably present on every fresh statement, so it can't be -- trusted as the only signal. -- -- So rather than committing to a single "best" P39 value (which could just -- as easily be "Member of Parliament for ..." or "Leader of the ... Party" -- as the actual head-of-government office), this collects EVERY current P39 -- candidate -- ones matching a P1001 filter for this article's own country -- first (when the data has that qualifier, which correctly resolves a -- shared monarch to the right realm), then every other current candidate -- -- and tries each in turn, using the FIRST one that actually resolves to a -- real Manx sitelink or label via getWdItemManxLink. In practice an -- ancillary role (a parliamentary seat, a party leadership) is very unlikely -- to have a dedicated gv.wiki article of its own, while the formal head-of- -- state/government office is exactly the kind of article gv.wiki is likely -- to have -- so this reliably lands on the right one without needing -- Wikidata's qualifiers to be perfectly curated. -- -- Returns nil only when NONE of the current P39 candidates resolves to -- anything on gv.wiki (or Module:Wd is unavailable, or there's no current -- P39 at all), so callers fall back to the property-label / hardcoded rungs -- below. local function getWdPositionTitle(headProperty) local personQid = getWdRawPropertyId(headProperty) if not personQid then return nil end local countryQid = getCurrentCountryQid() local candidates = {} if countryQid then for _, id in ipairs(getWdRawForeignPropertyIds(personQid, "P39", {"current"}, {["P1001"] = countryQid})) do table.insert(candidates, id) end end for _, id in ipairs(getWdRawForeignPropertyIds(personQid, "P39", {"current"})) do table.insert(candidates, id) end local tried = {} for _, qid in ipairs(candidates) do if not tried[qid] then tried[qid] = true local link = getWdItemManxLink(qid) if link then return link end end end return nil end -- Row templates. Every row in this table is a plain 2-cell -- `<th>label</th><td>value</td>` row — exactly the grid every OTHER -- submodule in this system uses (Module:Kishtey fys çheer/çhengaghyn, -- /balley, /bratteeyn). The old HTML template used a 3-column grid instead -- (a narrow indent-spacer <td>, a label <td>, a value <td>, with -- colspan="2"/colspan="3" on label-only/header rows) — mixing that 3-column -- convention into a 2-column table was the actual cause of the reported -- "bunching"/"enormous gap" distortion: rows with different physical cell -- counts in the same table force the browser to reconcile column widths -- unpredictably. Sub-items (individual leaders/houses/founding events under -- one shared label) are distinguished with a "•" bullet + reduced font -- weight on the label cell instead of a separate spacer column — matching -- how English Wikipedia's infobox marks up a list of leaders under one -- "Leader" heading. local ROW = '<tr%s><th style="vertical-align:top; white-space:nowrap; text-align:left; font-weight:bold;">%s</th><td style="vertical-align:top;">%s</td></tr>' local SUBROW = '<tr%s><th style="vertical-align:top; white-space:nowrap; text-align:left; font-weight:normal; padding-left:0.5em;">•&nbsp;%s</th><td style="vertical-align:top;">%s</td></tr>' local HEADER = '<tr class="mergedtoprow"><th colspan="2">%s</th></tr>' -- Builds a `class="..."` attribute (or an empty string), for the -- mergedrow/mergedbottomrow/mergedtoprow classes the old template uses to -- remove the double border between a header/label row and the indented -- sub-rows that visually belong under it. local function trClass(name) if name and name ~= "" then return ' class="' .. name .. '"' end return "" end -- Formats a run of bullet-prefixed sub-rows (leader pairs, house names, -- establishment events, ...) with the old template's merged-border -- convention: every row but the last is "mergedrow", the last is -- "mergedbottomrow" — so the whole run reads as one visually joined block -- under its header/label row. local function appendIndentRun(rows, items) for idx, item in ipairs(items) do local class = (idx == #items) and "mergedbottomrow" or "mergedrow" table.insert(rows, string.format(SUBROW, trClass(class), item[1], item[2])) end end -- Same divider the dispatcher module (Module:Kishtey fys çheer) uses BETWEEN -- whole submodules (see its own `dividerLine`/`appendModule`). Reused here, -- identically, to separate this module's own three internal sections -- (leaders/government, legislature, founding) the same visual way -- a -- divider is only inserted BETWEEN two sections that both actually produced -- rows, never before the first section or after the last, and never next to -- an empty/suppressed section (mirrors appendModule's own conditional). local dividerLine = '<tr><td colspan="2" style="border-top:1px solid #a2a9b1; padding:0; height:0px;"></td></tr>' local function appendSection(rows, sectionRows) if sectionRows and #sectionRows > 0 then if #rows > 0 then table.insert(rows, dividerLine) end for _, row in ipairs(sectionRows) do table.insert(rows, row) end end end function p.main(frame, args) -- Fallback verification to catch argument slots accurately if frame context shifts if not args then args = frame frame = mw.getCurrentFrame() end local rows = {} local govRows = {} local quaiylRows = {} local foundingRows = {} ---------------------------------------------------------------- -- 1-2. REILTYS (Government type) + FIR HOSHEE / TOSHEE (Leaders: -- head of state / head of government / etc.) -- `enmysN_fer-toshee` / `ennymN_fer-toshee` are the old, gendered -- param names, kept for backward compatibility with existing -- articles. `enmys_toshiaghN` / `ennym_toshiaghN` are the -- gender-neutral synonyms going forward ("toshiagh" = leader); -- either spelling works, and the new one takes priority when both -- are supplied for the same slot. Leaders are computed BEFORE the -- government-type row is emitted so that row can carry the right -- merged-border class when leader rows are going to follow it. ---------------------------------------------------------------- local govTypeRaw = getManual(args, {"sorçh_reiltys", "government_type"}) local govRef = getManual(args, {"imraa_reiltys"}) local govNote = getManual(args, {"noteyn_reiltys"}) if not govTypeRaw then -- Wikidata fallback via Module:Wd: basic form of government (P122), -- e.g. "unitary state, parliamentary system, constitutional -- monarchy" -- joins every value Wikidata records rather than just -- one, since this is normally split across several statements. -- Skipped entirely when the field was explicitly suppressed -- (`|sorçh_reiltys=none`), same as every other Wikidata-fallback -- field in this module. govTypeRaw = getWdProperties("P122", {"linked"}) end local govShown = govTypeRaw and not isNone(govTypeRaw) local leaderPairs = {} local manualLeaderGiven = false for i = 1, 5 do local title = getManual(args, {"enmys_toshiagh" .. i, "enmys" .. i .. "_fer-toshee"}) local name = getManual(args, {"ennym_toshiagh" .. i, "ennym" .. i .. "_fer-toshee"}) if title or name then manualLeaderGiven = true if not isNone(name) then table.insert(leaderPairs, {title = title or "", name = name or ""}) end end end local leaderRef = getManual(args, {"imraa_toshiagh", "imraa_fer-toshee"}) local leaderNote = getManual(args, {"noteyn_toshiagh", "noteyn_fer-toshee"}) local leadersSuppressed = isNone(getManual(args, {"fir_hoshee", "toshiaghyn"})) if not manualLeaderGiven and not leadersSuppressed then -- Wikidata fallback via Module:Wd: head of state (P35) / head of -- government (P6). Names are ALWAYS forced into a link (a redlink -- when gv.wiki has no article for that person yet) via -- ensureLinked, since an unlinked plain name is easy to mistake for -- a manual/unsourced value and gives editors nothing to click -- through to create the article. Titles try, in order: a manual -- override, the leader's own country-specific office (e.g. "Monark -- y Reeriaght Unnaneysit"), the Wikidata property's own label, then -- a hardcoded Manx fallback. local hos = ensureLinked(getWdProperty("P35", {"linked"})) local hog = ensureLinked(getWdProperty("P6", {"linked"})) if hos then local hosTitle = getManual(args, {"sorçh_kione_steat"}) or getWdOfficeItemTitle("P1313") -- "office held by head of state" -- set directly on the country, no person-level ambiguity or getWdPositionTitle("P35") or getWikidataPropertyLabel("P35") or "Kione steat" table.insert(leaderPairs, {title = hosTitle, name = hos}) end if hog then local hogTitle = getManual(args, {"sorçh_kione_reiltys"}) or getWdOfficeItemTitle("P1906") -- "office held by head of government" -- same reasoning as P1313 above or getWdPositionTitle("P6") or getWikidataPropertyLabel("P6") or "Kione reiltys" table.insert(leaderPairs, {title = hogTitle, name = hog}) end end if govShown then local govClass = (#leaderPairs > 0) and "mergedtoprow" or "" table.insert(govRows, string.format(ROW, trClass(govClass), "[[Reiltys]]", applyRefNote(govTypeRaw, govRef, govNote, frame))) elseif #leaderPairs > 0 then table.insert(govRows, string.format(HEADER, "[[Reiltys]]")) end if #leaderPairs > 0 then -- The shared manual ref/note for the whole leaders block is -- attached to the last row, same convention as a single footnote -- covering a list. (A Wikidata-sourced name already carries its own -- auto-built citation from getWdProperty.) local last = leaderPairs[#leaderPairs] last.name = applyRefNote(last.name, leaderRef, leaderNote, frame) local items = {} for _, leader in ipairs(leaderPairs) do table.insert(items, {leader.title, leader.name}) end appendIndentRun(govRows, items) end ---------------------------------------------------------------- -- 3. QUAIYL / ÇHIONNAL (Legislature) -- `çhionnal` is a synonym for `quaiyl`; `thie_heose` / `thie_heese` -- are synonyms for `quaiyl_syrjey` / `quaiyl_s'inshley` (upper / -- lower house). New spellings take priority when both are given. ---------------------------------------------------------------- local quaiyl = getManual(args, {"çhionnal", "quaiyl"}) local quaiylSyrjey = getManual(args, {"thie_heose", "quaiyl_syrjey"}) local quaiylInshley = getManual(args, {"thie_heese", "quaiyl_s'inshley", "quaiyl_sinshley"}) local quaiylRef = getManual(args, {"imraa_çhionnal", "imraa_quaiyl"}) local quaiylNote = getManual(args, {"noteyn_çhionnal", "noteyn_quaiyl"}) if not quaiyl and not quaiylSyrjey and not quaiylInshley then -- "short" asks Module:Wd for the item's short name (Wikidata -- P1813) first, e.g. "Parliament" instead of the full official -- "Parliament of the United Kingdom of Great Britain and Northern -- Ireland" -- matching enwiki's own concise style. Falls back to -- the item's normal label when no short name is set. quaiyl = getWdProperty("P194", {"linked", "short"}) end if quaiyl and not isNone(quaiyl) then local houseItems = {} if quaiylSyrjey and not isNone(quaiylSyrjey) then table.insert(houseItems, {"[[Thie heose]]", quaiylSyrjey}) end if quaiylInshley and not isNone(quaiylInshley) then table.insert(houseItems, {"[[Thie heese]]", quaiylInshley}) end local quaiylClass = (#houseItems > 0) and "mergedtoprow" or "" table.insert(quaiylRows, string.format(ROW, trClass(quaiylClass), "[[Çhionnal slattyssagh]]", applyRefNote(quaiyl, quaiylRef, quaiylNote, frame))) appendIndentRun(quaiylRows, houseItems) end ---------------------------------------------------------------- -- 4. BUNNEEAGHT / KIONDEEAGHT (Founding / constitution) and -- historical establishment events — manual-only, ported -- directly from the old template's numbered slots (1-9). -- `kionedeeaght` is a synonym for `kiondeeaght` in the label/note -- param names. ---------------------------------------------------------------- local foundingLabel = getManual(args, {"sorçh_kionedeeaght", "sorçh_kiondeeaght"}) or "Bunneeaght" local foundingValue = getManual(args, {"bunnit"}) local foundingNote = getManual(args, {"note_kionedeeaght", "note_kiondeeaght"}) local foundingRef = getManual(args, {"imraa_kionedeeaght", "imraa_kiondeeaght"}) local establishmentRows = {} for i = 1, 9 do local event = getManual(args, {"taghyrt" .. i .. "_bunnit"}) local date = getManual(args, {"date" .. i .. "_bunnit"}) if event then table.insert(establishmentRows, {event, date or ""}) end end if foundingValue or #establishmentRows > 0 then if foundingValue and not isNone(foundingValue) then local foundingClass = (#establishmentRows > 0) and "mergedtoprow" or "" table.insert(foundingRows, string.format(ROW, trClass(foundingClass), "[[" .. foundingLabel .. "]]", applyRefNote(foundingValue, foundingRef, foundingNote, frame))) elseif #establishmentRows > 0 then table.insert(foundingRows, string.format(HEADER, "[[" .. foundingLabel .. "]]")) end appendIndentRun(foundingRows, establishmentRows) elseif not isNone(getManual(args, {"bunnit"})) then -- Wikidata fallback via Module:Wd: inception (P571) — only when the -- whole establishment block was left unset (not explicitly |bunnit=none). -- NOTE on date precision: Module:Wd's own time-value formatting (see -- Config:getValue's `datatype == 'time'` branch) already renders a -- FULL day-month-year date whenever the underlying Wikidata statement -- itself is stored at day precision -- there is no flag this call is -- missing, and no truncation happens on our side (confirmed by the -- test harness, which feeds a day-precision value straight through -- unchanged). When only a year is shown on a real article, that is -- because THAT COUNTRY's P571 statement on Wikidata itself is only -- recorded at year precision (very common for older founding dates) -- -- not a bug here. The manual |bunnit= override remains the fix for -- any article where the Wikidata precision isn't good enough. local inception = getWdProperty("P571") if inception then table.insert(foundingRows, string.format(ROW, "", "[[" .. foundingLabel .. "]]", applyRefNote(inception, foundingRef, foundingNote, frame))) end end appendSection(rows, govRows) appendSection(rows, quaiylRows) appendSection(rows, foundingRows) if #rows == 0 then return nil end return table.concat(rows) end return p sq87etw2wti38djy29wanh3sypf2gxh 392997 392996 2026-09-10T00:33:54Z MacTire02 219 oops 392997 Scribunto text/plain local p = {} -- Module:Wd is gv.wiki's actual working Wikidata-fetch-and-cite module -- (confirmed by its localized /i18n submodule) — used instead of -- Module:WikidataIB, which has no working reference-building of its own. -- pcall so a wiki state where Wd (or its own Module:Wd/i18n) isn't set up -- degrades to "no Wikidata fallback" instead of breaking the infobox. local wdOK, Wd = pcall(require, "Module:Wd") -- Safely get manual parameters from priority list local function getManual(args, names) for _, name in ipairs(names) do local value = args[name] if value and mw.text.trim(value) ~= "" then return mw.text.trim(value) end end return nil end local function isNone(value) return value ~= nil and mw.text.trim(value):lower() == "none" end -- Append a manual reference (<ref>) and/or note ({{efn}}) to a value. This -- is the manual imraa_*/noteyn_* channel, same as Module:Kishtey fys -- çheer/çhengaghyn uses. It layers on top of a Wikidata-sourced value too -- (which already carries its own auto-built citation from getWdProperty -- below) in case an editor wants to add an extra citation or clarifying -- footnote of their own. local function applyRefNote(value, ref, note, frame) if not value then return value end if note and note ~= "" and frame then value = value .. frame:expandTemplate{ title = "efn", args = { note } } end if ref and ref ~= "" then value = value .. "<ref>" .. ref .. "</ref>" end return value end -- Fetch+format a single Wikidata property value via Module:Wd's "property" -- command, combined with its "reference" command so that, when the -- Wikidata statement itself carries references, Wd builds a real <ref> -- citation (Cite web / Cite Q) from them automatically — the same way -- gv.wiki's other Wd-based infoboxes already cite Wikidata data. `flags` -- is an optional array of extra Wd flags (e.g. {"linked"}). Returns nil -- when Wd isn't available, or the property has no value. local function getWdProperty(property, flags) if not wdOK or not Wd or not Wd._property then return nil end local callArgs = {} for _, f in ipairs(flags or {}) do table.insert(callArgs, f) end table.insert(callArgs, "reference") -- request an auto-built citation alongside the value table.insert(callArgs, "best") -- single best-ranked value, mirroring the old template's behaviour table.insert(callArgs, property) local ok, result = pcall(Wd._property, callArgs) if ok and result and result ~= "" then return result end return nil end -- Same as getWdProperty, but via Module:Wd's plural "properties" command, -- which joins EVERY matching value together (comma-separated by default) -- instead of just the single best one. Used for government type (P122 -- "basic form of government"), which Wikidata typically records as several -- separate statements on one country (e.g. "unitary state", "parliamentary -- system", "constitutional monarchy") rather than one combined phrase. local function getWdProperties(property, flags) if not wdOK or not Wd or not Wd._properties then return nil end local callArgs = {} for _, f in ipairs(flags or {}) do table.insert(callArgs, f) end table.insert(callArgs, "reference") table.insert(callArgs, property) local ok, result = pcall(Wd._properties, callArgs) if ok and result and result ~= "" then return result end return nil end -- Module:Wd's "linked" flag only produces a wikilink when the entity -- already has a gv sitelink (Config:getLabel returns the bare label, -- un-bracketed, otherwise — see Module:Wd source). For a leader whose -- article doesn't exist on gv.wiki yet, that means no link at all. Since -- an editor should still be able to click through (or see a redlink -- inviting the article to be written), this forces a wikilink around the -- label text when Wd didn't already supply one — without touching a -- trailing auto-built <ref>...</ref> citation, which Wd appends directly -- after the label/link text. local function ensureLinked(value) if not value or value == "" then return value end local label, refSuffix = value:match("^(.-)(<ref.*)$") if not label then label = value refSuffix = "" end if label:find("%[%[") then return value -- already a real link via a gv sitelink end label = mw.text.trim(label) if label == "" then return value end return "[[" .. label .. "]]" .. refSuffix end -- Label of the Wikidata PROPERTY itself (e.g. P35 -> "head of state"), used -- as a Wikidata-sourced fallback for a leader's title when no manual -- title/override is supplied. Deliberately uses getLabelByLang(property, -- "gv") rather than mw.wikibase.label(property): plain label() follows -- Wikidata's language-fallback chain and will happily hand back the -- English label when no Manx one exists (which is the common case for -- properties on Wikidata) — silently leaking English text like "head of -- state" into the Manx infobox. getLabelByLang only returns a value when a -- Manx label genuinely exists, so an untranslated property correctly falls -- through to the hardcoded Manx text below instead. local function getWikidataPropertyLabel(property) local ok, label = pcall(mw.wikibase.getLabelByLang, property, "gv") if ok and label and label ~= "" then return label end return nil end -- Raw QID (no linking/label formatting) of an entity-valued property on the -- CURRENT page's Wikidata item — e.g. P35's value (the head of state person) -- as a bare "Q..." id, so it can be used as the `eid` for a follow-up -- lookup on THAT person's own item (see getWdPositionTitle below). Uses -- Module:Wd's "raw" flag, which for an entity-id-valued statement returns -- the plain id instead of a formatted link/label. local function getWdRawPropertyId(property) if not wdOK or not Wd or not Wd._property then return nil end local ok, result = pcall(Wd._property, {"raw", "best", property}) if ok and result and type(result) == "string" and result:match("^Q%d+$") then return result end return nil end -- Raw QIDs of EVERY value of an entity-valued property on a FOREIGN -- Wikidata item (`eid`), not the current page's — e.g. the leader's own -- P39 ("position held") statements, which a real politician very often has -- several of at once (a parliamentary seat, a party leadership, AND a head- -- of-government office can all be simultaneously "current" -- see -- getWdPositionTitle below for why that matters). Uses Module:Wd's PLURAL -- "properties" command (not "property"), which -- unlike the singular -- command -- does not stop at a single "best" value, so every matching -- claim is returned, joined together; this extracts each "Q..." token from -- that joined string rather than relying on a specific separator, since -- Wd's separator choice isn't part of its documented contract. `eid` is -- passed the same way Module:Wd's own code does internally -- (`p._property{..., [p.args.eid] = id}`). `qualifiers` is an optional -- table of {qualifierPropertyId = requiredValue} pairs -- Module:Wd's -- claimCommand treats any hash key matching "P%d+" as a qualifier filter -- (see its `qualifierIDsAndValues`/`qualifierMatches` logic), letting a -- caller narrow the claims returned to just those with a matching -- qualifier (see getWdPositionTitle below, which uses this for P1001 -- "applies to jurisdiction"). Returns an empty table on any failure. local function getWdRawForeignPropertyIds(eid, property, extraFlags, qualifiers) if not wdOK or not Wd or not Wd._properties or not eid then return {} end local callArgs = {} for _, f in ipairs(extraFlags or {}) do table.insert(callArgs, f) end table.insert(callArgs, "raw") table.insert(callArgs, property) callArgs[Wd.args and Wd.args.eid or "eid"] = eid for qid, value in pairs(qualifiers or {}) do callArgs[qid] = value end local ok, result = pcall(Wd._properties, callArgs) if not ok or not result or type(result) ~= "string" or result == "" then return {} end local ids = {} for id in result:gmatch("Q%d+") do table.insert(ids, id) end return ids end -- The QID of the entity connected to the CURRENT page (e.g. the country the -- article is about), used to disambiguate a multi-realm head of state's P39 -- statements (see getWdPositionTitle below). Returns nil when the current -- page has no connected Wikidata item. local function getCurrentCountryQid() local ok, id = pcall(mw.wikibase.getEntityIdForCurrentPage) if ok and id and id ~= "" then return id end return nil end -- Manx country-specific office titles on gv.wiki follow the pattern -- "<role> y <country>" ("y" = "of the") -- e.g. "Monark y Reeriaght -- Unnaneysit", "Ard-vinishter y Reeriaght Unnaneysit". There is no separate -- short-form property reliably populated on Wikidata for these items, so -- rather than depending on one, this detaches the "y <country>" tail -- itself and keeps just the leading role word(s) -- "Monark", inserted as -- the display text of a link that still points at the full title. A title -- with no " y " in it (already just a bare role name) is returned as-is. local function shortManxForm(title) if not title or title == "" then return title end local short = title:match("^(.-)%sy%s") if short and short ~= "" then return short end return title end -- Capitalizes the first letter the way the wiki itself would (respecting -- Manx-specific case folding, e.g. digraphs like "çh"), via the content -- language object's own ucfirst -- NOT a plain Lua upper() on byte 1, which -- would mangle multi-byte UTF-8 and wouldn't match gv.wiki's own title- -- capitalization rules. Needed because a raw Wikidata LABEL (unlike a real -- page title/sitelink) is conventionally stored all-lowercase (e.g. -- "monark"), but both a link's display text and a red-linked target should -- read the way an actual Manx Wikipedia article title would. local function wikiUcfirst(text) if not text or text == "" then return text end local ok, result = pcall(function() return mw.language.getContentLanguage():ucfirst(text) end) if ok and result and result ~= "" then return result end return text end -- Given a Wikidata item ID for a specific office/position (e.g. "King of -- the United Kingdom"), build a wikilink using the gv sitelink (when one -- exists) or, failing that, a verified gv LABEL as the link target -- ALWAYS -- as a real wikilink, even when that means a redlink inviting the article to -- be written (per explicit instruction: an unlinked office title is -- indistinguishable from an unsourced one, same reasoning as ensureLinked() -- above for leader names). The display text has the "y <country>" tail -- detached (see shortManxForm above), e.g. "[[Monark y Reeriaght -- Unnaneysit|Monark]]". Never uses mw.wikibase.label's English-fallback- -- prone version -- same leak this module already had to fix once for -- property labels. Returns nil only when NEITHER a sitelink nor a gv label -- exists at all, so callers fall through to the generic hardcoded Manx text. local function getWdItemManxLink(qid) if not qid then return nil end local okSite, sitelinkTitle = pcall(mw.wikibase.sitelink, qid) if not okSite then sitelinkTitle = nil end local title = (sitelinkTitle and sitelinkTitle ~= "") and sitelinkTitle or nil if not title then local okLabel, gvLabel = pcall(mw.wikibase.getLabelByLang, qid, "gv") if okLabel and gvLabel and gvLabel ~= "" then -- Wikidata labels are conventionally lowercase; capitalize so the -- redlink reads (and will resolve/redirect) like a real title. title = wikiUcfirst(gvLabel) end end if not title then return nil end local short = shortManxForm(title) if short ~= title then return "[[" .. title .. "|" .. short .. "]]" end return "[[" .. title .. "]]" end -- Wikidata has two properties made specifically to solve this exact office- -- title problem, set directly on the COUNTRY's own item rather than on the -- office-holder: P1906 "office held by head of state" and P1313 "office held -- by head of government" (these two IDs are easy to transpose -- there's no -- mnemonic pattern distinguishing them -- and an earlier version of this -- module had them backwards; double-checked against wikidata.org's own -- property pages before fixing). Their value is the generic OFFICE item itself -- (e.g. "Chief Minister of the Isle of Man" / "Ard-hirveishagh Vannin") -- -- not a person, and not one of several roles a particular office-holder -- happens to hold right now. When a country's item has this property set, -- it sidesteps the multi-role-P39 ambiguity entirely (see getWdPositionTitle -- below): there's no need to guess which of a person's several concurrent -- "position held" statements is the right one, because Wikidata already -- names the office directly. Tried FIRST, before the person-chain fallback. local function getWdOfficeItemTitle(officeProperty) local officeQid = getWdRawPropertyId(officeProperty) if not officeQid then return nil end return getWdItemManxLink(officeQid) end -- FALLBACK ONLY (see getWdOfficeItemTitle above, tried first): the leader's -- own specific office title (e.g. "Monark y Reeriaght Unnaneysit" / -- "Ard-vinishter y Reeriaght Unnaneysit"), NOT the generic property -- description ("head of state"/"kione steat"), derived by chaining through -- the CURRENT OFFICE-HOLDER instead of a dedicated country-level property -- -- used only for a country whose Wikidata item doesn't have P1313/P1906 set. -- Wikidata attaches the country-specific title to the position-HOLDER's own -- "position held" (P39) statement, not to the country's P35/P6 statement — -- so this chains through the person: P35/P6 -> person's raw QID -> that -- person's current P39 value -> a Manx link/label for it. -- -- A head of state/government very often holds MULTIPLE simultaneous "current" -- P39 positions -- not just the classic shared-monarch case ("King of the -- United Kingdom", "King of Canada", "King of Australia", ... all current at -- once), but just as commonly a head of government who is ALSO, right now, a -- sitting member of their legislature AND the leader of their party. A brand -- new statement (e.g. someone who became PM only weeks ago) frequently has -- NO qualifier at all yet distinguishing "this is the state office" from -- "this is the party/parliamentary one" -- P1001 ("applies to jurisdiction") -- is the qualifier Wikidata uses for the shared-monarch case specifically, -- but isn't reliably present on every fresh statement, so it can't be -- trusted as the only signal. -- -- So rather than committing to a single "best" P39 value (which could just -- as easily be "Member of Parliament for ..." or "Leader of the ... Party" -- as the actual head-of-government office), this collects EVERY current P39 -- candidate -- ones matching a P1001 filter for this article's own country -- first (when the data has that qualifier, which correctly resolves a -- shared monarch to the right realm), then every other current candidate -- -- and tries each in turn, using the FIRST one that actually resolves to a -- real Manx sitelink or label via getWdItemManxLink. In practice an -- ancillary role (a parliamentary seat, a party leadership) is very unlikely -- to have a dedicated gv.wiki article of its own, while the formal head-of- -- state/government office is exactly the kind of article gv.wiki is likely -- to have -- so this reliably lands on the right one without needing -- Wikidata's qualifiers to be perfectly curated. -- -- Returns nil only when NONE of the current P39 candidates resolves to -- anything on gv.wiki (or Module:Wd is unavailable, or there's no current -- P39 at all), so callers fall back to the property-label / hardcoded rungs -- below. local function getWdPositionTitle(headProperty) local personQid = getWdRawPropertyId(headProperty) if not personQid then return nil end local countryQid = getCurrentCountryQid() local candidates = {} if countryQid then for _, id in ipairs(getWdRawForeignPropertyIds(personQid, "P39", {"current"}, {["P1001"] = countryQid})) do table.insert(candidates, id) end end for _, id in ipairs(getWdRawForeignPropertyIds(personQid, "P39", {"current"})) do table.insert(candidates, id) end local tried = {} for _, qid in ipairs(candidates) do if not tried[qid] then tried[qid] = true local link = getWdItemManxLink(qid) if link then return link end end end return nil end -- Row templates. Every row in this table is a plain 2-cell -- `<th>label</th><td>value</td>` row — exactly the grid every OTHER -- submodule in this system uses (Module:Kishtey fys çheer/çhengaghyn, -- /balley, /bratteeyn). The old HTML template used a 3-column grid instead -- (a narrow indent-spacer <td>, a label <td>, a value <td>, with -- colspan="2"/colspan="3" on label-only/header rows) — mixing that 3-column -- convention into a 2-column table was the actual cause of the reported -- "bunching"/"enormous gap" distortion: rows with different physical cell -- counts in the same table force the browser to reconcile column widths -- unpredictably. Sub-items (individual leaders/houses/founding events under -- one shared label) are distinguished with a "•" bullet + reduced font -- weight on the label cell instead of a separate spacer column — matching -- how English Wikipedia's infobox marks up a list of leaders under one -- "Leader" heading. local ROW = '<tr%s><th style="vertical-align:top; white-space:nowrap; text-align:left; font-weight:bold;">%s</th><td style="vertical-align:top;">%s</td></tr>' local SUBROW = '<tr%s><th style="vertical-align:top; white-space:nowrap; text-align:left; font-weight:normal; padding-left:0.5em;">•&nbsp;%s</th><td style="vertical-align:top;">%s</td></tr>' local HEADER = '<tr class="mergedtoprow"><th colspan="2" style="text-align:left;">%s</th></tr>' -- Builds a `class="..."` attribute (or an empty string), for the -- mergedrow/mergedbottomrow/mergedtoprow classes the old template uses to -- remove the double border between a header/label row and the indented -- sub-rows that visually belong under it. local function trClass(name) if name and name ~= "" then return ' class="' .. name .. '"' end return "" end -- Formats a run of bullet-prefixed sub-rows (leader pairs, house names, -- establishment events, ...) with the old template's merged-border -- convention: every row but the last is "mergedrow", the last is -- "mergedbottomrow" — so the whole run reads as one visually joined block -- under its header/label row. local function appendIndentRun(rows, items) for idx, item in ipairs(items) do local class = (idx == #items) and "mergedbottomrow" or "mergedrow" table.insert(rows, string.format(SUBROW, trClass(class), item[1], item[2])) end end -- Same divider the dispatcher module (Module:Kishtey fys çheer) uses BETWEEN -- whole submodules (see its own `dividerLine`/`appendModule`). Reused here, -- identically, to separate this module's own three internal sections -- (leaders/government, legislature, founding) the same visual way -- a -- divider is only inserted BETWEEN two sections that both actually produced -- rows, never before the first section or after the last, and never next to -- an empty/suppressed section (mirrors appendModule's own conditional). local dividerLine = '<tr><td colspan="2" style="border-top:1px solid #a2a9b1; padding:0; height:0px;"></td></tr>' local function appendSection(rows, sectionRows) if sectionRows and #sectionRows > 0 then if #rows > 0 then table.insert(rows, dividerLine) end for _, row in ipairs(sectionRows) do table.insert(rows, row) end end end function p.main(frame, args) -- Fallback verification to catch argument slots accurately if frame context shifts if not args then args = frame frame = mw.getCurrentFrame() end local rows = {} local govRows = {} local quaiylRows = {} local foundingRows = {} ---------------------------------------------------------------- -- 1-2. REILTYS (Government type) + FIR HOSHEE / TOSHEE (Leaders: -- head of state / head of government / etc.) -- `enmysN_fer-toshee` / `ennymN_fer-toshee` are the old, gendered -- param names, kept for backward compatibility with existing -- articles. `enmys_toshiaghN` / `ennym_toshiaghN` are the -- gender-neutral synonyms going forward ("toshiagh" = leader); -- either spelling works, and the new one takes priority when both -- are supplied for the same slot. Leaders are computed BEFORE the -- government-type row is emitted so that row can carry the right -- merged-border class when leader rows are going to follow it. ---------------------------------------------------------------- local govTypeRaw = getManual(args, {"sorçh_reiltys", "government_type"}) local govRef = getManual(args, {"imraa_reiltys"}) local govNote = getManual(args, {"noteyn_reiltys"}) if not govTypeRaw then -- Wikidata fallback via Module:Wd: basic form of government (P122), -- e.g. "unitary state, parliamentary system, constitutional -- monarchy" -- joins every value Wikidata records rather than just -- one, since this is normally split across several statements. -- Skipped entirely when the field was explicitly suppressed -- (`|sorçh_reiltys=none`), same as every other Wikidata-fallback -- field in this module. govTypeRaw = getWdProperties("P122", {"linked"}) end local govShown = govTypeRaw and not isNone(govTypeRaw) local leaderPairs = {} local manualLeaderGiven = false for i = 1, 5 do local title = getManual(args, {"enmys_toshiagh" .. i, "enmys" .. i .. "_fer-toshee"}) local name = getManual(args, {"ennym_toshiagh" .. i, "ennym" .. i .. "_fer-toshee"}) if title or name then manualLeaderGiven = true if not isNone(name) then table.insert(leaderPairs, {title = title or "", name = name or ""}) end end end local leaderRef = getManual(args, {"imraa_toshiagh", "imraa_fer-toshee"}) local leaderNote = getManual(args, {"noteyn_toshiagh", "noteyn_fer-toshee"}) local leadersSuppressed = isNone(getManual(args, {"fir_hoshee", "toshiaghyn"})) if not manualLeaderGiven and not leadersSuppressed then -- Wikidata fallback via Module:Wd: head of state (P35) / head of -- government (P6). Names are ALWAYS forced into a link (a redlink -- when gv.wiki has no article for that person yet) via -- ensureLinked, since an unlinked plain name is easy to mistake for -- a manual/unsourced value and gives editors nothing to click -- through to create the article. Titles try, in order: a manual -- override, the leader's own country-specific office (e.g. "Monark -- y Reeriaght Unnaneysit"), the Wikidata property's own label, then -- a hardcoded Manx fallback. local hos = ensureLinked(getWdProperty("P35", {"linked"})) local hog = ensureLinked(getWdProperty("P6", {"linked"})) if hos then local hosTitle = getManual(args, {"sorçh_kione_steat"}) or getWdOfficeItemTitle("P1906") -- "office held by head of state" -- set directly on the country, no person-level ambiguity or getWdPositionTitle("P35") or getWikidataPropertyLabel("P35") or "Kione steat" table.insert(leaderPairs, {title = hosTitle, name = hos}) end if hog then local hogTitle = getManual(args, {"sorçh_kione_reiltys"}) or getWdOfficeItemTitle("P1313") -- "office held by head of government" -- same reasoning as P1906 above or getWdPositionTitle("P6") or getWikidataPropertyLabel("P6") or "Kione reiltys" table.insert(leaderPairs, {title = hogTitle, name = hog}) end end if govShown then local govClass = (#leaderPairs > 0) and "mergedtoprow" or "" table.insert(govRows, string.format(ROW, trClass(govClass), "[[Reiltys]]", applyRefNote(govTypeRaw, govRef, govNote, frame))) elseif #leaderPairs > 0 then table.insert(govRows, string.format(HEADER, "[[Reiltys]]")) end if #leaderPairs > 0 then -- The shared manual ref/note for the whole leaders block is -- attached to the last row, same convention as a single footnote -- covering a list. (A Wikidata-sourced name already carries its own -- auto-built citation from getWdProperty.) local last = leaderPairs[#leaderPairs] last.name = applyRefNote(last.name, leaderRef, leaderNote, frame) local items = {} for _, leader in ipairs(leaderPairs) do table.insert(items, {leader.title, leader.name}) end appendIndentRun(govRows, items) end ---------------------------------------------------------------- -- 3. QUAIYL / ÇHIONNAL (Legislature) -- `çhionnal` is a synonym for `quaiyl`; `thie_heose` / `thie_heese` -- are synonyms for `quaiyl_syrjey` / `quaiyl_s'inshley` (upper / -- lower house). New spellings take priority when both are given. ---------------------------------------------------------------- local quaiyl = getManual(args, {"çhionnal", "quaiyl"}) local quaiylSyrjey = getManual(args, {"thie_heose", "quaiyl_syrjey"}) local quaiylInshley = getManual(args, {"thie_heese", "quaiyl_s'inshley", "quaiyl_sinshley"}) local quaiylRef = getManual(args, {"imraa_çhionnal", "imraa_quaiyl"}) local quaiylNote = getManual(args, {"noteyn_çhionnal", "noteyn_quaiyl"}) if not quaiyl and not quaiylSyrjey and not quaiylInshley then -- "short" asks Module:Wd for the item's short name (Wikidata -- P1813) first, e.g. "Parliament" instead of the full official -- "Parliament of the United Kingdom of Great Britain and Northern -- Ireland" -- matching enwiki's own concise style. Falls back to -- the item's normal label when no short name is set. quaiyl = getWdProperty("P194", {"linked", "short"}) end if quaiyl and not isNone(quaiyl) then local houseItems = {} if quaiylSyrjey and not isNone(quaiylSyrjey) then table.insert(houseItems, {"[[Thie heose]]", quaiylSyrjey}) end if quaiylInshley and not isNone(quaiylInshley) then table.insert(houseItems, {"[[Thie heese]]", quaiylInshley}) end local quaiylClass = (#houseItems > 0) and "mergedtoprow" or "" table.insert(quaiylRows, string.format(ROW, trClass(quaiylClass), "[[Çhionnal slattyssagh]]", applyRefNote(quaiyl, quaiylRef, quaiylNote, frame))) appendIndentRun(quaiylRows, houseItems) end ---------------------------------------------------------------- -- 4. BUNNEEAGHT / KIONDEEAGHT (Founding / constitution) and -- historical establishment events — manual-only, ported -- directly from the old template's numbered slots (1-9). -- `kionedeeaght` is a synonym for `kiondeeaght` in the label/note -- param names. ---------------------------------------------------------------- local foundingLabel = getManual(args, {"sorçh_kionedeeaght", "sorçh_kiondeeaght"}) or "Bunneeaght" local foundingValue = getManual(args, {"bunnit"}) local foundingNote = getManual(args, {"note_kionedeeaght", "note_kiondeeaght"}) local foundingRef = getManual(args, {"imraa_kionedeeaght", "imraa_kiondeeaght"}) local establishmentRows = {} for i = 1, 9 do local event = getManual(args, {"taghyrt" .. i .. "_bunnit"}) local date = getManual(args, {"date" .. i .. "_bunnit"}) if event then table.insert(establishmentRows, {event, date or ""}) end end if foundingValue or #establishmentRows > 0 then if foundingValue and not isNone(foundingValue) then local foundingClass = (#establishmentRows > 0) and "mergedtoprow" or "" table.insert(foundingRows, string.format(ROW, trClass(foundingClass), "[[" .. foundingLabel .. "]]", applyRefNote(foundingValue, foundingRef, foundingNote, frame))) elseif #establishmentRows > 0 then table.insert(foundingRows, string.format(HEADER, "[[" .. foundingLabel .. "]]")) end appendIndentRun(foundingRows, establishmentRows) elseif not isNone(getManual(args, {"bunnit"})) then -- Wikidata fallback via Module:Wd: inception (P571) — only when the -- whole establishment block was left unset (not explicitly |bunnit=none). -- NOTE on date precision: Module:Wd's own time-value formatting (see -- Config:getValue's `datatype == 'time'` branch) already renders a -- FULL day-month-year date whenever the underlying Wikidata statement -- itself is stored at day precision -- there is no flag this call is -- missing, and no truncation happens on our side (confirmed by the -- test harness, which feeds a day-precision value straight through -- unchanged). When only a year is shown on a real article, that is -- because THAT COUNTRY's P571 statement on Wikidata itself is only -- recorded at year precision (very common for older founding dates) -- -- not a bug here. The manual |bunnit= override remains the fix for -- any article where the Wikidata precision isn't good enough. local inception = getWdProperty("P571") if inception then table.insert(foundingRows, string.format(ROW, "", "[[" .. foundingLabel .. "]]", applyRefNote(inception, foundingRef, foundingNote, frame))) end end appendSection(rows, govRows) appendSection(rows, quaiylRows) appendSection(rows, foundingRows) if #rows == 0 then return nil end return table.concat(rows) end return p pgg4980plbuk2nr1vv0akjnrqwvsn9g 392998 392997 2026-09-10T00:44:42Z MacTire02 219 ++ 392998 Scribunto text/plain local p = {} -- Module:Wd is gv.wiki's actual working Wikidata-fetch-and-cite module -- (confirmed by its localized /i18n submodule) — used instead of -- Module:WikidataIB, which has no working reference-building of its own. -- pcall so a wiki state where Wd (or its own Module:Wd/i18n) isn't set up -- degrades to "no Wikidata fallback" instead of breaking the infobox. local wdOK, Wd = pcall(require, "Module:Wd") -- Safely get manual parameters from priority list local function getManual(args, names) for _, name in ipairs(names) do local value = args[name] if value and mw.text.trim(value) ~= "" then return mw.text.trim(value) end end return nil end local function isNone(value) return value ~= nil and mw.text.trim(value):lower() == "none" end -- Append a manual reference (<ref>) and/or note ({{efn}}) to a value. This -- is the manual imraa_*/noteyn_* channel, same as Module:Kishtey fys -- çheer/çhengaghyn uses. It layers on top of a Wikidata-sourced value too -- (which already carries its own auto-built citation from getWdProperty -- below) in case an editor wants to add an extra citation or clarifying -- footnote of their own. local function applyRefNote(value, ref, note, frame) if not value then return value end if note and note ~= "" and frame then value = value .. frame:expandTemplate{ title = "efn", args = { note } } end if ref and ref ~= "" then value = value .. "<ref>" .. ref .. "</ref>" end return value end -- Fetch+format a single Wikidata property value via Module:Wd's "property" -- command, combined with its "reference" command so that, when the -- Wikidata statement itself carries references, Wd builds a real <ref> -- citation (Cite web / Cite Q) from them automatically — the same way -- gv.wiki's other Wd-based infoboxes already cite Wikidata data. `flags` -- is an optional array of extra Wd flags (e.g. {"linked"}). Returns nil -- when Wd isn't available, or the property has no value. local function getWdProperty(property, flags) if not wdOK or not Wd or not Wd._property then return nil end local callArgs = {} for _, f in ipairs(flags or {}) do table.insert(callArgs, f) end table.insert(callArgs, "reference") -- request an auto-built citation alongside the value table.insert(callArgs, "best") -- single best-ranked value, mirroring the old template's behaviour table.insert(callArgs, property) local ok, result = pcall(Wd._property, callArgs) if ok and result and result ~= "" then return result end return nil end -- Same as getWdProperty, but via Module:Wd's plural "properties" command, -- which joins EVERY matching value together (comma-separated by default) -- instead of just the single best one. Used for government type (P122 -- "basic form of government"), which Wikidata typically records as several -- separate statements on one country (e.g. "unitary state", "parliamentary -- system", "constitutional monarchy") rather than one combined phrase. local function getWdProperties(property, flags) if not wdOK or not Wd or not Wd._properties then return nil end local callArgs = {} for _, f in ipairs(flags or {}) do table.insert(callArgs, f) end table.insert(callArgs, "reference") table.insert(callArgs, property) local ok, result = pcall(Wd._properties, callArgs) if ok and result and result ~= "" then return result end return nil end -- Module:Wd's "linked" flag only produces a wikilink when the entity -- already has a gv sitelink (Config:getLabel returns the bare label, -- un-bracketed, otherwise — see Module:Wd source). For a leader whose -- article doesn't exist on gv.wiki yet, that means no link at all. Since -- an editor should still be able to click through (or see a redlink -- inviting the article to be written), this forces a wikilink around the -- label text when Wd didn't already supply one — without touching a -- trailing auto-built <ref>...</ref> citation, which Wd appends directly -- after the label/link text. local function ensureLinked(value) if not value or value == "" then return value end local label, refSuffix = value:match("^(.-)(<ref.*)$") if not label then label = value refSuffix = "" end if label:find("%[%[") then return value -- already a real link via a gv sitelink end label = mw.text.trim(label) if label == "" then return value end return "[[" .. label .. "]]" .. refSuffix end -- Label of the Wikidata PROPERTY itself (e.g. P35 -> "head of state"), used -- as a Wikidata-sourced fallback for a leader's title when no manual -- title/override is supplied. Deliberately uses getLabelByLang(property, -- "gv") rather than mw.wikibase.label(property): plain label() follows -- Wikidata's language-fallback chain and will happily hand back the -- English label when no Manx one exists (which is the common case for -- properties on Wikidata) — silently leaking English text like "head of -- state" into the Manx infobox. getLabelByLang only returns a value when a -- Manx label genuinely exists, so an untranslated property correctly falls -- through to the hardcoded Manx text below instead. local function getWikidataPropertyLabel(property) local ok, label = pcall(mw.wikibase.getLabelByLang, property, "gv") if ok and label and label ~= "" then return label end return nil end -- Raw QID (no linking/label formatting) of an entity-valued property on the -- CURRENT page's Wikidata item — e.g. P35's value (the head of state person) -- as a bare "Q..." id, so it can be used as the `eid` for a follow-up -- lookup on THAT person's own item (see getWdPositionTitle below). Uses -- Module:Wd's "raw" flag, which for an entity-id-valued statement returns -- the plain id instead of a formatted link/label. local function getWdRawPropertyId(property) if not wdOK or not Wd or not Wd._property then return nil end local ok, result = pcall(Wd._property, {"raw", "best", property}) if ok and result and type(result) == "string" and result:match("^Q%d+$") then return result end return nil end -- Raw QIDs of EVERY value of an entity-valued property on a FOREIGN -- Wikidata item (`eid`), not the current page's — e.g. the leader's own -- P39 ("position held") statements, which a real politician very often has -- several of at once (a parliamentary seat, a party leadership, AND a head- -- of-government office can all be simultaneously "current" -- see -- getWdPositionTitle below for why that matters). Uses Module:Wd's PLURAL -- "properties" command (not "property"), which -- unlike the singular -- command -- does not stop at a single "best" value, so every matching -- claim is returned, joined together; this extracts each "Q..." token from -- that joined string rather than relying on a specific separator, since -- Wd's separator choice isn't part of its documented contract. `eid` is -- passed the same way Module:Wd's own code does internally -- (`p._property{..., [p.args.eid] = id}`). `qualifiers` is an optional -- table of {qualifierPropertyId = requiredValue} pairs -- Module:Wd's -- claimCommand treats any hash key matching "P%d+" as a qualifier filter -- (see its `qualifierIDsAndValues`/`qualifierMatches` logic), letting a -- caller narrow the claims returned to just those with a matching -- qualifier (see getWdPositionTitle below, which uses this for P1001 -- "applies to jurisdiction"). Returns an empty table on any failure. local function getWdRawForeignPropertyIds(eid, property, extraFlags, qualifiers) if not wdOK or not Wd or not Wd._properties or not eid then return {} end local callArgs = {} for _, f in ipairs(extraFlags or {}) do table.insert(callArgs, f) end table.insert(callArgs, "raw") table.insert(callArgs, property) callArgs[Wd.args and Wd.args.eid or "eid"] = eid for qid, value in pairs(qualifiers or {}) do callArgs[qid] = value end local ok, result = pcall(Wd._properties, callArgs) if not ok or not result or type(result) ~= "string" or result == "" then return {} end local ids = {} for id in result:gmatch("Q%d+") do table.insert(ids, id) end return ids end -- The QID of the entity connected to the CURRENT page (e.g. the country the -- article is about), used to disambiguate a multi-realm head of state's P39 -- statements (see getWdPositionTitle below). Returns nil when the current -- page has no connected Wikidata item. local function getCurrentCountryQid() local ok, id = pcall(mw.wikibase.getEntityIdForCurrentPage) if ok and id and id ~= "" then return id end return nil end -- Manx country-specific office titles on gv.wiki follow one of two -- constructions. The more complex one links the role to a multi-word country -- name via "y" ("of the") -- e.g. "Monark y Reeriaght Unnaneysit", "Ard- -- vinishter y Reeriaght Unnaneysit" -- so the first rung below detaches -- everything from the first " y " onward, keeping just the leading role -- word(s) ("Monark"). The simpler construction attaches a short/single-word -- country name directly, with no "y" connector at all -- e.g. "Ard- -- hirveishagh Vannin" (Chief Minister of Mann), "Çhiarn Vannin" (Lord of -- Mann), "Ard-shirveishagh Nalbin" (First Minister of Scotland) -- often in -- a mutated genitive form ("Mannin" -> "Vannin") that isn't practical to -- predict mechanically. Rather than trying to model Manx initial mutation, -- the second rung below just detaches everything from the LAST remaining -- space onward, keeping the role portion only -- "Ard-hirveishagh Vannin" -> -- "Ard-hirveishagh". There is no separate short-form property reliably -- populated on Wikidata for these items, so both rungs work purely -- mechanically off the title text itself, used as the display text of a -- link that still points at the full title. A title with no space at all -- (already just a bare role name, e.g. "Ard-whaiyl") is returned as-is. -- -- Exceptions: full titles that should always be used as-is, unshortened, -- even though they'd otherwise match one of the rungs above -- e.g. "Çhiarn -- Vannin" (Lord of Mann), where the mechanical last-space split would -- technically produce "Çhiarn" but that's not how this specific title -- should read. Checked before either rung is tried. local shortFormExceptions = { ["Çhiarn Vannin"] = true, } local function shortManxForm(title) if not title or title == "" then return title end if shortFormExceptions[title] then return title end local short = title:match("^(.-)%sy%s") if short and short ~= "" then return short end short = title:match("^(.+)%s%S+$") if short and short ~= "" then return short end return title end -- Capitalizes the first letter the way the wiki itself would (respecting -- Manx-specific case folding, e.g. digraphs like "çh"), via the content -- language object's own ucfirst -- NOT a plain Lua upper() on byte 1, which -- would mangle multi-byte UTF-8 and wouldn't match gv.wiki's own title- -- capitalization rules. Needed because a raw Wikidata LABEL (unlike a real -- page title/sitelink) is conventionally stored all-lowercase (e.g. -- "monark"), but both a link's display text and a red-linked target should -- read the way an actual Manx Wikipedia article title would. local function wikiUcfirst(text) if not text or text == "" then return text end local ok, result = pcall(function() return mw.language.getContentLanguage():ucfirst(text) end) if ok and result and result ~= "" then return result end return text end -- Given a Wikidata item ID for a specific office/position (e.g. "King of -- the United Kingdom"), build a wikilink using the gv sitelink (when one -- exists) or, failing that, a verified gv LABEL as the link target -- ALWAYS -- as a real wikilink, even when that means a redlink inviting the article to -- be written (per explicit instruction: an unlinked office title is -- indistinguishable from an unsourced one, same reasoning as ensureLinked() -- above for leader names). The display text has the "y <country>" tail -- detached (see shortManxForm above), e.g. "[[Monark y Reeriaght -- Unnaneysit|Monark]]". Never uses mw.wikibase.label's English-fallback- -- prone version -- same leak this module already had to fix once for -- property labels. Returns nil only when NEITHER a sitelink nor a gv label -- exists at all, so callers fall through to the generic hardcoded Manx text. local function getWdItemManxLink(qid) if not qid then return nil end local okSite, sitelinkTitle = pcall(mw.wikibase.sitelink, qid) if not okSite then sitelinkTitle = nil end local title = (sitelinkTitle and sitelinkTitle ~= "") and sitelinkTitle or nil if not title then local okLabel, gvLabel = pcall(mw.wikibase.getLabelByLang, qid, "gv") if okLabel and gvLabel and gvLabel ~= "" then -- Wikidata labels are conventionally lowercase; capitalize so the -- redlink reads (and will resolve/redirect) like a real title. title = wikiUcfirst(gvLabel) end end if not title then return nil end local short = shortManxForm(title) if short ~= title then return "[[" .. title .. "|" .. short .. "]]" end return "[[" .. title .. "]]" end -- Wikidata has two properties made specifically to solve this exact office- -- title problem, set directly on the COUNTRY's own item rather than on the -- office-holder: P1906 "office held by head of state" and P1313 "office held -- by head of government" (these two IDs are easy to transpose -- there's no -- mnemonic pattern distinguishing them -- and an earlier version of this -- module had them backwards; double-checked against wikidata.org's own -- property pages before fixing). Their value is the generic OFFICE item itself -- (e.g. "Chief Minister of the Isle of Man" / "Ard-hirveishagh Vannin") -- -- not a person, and not one of several roles a particular office-holder -- happens to hold right now. When a country's item has this property set, -- it sidesteps the multi-role-P39 ambiguity entirely (see getWdPositionTitle -- below): there's no need to guess which of a person's several concurrent -- "position held" statements is the right one, because Wikidata already -- names the office directly. Tried FIRST, before the person-chain fallback. local function getWdOfficeItemTitle(officeProperty) local officeQid = getWdRawPropertyId(officeProperty) if not officeQid then return nil end return getWdItemManxLink(officeQid) end -- FALLBACK ONLY (see getWdOfficeItemTitle above, tried first): the leader's -- own specific office title (e.g. "Monark y Reeriaght Unnaneysit" / -- "Ard-vinishter y Reeriaght Unnaneysit"), NOT the generic property -- description ("head of state"/"kione steat"), derived by chaining through -- the CURRENT OFFICE-HOLDER instead of a dedicated country-level property -- -- used only for a country whose Wikidata item doesn't have P1313/P1906 set. -- Wikidata attaches the country-specific title to the position-HOLDER's own -- "position held" (P39) statement, not to the country's P35/P6 statement — -- so this chains through the person: P35/P6 -> person's raw QID -> that -- person's current P39 value -> a Manx link/label for it. -- -- A head of state/government very often holds MULTIPLE simultaneous "current" -- P39 positions -- not just the classic shared-monarch case ("King of the -- United Kingdom", "King of Canada", "King of Australia", ... all current at -- once), but just as commonly a head of government who is ALSO, right now, a -- sitting member of their legislature AND the leader of their party. A brand -- new statement (e.g. someone who became PM only weeks ago) frequently has -- NO qualifier at all yet distinguishing "this is the state office" from -- "this is the party/parliamentary one" -- P1001 ("applies to jurisdiction") -- is the qualifier Wikidata uses for the shared-monarch case specifically, -- but isn't reliably present on every fresh statement, so it can't be -- trusted as the only signal. -- -- So rather than committing to a single "best" P39 value (which could just -- as easily be "Member of Parliament for ..." or "Leader of the ... Party" -- as the actual head-of-government office), this collects EVERY current P39 -- candidate -- ones matching a P1001 filter for this article's own country -- first (when the data has that qualifier, which correctly resolves a -- shared monarch to the right realm), then every other current candidate -- -- and tries each in turn, using the FIRST one that actually resolves to a -- real Manx sitelink or label via getWdItemManxLink. In practice an -- ancillary role (a parliamentary seat, a party leadership) is very unlikely -- to have a dedicated gv.wiki article of its own, while the formal head-of- -- state/government office is exactly the kind of article gv.wiki is likely -- to have -- so this reliably lands on the right one without needing -- Wikidata's qualifiers to be perfectly curated. -- -- Returns nil only when NONE of the current P39 candidates resolves to -- anything on gv.wiki (or Module:Wd is unavailable, or there's no current -- P39 at all), so callers fall back to the property-label / hardcoded rungs -- below. local function getWdPositionTitle(headProperty) local personQid = getWdRawPropertyId(headProperty) if not personQid then return nil end local countryQid = getCurrentCountryQid() local candidates = {} if countryQid then for _, id in ipairs(getWdRawForeignPropertyIds(personQid, "P39", {"current"}, {["P1001"] = countryQid})) do table.insert(candidates, id) end end for _, id in ipairs(getWdRawForeignPropertyIds(personQid, "P39", {"current"})) do table.insert(candidates, id) end local tried = {} for _, qid in ipairs(candidates) do if not tried[qid] then tried[qid] = true local link = getWdItemManxLink(qid) if link then return link end end end return nil end -- Row templates. Every row in this table is a plain 2-cell -- `<th>label</th><td>value</td>` row — exactly the grid every OTHER -- submodule in this system uses (Module:Kishtey fys çheer/çhengaghyn, -- /balley, /bratteeyn). The old HTML template used a 3-column grid instead -- (a narrow indent-spacer <td>, a label <td>, a value <td>, with -- colspan="2"/colspan="3" on label-only/header rows) — mixing that 3-column -- convention into a 2-column table was the actual cause of the reported -- "bunching"/"enormous gap" distortion: rows with different physical cell -- counts in the same table force the browser to reconcile column widths -- unpredictably. Sub-items (individual leaders/houses/founding events under -- one shared label) are distinguished with a "•" bullet + reduced font -- weight on the label cell instead of a separate spacer column — matching -- how English Wikipedia's infobox marks up a list of leaders under one -- "Leader" heading. local ROW = '<tr%s><th style="vertical-align:top; white-space:nowrap; text-align:left; font-weight:bold;">%s</th><td style="vertical-align:top;">%s</td></tr>' local SUBROW = '<tr%s><th style="vertical-align:top; white-space:nowrap; text-align:left; font-weight:normal; padding-left:0.5em;">•&nbsp;%s</th><td style="vertical-align:top;">%s</td></tr>' local HEADER = '<tr class="mergedtoprow"><th colspan="2" style="text-align:left;">%s</th></tr>' -- Builds a `class="..."` attribute (or an empty string), for the -- mergedrow/mergedbottomrow/mergedtoprow classes the old template uses to -- remove the double border between a header/label row and the indented -- sub-rows that visually belong under it. local function trClass(name) if name and name ~= "" then return ' class="' .. name .. '"' end return "" end -- Formats a run of bullet-prefixed sub-rows (leader pairs, house names, -- establishment events, ...) with the old template's merged-border -- convention: every row but the last is "mergedrow", the last is -- "mergedbottomrow" — so the whole run reads as one visually joined block -- under its header/label row. local function appendIndentRun(rows, items) for idx, item in ipairs(items) do local class = (idx == #items) and "mergedbottomrow" or "mergedrow" table.insert(rows, string.format(SUBROW, trClass(class), item[1], item[2])) end end -- Same divider the dispatcher module (Module:Kishtey fys çheer) uses BETWEEN -- whole submodules (see its own `dividerLine`/`appendModule`). Reused here, -- identically, to separate this module's own three internal sections -- (leaders/government, legislature, founding) the same visual way -- a -- divider is only inserted BETWEEN two sections that both actually produced -- rows, never before the first section or after the last, and never next to -- an empty/suppressed section (mirrors appendModule's own conditional). local dividerLine = '<tr><td colspan="2" style="border-top:1px solid #a2a9b1; padding:0; height:0px;"></td></tr>' local function appendSection(rows, sectionRows) if sectionRows and #sectionRows > 0 then if #rows > 0 then table.insert(rows, dividerLine) end for _, row in ipairs(sectionRows) do table.insert(rows, row) end end end function p.main(frame, args) -- Fallback verification to catch argument slots accurately if frame context shifts if not args then args = frame frame = mw.getCurrentFrame() end local rows = {} local govRows = {} local quaiylRows = {} local foundingRows = {} ---------------------------------------------------------------- -- 1-2. REILTYS (Government type) + FIR HOSHEE / TOSHEE (Leaders: -- head of state / head of government / etc.) -- `enmysN_fer-toshee` / `ennymN_fer-toshee` are the old, gendered -- param names, kept for backward compatibility with existing -- articles. `enmys_toshiaghN` / `ennym_toshiaghN` are the -- gender-neutral synonyms going forward ("toshiagh" = leader); -- either spelling works, and the new one takes priority when both -- are supplied for the same slot. Leaders are computed BEFORE the -- government-type row is emitted so that row can carry the right -- merged-border class when leader rows are going to follow it. ---------------------------------------------------------------- local govTypeRaw = getManual(args, {"sorçh_reiltys", "government_type"}) local govRef = getManual(args, {"imraa_reiltys"}) local govNote = getManual(args, {"noteyn_reiltys"}) if not govTypeRaw then -- Wikidata fallback via Module:Wd: basic form of government (P122), -- e.g. "unitary state, parliamentary system, constitutional -- monarchy" -- joins every value Wikidata records rather than just -- one, since this is normally split across several statements. -- Skipped entirely when the field was explicitly suppressed -- (`|sorçh_reiltys=none`), same as every other Wikidata-fallback -- field in this module. govTypeRaw = getWdProperties("P122", {"linked"}) end local govShown = govTypeRaw and not isNone(govTypeRaw) local leaderPairs = {} local manualLeaderGiven = false for i = 1, 5 do local title = getManual(args, {"enmys_toshiagh" .. i, "enmys" .. i .. "_fer-toshee"}) local name = getManual(args, {"ennym_toshiagh" .. i, "ennym" .. i .. "_fer-toshee"}) if title or name then manualLeaderGiven = true if not isNone(name) then table.insert(leaderPairs, {title = title or "", name = name or ""}) end end end local leaderRef = getManual(args, {"imraa_toshiagh", "imraa_fer-toshee"}) local leaderNote = getManual(args, {"noteyn_toshiagh", "noteyn_fer-toshee"}) local leadersSuppressed = isNone(getManual(args, {"fir_hoshee", "toshiaghyn"})) if not manualLeaderGiven and not leadersSuppressed then -- Wikidata fallback via Module:Wd: head of state (P35) / head of -- government (P6). Names are ALWAYS forced into a link (a redlink -- when gv.wiki has no article for that person yet) via -- ensureLinked, since an unlinked plain name is easy to mistake for -- a manual/unsourced value and gives editors nothing to click -- through to create the article. Titles try, in order: a manual -- override, the leader's own country-specific office (e.g. "Monark -- y Reeriaght Unnaneysit"), the Wikidata property's own label, then -- a hardcoded Manx fallback. local hos = ensureLinked(getWdProperty("P35", {"linked"})) local hog = ensureLinked(getWdProperty("P6", {"linked"})) if hos then local hosTitle = getManual(args, {"sorçh_kione_steat"}) or getWdOfficeItemTitle("P1906") -- "office held by head of state" -- set directly on the country, no person-level ambiguity or getWdPositionTitle("P35") or getWikidataPropertyLabel("P35") or "Kione steat" table.insert(leaderPairs, {title = hosTitle, name = hos}) end if hog then local hogTitle = getManual(args, {"sorçh_kione_reiltys"}) or getWdOfficeItemTitle("P1313") -- "office held by head of government" -- same reasoning as P1906 above or getWdPositionTitle("P6") or getWikidataPropertyLabel("P6") or "Kione reiltys" table.insert(leaderPairs, {title = hogTitle, name = hog}) end end if govShown then local govClass = (#leaderPairs > 0) and "mergedtoprow" or "" table.insert(govRows, string.format(ROW, trClass(govClass), "[[Reiltys]]", applyRefNote(govTypeRaw, govRef, govNote, frame))) elseif #leaderPairs > 0 then table.insert(govRows, string.format(HEADER, "[[Reiltys]]")) end if #leaderPairs > 0 then -- The shared manual ref/note for the whole leaders block is -- attached to the last row, same convention as a single footnote -- covering a list. (A Wikidata-sourced name already carries its own -- auto-built citation from getWdProperty.) local last = leaderPairs[#leaderPairs] last.name = applyRefNote(last.name, leaderRef, leaderNote, frame) local items = {} for _, leader in ipairs(leaderPairs) do table.insert(items, {leader.title, leader.name}) end appendIndentRun(govRows, items) end ---------------------------------------------------------------- -- 3. QUAIYL / ÇHIONNAL (Legislature) -- `çhionnal` is a synonym for `quaiyl`; `thie_heose` / `thie_heese` -- are synonyms for `quaiyl_syrjey` / `quaiyl_s'inshley` (upper / -- lower house). New spellings take priority when both are given. ---------------------------------------------------------------- local quaiyl = getManual(args, {"çhionnal", "quaiyl"}) local quaiylSyrjey = getManual(args, {"thie_heose", "quaiyl_syrjey"}) local quaiylInshley = getManual(args, {"thie_heese", "quaiyl_s'inshley", "quaiyl_sinshley"}) local quaiylRef = getManual(args, {"imraa_çhionnal", "imraa_quaiyl"}) local quaiylNote = getManual(args, {"noteyn_çhionnal", "noteyn_quaiyl"}) if not quaiyl and not quaiylSyrjey and not quaiylInshley then -- "short" asks Module:Wd for the item's short name (Wikidata -- P1813) first, e.g. "Parliament" instead of the full official -- "Parliament of the United Kingdom of Great Britain and Northern -- Ireland" -- matching enwiki's own concise style. Falls back to -- the item's normal label when no short name is set. quaiyl = getWdProperty("P194", {"linked", "short"}) end if quaiyl and not isNone(quaiyl) then local houseItems = {} if quaiylSyrjey and not isNone(quaiylSyrjey) then table.insert(houseItems, {"[[Thie heose]]", quaiylSyrjey}) end if quaiylInshley and not isNone(quaiylInshley) then table.insert(houseItems, {"[[Thie heese]]", quaiylInshley}) end local quaiylClass = (#houseItems > 0) and "mergedtoprow" or "" table.insert(quaiylRows, string.format(ROW, trClass(quaiylClass), "[[Çhionnal slattyssagh]]", applyRefNote(quaiyl, quaiylRef, quaiylNote, frame))) appendIndentRun(quaiylRows, houseItems) end ---------------------------------------------------------------- -- 4. BUNNEEAGHT / KIONDEEAGHT (Founding / constitution) and -- historical establishment events — manual-only, ported -- directly from the old template's numbered slots (1-9). -- `kionedeeaght` is a synonym for `kiondeeaght` in the label/note -- param names. ---------------------------------------------------------------- local foundingLabel = getManual(args, {"sorçh_kionedeeaght", "sorçh_kiondeeaght"}) or "Bunneeaght" local foundingValue = getManual(args, {"bunnit"}) local foundingNote = getManual(args, {"note_kionedeeaght", "note_kiondeeaght"}) local foundingRef = getManual(args, {"imraa_kionedeeaght", "imraa_kiondeeaght"}) local establishmentRows = {} for i = 1, 9 do local event = getManual(args, {"taghyrt" .. i .. "_bunnit"}) local date = getManual(args, {"date" .. i .. "_bunnit"}) if event then table.insert(establishmentRows, {event, date or ""}) end end if foundingValue or #establishmentRows > 0 then if foundingValue and not isNone(foundingValue) then local foundingClass = (#establishmentRows > 0) and "mergedtoprow" or "" table.insert(foundingRows, string.format(ROW, trClass(foundingClass), "[[" .. foundingLabel .. "]]", applyRefNote(foundingValue, foundingRef, foundingNote, frame))) elseif #establishmentRows > 0 then table.insert(foundingRows, string.format(HEADER, "[[" .. foundingLabel .. "]]")) end appendIndentRun(foundingRows, establishmentRows) elseif not isNone(getManual(args, {"bunnit"})) then -- Wikidata fallback via Module:Wd: inception (P571) — only when the -- whole establishment block was left unset (not explicitly |bunnit=none). -- NOTE on date precision: Module:Wd's own time-value formatting (see -- Config:getValue's `datatype == 'time'` branch) already renders a -- FULL day-month-year date whenever the underlying Wikidata statement -- itself is stored at day precision -- there is no flag this call is -- missing, and no truncation happens on our side (confirmed by the -- test harness, which feeds a day-precision value straight through -- unchanged). When only a year is shown on a real article, that is -- because THAT COUNTRY's P571 statement on Wikidata itself is only -- recorded at year precision (very common for older founding dates) -- -- not a bug here. The manual |bunnit= override remains the fix for -- any article where the Wikidata precision isn't good enough. local inception = getWdProperty("P571") if inception then table.insert(foundingRows, string.format(ROW, "", "[[" .. foundingLabel .. "]]", applyRefNote(inception, foundingRef, foundingNote, frame))) end end appendSection(rows, govRows) appendSection(rows, quaiylRows) appendSection(rows, foundingRows) if #rows == 0 then return nil end return table.concat(rows) end return p dxa6e5cqpvna54spo3468l66qufbyhk 392999 392998 2026-09-10T01:35:36Z MacTire02 219 cur Module:Ennym cheerey rish 392999 Scribunto text/plain local p = {} -- Module:Wd is gv.wiki's actual working Wikidata-fetch-and-cite module -- (confirmed by its localized /i18n submodule) — used instead of -- Module:WikidataIB, which has no working reference-building of its own. -- pcall so a wiki state where Wd (or its own Module:Wd/i18n) isn't set up -- degrades to "no Wikidata fallback" instead of breaking the infobox. local wdOK, Wd = pcall(require, "Module:Wd") -- Module:Ennym çheerey ("country names") already keeps a hand-curated table -- of each country's own Manx GENITIVE/mutated form (e.g. "Mannin" -> -- "Vannin", "Nalbin" -> "ny h-Albey", "Yn Reeriaght Unnaneysit" -> "y -- Reeriaght Unnaneysit") -- exactly the linguistic knowledge shortManxForm -- below otherwise has to guess at mechanically (see getCurrentCountryGenitive -- and shortManxForm further down for how this is used). pcall so a wiki -- state where this module isn't available degrades to the purely mechanical -- fallback instead of breaking the infobox. local ennymOK, EnnymCheerey = pcall(require, "Module:Ennym çheerey") -- Safely get manual parameters from priority list local function getManual(args, names) for _, name in ipairs(names) do local value = args[name] if value and mw.text.trim(value) ~= "" then return mw.text.trim(value) end end return nil end local function isNone(value) return value ~= nil and mw.text.trim(value):lower() == "none" end -- Append a manual reference (<ref>) and/or note ({{efn}}) to a value. This -- is the manual imraa_*/noteyn_* channel, same as Module:Kishtey fys -- çheer/çhengaghyn uses. It layers on top of a Wikidata-sourced value too -- (which already carries its own auto-built citation from getWdProperty -- below) in case an editor wants to add an extra citation or clarifying -- footnote of their own. local function applyRefNote(value, ref, note, frame) if not value then return value end if note and note ~= "" and frame then value = value .. frame:expandTemplate{ title = "efn", args = { note } } end if ref and ref ~= "" then value = value .. "<ref>" .. ref .. "</ref>" end return value end -- Fetch+format a single Wikidata property value via Module:Wd's "property" -- command, combined with its "reference" command so that, when the -- Wikidata statement itself carries references, Wd builds a real <ref> -- citation (Cite web / Cite Q) from them automatically — the same way -- gv.wiki's other Wd-based infoboxes already cite Wikidata data. `flags` -- is an optional array of extra Wd flags (e.g. {"linked"}). Returns nil -- when Wd isn't available, or the property has no value. local function getWdProperty(property, flags) if not wdOK or not Wd or not Wd._property then return nil end local callArgs = {} for _, f in ipairs(flags or {}) do table.insert(callArgs, f) end table.insert(callArgs, "reference") -- request an auto-built citation alongside the value table.insert(callArgs, "best") -- single best-ranked value, mirroring the old template's behaviour table.insert(callArgs, property) local ok, result = pcall(Wd._property, callArgs) if ok and result and result ~= "" then return result end return nil end -- Same as getWdProperty, but via Module:Wd's plural "properties" command, -- which joins EVERY matching value together (comma-separated by default) -- instead of just the single best one. Used for government type (P122 -- "basic form of government"), which Wikidata typically records as several -- separate statements on one country (e.g. "unitary state", "parliamentary -- system", "constitutional monarchy") rather than one combined phrase. local function getWdProperties(property, flags) if not wdOK or not Wd or not Wd._properties then return nil end local callArgs = {} for _, f in ipairs(flags or {}) do table.insert(callArgs, f) end table.insert(callArgs, "reference") table.insert(callArgs, property) local ok, result = pcall(Wd._properties, callArgs) if ok and result and result ~= "" then return result end return nil end -- Module:Wd's "linked" flag only produces a wikilink when the entity -- already has a gv sitelink (Config:getLabel returns the bare label, -- un-bracketed, otherwise — see Module:Wd source). For a leader whose -- article doesn't exist on gv.wiki yet, that means no link at all. Since -- an editor should still be able to click through (or see a redlink -- inviting the article to be written), this forces a wikilink around the -- label text when Wd didn't already supply one — without touching a -- trailing auto-built <ref>...</ref> citation, which Wd appends directly -- after the label/link text. local function ensureLinked(value) if not value or value == "" then return value end local label, refSuffix = value:match("^(.-)(<ref.*)$") if not label then label = value refSuffix = "" end if label:find("%[%[") then return value -- already a real link via a gv sitelink end label = mw.text.trim(label) if label == "" then return value end return "[[" .. label .. "]]" .. refSuffix end -- Label of the Wikidata PROPERTY itself (e.g. P35 -> "head of state"), used -- as a Wikidata-sourced fallback for a leader's title when no manual -- title/override is supplied. Deliberately uses getLabelByLang(property, -- "gv") rather than mw.wikibase.label(property): plain label() follows -- Wikidata's language-fallback chain and will happily hand back the -- English label when no Manx one exists (which is the common case for -- properties on Wikidata) — silently leaking English text like "head of -- state" into the Manx infobox. getLabelByLang only returns a value when a -- Manx label genuinely exists, so an untranslated property correctly falls -- through to the hardcoded Manx text below instead. local function getWikidataPropertyLabel(property) local ok, label = pcall(mw.wikibase.getLabelByLang, property, "gv") if ok and label and label ~= "" then return label end return nil end -- Raw QID (no linking/label formatting) of an entity-valued property on the -- CURRENT page's Wikidata item — e.g. P35's value (the head of state person) -- as a bare "Q..." id, so it can be used as the `eid` for a follow-up -- lookup on THAT person's own item (see getWdPositionTitle below). Uses -- Module:Wd's "raw" flag, which for an entity-id-valued statement returns -- the plain id instead of a formatted link/label. local function getWdRawPropertyId(property) if not wdOK or not Wd or not Wd._property then return nil end local ok, result = pcall(Wd._property, {"raw", "best", property}) if ok and result and type(result) == "string" and result:match("^Q%d+$") then return result end return nil end -- Raw QIDs of EVERY value of an entity-valued property on a FOREIGN -- Wikidata item (`eid`), not the current page's — e.g. the leader's own -- P39 ("position held") statements, which a real politician very often has -- several of at once (a parliamentary seat, a party leadership, AND a head- -- of-government office can all be simultaneously "current" -- see -- getWdPositionTitle below for why that matters). Uses Module:Wd's PLURAL -- "properties" command (not "property"), which -- unlike the singular -- command -- does not stop at a single "best" value, so every matching -- claim is returned, joined together; this extracts each "Q..." token from -- that joined string rather than relying on a specific separator, since -- Wd's separator choice isn't part of its documented contract. `eid` is -- passed the same way Module:Wd's own code does internally -- (`p._property{..., [p.args.eid] = id}`). `qualifiers` is an optional -- table of {qualifierPropertyId = requiredValue} pairs -- Module:Wd's -- claimCommand treats any hash key matching "P%d+" as a qualifier filter -- (see its `qualifierIDsAndValues`/`qualifierMatches` logic), letting a -- caller narrow the claims returned to just those with a matching -- qualifier (see getWdPositionTitle below, which uses this for P1001 -- "applies to jurisdiction"). Returns an empty table on any failure. local function getWdRawForeignPropertyIds(eid, property, extraFlags, qualifiers) if not wdOK or not Wd or not Wd._properties or not eid then return {} end local callArgs = {} for _, f in ipairs(extraFlags or {}) do table.insert(callArgs, f) end table.insert(callArgs, "raw") table.insert(callArgs, property) callArgs[Wd.args and Wd.args.eid or "eid"] = eid for qid, value in pairs(qualifiers or {}) do callArgs[qid] = value end local ok, result = pcall(Wd._properties, callArgs) if not ok or not result or type(result) ~= "string" or result == "" then return {} end local ids = {} for id in result:gmatch("Q%d+") do table.insert(ids, id) end return ids end -- The QID of the entity connected to the CURRENT page (e.g. the country the -- article is about), used to disambiguate a multi-realm head of state's P39 -- statements (see getWdPositionTitle below). Returns nil when the current -- page has no connected Wikidata item. local function getCurrentCountryQid() local ok, id = pcall(mw.wikibase.getEntityIdForCurrentPage) if ok and id and id ~= "" then return id end return nil end -- The exact Manx GENITIVE form of the CURRENT PAGE's own country/territory -- -- e.g. "Vannin" for the Isle of Man's own article, "y Reeriaght -- Unnaneysit" for the UK's -- looked up from Module:Ennym çheerey's shared, -- hand-curated table (see shortManxForm below for how this is used). -- Derived from the current page's own title, which -- for a country/ -- territory article -- IS that country's plain Manx name, the same key -- Module:Ennym çheerey's table is keyed on. Returns nil when -- Module:Ennym çheerey isn't available, the current page has no title -- (shouldn't happen in practice), or the lookup itself fails for any reason -- -- all pcall'd defensively so a missing/renamed dependency just falls -- through to shortManxForm's mechanical fallback rungs instead of erroring. local function getCurrentCountryGenitive() if not ennymOK or not EnnymCheerey or not EnnymCheerey.genitive then return nil end local okTitle, title = pcall(function() return mw.title.getCurrentTitle().text end) if not okTitle or not title or title == "" then return nil end local okGen, genitive = pcall(EnnymCheerey.genitive, title) if okGen and genitive and genitive ~= "" then return genitive end return nil end -- Manx country-specific office titles on gv.wiki attach the CURRENT page's -- own country name to a role, in one of two constructions -- e.g. "Monark y -- Reeriaght Unnaneysit" (a "y"/"of the" connector, for longer/multi-word -- country names) or "Ard-hirveishagh Vannin" (the country attached directly, -- often in a mutated genitive form, for shorter ones). Either way, this -- keeps just the leading role word(s) as the link's DISPLAY text while the -- link target stays the full title -- e.g. "[[Monark y Reeriaght -- Unnaneysit|Monark]]", "[[Ard-hirveishagh Vannin|Ard-hirveishagh]]". -- -- Rung 0 (linguistically correct, tried first): Module:Ennym çheerey already -- keeps a hand-curated table of exactly this -- each country's own Manx -- genitive form, "y "/"yn " prefix (or lack of one) and initial mutation -- included. getCurrentCountryGenitive() above resolves that for the CURRENT -- article's own country; if the office title ends with " " followed by that -- exact genitive form, this strips it with certainty, rather than guessing -- -- and adding a country to that ONE shared table (already documented -- there as extensible) benefits every module that uses it, not just this -- one. -- -- Rungs 1-2 (mechanical fallback, used only when rung 0 doesn't apply -- -- Module:Ennym çheerey unavailable, or this country/title isn't covered by -- its table yet): detach everything from the first " y " onward (rung 1), -- or, failing that, everything from the LAST remaining space onward (rung -- 2) -- a blind guess that happens to match the real construction in every -- case seen so far, but isn't linguistically guaranteed the way rung 0 is. -- -- A title with no space at all (already just a bare role name, e.g. -- "Ard-whaiyl") falls through every rung unchanged. -- -- Exceptions: full titles that should always be used as-is, unshortened, -- even though they'd otherwise match a rung above -- e.g. "Çhiarn Vannin" -- (Lord of Mann), where stripping " Vannin" would technically be correct per -- Module:Ennym çheerey's own genitive table, but that's not how this -- specific title should read. Checked before any rung is tried. local shortFormExceptions = { ["Çhiarn Vannin"] = true, } local function shortManxForm(title) if not title or title == "" then return title end if shortFormExceptions[title] then return title end local countryGenitive = getCurrentCountryGenitive() if countryGenitive then local suffix = " " .. countryGenitive if #title > #suffix and title:sub(-#suffix) == suffix then return title:sub(1, #title - #suffix) end end local short = title:match("^(.-)%sy%s") if short and short ~= "" then return short end short = title:match("^(.+)%s%S+$") if short and short ~= "" then return short end return title end -- Capitalizes the first letter the way the wiki itself would (respecting -- Manx-specific case folding, e.g. digraphs like "çh"), via the content -- language object's own ucfirst -- NOT a plain Lua upper() on byte 1, which -- would mangle multi-byte UTF-8 and wouldn't match gv.wiki's own title- -- capitalization rules. Needed because a raw Wikidata LABEL (unlike a real -- page title/sitelink) is conventionally stored all-lowercase (e.g. -- "monark"), but both a link's display text and a red-linked target should -- read the way an actual Manx Wikipedia article title would. local function wikiUcfirst(text) if not text or text == "" then return text end local ok, result = pcall(function() return mw.language.getContentLanguage():ucfirst(text) end) if ok and result and result ~= "" then return result end return text end -- Given a Wikidata item ID for a specific office/position (e.g. "King of -- the United Kingdom"), build a wikilink using the gv sitelink (when one -- exists) or, failing that, a verified gv LABEL as the link target -- ALWAYS -- as a real wikilink, even when that means a redlink inviting the article to -- be written (per explicit instruction: an unlinked office title is -- indistinguishable from an unsourced one, same reasoning as ensureLinked() -- above for leader names). The display text has the "y <country>" tail -- detached (see shortManxForm above), e.g. "[[Monark y Reeriaght -- Unnaneysit|Monark]]". Never uses mw.wikibase.label's English-fallback- -- prone version -- same leak this module already had to fix once for -- property labels. Returns nil only when NEITHER a sitelink nor a gv label -- exists at all, so callers fall through to the generic hardcoded Manx text. local function getWdItemManxLink(qid) if not qid then return nil end local okSite, sitelinkTitle = pcall(mw.wikibase.sitelink, qid) if not okSite then sitelinkTitle = nil end local title = (sitelinkTitle and sitelinkTitle ~= "") and sitelinkTitle or nil if not title then local okLabel, gvLabel = pcall(mw.wikibase.getLabelByLang, qid, "gv") if okLabel and gvLabel and gvLabel ~= "" then -- Wikidata labels are conventionally lowercase; capitalize so the -- redlink reads (and will resolve/redirect) like a real title. title = wikiUcfirst(gvLabel) end end if not title then return nil end local short = shortManxForm(title) if short ~= title then return "[[" .. title .. "|" .. short .. "]]" end return "[[" .. title .. "]]" end -- Wikidata has two properties made specifically to solve this exact office- -- title problem, set directly on the COUNTRY's own item rather than on the -- office-holder: P1906 "office held by head of state" and P1313 "office held -- by head of government" (these two IDs are easy to transpose -- there's no -- mnemonic pattern distinguishing them -- and an earlier version of this -- module had them backwards; double-checked against wikidata.org's own -- property pages before fixing). Their value is the generic OFFICE item itself -- (e.g. "Chief Minister of the Isle of Man" / "Ard-hirveishagh Vannin") -- -- not a person, and not one of several roles a particular office-holder -- happens to hold right now. When a country's item has this property set, -- it sidesteps the multi-role-P39 ambiguity entirely (see getWdPositionTitle -- below): there's no need to guess which of a person's several concurrent -- "position held" statements is the right one, because Wikidata already -- names the office directly. Tried FIRST, before the person-chain fallback. local function getWdOfficeItemTitle(officeProperty) local officeQid = getWdRawPropertyId(officeProperty) if not officeQid then return nil end return getWdItemManxLink(officeQid) end -- FALLBACK ONLY (see getWdOfficeItemTitle above, tried first): the leader's -- own specific office title (e.g. "Monark y Reeriaght Unnaneysit" / -- "Ard-vinishter y Reeriaght Unnaneysit"), NOT the generic property -- description ("head of state"/"kione steat"), derived by chaining through -- the CURRENT OFFICE-HOLDER instead of a dedicated country-level property -- -- used only for a country whose Wikidata item doesn't have P1313/P1906 set. -- Wikidata attaches the country-specific title to the position-HOLDER's own -- "position held" (P39) statement, not to the country's P35/P6 statement — -- so this chains through the person: P35/P6 -> person's raw QID -> that -- person's current P39 value -> a Manx link/label for it. -- -- A head of state/government very often holds MULTIPLE simultaneous "current" -- P39 positions -- not just the classic shared-monarch case ("King of the -- United Kingdom", "King of Canada", "King of Australia", ... all current at -- once), but just as commonly a head of government who is ALSO, right now, a -- sitting member of their legislature AND the leader of their party. A brand -- new statement (e.g. someone who became PM only weeks ago) frequently has -- NO qualifier at all yet distinguishing "this is the state office" from -- "this is the party/parliamentary one" -- P1001 ("applies to jurisdiction") -- is the qualifier Wikidata uses for the shared-monarch case specifically, -- but isn't reliably present on every fresh statement, so it can't be -- trusted as the only signal. -- -- So rather than committing to a single "best" P39 value (which could just -- as easily be "Member of Parliament for ..." or "Leader of the ... Party" -- as the actual head-of-government office), this collects EVERY current P39 -- candidate -- ones matching a P1001 filter for this article's own country -- first (when the data has that qualifier, which correctly resolves a -- shared monarch to the right realm), then every other current candidate -- -- and tries each in turn, using the FIRST one that actually resolves to a -- real Manx sitelink or label via getWdItemManxLink. In practice an -- ancillary role (a parliamentary seat, a party leadership) is very unlikely -- to have a dedicated gv.wiki article of its own, while the formal head-of- -- state/government office is exactly the kind of article gv.wiki is likely -- to have -- so this reliably lands on the right one without needing -- Wikidata's qualifiers to be perfectly curated. -- -- Returns nil only when NONE of the current P39 candidates resolves to -- anything on gv.wiki (or Module:Wd is unavailable, or there's no current -- P39 at all), so callers fall back to the property-label / hardcoded rungs -- below. local function getWdPositionTitle(headProperty) local personQid = getWdRawPropertyId(headProperty) if not personQid then return nil end local countryQid = getCurrentCountryQid() local candidates = {} if countryQid then for _, id in ipairs(getWdRawForeignPropertyIds(personQid, "P39", {"current"}, {["P1001"] = countryQid})) do table.insert(candidates, id) end end for _, id in ipairs(getWdRawForeignPropertyIds(personQid, "P39", {"current"})) do table.insert(candidates, id) end local tried = {} for _, qid in ipairs(candidates) do if not tried[qid] then tried[qid] = true local link = getWdItemManxLink(qid) if link then return link end end end return nil end -- Row templates. Every row in this table is a plain 2-cell -- `<th>label</th><td>value</td>` row — exactly the grid every OTHER -- submodule in this system uses (Module:Kishtey fys çheer/çhengaghyn, -- /balley, /bratteeyn). The old HTML template used a 3-column grid instead -- (a narrow indent-spacer <td>, a label <td>, a value <td>, with -- colspan="2"/colspan="3" on label-only/header rows) — mixing that 3-column -- convention into a 2-column table was the actual cause of the reported -- "bunching"/"enormous gap" distortion: rows with different physical cell -- counts in the same table force the browser to reconcile column widths -- unpredictably. Sub-items (individual leaders/houses/founding events under -- one shared label) are distinguished with a "•" bullet + reduced font -- weight on the label cell instead of a separate spacer column — matching -- how English Wikipedia's infobox marks up a list of leaders under one -- "Leader" heading. local ROW = '<tr%s><th style="vertical-align:top; white-space:nowrap; text-align:left; font-weight:bold;">%s</th><td style="vertical-align:top;">%s</td></tr>' local SUBROW = '<tr%s><th style="vertical-align:top; white-space:nowrap; text-align:left; font-weight:normal; padding-left:0.5em;">•&nbsp;%s</th><td style="vertical-align:top;">%s</td></tr>' local HEADER = '<tr class="mergedtoprow"><th colspan="2" style="text-align:left;">%s</th></tr>' -- Builds a `class="..."` attribute (or an empty string), for the -- mergedrow/mergedbottomrow/mergedtoprow classes the old template uses to -- remove the double border between a header/label row and the indented -- sub-rows that visually belong under it. local function trClass(name) if name and name ~= "" then return ' class="' .. name .. '"' end return "" end -- Formats a run of bullet-prefixed sub-rows (leader pairs, house names, -- establishment events, ...) with the old template's merged-border -- convention: every row but the last is "mergedrow", the last is -- "mergedbottomrow" — so the whole run reads as one visually joined block -- under its header/label row. local function appendIndentRun(rows, items) for idx, item in ipairs(items) do local class = (idx == #items) and "mergedbottomrow" or "mergedrow" table.insert(rows, string.format(SUBROW, trClass(class), item[1], item[2])) end end -- Same divider the dispatcher module (Module:Kishtey fys çheer) uses BETWEEN -- whole submodules (see its own `dividerLine`/`appendModule`). Reused here, -- identically, to separate this module's own three internal sections -- (leaders/government, legislature, founding) the same visual way -- a -- divider is only inserted BETWEEN two sections that both actually produced -- rows, never before the first section or after the last, and never next to -- an empty/suppressed section (mirrors appendModule's own conditional). local dividerLine = '<tr><td colspan="2" style="border-top:1px solid #a2a9b1; padding:0; height:0px;"></td></tr>' local function appendSection(rows, sectionRows) if sectionRows and #sectionRows > 0 then if #rows > 0 then table.insert(rows, dividerLine) end for _, row in ipairs(sectionRows) do table.insert(rows, row) end end end function p.main(frame, args) -- Fallback verification to catch argument slots accurately if frame context shifts if not args then args = frame frame = mw.getCurrentFrame() end local rows = {} local govRows = {} local quaiylRows = {} local foundingRows = {} ---------------------------------------------------------------- -- 1-2. REILTYS (Government type) + FIR HOSHEE / TOSHEE (Leaders: -- head of state / head of government / etc.) -- `enmysN_fer-toshee` / `ennymN_fer-toshee` are the old, gendered -- param names, kept for backward compatibility with existing -- articles. `enmys_toshiaghN` / `ennym_toshiaghN` are the -- gender-neutral synonyms going forward ("toshiagh" = leader); -- either spelling works, and the new one takes priority when both -- are supplied for the same slot. Leaders are computed BEFORE the -- government-type row is emitted so that row can carry the right -- merged-border class when leader rows are going to follow it. ---------------------------------------------------------------- local govTypeRaw = getManual(args, {"sorçh_reiltys", "government_type"}) local govRef = getManual(args, {"imraa_reiltys"}) local govNote = getManual(args, {"noteyn_reiltys"}) if not govTypeRaw then -- Wikidata fallback via Module:Wd: basic form of government (P122), -- e.g. "unitary state, parliamentary system, constitutional -- monarchy" -- joins every value Wikidata records rather than just -- one, since this is normally split across several statements. -- Skipped entirely when the field was explicitly suppressed -- (`|sorçh_reiltys=none`), same as every other Wikidata-fallback -- field in this module. govTypeRaw = getWdProperties("P122", {"linked"}) end local govShown = govTypeRaw and not isNone(govTypeRaw) local leaderPairs = {} local manualLeaderGiven = false for i = 1, 5 do local title = getManual(args, {"enmys_toshiagh" .. i, "enmys" .. i .. "_fer-toshee"}) local name = getManual(args, {"ennym_toshiagh" .. i, "ennym" .. i .. "_fer-toshee"}) if title or name then manualLeaderGiven = true if not isNone(name) then table.insert(leaderPairs, {title = title or "", name = name or ""}) end end end local leaderRef = getManual(args, {"imraa_toshiagh", "imraa_fer-toshee"}) local leaderNote = getManual(args, {"noteyn_toshiagh", "noteyn_fer-toshee"}) local leadersSuppressed = isNone(getManual(args, {"fir_hoshee", "toshiaghyn"})) if not manualLeaderGiven and not leadersSuppressed then -- Wikidata fallback via Module:Wd: head of state (P35) / head of -- government (P6). Names are ALWAYS forced into a link (a redlink -- when gv.wiki has no article for that person yet) via -- ensureLinked, since an unlinked plain name is easy to mistake for -- a manual/unsourced value and gives editors nothing to click -- through to create the article. Titles try, in order: a manual -- override, the leader's own country-specific office (e.g. "Monark -- y Reeriaght Unnaneysit"), the Wikidata property's own label, then -- a hardcoded Manx fallback. local hos = ensureLinked(getWdProperty("P35", {"linked"})) local hog = ensureLinked(getWdProperty("P6", {"linked"})) if hos then local hosTitle = getManual(args, {"sorçh_kione_steat"}) or getWdOfficeItemTitle("P1906") -- "office held by head of state" -- set directly on the country, no person-level ambiguity or getWdPositionTitle("P35") or getWikidataPropertyLabel("P35") or "Kione steat" table.insert(leaderPairs, {title = hosTitle, name = hos}) end if hog then local hogTitle = getManual(args, {"sorçh_kione_reiltys"}) or getWdOfficeItemTitle("P1313") -- "office held by head of government" -- same reasoning as P1906 above or getWdPositionTitle("P6") or getWikidataPropertyLabel("P6") or "Kione reiltys" table.insert(leaderPairs, {title = hogTitle, name = hog}) end end if govShown then local govClass = (#leaderPairs > 0) and "mergedtoprow" or "" table.insert(govRows, string.format(ROW, trClass(govClass), "[[Reiltys]]", applyRefNote(govTypeRaw, govRef, govNote, frame))) elseif #leaderPairs > 0 then table.insert(govRows, string.format(HEADER, "[[Reiltys]]")) end if #leaderPairs > 0 then -- The shared manual ref/note for the whole leaders block is -- attached to the last row, same convention as a single footnote -- covering a list. (A Wikidata-sourced name already carries its own -- auto-built citation from getWdProperty.) local last = leaderPairs[#leaderPairs] last.name = applyRefNote(last.name, leaderRef, leaderNote, frame) local items = {} for _, leader in ipairs(leaderPairs) do table.insert(items, {leader.title, leader.name}) end appendIndentRun(govRows, items) end ---------------------------------------------------------------- -- 3. QUAIYL / ÇHIONNAL (Legislature) -- `çhionnal` is a synonym for `quaiyl`; `thie_heose` / `thie_heese` -- are synonyms for `quaiyl_syrjey` / `quaiyl_s'inshley` (upper / -- lower house). New spellings take priority when both are given. ---------------------------------------------------------------- local quaiyl = getManual(args, {"çhionnal", "quaiyl"}) local quaiylSyrjey = getManual(args, {"thie_heose", "quaiyl_syrjey"}) local quaiylInshley = getManual(args, {"thie_heese", "quaiyl_s'inshley", "quaiyl_sinshley"}) local quaiylRef = getManual(args, {"imraa_çhionnal", "imraa_quaiyl"}) local quaiylNote = getManual(args, {"noteyn_çhionnal", "noteyn_quaiyl"}) if not quaiyl and not quaiylSyrjey and not quaiylInshley then -- "short" asks Module:Wd for the item's short name (Wikidata -- P1813) first, e.g. "Parliament" instead of the full official -- "Parliament of the United Kingdom of Great Britain and Northern -- Ireland" -- matching enwiki's own concise style. Falls back to -- the item's normal label when no short name is set. quaiyl = getWdProperty("P194", {"linked", "short"}) end if quaiyl and not isNone(quaiyl) then local houseItems = {} if quaiylSyrjey and not isNone(quaiylSyrjey) then table.insert(houseItems, {"[[Thie heose]]", quaiylSyrjey}) end if quaiylInshley and not isNone(quaiylInshley) then table.insert(houseItems, {"[[Thie heese]]", quaiylInshley}) end local quaiylClass = (#houseItems > 0) and "mergedtoprow" or "" table.insert(quaiylRows, string.format(ROW, trClass(quaiylClass), "[[Çhionnal slattyssagh]]", applyRefNote(quaiyl, quaiylRef, quaiylNote, frame))) appendIndentRun(quaiylRows, houseItems) end ---------------------------------------------------------------- -- 4. BUNNEEAGHT / KIONDEEAGHT (Founding / constitution) and -- historical establishment events — manual-only, ported -- directly from the old template's numbered slots (1-9). -- `kionedeeaght` is a synonym for `kiondeeaght` in the label/note -- param names. ---------------------------------------------------------------- local foundingLabel = getManual(args, {"sorçh_kionedeeaght", "sorçh_kiondeeaght"}) or "Bunneeaght" local foundingValue = getManual(args, {"bunnit"}) local foundingNote = getManual(args, {"note_kionedeeaght", "note_kiondeeaght"}) local foundingRef = getManual(args, {"imraa_kionedeeaght", "imraa_kiondeeaght"}) local establishmentRows = {} for i = 1, 9 do local event = getManual(args, {"taghyrt" .. i .. "_bunnit"}) local date = getManual(args, {"date" .. i .. "_bunnit"}) if event then table.insert(establishmentRows, {event, date or ""}) end end if foundingValue or #establishmentRows > 0 then if foundingValue and not isNone(foundingValue) then local foundingClass = (#establishmentRows > 0) and "mergedtoprow" or "" table.insert(foundingRows, string.format(ROW, trClass(foundingClass), "[[" .. foundingLabel .. "]]", applyRefNote(foundingValue, foundingRef, foundingNote, frame))) elseif #establishmentRows > 0 then table.insert(foundingRows, string.format(HEADER, "[[" .. foundingLabel .. "]]")) end appendIndentRun(foundingRows, establishmentRows) elseif not isNone(getManual(args, {"bunnit"})) then -- Wikidata fallback via Module:Wd: inception (P571) — only when the -- whole establishment block was left unset (not explicitly |bunnit=none). -- NOTE on date precision: Module:Wd's own time-value formatting (see -- Config:getValue's `datatype == 'time'` branch) already renders a -- FULL day-month-year date whenever the underlying Wikidata statement -- itself is stored at day precision -- there is no flag this call is -- missing, and no truncation happens on our side (confirmed by the -- test harness, which feeds a day-precision value straight through -- unchanged). When only a year is shown on a real article, that is -- because THAT COUNTRY's P571 statement on Wikidata itself is only -- recorded at year precision (very common for older founding dates) -- -- not a bug here. The manual |bunnit= override remains the fix for -- any article where the Wikidata precision isn't good enough. local inception = getWdProperty("P571") if inception then table.insert(foundingRows, string.format(ROW, "", "[[" .. foundingLabel .. "]]", applyRefNote(inception, foundingRef, foundingNote, frame))) end end appendSection(rows, govRows) appendSection(rows, quaiylRows) appendSection(rows, foundingRows) if #rows == 0 then return nil end return table.concat(rows) end return p ku00t88ec9hwey019dzxbxndtsvbg64 393001 392999 2026-09-10T01:45:26Z MacTire02 219 ++ 393001 Scribunto text/plain local p = {} -- Module:Wd is gv.wiki's actual working Wikidata-fetch-and-cite module -- (confirmed by its localized /i18n submodule) — used instead of -- Module:WikidataIB, which has no working reference-building of its own. -- pcall so a wiki state where Wd (or its own Module:Wd/i18n) isn't set up -- degrades to "no Wikidata fallback" instead of breaking the infobox. local wdOK, Wd = pcall(require, "Module:Wd") -- Module:Ennym çheerey ("country names") already keeps a hand-curated table -- of each country's own Manx GENITIVE/mutated form (e.g. "Mannin" -> -- "Vannin", "Nalbin" -> "ny h-Albey", "Yn Reeriaght Unnaneysit" -> "y -- Reeriaght Unnaneysit") -- exactly the linguistic knowledge shortManxForm -- below otherwise has to guess at mechanically (see getCurrentCountryGenitive -- and shortManxForm further down for how this is used). pcall so a wiki -- state where this module isn't available degrades to the purely mechanical -- fallback instead of breaking the infobox. local ennymOK, EnnymCheerey = pcall(require, "Module:Ennym çheerey") -- Safely get manual parameters from priority list local function getManual(args, names) for _, name in ipairs(names) do local value = args[name] if value and mw.text.trim(value) ~= "" then return mw.text.trim(value) end end return nil end local function isNone(value) return value ~= nil and mw.text.trim(value):lower() == "none" end -- Append a manual reference (<ref>) and/or note ({{efn}}) to a value. This -- is the manual imraa_*/noteyn_* channel, same as Module:Kishtey fys -- çheer/çhengaghyn uses. It layers on top of a Wikidata-sourced value too -- (which already carries its own auto-built citation from getWdProperty -- below) in case an editor wants to add an extra citation or clarifying -- footnote of their own. local function applyRefNote(value, ref, note, frame) if not value then return value end if note and note ~= "" and frame then value = value .. frame:expandTemplate{ title = "efn", args = { note } } end if ref and ref ~= "" then value = value .. "<ref>" .. ref .. "</ref>" end return value end -- Fetch+format a single Wikidata property value via Module:Wd's "property" -- command, combined with its "reference" command so that, when the -- Wikidata statement itself carries references, Wd builds a real <ref> -- citation (Cite web / Cite Q) from them automatically — the same way -- gv.wiki's other Wd-based infoboxes already cite Wikidata data. `flags` -- is an optional array of extra Wd flags (e.g. {"linked"}). Returns nil -- when Wd isn't available, or the property has no value. local function getWdProperty(property, flags) if not wdOK or not Wd or not Wd._property then return nil end local callArgs = {} for _, f in ipairs(flags or {}) do table.insert(callArgs, f) end table.insert(callArgs, "reference") -- request an auto-built citation alongside the value table.insert(callArgs, "best") -- single best-ranked value, mirroring the old template's behaviour table.insert(callArgs, property) local ok, result = pcall(Wd._property, callArgs) if ok and result and result ~= "" then return result end return nil end -- Same as getWdProperty, but via Module:Wd's plural "properties" command, -- which joins EVERY matching value together (comma-separated by default) -- instead of just the single best one. Used for government type (P122 -- "basic form of government"), which Wikidata typically records as several -- separate statements on one country (e.g. "unitary state", "parliamentary -- system", "constitutional monarchy") rather than one combined phrase. local function getWdProperties(property, flags) if not wdOK or not Wd or not Wd._properties then return nil end local callArgs = {} for _, f in ipairs(flags or {}) do table.insert(callArgs, f) end table.insert(callArgs, "reference") table.insert(callArgs, property) local ok, result = pcall(Wd._properties, callArgs) if ok and result and result ~= "" then return result end return nil end -- Module:Wd's "linked" flag only produces a wikilink when the entity -- already has a gv sitelink (Config:getLabel returns the bare label, -- un-bracketed, otherwise — see Module:Wd source). For a leader whose -- article doesn't exist on gv.wiki yet, that means no link at all. Since -- an editor should still be able to click through (or see a redlink -- inviting the article to be written), this forces a wikilink around the -- label text when Wd didn't already supply one — without touching a -- trailing auto-built <ref>...</ref> citation, which Wd appends directly -- after the label/link text. local function ensureLinked(value) if not value or value == "" then return value end local label, refSuffix = value:match("^(.-)(<ref.*)$") if not label then label = value refSuffix = "" end if label:find("%[%[") then return value -- already a real link via a gv sitelink end label = mw.text.trim(label) if label == "" then return value end return "[[" .. label .. "]]" .. refSuffix end -- Label of the Wikidata PROPERTY itself (e.g. P35 -> "head of state"), used -- as a Wikidata-sourced fallback for a leader's title when no manual -- title/override is supplied. Deliberately uses getLabelByLang(property, -- "gv") rather than mw.wikibase.label(property): plain label() follows -- Wikidata's language-fallback chain and will happily hand back the -- English label when no Manx one exists (which is the common case for -- properties on Wikidata) — silently leaking English text like "head of -- state" into the Manx infobox. getLabelByLang only returns a value when a -- Manx label genuinely exists, so an untranslated property correctly falls -- through to the hardcoded Manx text below instead. local function getWikidataPropertyLabel(property) local ok, label = pcall(mw.wikibase.getLabelByLang, property, "gv") if ok and label and label ~= "" then return label end return nil end -- Raw QID (no linking/label formatting) of an entity-valued property on the -- CURRENT page's Wikidata item — e.g. P35's value (the head of state person) -- as a bare "Q..." id, so it can be used as the `eid` for a follow-up -- lookup on THAT person's own item (see getWdPositionTitle below). Uses -- Module:Wd's "raw" flag, which for an entity-id-valued statement returns -- the plain id instead of a formatted link/label. local function getWdRawPropertyId(property) if not wdOK or not Wd or not Wd._property then return nil end local ok, result = pcall(Wd._property, {"raw", "best", property}) if ok and result and type(result) == "string" and result:match("^Q%d+$") then return result end return nil end -- Raw QIDs of EVERY value of an entity-valued property on a FOREIGN -- Wikidata item (`eid`), not the current page's — e.g. the leader's own -- P39 ("position held") statements, which a real politician very often has -- several of at once (a parliamentary seat, a party leadership, AND a head- -- of-government office can all be simultaneously "current" -- see -- getWdPositionTitle below for why that matters). Uses Module:Wd's PLURAL -- "properties" command (not "property"), which -- unlike the singular -- command -- does not stop at a single "best" value, so every matching -- claim is returned, joined together; this extracts each "Q..." token from -- that joined string rather than relying on a specific separator, since -- Wd's separator choice isn't part of its documented contract. `eid` is -- passed the same way Module:Wd's own code does internally -- (`p._property{..., [p.args.eid] = id}`). `qualifiers` is an optional -- table of {qualifierPropertyId = requiredValue} pairs -- Module:Wd's -- claimCommand treats any hash key matching "P%d+" as a qualifier filter -- (see its `qualifierIDsAndValues`/`qualifierMatches` logic), letting a -- caller narrow the claims returned to just those with a matching -- qualifier (see getWdPositionTitle below, which uses this for P1001 -- "applies to jurisdiction"). Returns an empty table on any failure. local function getWdRawForeignPropertyIds(eid, property, extraFlags, qualifiers) if not wdOK or not Wd or not Wd._properties or not eid then return {} end local callArgs = {} for _, f in ipairs(extraFlags or {}) do table.insert(callArgs, f) end table.insert(callArgs, "raw") table.insert(callArgs, property) callArgs[Wd.args and Wd.args.eid or "eid"] = eid for qid, value in pairs(qualifiers or {}) do callArgs[qid] = value end local ok, result = pcall(Wd._properties, callArgs) if not ok or not result or type(result) ~= "string" or result == "" then return {} end local ids = {} for id in result:gmatch("Q%d+") do table.insert(ids, id) end return ids end -- The QID of the entity connected to the CURRENT page (e.g. the country the -- article is about), used to disambiguate a multi-realm head of state's P39 -- statements (see getWdPositionTitle below). Returns nil when the current -- page has no connected Wikidata item. local function getCurrentCountryQid() local ok, id = pcall(mw.wikibase.getEntityIdForCurrentPage) if ok and id and id ~= "" then return id end return nil end -- The exact Manx GENITIVE form of the CURRENT PAGE's own country/territory -- -- e.g. "Vannin" for the Isle of Man's own article, "y Reeriaght -- Unnaneysit" for the UK's -- looked up from Module:Ennym çheerey's shared, -- hand-curated table (see shortManxForm below for how this is used). -- Derived from the current page's own title, which -- for a country/ -- territory article -- IS that country's plain Manx name, the same key -- Module:Ennym çheerey's table is keyed on. Returns nil when -- Module:Ennym çheerey isn't available, the current page has no title -- (shouldn't happen in practice), or the lookup itself fails for any reason -- -- all pcall'd defensively so a missing/renamed dependency just falls -- through to shortManxForm's mechanical fallback rungs instead of erroring. local function getCurrentCountryGenitive() if not ennymOK or not EnnymCheerey or not EnnymCheerey.genitive then return nil end local okTitle, title = pcall(function() return mw.title.getCurrentTitle().text end) if not okTitle or not title or title == "" then return nil end local okGen, genitive = pcall(EnnymCheerey.genitive, title) if okGen and genitive and genitive ~= "" then return genitive end return nil end -- Manx country-specific office titles on gv.wiki attach the CURRENT page's -- own country name to a role, in one of two constructions -- e.g. "Monark y -- Reeriaght Unnaneysit" (a "y"/"of the" connector, for longer/multi-word -- country names) or "Ard-hirveishagh Vannin" (the country attached directly, -- often in a mutated genitive form, for shorter ones). Either way, this -- keeps just the leading role word(s) as the link's DISPLAY text while the -- link target stays the full title -- e.g. "[[Monark y Reeriaght -- Unnaneysit|Monark]]", "[[Ard-hirveishagh Vannin|Ard-hirveishagh]]". -- -- Rung 0 (linguistically correct, tried first): Module:Ennym çheerey already -- keeps a hand-curated table of exactly this -- each country's own Manx -- genitive form, "y "/"yn " prefix (or lack of one) and initial mutation -- included. getCurrentCountryGenitive() above resolves that for the CURRENT -- article's own country; if the office title ends with " " followed by that -- exact genitive form, this strips it with certainty, rather than guessing -- -- and adding a country to that ONE shared table (already documented -- there as extensible) benefits every module that uses it, not just this -- one. -- -- Rungs 1-2 (mechanical fallback, used only when rung 0 doesn't apply -- -- Module:Ennym çheerey unavailable, or this country/title isn't covered by -- its table yet): detach everything from the first " y " onward (rung 1), -- or, failing that, everything from the LAST remaining space onward (rung -- 2) -- a blind guess that happens to match the real construction in every -- case seen so far, but isn't linguistically guaranteed the way rung 0 is. -- -- A title with no space at all (already just a bare role name, e.g. -- "Ard-whaiyl") falls through every rung unchanged. -- -- Exceptions: full titles that should always be used as-is, unshortened, -- even though they'd otherwise match a rung above -- e.g. "Çhiarn Vannin" -- (Lord of Mann), where stripping " Vannin" would technically be correct per -- Module:Ennym çheerey's own genitive table, but that's not how this -- specific title should read. Checked before any rung is tried. local shortFormExceptions = { ["Çhiarn Vannin"] = true, } local function shortManxForm(title) if not title or title == "" then return title end if shortFormExceptions[title] then return title end local countryGenitive = getCurrentCountryGenitive() if countryGenitive then local suffix = " " .. countryGenitive if #title > #suffix and title:sub(-#suffix) == suffix then return title:sub(1, #title - #suffix) end end local short = title:match("^(.-)%sy%s") if short and short ~= "" then return short end short = title:match("^(.+)%s%S+$") if short and short ~= "" then return short end return title end -- A conservative cousin of shortManxForm, used ONLY for a PERSON's own name -- (see shortenLinkedCountryName below), never for an office title. A shared -- monarch is the one case where gv.wiki has to disambiguate a PERSON's own -- article per realm the same way office-title items are (e.g. an article -- titled "Çhalse III y Reeriaght Unnaneysit" for the UK's Charles III, -- distinct from his article for another realm) -- so this strips exactly -- that same country-genitive tail when it's genuinely present. Deliberately -- OMITS shortManxForm's rung 2 (blind last-space split): that rung is safe -- for an office title (which always ends in a country reference) but would -- be actively wrong for an ordinary two/three-word person's name with no -- country suffix at all -- e.g. it would mangle "Charse III" into "Charse", -- silently dropping the regnal numeral. Only the two rungs that require a -- genuine, identifiable country-genitive match are used here: Module:Ennym -- çheerey's exact genitive suffix (rung 0), or an explicit " y " token -- (rung 1) -- both of gv.wiki's known cases ("Çhalse III y Reeriaght -- Unnaneysit", "Louisagh IV y Rank") already contain a literal " y ", so -- rung 1 alone would catch them even without Module:Ennym çheerey data. local function shortenCountrySuffixedName(name) if not name or name == "" then return name end local countryGenitive = getCurrentCountryGenitive() if countryGenitive then local suffix = " " .. countryGenitive if #name > #suffix and name:sub(-#suffix) == suffix then return name:sub(1, #name - #suffix) end end local short = name:match("^(.-)%sy%s") if short and short ~= "" then return short end return name end -- Shortens the DISPLAY text of the head-of-state's own linked name when -- gv.wiki's article for them is a per-realm-disambiguated one (see -- shortenCountrySuffixedName above) -- e.g. turning the unpiped -- "[[Çhalse III y Reeriaght Unnaneysit]]" Module:Wd hands back (it has -- nothing else to use as display text there) into the piped -- "[[Çhalse III y Reeriaght Unnaneysit|Çhalse III]]", leaving the link -- target and any trailing manual/auto <ref> citation completely untouched. -- Deliberately scoped to the HEAD-OF-STATE slot only (see its call site in -- p.main) rather than a general-purpose name formatter: an ordinary head of -- government is never the same person across several countries, so their -- own gv article is never disambiguated this way in the first place -- -- structurally, only a shared monarch produces this shape of data at all, -- which is what "condition this on the head of state being a monarch" -- comes down to in practice, without a separate Wikidata lookup to confirm -- it. Only fires on a bare, unpiped "[[target]]" link with no existing -- custom display text (i.e. nothing this module or Wd itself already chose -- to show instead) -- a name that's already piped, or has no country suffix -- to strip at all, is returned completely unchanged. local function shortenLinkedCountryName(value) if not value or value == "" then return value end local main, refSuffix = value:match("^(.-)(<ref.*)$") if not main then main = value refSuffix = "" end local target = main:match("^%[%[([^%[%]|]+)%]%]$") if not target then return value end local short = shortenCountrySuffixedName(target) if short ~= target then return "[[" .. target .. "|" .. short .. "]]" .. refSuffix end return value end -- Capitalizes the first letter the way the wiki itself would (respecting -- Manx-specific case folding, e.g. digraphs like "çh"), via the content -- language object's own ucfirst -- NOT a plain Lua upper() on byte 1, which -- would mangle multi-byte UTF-8 and wouldn't match gv.wiki's own title- -- capitalization rules. Needed because a raw Wikidata LABEL (unlike a real -- page title/sitelink) is conventionally stored all-lowercase (e.g. -- "monark"), but both a link's display text and a red-linked target should -- read the way an actual Manx Wikipedia article title would. local function wikiUcfirst(text) if not text or text == "" then return text end local ok, result = pcall(function() return mw.language.getContentLanguage():ucfirst(text) end) if ok and result and result ~= "" then return result end return text end -- Given a Wikidata item ID for a specific office/position (e.g. "King of -- the United Kingdom"), build a wikilink using the gv sitelink (when one -- exists) or, failing that, a verified gv LABEL as the link target -- ALWAYS -- as a real wikilink, even when that means a redlink inviting the article to -- be written (per explicit instruction: an unlinked office title is -- indistinguishable from an unsourced one, same reasoning as ensureLinked() -- above for leader names). The display text has the "y <country>" tail -- detached (see shortManxForm above), e.g. "[[Monark y Reeriaght -- Unnaneysit|Monark]]". Never uses mw.wikibase.label's English-fallback- -- prone version -- same leak this module already had to fix once for -- property labels. Returns nil only when NEITHER a sitelink nor a gv label -- exists at all, so callers fall through to the generic hardcoded Manx text. local function getWdItemManxLink(qid) if not qid then return nil end local okSite, sitelinkTitle = pcall(mw.wikibase.sitelink, qid) if not okSite then sitelinkTitle = nil end local title = (sitelinkTitle and sitelinkTitle ~= "") and sitelinkTitle or nil if not title then local okLabel, gvLabel = pcall(mw.wikibase.getLabelByLang, qid, "gv") if okLabel and gvLabel and gvLabel ~= "" then -- Wikidata labels are conventionally lowercase; capitalize so the -- redlink reads (and will resolve/redirect) like a real title. title = wikiUcfirst(gvLabel) end end if not title then return nil end local short = shortManxForm(title) if short ~= title then return "[[" .. title .. "|" .. short .. "]]" end return "[[" .. title .. "]]" end -- Wikidata has two properties made specifically to solve this exact office- -- title problem, set directly on the COUNTRY's own item rather than on the -- office-holder: P1906 "office held by head of state" and P1313 "office held -- by head of government" (these two IDs are easy to transpose -- there's no -- mnemonic pattern distinguishing them -- and an earlier version of this -- module had them backwards; double-checked against wikidata.org's own -- property pages before fixing). Their value is the generic OFFICE item itself -- (e.g. "Chief Minister of the Isle of Man" / "Ard-hirveishagh Vannin") -- -- not a person, and not one of several roles a particular office-holder -- happens to hold right now. When a country's item has this property set, -- it sidesteps the multi-role-P39 ambiguity entirely (see getWdPositionTitle -- below): there's no need to guess which of a person's several concurrent -- "position held" statements is the right one, because Wikidata already -- names the office directly. Tried FIRST, before the person-chain fallback. local function getWdOfficeItemTitle(officeProperty) local officeQid = getWdRawPropertyId(officeProperty) if not officeQid then return nil end return getWdItemManxLink(officeQid) end -- FALLBACK ONLY (see getWdOfficeItemTitle above, tried first): the leader's -- own specific office title (e.g. "Monark y Reeriaght Unnaneysit" / -- "Ard-vinishter y Reeriaght Unnaneysit"), NOT the generic property -- description ("head of state"/"kione steat"), derived by chaining through -- the CURRENT OFFICE-HOLDER instead of a dedicated country-level property -- -- used only for a country whose Wikidata item doesn't have P1313/P1906 set. -- Wikidata attaches the country-specific title to the position-HOLDER's own -- "position held" (P39) statement, not to the country's P35/P6 statement — -- so this chains through the person: P35/P6 -> person's raw QID -> that -- person's current P39 value -> a Manx link/label for it. -- -- A head of state/government very often holds MULTIPLE simultaneous "current" -- P39 positions -- not just the classic shared-monarch case ("King of the -- United Kingdom", "King of Canada", "King of Australia", ... all current at -- once), but just as commonly a head of government who is ALSO, right now, a -- sitting member of their legislature AND the leader of their party. A brand -- new statement (e.g. someone who became PM only weeks ago) frequently has -- NO qualifier at all yet distinguishing "this is the state office" from -- "this is the party/parliamentary one" -- P1001 ("applies to jurisdiction") -- is the qualifier Wikidata uses for the shared-monarch case specifically, -- but isn't reliably present on every fresh statement, so it can't be -- trusted as the only signal. -- -- So rather than committing to a single "best" P39 value (which could just -- as easily be "Member of Parliament for ..." or "Leader of the ... Party" -- as the actual head-of-government office), this collects EVERY current P39 -- candidate -- ones matching a P1001 filter for this article's own country -- first (when the data has that qualifier, which correctly resolves a -- shared monarch to the right realm), then every other current candidate -- -- and tries each in turn, using the FIRST one that actually resolves to a -- real Manx sitelink or label via getWdItemManxLink. In practice an -- ancillary role (a parliamentary seat, a party leadership) is very unlikely -- to have a dedicated gv.wiki article of its own, while the formal head-of- -- state/government office is exactly the kind of article gv.wiki is likely -- to have -- so this reliably lands on the right one without needing -- Wikidata's qualifiers to be perfectly curated. -- -- Returns nil only when NONE of the current P39 candidates resolves to -- anything on gv.wiki (or Module:Wd is unavailable, or there's no current -- P39 at all), so callers fall back to the property-label / hardcoded rungs -- below. local function getWdPositionTitle(headProperty) local personQid = getWdRawPropertyId(headProperty) if not personQid then return nil end local countryQid = getCurrentCountryQid() local candidates = {} if countryQid then for _, id in ipairs(getWdRawForeignPropertyIds(personQid, "P39", {"current"}, {["P1001"] = countryQid})) do table.insert(candidates, id) end end for _, id in ipairs(getWdRawForeignPropertyIds(personQid, "P39", {"current"})) do table.insert(candidates, id) end local tried = {} for _, qid in ipairs(candidates) do if not tried[qid] then tried[qid] = true local link = getWdItemManxLink(qid) if link then return link end end end return nil end -- Row templates. Every row in this table is a plain 2-cell -- `<th>label</th><td>value</td>` row — exactly the grid every OTHER -- submodule in this system uses (Module:Kishtey fys çheer/çhengaghyn, -- /balley, /bratteeyn). The old HTML template used a 3-column grid instead -- (a narrow indent-spacer <td>, a label <td>, a value <td>, with -- colspan="2"/colspan="3" on label-only/header rows) — mixing that 3-column -- convention into a 2-column table was the actual cause of the reported -- "bunching"/"enormous gap" distortion: rows with different physical cell -- counts in the same table force the browser to reconcile column widths -- unpredictably. Sub-items (individual leaders/houses/founding events under -- one shared label) are distinguished with a "•" bullet + reduced font -- weight on the label cell instead of a separate spacer column — matching -- how English Wikipedia's infobox marks up a list of leaders under one -- "Leader" heading. local ROW = '<tr%s><th style="vertical-align:top; white-space:nowrap; text-align:left; font-weight:bold;">%s</th><td style="vertical-align:top;">%s</td></tr>' local SUBROW = '<tr%s><th style="vertical-align:top; white-space:nowrap; text-align:left; font-weight:normal; padding-left:0.5em;">•&nbsp;%s</th><td style="vertical-align:top;">%s</td></tr>' local HEADER = '<tr class="mergedtoprow"><th colspan="2" style="text-align:left;">%s</th></tr>' -- Builds a `class="..."` attribute (or an empty string), for the -- mergedrow/mergedbottomrow/mergedtoprow classes the old template uses to -- remove the double border between a header/label row and the indented -- sub-rows that visually belong under it. local function trClass(name) if name and name ~= "" then return ' class="' .. name .. '"' end return "" end -- Formats a run of bullet-prefixed sub-rows (leader pairs, house names, -- establishment events, ...) with the old template's merged-border -- convention: every row but the last is "mergedrow", the last is -- "mergedbottomrow" — so the whole run reads as one visually joined block -- under its header/label row. local function appendIndentRun(rows, items) for idx, item in ipairs(items) do local class = (idx == #items) and "mergedbottomrow" or "mergedrow" table.insert(rows, string.format(SUBROW, trClass(class), item[1], item[2])) end end -- Same divider the dispatcher module (Module:Kishtey fys çheer) uses BETWEEN -- whole submodules (see its own `dividerLine`/`appendModule`). Reused here, -- identically, to separate this module's own three internal sections -- (leaders/government, legislature, founding) the same visual way -- a -- divider is only inserted BETWEEN two sections that both actually produced -- rows, never before the first section or after the last, and never next to -- an empty/suppressed section (mirrors appendModule's own conditional). local dividerLine = '<tr><td colspan="2" style="border-top:1px solid #a2a9b1; padding:0; height:0px;"></td></tr>' local function appendSection(rows, sectionRows) if sectionRows and #sectionRows > 0 then if #rows > 0 then table.insert(rows, dividerLine) end for _, row in ipairs(sectionRows) do table.insert(rows, row) end end end function p.main(frame, args) -- Fallback verification to catch argument slots accurately if frame context shifts if not args then args = frame frame = mw.getCurrentFrame() end local rows = {} local govRows = {} local quaiylRows = {} local foundingRows = {} ---------------------------------------------------------------- -- 1-2. REILTYS (Government type) + FIR HOSHEE / TOSHEE (Leaders: -- head of state / head of government / etc.) -- `enmysN_fer-toshee` / `ennymN_fer-toshee` are the old, gendered -- param names, kept for backward compatibility with existing -- articles. `enmys_toshiaghN` / `ennym_toshiaghN` are the -- gender-neutral synonyms going forward ("toshiagh" = leader); -- either spelling works, and the new one takes priority when both -- are supplied for the same slot. Leaders are computed BEFORE the -- government-type row is emitted so that row can carry the right -- merged-border class when leader rows are going to follow it. ---------------------------------------------------------------- local govTypeRaw = getManual(args, {"sorçh_reiltys", "government_type"}) local govRef = getManual(args, {"imraa_reiltys"}) local govNote = getManual(args, {"noteyn_reiltys"}) if not govTypeRaw then -- Wikidata fallback via Module:Wd: basic form of government (P122), -- e.g. "unitary state, parliamentary system, constitutional -- monarchy" -- joins every value Wikidata records rather than just -- one, since this is normally split across several statements. -- Skipped entirely when the field was explicitly suppressed -- (`|sorçh_reiltys=none`), same as every other Wikidata-fallback -- field in this module. govTypeRaw = getWdProperties("P122", {"linked"}) end local govShown = govTypeRaw and not isNone(govTypeRaw) local leaderPairs = {} local manualLeaderGiven = false for i = 1, 5 do local title = getManual(args, {"enmys_toshiagh" .. i, "enmys" .. i .. "_fer-toshee"}) local name = getManual(args, {"ennym_toshiagh" .. i, "ennym" .. i .. "_fer-toshee"}) if title or name then manualLeaderGiven = true if not isNone(name) then table.insert(leaderPairs, {title = title or "", name = name or ""}) end end end local leaderRef = getManual(args, {"imraa_toshiagh", "imraa_fer-toshee"}) local leaderNote = getManual(args, {"noteyn_toshiagh", "noteyn_fer-toshee"}) local leadersSuppressed = isNone(getManual(args, {"fir_hoshee", "toshiaghyn"})) if not manualLeaderGiven and not leadersSuppressed then -- Wikidata fallback via Module:Wd: head of state (P35) / head of -- government (P6). Names are ALWAYS forced into a link (a redlink -- when gv.wiki has no article for that person yet) via -- ensureLinked, since an unlinked plain name is easy to mistake for -- a manual/unsourced value and gives editors nothing to click -- through to create the article. Titles try, in order: a manual -- override, the leader's own country-specific office (e.g. "Monark -- y Reeriaght Unnaneysit"), the Wikidata property's own label, then -- a hardcoded Manx fallback. local hos = shortenLinkedCountryName(ensureLinked(getWdProperty("P35", {"linked"}))) local hog = ensureLinked(getWdProperty("P6", {"linked"})) if hos then local hosTitle = getManual(args, {"sorçh_kione_steat"}) or getWdOfficeItemTitle("P1906") -- "office held by head of state" -- set directly on the country, no person-level ambiguity or getWdPositionTitle("P35") or getWikidataPropertyLabel("P35") or "Kione steat" table.insert(leaderPairs, {title = hosTitle, name = hos}) end if hog then local hogTitle = getManual(args, {"sorçh_kione_reiltys"}) or getWdOfficeItemTitle("P1313") -- "office held by head of government" -- same reasoning as P1906 above or getWdPositionTitle("P6") or getWikidataPropertyLabel("P6") or "Kione reiltys" table.insert(leaderPairs, {title = hogTitle, name = hog}) end end if govShown then local govClass = (#leaderPairs > 0) and "mergedtoprow" or "" table.insert(govRows, string.format(ROW, trClass(govClass), "[[Reiltys]]", applyRefNote(govTypeRaw, govRef, govNote, frame))) elseif #leaderPairs > 0 then table.insert(govRows, string.format(HEADER, "[[Reiltys]]")) end if #leaderPairs > 0 then -- The shared manual ref/note for the whole leaders block is -- attached to the last row, same convention as a single footnote -- covering a list. (A Wikidata-sourced name already carries its own -- auto-built citation from getWdProperty.) local last = leaderPairs[#leaderPairs] last.name = applyRefNote(last.name, leaderRef, leaderNote, frame) local items = {} for _, leader in ipairs(leaderPairs) do table.insert(items, {leader.title, leader.name}) end appendIndentRun(govRows, items) end ---------------------------------------------------------------- -- 3. QUAIYL / ÇHIONNAL (Legislature) -- `çhionnal` is a synonym for `quaiyl`; `thie_heose` / `thie_heese` -- are synonyms for `quaiyl_syrjey` / `quaiyl_s'inshley` (upper / -- lower house). New spellings take priority when both are given. ---------------------------------------------------------------- local quaiyl = getManual(args, {"çhionnal", "quaiyl"}) local quaiylSyrjey = getManual(args, {"thie_heose", "quaiyl_syrjey"}) local quaiylInshley = getManual(args, {"thie_heese", "quaiyl_s'inshley", "quaiyl_sinshley"}) local quaiylRef = getManual(args, {"imraa_çhionnal", "imraa_quaiyl"}) local quaiylNote = getManual(args, {"noteyn_çhionnal", "noteyn_quaiyl"}) if not quaiyl and not quaiylSyrjey and not quaiylInshley then -- "short" asks Module:Wd for the item's short name (Wikidata -- P1813) first, e.g. "Parliament" instead of the full official -- "Parliament of the United Kingdom of Great Britain and Northern -- Ireland" -- matching enwiki's own concise style. Falls back to -- the item's normal label when no short name is set. quaiyl = getWdProperty("P194", {"linked", "short"}) end if quaiyl and not isNone(quaiyl) then local houseItems = {} if quaiylSyrjey and not isNone(quaiylSyrjey) then table.insert(houseItems, {"[[Thie heose]]", quaiylSyrjey}) end if quaiylInshley and not isNone(quaiylInshley) then table.insert(houseItems, {"[[Thie heese]]", quaiylInshley}) end local quaiylClass = (#houseItems > 0) and "mergedtoprow" or "" table.insert(quaiylRows, string.format(ROW, trClass(quaiylClass), "[[Çhionnal slattyssagh]]", applyRefNote(quaiyl, quaiylRef, quaiylNote, frame))) appendIndentRun(quaiylRows, houseItems) end ---------------------------------------------------------------- -- 4. BUNNEEAGHT / KIONDEEAGHT (Founding / constitution) and -- historical establishment events — manual-only, ported -- directly from the old template's numbered slots (1-9). -- `kionedeeaght` is a synonym for `kiondeeaght` in the label/note -- param names. ---------------------------------------------------------------- local foundingLabel = getManual(args, {"sorçh_kionedeeaght", "sorçh_kiondeeaght"}) or "Bunneeaght" local foundingValue = getManual(args, {"bunnit"}) local foundingNote = getManual(args, {"note_kionedeeaght", "note_kiondeeaght"}) local foundingRef = getManual(args, {"imraa_kionedeeaght", "imraa_kiondeeaght"}) local establishmentRows = {} for i = 1, 9 do local event = getManual(args, {"taghyrt" .. i .. "_bunnit"}) local date = getManual(args, {"date" .. i .. "_bunnit"}) if event then table.insert(establishmentRows, {event, date or ""}) end end if foundingValue or #establishmentRows > 0 then if foundingValue and not isNone(foundingValue) then local foundingClass = (#establishmentRows > 0) and "mergedtoprow" or "" table.insert(foundingRows, string.format(ROW, trClass(foundingClass), "[[" .. foundingLabel .. "]]", applyRefNote(foundingValue, foundingRef, foundingNote, frame))) elseif #establishmentRows > 0 then table.insert(foundingRows, string.format(HEADER, "[[" .. foundingLabel .. "]]")) end appendIndentRun(foundingRows, establishmentRows) elseif not isNone(getManual(args, {"bunnit"})) then -- Wikidata fallback via Module:Wd: inception (P571) — only when the -- whole establishment block was left unset (not explicitly |bunnit=none). -- NOTE on date precision: Module:Wd's own time-value formatting (see -- Config:getValue's `datatype == 'time'` branch) already renders a -- FULL day-month-year date whenever the underlying Wikidata statement -- itself is stored at day precision -- there is no flag this call is -- missing, and no truncation happens on our side (confirmed by the -- test harness, which feeds a day-precision value straight through -- unchanged). When only a year is shown on a real article, that is -- because THAT COUNTRY's P571 statement on Wikidata itself is only -- recorded at year precision (very common for older founding dates) -- -- not a bug here. The manual |bunnit= override remains the fix for -- any article where the Wikidata precision isn't good enough. local inception = getWdProperty("P571") if inception then table.insert(foundingRows, string.format(ROW, "", "[[" .. foundingLabel .. "]]", applyRefNote(inception, foundingRef, foundingNote, frame))) end end appendSection(rows, govRows) appendSection(rows, quaiylRows) appendSection(rows, foundingRows) if #rows == 0 then return nil end return table.concat(rows) end return p 011semkksofrdpwuhqy7prajwf3uejd 393003 393001 2026-09-10T01:50:45Z MacTire02 219 ++ 393003 Scribunto text/plain local p = {} -- Module:Wd is gv.wiki's actual working Wikidata-fetch-and-cite module -- (confirmed by its localized /i18n submodule) — used instead of -- Module:WikidataIB, which has no working reference-building of its own. -- pcall so a wiki state where Wd (or its own Module:Wd/i18n) isn't set up -- degrades to "no Wikidata fallback" instead of breaking the infobox. local wdOK, Wd = pcall(require, "Module:Wd") -- Module:Ennym çheerey ("country names") already keeps a hand-curated table -- of each country's own Manx GENITIVE/mutated form (e.g. "Mannin" -> -- "Vannin", "Nalbin" -> "ny h-Albey", "Yn Reeriaght Unnaneysit" -> "y -- Reeriaght Unnaneysit") -- exactly the linguistic knowledge shortManxForm -- below otherwise has to guess at mechanically (see getCurrentCountryGenitive -- and shortManxForm further down for how this is used). pcall so a wiki -- state where this module isn't available degrades to the purely mechanical -- fallback instead of breaking the infobox. local ennymOK, EnnymCheerey = pcall(require, "Module:Ennym çheerey") -- Safely get manual parameters from priority list local function getManual(args, names) for _, name in ipairs(names) do local value = args[name] if value and mw.text.trim(value) ~= "" then return mw.text.trim(value) end end return nil end local function isNone(value) return value ~= nil and mw.text.trim(value):lower() == "none" end -- Append a manual reference (<ref>) and/or note ({{efn}}) to a value. This -- is the manual imraa_*/noteyn_* channel, same as Module:Kishtey fys -- çheer/çhengaghyn uses. It layers on top of a Wikidata-sourced value too -- (which already carries its own auto-built citation from getWdProperty -- below) in case an editor wants to add an extra citation or clarifying -- footnote of their own. local function applyRefNote(value, ref, note, frame) if not value then return value end if note and note ~= "" and frame then value = value .. frame:expandTemplate{ title = "efn", args = { note } } end if ref and ref ~= "" then value = value .. "<ref>" .. ref .. "</ref>" end return value end -- Fetch+format a single Wikidata property value via Module:Wd's "property" -- command, combined with its "reference" command so that, when the -- Wikidata statement itself carries references, Wd builds a real <ref> -- citation (Cite web / Cite Q) from them automatically — the same way -- gv.wiki's other Wd-based infoboxes already cite Wikidata data. `flags` -- is an optional array of extra Wd flags (e.g. {"linked"}). Returns nil -- when Wd isn't available, or the property has no value. local function getWdProperty(property, flags) if not wdOK or not Wd or not Wd._property then return nil end local callArgs = {} for _, f in ipairs(flags or {}) do table.insert(callArgs, f) end table.insert(callArgs, "reference") -- request an auto-built citation alongside the value table.insert(callArgs, "best") -- single best-ranked value, mirroring the old template's behaviour table.insert(callArgs, property) local ok, result = pcall(Wd._property, callArgs) if ok and result and result ~= "" then return result end return nil end -- Same as getWdProperty, but via Module:Wd's plural "properties" command, -- which joins EVERY matching value together (comma-separated by default) -- instead of just the single best one. Used for government type (P122 -- "basic form of government"), which Wikidata typically records as several -- separate statements on one country (e.g. "unitary state", "parliamentary -- system", "constitutional monarchy") rather than one combined phrase. local function getWdProperties(property, flags) if not wdOK or not Wd or not Wd._properties then return nil end local callArgs = {} for _, f in ipairs(flags or {}) do table.insert(callArgs, f) end table.insert(callArgs, "reference") table.insert(callArgs, property) local ok, result = pcall(Wd._properties, callArgs) if ok and result and result ~= "" then return result end return nil end -- Module:Wd's "linked" flag only produces a wikilink when the entity -- already has a gv sitelink (Config:getLabel returns the bare label, -- un-bracketed, otherwise — see Module:Wd source). For a leader whose -- article doesn't exist on gv.wiki yet, that means no link at all. Since -- an editor should still be able to click through (or see a redlink -- inviting the article to be written), this forces a wikilink around the -- label text when Wd didn't already supply one — without touching a -- trailing auto-built <ref>...</ref> citation, which Wd appends directly -- after the label/link text. local function ensureLinked(value) if not value or value == "" then return value end local label, refSuffix = value:match("^(.-)(<ref.*)$") if not label then label = value refSuffix = "" end if label:find("%[%[") then return value -- already a real link via a gv sitelink end label = mw.text.trim(label) if label == "" then return value end return "[[" .. label .. "]]" .. refSuffix end -- Label of the Wikidata PROPERTY itself (e.g. P35 -> "head of state"), used -- as a Wikidata-sourced fallback for a leader's title when no manual -- title/override is supplied. Deliberately uses getLabelByLang(property, -- "gv") rather than mw.wikibase.label(property): plain label() follows -- Wikidata's language-fallback chain and will happily hand back the -- English label when no Manx one exists (which is the common case for -- properties on Wikidata) — silently leaking English text like "head of -- state" into the Manx infobox. getLabelByLang only returns a value when a -- Manx label genuinely exists, so an untranslated property correctly falls -- through to the hardcoded Manx text below instead. local function getWikidataPropertyLabel(property) local ok, label = pcall(mw.wikibase.getLabelByLang, property, "gv") if ok and label and label ~= "" then return label end return nil end -- Raw QID (no linking/label formatting) of an entity-valued property on the -- CURRENT page's Wikidata item — e.g. P35's value (the head of state person) -- as a bare "Q..." id, so it can be used as the `eid` for a follow-up -- lookup on THAT person's own item (see getWdPositionTitle below). Uses -- Module:Wd's "raw" flag, which for an entity-id-valued statement returns -- the plain id instead of a formatted link/label. local function getWdRawPropertyId(property) if not wdOK or not Wd or not Wd._property then return nil end local ok, result = pcall(Wd._property, {"raw", "best", property}) if ok and result and type(result) == "string" and result:match("^Q%d+$") then return result end return nil end -- Raw QIDs of EVERY value of an entity-valued property on a FOREIGN -- Wikidata item (`eid`), not the current page's — e.g. the leader's own -- P39 ("position held") statements, which a real politician very often has -- several of at once (a parliamentary seat, a party leadership, AND a head- -- of-government office can all be simultaneously "current" -- see -- getWdPositionTitle below for why that matters). Uses Module:Wd's PLURAL -- "properties" command (not "property"), which -- unlike the singular -- command -- does not stop at a single "best" value, so every matching -- claim is returned, joined together; this extracts each "Q..." token from -- that joined string rather than relying on a specific separator, since -- Wd's separator choice isn't part of its documented contract. `eid` is -- passed the same way Module:Wd's own code does internally -- (`p._property{..., [p.args.eid] = id}`). `qualifiers` is an optional -- table of {qualifierPropertyId = requiredValue} pairs -- Module:Wd's -- claimCommand treats any hash key matching "P%d+" as a qualifier filter -- (see its `qualifierIDsAndValues`/`qualifierMatches` logic), letting a -- caller narrow the claims returned to just those with a matching -- qualifier (see getWdPositionTitle below, which uses this for P1001 -- "applies to jurisdiction"). Returns an empty table on any failure. local function getWdRawForeignPropertyIds(eid, property, extraFlags, qualifiers) if not wdOK or not Wd or not Wd._properties or not eid then return {} end local callArgs = {} for _, f in ipairs(extraFlags or {}) do table.insert(callArgs, f) end table.insert(callArgs, "raw") table.insert(callArgs, property) callArgs[Wd.args and Wd.args.eid or "eid"] = eid for qid, value in pairs(qualifiers or {}) do callArgs[qid] = value end local ok, result = pcall(Wd._properties, callArgs) if not ok or not result or type(result) ~= "string" or result == "" then return {} end local ids = {} for id in result:gmatch("Q%d+") do table.insert(ids, id) end return ids end -- The QID of the entity connected to the CURRENT page (e.g. the country the -- article is about), used to disambiguate a multi-realm head of state's P39 -- statements (see getWdPositionTitle below). Returns nil when the current -- page has no connected Wikidata item. local function getCurrentCountryQid() local ok, id = pcall(mw.wikibase.getEntityIdForCurrentPage) if ok and id and id ~= "" then return id end return nil end -- The exact Manx GENITIVE form of the CURRENT PAGE's own country/territory -- -- e.g. "Vannin" for the Isle of Man's own article, "y Reeriaght -- Unnaneysit" for the UK's -- looked up from Module:Ennym çheerey's shared, -- hand-curated table (see shortManxForm below for how this is used). -- Derived from the current page's own title, which -- for a country/ -- territory article -- IS that country's plain Manx name, the same key -- Module:Ennym çheerey's table is keyed on. Returns nil when -- Module:Ennym çheerey isn't available, the current page has no title -- (shouldn't happen in practice), or the lookup itself fails for any reason -- -- all pcall'd defensively so a missing/renamed dependency just falls -- through to shortManxForm's mechanical fallback rungs instead of erroring. local function getCurrentCountryGenitive() if not ennymOK or not EnnymCheerey or not EnnymCheerey.genitive then return nil end local okTitle, title = pcall(function() return mw.title.getCurrentTitle().text end) if not okTitle or not title or title == "" then return nil end local okGen, genitive = pcall(EnnymCheerey.genitive, title) if okGen and genitive and genitive ~= "" then return genitive end return nil end -- Manx country-specific office titles on gv.wiki attach the CURRENT page's -- own country name to a role, in one of two constructions -- e.g. "Monark y -- Reeriaght Unnaneysit" (a "y"/"of the" connector, for longer/multi-word -- country names) or "Ard-hirveishagh Vannin" (the country attached directly, -- often in a mutated genitive form, for shorter ones). Either way, this -- keeps just the leading role word(s) as the link's DISPLAY text while the -- link target stays the full title -- e.g. "[[Monark y Reeriaght -- Unnaneysit|Monark]]", "[[Ard-hirveishagh Vannin|Ard-hirveishagh]]". -- -- Rung 0 (linguistically correct, tried first): Module:Ennym çheerey already -- keeps a hand-curated table of exactly this -- each country's own Manx -- genitive form, "y "/"yn " prefix (or lack of one) and initial mutation -- included. getCurrentCountryGenitive() above resolves that for the CURRENT -- article's own country; if the office title ends with " " followed by that -- exact genitive form, this strips it with certainty, rather than guessing -- -- and adding a country to that ONE shared table (already documented -- there as extensible) benefits every module that uses it, not just this -- one. -- -- Rungs 1-2 (mechanical fallback, used only when rung 0 doesn't apply -- -- Module:Ennym çheerey unavailable, or this country/title isn't covered by -- its table yet): detach everything from the first " y " onward (rung 1), -- or, failing that, everything from the LAST remaining space onward (rung -- 2) -- a blind guess that happens to match the real construction in every -- case seen so far, but isn't linguistically guaranteed the way rung 0 is. -- -- A title with no space at all (already just a bare role name, e.g. -- "Ard-whaiyl") falls through every rung unchanged. -- -- Exceptions: full titles that should always be used as-is, unshortened, -- even though they'd otherwise match a rung above -- e.g. "Çhiarn Vannin" -- (Lord of Mann), where stripping " Vannin" would technically be correct per -- Module:Ennym çheerey's own genitive table, but that's not how this -- specific title should read. Checked before any rung is tried. local shortFormExceptions = { ["Çhiarn Vannin"] = true, } local function shortManxForm(title) if not title or title == "" then return title end if shortFormExceptions[title] then return title end local countryGenitive = getCurrentCountryGenitive() if countryGenitive then local suffix = " " .. countryGenitive if #title > #suffix and title:sub(-#suffix) == suffix then return title:sub(1, #title - #suffix) end end local short = title:match("^(.-)%sy%s") if short and short ~= "" then return short end short = title:match("^(.+)%s%S+$") if short and short ~= "" then return short end return title end -- A conservative cousin of shortManxForm, used ONLY for a PERSON's own name -- (see shortenLinkedCountryName below), never for an office title. A shared -- monarch is the one case where gv.wiki has to disambiguate a PERSON's own -- article per realm the same way office-title items are (e.g. an article -- titled "Çhalse III y Reeriaght Unnaneysit" for the UK's Charles III, -- distinct from his article for another realm) -- so this strips exactly -- that same country-genitive tail when it's genuinely present. Deliberately -- OMITS shortManxForm's rung 2 (blind last-space split): that rung is safe -- for an office title (which always ends in a country reference) but would -- be actively wrong for an ordinary two/three-word person's name with no -- country suffix at all -- e.g. it would mangle "Charse III" into "Charse", -- silently dropping the regnal numeral. Only the two rungs that require a -- genuine, identifiable country-genitive match are used here: Module:Ennym -- çheerey's exact genitive suffix (rung 0), or an explicit " y " token -- (rung 1) -- both of gv.wiki's known cases ("Çhalse III y Reeriaght -- Unnaneysit", "Louisagh IV y Rank") already contain a literal " y ", so -- rung 1 alone would catch them even without Module:Ennym çheerey data. local function shortenCountrySuffixedName(name) if not name or name == "" then return name end local countryGenitive = getCurrentCountryGenitive() if countryGenitive then local suffix = " " .. countryGenitive if #name > #suffix and name:sub(-#suffix) == suffix then return name:sub(1, #name - #suffix) end end local short = name:match("^(.-)%sy%s") if short and short ~= "" then return short end return name end -- Shortens the DISPLAY text of the head-of-state's own linked name when -- gv.wiki's article for them is a per-realm-disambiguated one (see -- shortenCountrySuffixedName above) -- e.g. turning the unpiped -- "[[Çhalse III y Reeriaght Unnaneysit]]" Module:Wd hands back (it has -- nothing else to use as display text there) into the piped -- "[[Çhalse III y Reeriaght Unnaneysit|Çhalse III]]", leaving the link -- target and any trailing manual/auto <ref> citation completely untouched. -- Deliberately scoped to the HEAD-OF-STATE slot only (see its call site in -- p.main) rather than a general-purpose name formatter: an ordinary head of -- government is never the same person across several countries, so their -- own gv article is never disambiguated this way in the first place -- -- structurally, only a shared monarch produces this shape of data at all, -- which is what "condition this on the head of state being a monarch" -- comes down to in practice, without a separate Wikidata lookup to confirm -- it. Only fires on a bare, unpiped "[[target]]" link with no existing -- custom display text (i.e. nothing this module or Wd itself already chose -- to show instead) -- a name that's already piped, or has no country suffix -- to strip at all, is returned completely unchanged. -- Handles BOTH a bare "[[target]]" link and an already-piped "[[target| -- display]]" one, shortening whichever text is CURRENTLY being displayed -- -- not just the bare-unpiped case. This is deliberately more permissive than -- checking only for an unpiped link: Module:Wd's own buildWikilink normally -- produces the unpiped form specifically when the Wikidata label and the gv -- sitelink title are identical, but relying on that always holding (rather -- than on what's actually visible to the reader) is exactly the kind of -- assumption that can quietly stop matching if Wd's output shape ever -- differs even slightly -- e.g. a piped link whose display text still -- happens to be the full disambiguated title. Working from whatever text is -- actually displayed, rather than assuming it must be unpiped, is more -- robust either way. local function shortenLinkedCountryName(value) if not value or value == "" then return value end local main, refSuffix = value:match("^(.-)(<ref.*)$") if not main then main = value refSuffix = "" end local target, display = main:match("^%[%[([^%[%]|]+)|([^%[%]|]+)%]%]$") if not target then target = main:match("^%[%[([^%[%]|]+)%]%]$") display = target end if not target then return value end local short = shortenCountrySuffixedName(display) if short ~= display then return "[[" .. target .. "|" .. short .. "]]" .. refSuffix end return value end -- Capitalizes the first letter the way the wiki itself would (respecting -- Manx-specific case folding, e.g. digraphs like "çh"), via the content -- language object's own ucfirst -- NOT a plain Lua upper() on byte 1, which -- would mangle multi-byte UTF-8 and wouldn't match gv.wiki's own title- -- capitalization rules. Needed because a raw Wikidata LABEL (unlike a real -- page title/sitelink) is conventionally stored all-lowercase (e.g. -- "monark"), but both a link's display text and a red-linked target should -- read the way an actual Manx Wikipedia article title would. local function wikiUcfirst(text) if not text or text == "" then return text end local ok, result = pcall(function() return mw.language.getContentLanguage():ucfirst(text) end) if ok and result and result ~= "" then return result end return text end -- Given a Wikidata item ID for a specific office/position (e.g. "King of -- the United Kingdom"), build a wikilink using the gv sitelink (when one -- exists) or, failing that, a verified gv LABEL as the link target -- ALWAYS -- as a real wikilink, even when that means a redlink inviting the article to -- be written (per explicit instruction: an unlinked office title is -- indistinguishable from an unsourced one, same reasoning as ensureLinked() -- above for leader names). The display text has the "y <country>" tail -- detached (see shortManxForm above), e.g. "[[Monark y Reeriaght -- Unnaneysit|Monark]]". Never uses mw.wikibase.label's English-fallback- -- prone version -- same leak this module already had to fix once for -- property labels. Returns nil only when NEITHER a sitelink nor a gv label -- exists at all, so callers fall through to the generic hardcoded Manx text. local function getWdItemManxLink(qid) if not qid then return nil end local okSite, sitelinkTitle = pcall(mw.wikibase.sitelink, qid) if not okSite then sitelinkTitle = nil end local title = (sitelinkTitle and sitelinkTitle ~= "") and sitelinkTitle or nil if not title then local okLabel, gvLabel = pcall(mw.wikibase.getLabelByLang, qid, "gv") if okLabel and gvLabel and gvLabel ~= "" then -- Wikidata labels are conventionally lowercase; capitalize so the -- redlink reads (and will resolve/redirect) like a real title. title = wikiUcfirst(gvLabel) end end if not title then return nil end local short = shortManxForm(title) if short ~= title then return "[[" .. title .. "|" .. short .. "]]" end return "[[" .. title .. "]]" end -- Wikidata has two properties made specifically to solve this exact office- -- title problem, set directly on the COUNTRY's own item rather than on the -- office-holder: P1906 "office held by head of state" and P1313 "office held -- by head of government" (these two IDs are easy to transpose -- there's no -- mnemonic pattern distinguishing them -- and an earlier version of this -- module had them backwards; double-checked against wikidata.org's own -- property pages before fixing). Their value is the generic OFFICE item itself -- (e.g. "Chief Minister of the Isle of Man" / "Ard-hirveishagh Vannin") -- -- not a person, and not one of several roles a particular office-holder -- happens to hold right now. When a country's item has this property set, -- it sidesteps the multi-role-P39 ambiguity entirely (see getWdPositionTitle -- below): there's no need to guess which of a person's several concurrent -- "position held" statements is the right one, because Wikidata already -- names the office directly. Tried FIRST, before the person-chain fallback. local function getWdOfficeItemTitle(officeProperty) local officeQid = getWdRawPropertyId(officeProperty) if not officeQid then return nil end return getWdItemManxLink(officeQid) end -- FALLBACK ONLY (see getWdOfficeItemTitle above, tried first): the leader's -- own specific office title (e.g. "Monark y Reeriaght Unnaneysit" / -- "Ard-vinishter y Reeriaght Unnaneysit"), NOT the generic property -- description ("head of state"/"kione steat"), derived by chaining through -- the CURRENT OFFICE-HOLDER instead of a dedicated country-level property -- -- used only for a country whose Wikidata item doesn't have P1313/P1906 set. -- Wikidata attaches the country-specific title to the position-HOLDER's own -- "position held" (P39) statement, not to the country's P35/P6 statement — -- so this chains through the person: P35/P6 -> person's raw QID -> that -- person's current P39 value -> a Manx link/label for it. -- -- A head of state/government very often holds MULTIPLE simultaneous "current" -- P39 positions -- not just the classic shared-monarch case ("King of the -- United Kingdom", "King of Canada", "King of Australia", ... all current at -- once), but just as commonly a head of government who is ALSO, right now, a -- sitting member of their legislature AND the leader of their party. A brand -- new statement (e.g. someone who became PM only weeks ago) frequently has -- NO qualifier at all yet distinguishing "this is the state office" from -- "this is the party/parliamentary one" -- P1001 ("applies to jurisdiction") -- is the qualifier Wikidata uses for the shared-monarch case specifically, -- but isn't reliably present on every fresh statement, so it can't be -- trusted as the only signal. -- -- So rather than committing to a single "best" P39 value (which could just -- as easily be "Member of Parliament for ..." or "Leader of the ... Party" -- as the actual head-of-government office), this collects EVERY current P39 -- candidate -- ones matching a P1001 filter for this article's own country -- first (when the data has that qualifier, which correctly resolves a -- shared monarch to the right realm), then every other current candidate -- -- and tries each in turn, using the FIRST one that actually resolves to a -- real Manx sitelink or label via getWdItemManxLink. In practice an -- ancillary role (a parliamentary seat, a party leadership) is very unlikely -- to have a dedicated gv.wiki article of its own, while the formal head-of- -- state/government office is exactly the kind of article gv.wiki is likely -- to have -- so this reliably lands on the right one without needing -- Wikidata's qualifiers to be perfectly curated. -- -- Returns nil only when NONE of the current P39 candidates resolves to -- anything on gv.wiki (or Module:Wd is unavailable, or there's no current -- P39 at all), so callers fall back to the property-label / hardcoded rungs -- below. local function getWdPositionTitle(headProperty) local personQid = getWdRawPropertyId(headProperty) if not personQid then return nil end local countryQid = getCurrentCountryQid() local candidates = {} if countryQid then for _, id in ipairs(getWdRawForeignPropertyIds(personQid, "P39", {"current"}, {["P1001"] = countryQid})) do table.insert(candidates, id) end end for _, id in ipairs(getWdRawForeignPropertyIds(personQid, "P39", {"current"})) do table.insert(candidates, id) end local tried = {} for _, qid in ipairs(candidates) do if not tried[qid] then tried[qid] = true local link = getWdItemManxLink(qid) if link then return link end end end return nil end -- Row templates. Every row in this table is a plain 2-cell -- `<th>label</th><td>value</td>` row — exactly the grid every OTHER -- submodule in this system uses (Module:Kishtey fys çheer/çhengaghyn, -- /balley, /bratteeyn). The old HTML template used a 3-column grid instead -- (a narrow indent-spacer <td>, a label <td>, a value <td>, with -- colspan="2"/colspan="3" on label-only/header rows) — mixing that 3-column -- convention into a 2-column table was the actual cause of the reported -- "bunching"/"enormous gap" distortion: rows with different physical cell -- counts in the same table force the browser to reconcile column widths -- unpredictably. Sub-items (individual leaders/houses/founding events under -- one shared label) are distinguished with a "•" bullet + reduced font -- weight on the label cell instead of a separate spacer column — matching -- how English Wikipedia's infobox marks up a list of leaders under one -- "Leader" heading. local ROW = '<tr%s><th style="vertical-align:top; white-space:nowrap; text-align:left; font-weight:bold;">%s</th><td style="vertical-align:top;">%s</td></tr>' local SUBROW = '<tr%s><th style="vertical-align:top; white-space:nowrap; text-align:left; font-weight:normal; padding-left:0.5em;">•&nbsp;%s</th><td style="vertical-align:top;">%s</td></tr>' local HEADER = '<tr class="mergedtoprow"><th colspan="2" style="text-align:left;">%s</th></tr>' -- Builds a `class="..."` attribute (or an empty string), for the -- mergedrow/mergedbottomrow/mergedtoprow classes the old template uses to -- remove the double border between a header/label row and the indented -- sub-rows that visually belong under it. local function trClass(name) if name and name ~= "" then return ' class="' .. name .. '"' end return "" end -- Formats a run of bullet-prefixed sub-rows (leader pairs, house names, -- establishment events, ...) with the old template's merged-border -- convention: every row but the last is "mergedrow", the last is -- "mergedbottomrow" — so the whole run reads as one visually joined block -- under its header/label row. local function appendIndentRun(rows, items) for idx, item in ipairs(items) do local class = (idx == #items) and "mergedbottomrow" or "mergedrow" table.insert(rows, string.format(SUBROW, trClass(class), item[1], item[2])) end end -- Same divider the dispatcher module (Module:Kishtey fys çheer) uses BETWEEN -- whole submodules (see its own `dividerLine`/`appendModule`). Reused here, -- identically, to separate this module's own three internal sections -- (leaders/government, legislature, founding) the same visual way -- a -- divider is only inserted BETWEEN two sections that both actually produced -- rows, never before the first section or after the last, and never next to -- an empty/suppressed section (mirrors appendModule's own conditional). local dividerLine = '<tr><td colspan="2" style="border-top:1px solid #a2a9b1; padding:0; height:0px;"></td></tr>' local function appendSection(rows, sectionRows) if sectionRows and #sectionRows > 0 then if #rows > 0 then table.insert(rows, dividerLine) end for _, row in ipairs(sectionRows) do table.insert(rows, row) end end end function p.main(frame, args) -- Fallback verification to catch argument slots accurately if frame context shifts if not args then args = frame frame = mw.getCurrentFrame() end local rows = {} local govRows = {} local quaiylRows = {} local foundingRows = {} ---------------------------------------------------------------- -- 1-2. REILTYS (Government type) + FIR HOSHEE / TOSHEE (Leaders: -- head of state / head of government / etc.) -- `enmysN_fer-toshee` / `ennymN_fer-toshee` are the old, gendered -- param names, kept for backward compatibility with existing -- articles. `enmys_toshiaghN` / `ennym_toshiaghN` are the -- gender-neutral synonyms going forward ("toshiagh" = leader); -- either spelling works, and the new one takes priority when both -- are supplied for the same slot. Leaders are computed BEFORE the -- government-type row is emitted so that row can carry the right -- merged-border class when leader rows are going to follow it. ---------------------------------------------------------------- local govTypeRaw = getManual(args, {"sorçh_reiltys", "government_type"}) local govRef = getManual(args, {"imraa_reiltys"}) local govNote = getManual(args, {"noteyn_reiltys"}) if not govTypeRaw then -- Wikidata fallback via Module:Wd: basic form of government (P122), -- e.g. "unitary state, parliamentary system, constitutional -- monarchy" -- joins every value Wikidata records rather than just -- one, since this is normally split across several statements. -- Skipped entirely when the field was explicitly suppressed -- (`|sorçh_reiltys=none`), same as every other Wikidata-fallback -- field in this module. govTypeRaw = getWdProperties("P122", {"linked"}) end local govShown = govTypeRaw and not isNone(govTypeRaw) local leaderPairs = {} local manualLeaderGiven = false for i = 1, 5 do local title = getManual(args, {"enmys_toshiagh" .. i, "enmys" .. i .. "_fer-toshee"}) local name = getManual(args, {"ennym_toshiagh" .. i, "ennym" .. i .. "_fer-toshee"}) if title or name then manualLeaderGiven = true if not isNone(name) then table.insert(leaderPairs, {title = title or "", name = name or ""}) end end end local leaderRef = getManual(args, {"imraa_toshiagh", "imraa_fer-toshee"}) local leaderNote = getManual(args, {"noteyn_toshiagh", "noteyn_fer-toshee"}) local leadersSuppressed = isNone(getManual(args, {"fir_hoshee", "toshiaghyn"})) if not manualLeaderGiven and not leadersSuppressed then -- Wikidata fallback via Module:Wd: head of state (P35) / head of -- government (P6). Names are ALWAYS forced into a link (a redlink -- when gv.wiki has no article for that person yet) via -- ensureLinked, since an unlinked plain name is easy to mistake for -- a manual/unsourced value and gives editors nothing to click -- through to create the article. Titles try, in order: a manual -- override, the leader's own country-specific office (e.g. "Monark -- y Reeriaght Unnaneysit"), the Wikidata property's own label, then -- a hardcoded Manx fallback. local hos = shortenLinkedCountryName(ensureLinked(getWdProperty("P35", {"linked"}))) local hog = ensureLinked(getWdProperty("P6", {"linked"})) if hos then local hosTitle = getManual(args, {"sorçh_kione_steat"}) or getWdOfficeItemTitle("P1906") -- "office held by head of state" -- set directly on the country, no person-level ambiguity or getWdPositionTitle("P35") or getWikidataPropertyLabel("P35") or "Kione steat" table.insert(leaderPairs, {title = hosTitle, name = hos}) end if hog then local hogTitle = getManual(args, {"sorçh_kione_reiltys"}) or getWdOfficeItemTitle("P1313") -- "office held by head of government" -- same reasoning as P1906 above or getWdPositionTitle("P6") or getWikidataPropertyLabel("P6") or "Kione reiltys" table.insert(leaderPairs, {title = hogTitle, name = hog}) end end if govShown then local govClass = (#leaderPairs > 0) and "mergedtoprow" or "" table.insert(govRows, string.format(ROW, trClass(govClass), "[[Reiltys]]", applyRefNote(govTypeRaw, govRef, govNote, frame))) elseif #leaderPairs > 0 then table.insert(govRows, string.format(HEADER, "[[Reiltys]]")) end if #leaderPairs > 0 then -- The shared manual ref/note for the whole leaders block is -- attached to the last row, same convention as a single footnote -- covering a list. (A Wikidata-sourced name already carries its own -- auto-built citation from getWdProperty.) local last = leaderPairs[#leaderPairs] last.name = applyRefNote(last.name, leaderRef, leaderNote, frame) local items = {} for _, leader in ipairs(leaderPairs) do table.insert(items, {leader.title, leader.name}) end appendIndentRun(govRows, items) end ---------------------------------------------------------------- -- 3. QUAIYL / ÇHIONNAL (Legislature) -- `çhionnal` is a synonym for `quaiyl`; `thie_heose` / `thie_heese` -- are synonyms for `quaiyl_syrjey` / `quaiyl_s'inshley` (upper / -- lower house). New spellings take priority when both are given. ---------------------------------------------------------------- local quaiyl = getManual(args, {"çhionnal", "quaiyl"}) local quaiylSyrjey = getManual(args, {"thie_heose", "quaiyl_syrjey"}) local quaiylInshley = getManual(args, {"thie_heese", "quaiyl_s'inshley", "quaiyl_sinshley"}) local quaiylRef = getManual(args, {"imraa_çhionnal", "imraa_quaiyl"}) local quaiylNote = getManual(args, {"noteyn_çhionnal", "noteyn_quaiyl"}) if not quaiyl and not quaiylSyrjey and not quaiylInshley then -- "short" asks Module:Wd for the item's short name (Wikidata -- P1813) first, e.g. "Parliament" instead of the full official -- "Parliament of the United Kingdom of Great Britain and Northern -- Ireland" -- matching enwiki's own concise style. Falls back to -- the item's normal label when no short name is set. quaiyl = getWdProperty("P194", {"linked", "short"}) end if quaiyl and not isNone(quaiyl) then local houseItems = {} if quaiylSyrjey and not isNone(quaiylSyrjey) then table.insert(houseItems, {"[[Thie heose]]", quaiylSyrjey}) end if quaiylInshley and not isNone(quaiylInshley) then table.insert(houseItems, {"[[Thie heese]]", quaiylInshley}) end local quaiylClass = (#houseItems > 0) and "mergedtoprow" or "" table.insert(quaiylRows, string.format(ROW, trClass(quaiylClass), "[[Çhionnal slattyssagh]]", applyRefNote(quaiyl, quaiylRef, quaiylNote, frame))) appendIndentRun(quaiylRows, houseItems) end ---------------------------------------------------------------- -- 4. BUNNEEAGHT / KIONDEEAGHT (Founding / constitution) and -- historical establishment events — manual-only, ported -- directly from the old template's numbered slots (1-9). -- `kionedeeaght` is a synonym for `kiondeeaght` in the label/note -- param names. ---------------------------------------------------------------- local foundingLabel = getManual(args, {"sorçh_kionedeeaght", "sorçh_kiondeeaght"}) or "Bunneeaght" local foundingValue = getManual(args, {"bunnit"}) local foundingNote = getManual(args, {"note_kionedeeaght", "note_kiondeeaght"}) local foundingRef = getManual(args, {"imraa_kionedeeaght", "imraa_kiondeeaght"}) local establishmentRows = {} for i = 1, 9 do local event = getManual(args, {"taghyrt" .. i .. "_bunnit"}) local date = getManual(args, {"date" .. i .. "_bunnit"}) if event then table.insert(establishmentRows, {event, date or ""}) end end if foundingValue or #establishmentRows > 0 then if foundingValue and not isNone(foundingValue) then local foundingClass = (#establishmentRows > 0) and "mergedtoprow" or "" table.insert(foundingRows, string.format(ROW, trClass(foundingClass), "[[" .. foundingLabel .. "]]", applyRefNote(foundingValue, foundingRef, foundingNote, frame))) elseif #establishmentRows > 0 then table.insert(foundingRows, string.format(HEADER, "[[" .. foundingLabel .. "]]")) end appendIndentRun(foundingRows, establishmentRows) elseif not isNone(getManual(args, {"bunnit"})) then -- Wikidata fallback via Module:Wd: inception (P571) — only when the -- whole establishment block was left unset (not explicitly |bunnit=none). -- NOTE on date precision: Module:Wd's own time-value formatting (see -- Config:getValue's `datatype == 'time'` branch) already renders a -- FULL day-month-year date whenever the underlying Wikidata statement -- itself is stored at day precision -- there is no flag this call is -- missing, and no truncation happens on our side (confirmed by the -- test harness, which feeds a day-precision value straight through -- unchanged). When only a year is shown on a real article, that is -- because THAT COUNTRY's P571 statement on Wikidata itself is only -- recorded at year precision (very common for older founding dates) -- -- not a bug here. The manual |bunnit= override remains the fix for -- any article where the Wikidata precision isn't good enough. local inception = getWdProperty("P571") if inception then table.insert(foundingRows, string.format(ROW, "", "[[" .. foundingLabel .. "]]", applyRefNote(inception, foundingRef, foundingNote, frame))) end end appendSection(rows, govRows) appendSection(rows, quaiylRows) appendSection(rows, foundingRows) if #rows == 0 then return nil end return table.concat(rows) end return p sxrfsknz14v3bxr6rjtq4ofazetuqty 393004 393003 2026-09-10T01:54:14Z MacTire02 219 ++ 393004 Scribunto text/plain local p = {} -- Module:Wd is gv.wiki's actual working Wikidata-fetch-and-cite module -- (confirmed by its localized /i18n submodule) — used instead of -- Module:WikidataIB, which has no working reference-building of its own. -- pcall so a wiki state where Wd (or its own Module:Wd/i18n) isn't set up -- degrades to "no Wikidata fallback" instead of breaking the infobox. local wdOK, Wd = pcall(require, "Module:Wd") -- Module:Enmyn çheerey ("country names") already keeps a hand-curated table -- of each country's own Manx GENITIVE/mutated form (e.g. "Mannin" -> -- "Vannin", "Nalbin" -> "ny h-Albey", "Yn Reeriaght Unnaneysit" -> "y -- Reeriaght Unnaneysit") -- exactly the linguistic knowledge shortManxForm -- below otherwise has to guess at mechanically (see getCurrentCountryGenitive -- and shortManxForm further down for how this is used). pcall so a wiki -- state where this module isn't available degrades to the purely mechanical -- fallback instead of breaking the infobox. local ennymOK, EnmynCheerey = pcall(require, "Module:Enmyn çheerey") -- Safely get manual parameters from priority list local function getManual(args, names) for _, name in ipairs(names) do local value = args[name] if value and mw.text.trim(value) ~= "" then return mw.text.trim(value) end end return nil end local function isNone(value) return value ~= nil and mw.text.trim(value):lower() == "none" end -- Append a manual reference (<ref>) and/or note ({{efn}}) to a value. This -- is the manual imraa_*/noteyn_* channel, same as Module:Kishtey fys -- çheer/çhengaghyn uses. It layers on top of a Wikidata-sourced value too -- (which already carries its own auto-built citation from getWdProperty -- below) in case an editor wants to add an extra citation or clarifying -- footnote of their own. local function applyRefNote(value, ref, note, frame) if not value then return value end if note and note ~= "" and frame then value = value .. frame:expandTemplate{ title = "efn", args = { note } } end if ref and ref ~= "" then value = value .. "<ref>" .. ref .. "</ref>" end return value end -- Fetch+format a single Wikidata property value via Module:Wd's "property" -- command, combined with its "reference" command so that, when the -- Wikidata statement itself carries references, Wd builds a real <ref> -- citation (Cite web / Cite Q) from them automatically — the same way -- gv.wiki's other Wd-based infoboxes already cite Wikidata data. `flags` -- is an optional array of extra Wd flags (e.g. {"linked"}). Returns nil -- when Wd isn't available, or the property has no value. local function getWdProperty(property, flags) if not wdOK or not Wd or not Wd._property then return nil end local callArgs = {} for _, f in ipairs(flags or {}) do table.insert(callArgs, f) end table.insert(callArgs, "reference") -- request an auto-built citation alongside the value table.insert(callArgs, "best") -- single best-ranked value, mirroring the old template's behaviour table.insert(callArgs, property) local ok, result = pcall(Wd._property, callArgs) if ok and result and result ~= "" then return result end return nil end -- Same as getWdProperty, but via Module:Wd's plural "properties" command, -- which joins EVERY matching value together (comma-separated by default) -- instead of just the single best one. Used for government type (P122 -- "basic form of government"), which Wikidata typically records as several -- separate statements on one country (e.g. "unitary state", "parliamentary -- system", "constitutional monarchy") rather than one combined phrase. local function getWdProperties(property, flags) if not wdOK or not Wd or not Wd._properties then return nil end local callArgs = {} for _, f in ipairs(flags or {}) do table.insert(callArgs, f) end table.insert(callArgs, "reference") table.insert(callArgs, property) local ok, result = pcall(Wd._properties, callArgs) if ok and result and result ~= "" then return result end return nil end -- Module:Wd's "linked" flag only produces a wikilink when the entity -- already has a gv sitelink (Config:getLabel returns the bare label, -- un-bracketed, otherwise — see Module:Wd source). For a leader whose -- article doesn't exist on gv.wiki yet, that means no link at all. Since -- an editor should still be able to click through (or see a redlink -- inviting the article to be written), this forces a wikilink around the -- label text when Wd didn't already supply one — without touching a -- trailing auto-built <ref>...</ref> citation, which Wd appends directly -- after the label/link text. local function ensureLinked(value) if not value or value == "" then return value end local label, refSuffix = value:match("^(.-)(<ref.*)$") if not label then label = value refSuffix = "" end if label:find("%[%[") then return value -- already a real link via a gv sitelink end label = mw.text.trim(label) if label == "" then return value end return "[[" .. label .. "]]" .. refSuffix end -- Label of the Wikidata PROPERTY itself (e.g. P35 -> "head of state"), used -- as a Wikidata-sourced fallback for a leader's title when no manual -- title/override is supplied. Deliberately uses getLabelByLang(property, -- "gv") rather than mw.wikibase.label(property): plain label() follows -- Wikidata's language-fallback chain and will happily hand back the -- English label when no Manx one exists (which is the common case for -- properties on Wikidata) — silently leaking English text like "head of -- state" into the Manx infobox. getLabelByLang only returns a value when a -- Manx label genuinely exists, so an untranslated property correctly falls -- through to the hardcoded Manx text below instead. local function getWikidataPropertyLabel(property) local ok, label = pcall(mw.wikibase.getLabelByLang, property, "gv") if ok and label and label ~= "" then return label end return nil end -- Raw QID (no linking/label formatting) of an entity-valued property on the -- CURRENT page's Wikidata item — e.g. P35's value (the head of state person) -- as a bare "Q..." id, so it can be used as the `eid` for a follow-up -- lookup on THAT person's own item (see getWdPositionTitle below). Uses -- Module:Wd's "raw" flag, which for an entity-id-valued statement returns -- the plain id instead of a formatted link/label. local function getWdRawPropertyId(property) if not wdOK or not Wd or not Wd._property then return nil end local ok, result = pcall(Wd._property, {"raw", "best", property}) if ok and result and type(result) == "string" and result:match("^Q%d+$") then return result end return nil end -- Raw QIDs of EVERY value of an entity-valued property on a FOREIGN -- Wikidata item (`eid`), not the current page's — e.g. the leader's own -- P39 ("position held") statements, which a real politician very often has -- several of at once (a parliamentary seat, a party leadership, AND a head- -- of-government office can all be simultaneously "current" -- see -- getWdPositionTitle below for why that matters). Uses Module:Wd's PLURAL -- "properties" command (not "property"), which -- unlike the singular -- command -- does not stop at a single "best" value, so every matching -- claim is returned, joined together; this extracts each "Q..." token from -- that joined string rather than relying on a specific separator, since -- Wd's separator choice isn't part of its documented contract. `eid` is -- passed the same way Module:Wd's own code does internally -- (`p._property{..., [p.args.eid] = id}`). `qualifiers` is an optional -- table of {qualifierPropertyId = requiredValue} pairs -- Module:Wd's -- claimCommand treats any hash key matching "P%d+" as a qualifier filter -- (see its `qualifierIDsAndValues`/`qualifierMatches` logic), letting a -- caller narrow the claims returned to just those with a matching -- qualifier (see getWdPositionTitle below, which uses this for P1001 -- "applies to jurisdiction"). Returns an empty table on any failure. local function getWdRawForeignPropertyIds(eid, property, extraFlags, qualifiers) if not wdOK or not Wd or not Wd._properties or not eid then return {} end local callArgs = {} for _, f in ipairs(extraFlags or {}) do table.insert(callArgs, f) end table.insert(callArgs, "raw") table.insert(callArgs, property) callArgs[Wd.args and Wd.args.eid or "eid"] = eid for qid, value in pairs(qualifiers or {}) do callArgs[qid] = value end local ok, result = pcall(Wd._properties, callArgs) if not ok or not result or type(result) ~= "string" or result == "" then return {} end local ids = {} for id in result:gmatch("Q%d+") do table.insert(ids, id) end return ids end -- The QID of the entity connected to the CURRENT page (e.g. the country the -- article is about), used to disambiguate a multi-realm head of state's P39 -- statements (see getWdPositionTitle below). Returns nil when the current -- page has no connected Wikidata item. local function getCurrentCountryQid() local ok, id = pcall(mw.wikibase.getEntityIdForCurrentPage) if ok and id and id ~= "" then return id end return nil end -- The exact Manx GENITIVE form of the CURRENT PAGE's own country/territory -- -- e.g. "Vannin" for the Isle of Man's own article, "y Reeriaght -- Unnaneysit" for the UK's -- looked up from Module:Enmyn çheerey's shared, -- hand-curated table (see shortManxForm below for how this is used). -- Derived from the current page's own title, which -- for a country/ -- territory article -- IS that country's plain Manx name, the same key -- Module:Enmyn çheerey's table is keyed on. Returns nil when -- Module:Enmyn çheerey isn't available, the current page has no title -- (shouldn't happen in practice), or the lookup itself fails for any reason -- -- all pcall'd defensively so a missing/renamed dependency just falls -- through to shortManxForm's mechanical fallback rungs instead of erroring. local function getCurrentCountryGenitive() if not ennymOK or not EnmynCheerey or not EnmynCheerey.genitive then return nil end local okTitle, title = pcall(function() return mw.title.getCurrentTitle().text end) if not okTitle or not title or title == "" then return nil end local okGen, genitive = pcall(EnmynCheerey.genitive, title) if okGen and genitive and genitive ~= "" then return genitive end return nil end -- Manx country-specific office titles on gv.wiki attach the CURRENT page's -- own country name to a role, in one of two constructions -- e.g. "Monark y -- Reeriaght Unnaneysit" (a "y"/"of the" connector, for longer/multi-word -- country names) or "Ard-hirveishagh Vannin" (the country attached directly, -- often in a mutated genitive form, for shorter ones). Either way, this -- keeps just the leading role word(s) as the link's DISPLAY text while the -- link target stays the full title -- e.g. "[[Monark y Reeriaght -- Unnaneysit|Monark]]", "[[Ard-hirveishagh Vannin|Ard-hirveishagh]]". -- -- Rung 0 (linguistically correct, tried first): Module:Enmyn çheerey already -- keeps a hand-curated table of exactly this -- each country's own Manx -- genitive form, "y "/"yn " prefix (or lack of one) and initial mutation -- included. getCurrentCountryGenitive() above resolves that for the CURRENT -- article's own country; if the office title ends with " " followed by that -- exact genitive form, this strips it with certainty, rather than guessing -- -- and adding a country to that ONE shared table (already documented -- there as extensible) benefits every module that uses it, not just this -- one. -- -- Rungs 1-2 (mechanical fallback, used only when rung 0 doesn't apply -- -- Module:Enmyn çheerey unavailable, or this country/title isn't covered by -- its table yet): detach everything from the first " y " onward (rung 1), -- or, failing that, everything from the LAST remaining space onward (rung -- 2) -- a blind guess that happens to match the real construction in every -- case seen so far, but isn't linguistically guaranteed the way rung 0 is. -- -- A title with no space at all (already just a bare role name, e.g. -- "Ard-whaiyl") falls through every rung unchanged. -- -- Exceptions: full titles that should always be used as-is, unshortened, -- even though they'd otherwise match a rung above -- e.g. "Çhiarn Vannin" -- (Lord of Mann), where stripping " Vannin" would technically be correct per -- Module:Enmyn çheerey's own genitive table, but that's not how this -- specific title should read. Checked before any rung is tried. local shortFormExceptions = { ["Çhiarn Vannin"] = true, } local function shortManxForm(title) if not title or title == "" then return title end if shortFormExceptions[title] then return title end local countryGenitive = getCurrentCountryGenitive() if countryGenitive then local suffix = " " .. countryGenitive if #title > #suffix and title:sub(-#suffix) == suffix then return title:sub(1, #title - #suffix) end end local short = title:match("^(.-)%sy%s") if short and short ~= "" then return short end short = title:match("^(.+)%s%S+$") if short and short ~= "" then return short end return title end -- A conservative cousin of shortManxForm, used ONLY for a PERSON's own name -- (see shortenLinkedCountryName below), never for an office title. A shared -- monarch is the one case where gv.wiki has to disambiguate a PERSON's own -- article per realm the same way office-title items are (e.g. an article -- titled "Çhalse III y Reeriaght Unnaneysit" for the UK's Charles III, -- distinct from his article for another realm) -- so this strips exactly -- that same country-genitive tail when it's genuinely present. Deliberately -- OMITS shortManxForm's rung 2 (blind last-space split): that rung is safe -- for an office title (which always ends in a country reference) but would -- be actively wrong for an ordinary two/three-word person's name with no -- country suffix at all -- e.g. it would mangle "Charse III" into "Charse", -- silently dropping the regnal numeral. Only the two rungs that require a -- genuine, identifiable country-genitive match are used here: Module:Enmyn -- çheerey's exact genitive suffix (rung 0), or an explicit " y " token -- (rung 1) -- both of gv.wiki's known cases ("Çhalse III y Reeriaght -- Unnaneysit", "Louisagh IV y Rank") already contain a literal " y ", so -- rung 1 alone would catch them even without Module:Enmyn çheerey data. local function shortenCountrySuffixedName(name) if not name or name == "" then return name end local countryGenitive = getCurrentCountryGenitive() if countryGenitive then local suffix = " " .. countryGenitive if #name > #suffix and name:sub(-#suffix) == suffix then return name:sub(1, #name - #suffix) end end local short = name:match("^(.-)%sy%s") if short and short ~= "" then return short end return name end -- Shortens the DISPLAY text of the head-of-state's own linked name when -- gv.wiki's article for them is a per-realm-disambiguated one (see -- shortenCountrySuffixedName above) -- e.g. turning the unpiped -- "[[Çhalse III y Reeriaght Unnaneysit]]" Module:Wd hands back (it has -- nothing else to use as display text there) into the piped -- "[[Çhalse III y Reeriaght Unnaneysit|Çhalse III]]", leaving the link -- target and any trailing manual/auto <ref> citation completely untouched. -- Deliberately scoped to the HEAD-OF-STATE slot only (see its call site in -- p.main) rather than a general-purpose name formatter: an ordinary head of -- government is never the same person across several countries, so their -- own gv article is never disambiguated this way in the first place -- -- structurally, only a shared monarch produces this shape of data at all, -- which is what "condition this on the head of state being a monarch" -- comes down to in practice, without a separate Wikidata lookup to confirm -- it. Only fires on a bare, unpiped "[[target]]" link with no existing -- custom display text (i.e. nothing this module or Wd itself already chose -- to show instead) -- a name that's already piped, or has no country suffix -- to strip at all, is returned completely unchanged. -- Handles BOTH a bare "[[target]]" link and an already-piped "[[target| -- display]]" one, shortening whichever text is CURRENTLY being displayed -- -- not just the bare-unpiped case. This is deliberately more permissive than -- checking only for an unpiped link: Module:Wd's own buildWikilink normally -- produces the unpiped form specifically when the Wikidata label and the gv -- sitelink title are identical, but relying on that always holding (rather -- than on what's actually visible to the reader) is exactly the kind of -- assumption that can quietly stop matching if Wd's output shape ever -- differs even slightly -- e.g. a piped link whose display text still -- happens to be the full disambiguated title. Working from whatever text is -- actually displayed, rather than assuming it must be unpiped, is more -- robust either way. local function shortenLinkedCountryName(value) if not value or value == "" then return value end local main, refSuffix = value:match("^(.-)(<ref.*)$") if not main then main = value refSuffix = "" end local target, display = main:match("^%[%[([^%[%]|]+)|([^%[%]|]+)%]%]$") if not target then target = main:match("^%[%[([^%[%]|]+)%]%]$") display = target end if not target then return value end local short = shortenCountrySuffixedName(display) if short ~= display then return "[[" .. target .. "|" .. short .. "]]" .. refSuffix end return value end -- Capitalizes the first letter the way the wiki itself would (respecting -- Manx-specific case folding, e.g. digraphs like "çh"), via the content -- language object's own ucfirst -- NOT a plain Lua upper() on byte 1, which -- would mangle multi-byte UTF-8 and wouldn't match gv.wiki's own title- -- capitalization rules. Needed because a raw Wikidata LABEL (unlike a real -- page title/sitelink) is conventionally stored all-lowercase (e.g. -- "monark"), but both a link's display text and a red-linked target should -- read the way an actual Manx Wikipedia article title would. local function wikiUcfirst(text) if not text or text == "" then return text end local ok, result = pcall(function() return mw.language.getContentLanguage():ucfirst(text) end) if ok and result and result ~= "" then return result end return text end -- Given a Wikidata item ID for a specific office/position (e.g. "King of -- the United Kingdom"), build a wikilink using the gv sitelink (when one -- exists) or, failing that, a verified gv LABEL as the link target -- ALWAYS -- as a real wikilink, even when that means a redlink inviting the article to -- be written (per explicit instruction: an unlinked office title is -- indistinguishable from an unsourced one, same reasoning as ensureLinked() -- above for leader names). The display text has the "y <country>" tail -- detached (see shortManxForm above), e.g. "[[Monark y Reeriaght -- Unnaneysit|Monark]]". Never uses mw.wikibase.label's English-fallback- -- prone version -- same leak this module already had to fix once for -- property labels. Returns nil only when NEITHER a sitelink nor a gv label -- exists at all, so callers fall through to the generic hardcoded Manx text. local function getWdItemManxLink(qid) if not qid then return nil end local okSite, sitelinkTitle = pcall(mw.wikibase.sitelink, qid) if not okSite then sitelinkTitle = nil end local title = (sitelinkTitle and sitelinkTitle ~= "") and sitelinkTitle or nil if not title then local okLabel, gvLabel = pcall(mw.wikibase.getLabelByLang, qid, "gv") if okLabel and gvLabel and gvLabel ~= "" then -- Wikidata labels are conventionally lowercase; capitalize so the -- redlink reads (and will resolve/redirect) like a real title. title = wikiUcfirst(gvLabel) end end if not title then return nil end local short = shortManxForm(title) if short ~= title then return "[[" .. title .. "|" .. short .. "]]" end return "[[" .. title .. "]]" end -- Wikidata has two properties made specifically to solve this exact office- -- title problem, set directly on the COUNTRY's own item rather than on the -- office-holder: P1906 "office held by head of state" and P1313 "office held -- by head of government" (these two IDs are easy to transpose -- there's no -- mnemonic pattern distinguishing them -- and an earlier version of this -- module had them backwards; double-checked against wikidata.org's own -- property pages before fixing). Their value is the generic OFFICE item itself -- (e.g. "Chief Minister of the Isle of Man" / "Ard-hirveishagh Vannin") -- -- not a person, and not one of several roles a particular office-holder -- happens to hold right now. When a country's item has this property set, -- it sidesteps the multi-role-P39 ambiguity entirely (see getWdPositionTitle -- below): there's no need to guess which of a person's several concurrent -- "position held" statements is the right one, because Wikidata already -- names the office directly. Tried FIRST, before the person-chain fallback. local function getWdOfficeItemTitle(officeProperty) local officeQid = getWdRawPropertyId(officeProperty) if not officeQid then return nil end return getWdItemManxLink(officeQid) end -- FALLBACK ONLY (see getWdOfficeItemTitle above, tried first): the leader's -- own specific office title (e.g. "Monark y Reeriaght Unnaneysit" / -- "Ard-vinishter y Reeriaght Unnaneysit"), NOT the generic property -- description ("head of state"/"kione steat"), derived by chaining through -- the CURRENT OFFICE-HOLDER instead of a dedicated country-level property -- -- used only for a country whose Wikidata item doesn't have P1313/P1906 set. -- Wikidata attaches the country-specific title to the position-HOLDER's own -- "position held" (P39) statement, not to the country's P35/P6 statement — -- so this chains through the person: P35/P6 -> person's raw QID -> that -- person's current P39 value -> a Manx link/label for it. -- -- A head of state/government very often holds MULTIPLE simultaneous "current" -- P39 positions -- not just the classic shared-monarch case ("King of the -- United Kingdom", "King of Canada", "King of Australia", ... all current at -- once), but just as commonly a head of government who is ALSO, right now, a -- sitting member of their legislature AND the leader of their party. A brand -- new statement (e.g. someone who became PM only weeks ago) frequently has -- NO qualifier at all yet distinguishing "this is the state office" from -- "this is the party/parliamentary one" -- P1001 ("applies to jurisdiction") -- is the qualifier Wikidata uses for the shared-monarch case specifically, -- but isn't reliably present on every fresh statement, so it can't be -- trusted as the only signal. -- -- So rather than committing to a single "best" P39 value (which could just -- as easily be "Member of Parliament for ..." or "Leader of the ... Party" -- as the actual head-of-government office), this collects EVERY current P39 -- candidate -- ones matching a P1001 filter for this article's own country -- first (when the data has that qualifier, which correctly resolves a -- shared monarch to the right realm), then every other current candidate -- -- and tries each in turn, using the FIRST one that actually resolves to a -- real Manx sitelink or label via getWdItemManxLink. In practice an -- ancillary role (a parliamentary seat, a party leadership) is very unlikely -- to have a dedicated gv.wiki article of its own, while the formal head-of- -- state/government office is exactly the kind of article gv.wiki is likely -- to have -- so this reliably lands on the right one without needing -- Wikidata's qualifiers to be perfectly curated. -- -- Returns nil only when NONE of the current P39 candidates resolves to -- anything on gv.wiki (or Module:Wd is unavailable, or there's no current -- P39 at all), so callers fall back to the property-label / hardcoded rungs -- below. local function getWdPositionTitle(headProperty) local personQid = getWdRawPropertyId(headProperty) if not personQid then return nil end local countryQid = getCurrentCountryQid() local candidates = {} if countryQid then for _, id in ipairs(getWdRawForeignPropertyIds(personQid, "P39", {"current"}, {["P1001"] = countryQid})) do table.insert(candidates, id) end end for _, id in ipairs(getWdRawForeignPropertyIds(personQid, "P39", {"current"})) do table.insert(candidates, id) end local tried = {} for _, qid in ipairs(candidates) do if not tried[qid] then tried[qid] = true local link = getWdItemManxLink(qid) if link then return link end end end return nil end -- Row templates. Every row in this table is a plain 2-cell -- `<th>label</th><td>value</td>` row — exactly the grid every OTHER -- submodule in this system uses (Module:Kishtey fys çheer/çhengaghyn, -- /balley, /bratteeyn). The old HTML template used a 3-column grid instead -- (a narrow indent-spacer <td>, a label <td>, a value <td>, with -- colspan="2"/colspan="3" on label-only/header rows) — mixing that 3-column -- convention into a 2-column table was the actual cause of the reported -- "bunching"/"enormous gap" distortion: rows with different physical cell -- counts in the same table force the browser to reconcile column widths -- unpredictably. Sub-items (individual leaders/houses/founding events under -- one shared label) are distinguished with a "•" bullet + reduced font -- weight on the label cell instead of a separate spacer column — matching -- how English Wikipedia's infobox marks up a list of leaders under one -- "Leader" heading. local ROW = '<tr%s><th style="vertical-align:top; white-space:nowrap; text-align:left; font-weight:bold;">%s</th><td style="vertical-align:top;">%s</td></tr>' local SUBROW = '<tr%s><th style="vertical-align:top; white-space:nowrap; text-align:left; font-weight:normal; padding-left:0.5em;">•&nbsp;%s</th><td style="vertical-align:top;">%s</td></tr>' local HEADER = '<tr class="mergedtoprow"><th colspan="2" style="text-align:left;">%s</th></tr>' -- Builds a `class="..."` attribute (or an empty string), for the -- mergedrow/mergedbottomrow/mergedtoprow classes the old template uses to -- remove the double border between a header/label row and the indented -- sub-rows that visually belong under it. local function trClass(name) if name and name ~= "" then return ' class="' .. name .. '"' end return "" end -- Formats a run of bullet-prefixed sub-rows (leader pairs, house names, -- establishment events, ...) with the old template's merged-border -- convention: every row but the last is "mergedrow", the last is -- "mergedbottomrow" — so the whole run reads as one visually joined block -- under its header/label row. local function appendIndentRun(rows, items) for idx, item in ipairs(items) do local class = (idx == #items) and "mergedbottomrow" or "mergedrow" table.insert(rows, string.format(SUBROW, trClass(class), item[1], item[2])) end end -- Same divider the dispatcher module (Module:Kishtey fys çheer) uses BETWEEN -- whole submodules (see its own `dividerLine`/`appendModule`). Reused here, -- identically, to separate this module's own three internal sections -- (leaders/government, legislature, founding) the same visual way -- a -- divider is only inserted BETWEEN two sections that both actually produced -- rows, never before the first section or after the last, and never next to -- an empty/suppressed section (mirrors appendModule's own conditional). local dividerLine = '<tr><td colspan="2" style="border-top:1px solid #a2a9b1; padding:0; height:0px;"></td></tr>' local function appendSection(rows, sectionRows) if sectionRows and #sectionRows > 0 then if #rows > 0 then table.insert(rows, dividerLine) end for _, row in ipairs(sectionRows) do table.insert(rows, row) end end end function p.main(frame, args) -- Fallback verification to catch argument slots accurately if frame context shifts if not args then args = frame frame = mw.getCurrentFrame() end local rows = {} local govRows = {} local quaiylRows = {} local foundingRows = {} ---------------------------------------------------------------- -- 1-2. REILTYS (Government type) + FIR HOSHEE / TOSHEE (Leaders: -- head of state / head of government / etc.) -- `enmysN_fer-toshee` / `ennymN_fer-toshee` are the old, gendered -- param names, kept for backward compatibility with existing -- articles. `enmys_toshiaghN` / `ennym_toshiaghN` are the -- gender-neutral synonyms going forward ("toshiagh" = leader); -- either spelling works, and the new one takes priority when both -- are supplied for the same slot. Leaders are computed BEFORE the -- government-type row is emitted so that row can carry the right -- merged-border class when leader rows are going to follow it. ---------------------------------------------------------------- local govTypeRaw = getManual(args, {"sorçh_reiltys", "government_type"}) local govRef = getManual(args, {"imraa_reiltys"}) local govNote = getManual(args, {"noteyn_reiltys"}) if not govTypeRaw then -- Wikidata fallback via Module:Wd: basic form of government (P122), -- e.g. "unitary state, parliamentary system, constitutional -- monarchy" -- joins every value Wikidata records rather than just -- one, since this is normally split across several statements. -- Skipped entirely when the field was explicitly suppressed -- (`|sorçh_reiltys=none`), same as every other Wikidata-fallback -- field in this module. govTypeRaw = getWdProperties("P122", {"linked"}) end local govShown = govTypeRaw and not isNone(govTypeRaw) local leaderPairs = {} local manualLeaderGiven = false for i = 1, 5 do local title = getManual(args, {"enmys_toshiagh" .. i, "enmys" .. i .. "_fer-toshee"}) local name = getManual(args, {"ennym_toshiagh" .. i, "ennym" .. i .. "_fer-toshee"}) if title or name then manualLeaderGiven = true if not isNone(name) then table.insert(leaderPairs, {title = title or "", name = name or ""}) end end end local leaderRef = getManual(args, {"imraa_toshiagh", "imraa_fer-toshee"}) local leaderNote = getManual(args, {"noteyn_toshiagh", "noteyn_fer-toshee"}) local leadersSuppressed = isNone(getManual(args, {"fir_hoshee", "toshiaghyn"})) if not manualLeaderGiven and not leadersSuppressed then -- Wikidata fallback via Module:Wd: head of state (P35) / head of -- government (P6). Names are ALWAYS forced into a link (a redlink -- when gv.wiki has no article for that person yet) via -- ensureLinked, since an unlinked plain name is easy to mistake for -- a manual/unsourced value and gives editors nothing to click -- through to create the article. Titles try, in order: a manual -- override, the leader's own country-specific office (e.g. "Monark -- y Reeriaght Unnaneysit"), the Wikidata property's own label, then -- a hardcoded Manx fallback. local hos = shortenLinkedCountryName(ensureLinked(getWdProperty("P35", {"linked"}))) local hog = ensureLinked(getWdProperty("P6", {"linked"})) if hos then local hosTitle = getManual(args, {"sorçh_kione_steat"}) or getWdOfficeItemTitle("P1906") -- "office held by head of state" -- set directly on the country, no person-level ambiguity or getWdPositionTitle("P35") or getWikidataPropertyLabel("P35") or "Kione steat" table.insert(leaderPairs, {title = hosTitle, name = hos}) end if hog then local hogTitle = getManual(args, {"sorçh_kione_reiltys"}) or getWdOfficeItemTitle("P1313") -- "office held by head of government" -- same reasoning as P1906 above or getWdPositionTitle("P6") or getWikidataPropertyLabel("P6") or "Kione reiltys" table.insert(leaderPairs, {title = hogTitle, name = hog}) end end if govShown then local govClass = (#leaderPairs > 0) and "mergedtoprow" or "" table.insert(govRows, string.format(ROW, trClass(govClass), "[[Reiltys]]", applyRefNote(govTypeRaw, govRef, govNote, frame))) elseif #leaderPairs > 0 then table.insert(govRows, string.format(HEADER, "[[Reiltys]]")) end if #leaderPairs > 0 then -- The shared manual ref/note for the whole leaders block is -- attached to the last row, same convention as a single footnote -- covering a list. (A Wikidata-sourced name already carries its own -- auto-built citation from getWdProperty.) local last = leaderPairs[#leaderPairs] last.name = applyRefNote(last.name, leaderRef, leaderNote, frame) local items = {} for _, leader in ipairs(leaderPairs) do table.insert(items, {leader.title, leader.name}) end appendIndentRun(govRows, items) end ---------------------------------------------------------------- -- 3. QUAIYL / ÇHIONNAL (Legislature) -- `çhionnal` is a synonym for `quaiyl`; `thie_heose` / `thie_heese` -- are synonyms for `quaiyl_syrjey` / `quaiyl_s'inshley` (upper / -- lower house). New spellings take priority when both are given. ---------------------------------------------------------------- local quaiyl = getManual(args, {"çhionnal", "quaiyl"}) local quaiylSyrjey = getManual(args, {"thie_heose", "quaiyl_syrjey"}) local quaiylInshley = getManual(args, {"thie_heese", "quaiyl_s'inshley", "quaiyl_sinshley"}) local quaiylRef = getManual(args, {"imraa_çhionnal", "imraa_quaiyl"}) local quaiylNote = getManual(args, {"noteyn_çhionnal", "noteyn_quaiyl"}) if not quaiyl and not quaiylSyrjey and not quaiylInshley then -- "short" asks Module:Wd for the item's short name (Wikidata -- P1813) first, e.g. "Parliament" instead of the full official -- "Parliament of the United Kingdom of Great Britain and Northern -- Ireland" -- matching enwiki's own concise style. Falls back to -- the item's normal label when no short name is set. quaiyl = getWdProperty("P194", {"linked", "short"}) end if quaiyl and not isNone(quaiyl) then local houseItems = {} if quaiylSyrjey and not isNone(quaiylSyrjey) then table.insert(houseItems, {"[[Thie heose]]", quaiylSyrjey}) end if quaiylInshley and not isNone(quaiylInshley) then table.insert(houseItems, {"[[Thie heese]]", quaiylInshley}) end local quaiylClass = (#houseItems > 0) and "mergedtoprow" or "" table.insert(quaiylRows, string.format(ROW, trClass(quaiylClass), "[[Çhionnal slattyssagh]]", applyRefNote(quaiyl, quaiylRef, quaiylNote, frame))) appendIndentRun(quaiylRows, houseItems) end ---------------------------------------------------------------- -- 4. BUNNEEAGHT / KIONDEEAGHT (Founding / constitution) and -- historical establishment events — manual-only, ported -- directly from the old template's numbered slots (1-9). -- `kionedeeaght` is a synonym for `kiondeeaght` in the label/note -- param names. ---------------------------------------------------------------- local foundingLabel = getManual(args, {"sorçh_kionedeeaght", "sorçh_kiondeeaght"}) or "Bunneeaght" local foundingValue = getManual(args, {"bunnit"}) local foundingNote = getManual(args, {"note_kionedeeaght", "note_kiondeeaght"}) local foundingRef = getManual(args, {"imraa_kionedeeaght", "imraa_kiondeeaght"}) local establishmentRows = {} for i = 1, 9 do local event = getManual(args, {"taghyrt" .. i .. "_bunnit"}) local date = getManual(args, {"date" .. i .. "_bunnit"}) if event then table.insert(establishmentRows, {event, date or ""}) end end if foundingValue or #establishmentRows > 0 then if foundingValue and not isNone(foundingValue) then local foundingClass = (#establishmentRows > 0) and "mergedtoprow" or "" table.insert(foundingRows, string.format(ROW, trClass(foundingClass), "[[" .. foundingLabel .. "]]", applyRefNote(foundingValue, foundingRef, foundingNote, frame))) elseif #establishmentRows > 0 then table.insert(foundingRows, string.format(HEADER, "[[" .. foundingLabel .. "]]")) end appendIndentRun(foundingRows, establishmentRows) elseif not isNone(getManual(args, {"bunnit"})) then -- Wikidata fallback via Module:Wd: inception (P571) — only when the -- whole establishment block was left unset (not explicitly |bunnit=none). -- NOTE on date precision: Module:Wd's own time-value formatting (see -- Config:getValue's `datatype == 'time'` branch) already renders a -- FULL day-month-year date whenever the underlying Wikidata statement -- itself is stored at day precision -- there is no flag this call is -- missing, and no truncation happens on our side (confirmed by the -- test harness, which feeds a day-precision value straight through -- unchanged). When only a year is shown on a real article, that is -- because THAT COUNTRY's P571 statement on Wikidata itself is only -- recorded at year precision (very common for older founding dates) -- -- not a bug here. The manual |bunnit= override remains the fix for -- any article where the Wikidata precision isn't good enough. local inception = getWdProperty("P571") if inception then table.insert(foundingRows, string.format(ROW, "", "[[" .. foundingLabel .. "]]", applyRefNote(inception, foundingRef, foundingNote, frame))) end end appendSection(rows, govRows) appendSection(rows, quaiylRows) appendSection(rows, foundingRows) if #rows == 0 then return nil end return table.concat(rows) end return p rszjkl9vr3huwsu45oxj77ezixsm6cd 393006 393004 2026-09-10T02:33:44Z MacTire02 219 ++ 393006 Scribunto text/plain local p = {} -- Module:Wd is gv.wiki's actual working Wikidata-fetch-and-cite module -- (confirmed by its localized /i18n submodule) — used instead of -- Module:WikidataIB, which has no working reference-building of its own. -- pcall so a wiki state where Wd (or its own Module:Wd/i18n) isn't set up -- degrades to "no Wikidata fallback" instead of breaking the infobox. local wdOK, Wd = pcall(require, "Module:Wd") -- Module:Ennym çheerey ("country names") already keeps a hand-curated table -- of each country's own Manx GENITIVE/mutated form (e.g. "Mannin" -> -- "Vannin", "Nalbin" -> "ny h-Albey", "Yn Reeriaght Unnaneysit" -> "y -- Reeriaght Unnaneysit") -- exactly the linguistic knowledge shortManxForm -- below otherwise has to guess at mechanically (see getCurrentCountryGenitive -- and shortManxForm further down for how this is used). pcall so a wiki -- state where this module isn't available degrades to the purely mechanical -- fallback instead of breaking the infobox. local ennymOK, EnnymCheerey = pcall(require, "Module:Ennym çheerey") -- Module:Kishtey fys çheer/ennym-wd -- the shared "Manx label, with a -- linked-to-Wikidata non-Manx fallback" helper (see its own header comment -- for the full three-tier rationale). Used as the LAST rung in -- getWdItemManxLink below, only once a genuine Manx sitelink/label has -- already been checked for and not found. pcall'd for the same reason as -- the two requires above: a wiki state missing this submodule just means -- this particular fallback rung is unavailable, not a broken infobox. local ennymWdOK, EnnymWd = pcall(require, "Module:Kishtey fys çheer/ennym-wd") -- Safely get manual parameters from priority list local function getManual(args, names) for _, name in ipairs(names) do local value = args[name] if value and mw.text.trim(value) ~= "" then return mw.text.trim(value) end end return nil end local function isNone(value) return value ~= nil and mw.text.trim(value):lower() == "none" end -- Append a manual reference (<ref>) and/or note ({{efn}}) to a value. This -- is the manual imraa_*/noteyn_* channel, same as Module:Kishtey fys -- çheer/çhengaghyn uses. It layers on top of a Wikidata-sourced value too -- (which already carries its own auto-built citation from getWdProperty -- below) in case an editor wants to add an extra citation or clarifying -- footnote of their own. local function applyRefNote(value, ref, note, frame) if not value then return value end if note and note ~= "" and frame then value = value .. frame:expandTemplate{ title = "efn", args = { note } } end if ref and ref ~= "" then value = value .. "<ref>" .. ref .. "</ref>" end return value end -- Fetch+format a single Wikidata property value via Module:Wd's "property" -- command, combined with its "reference" command so that, when the -- Wikidata statement itself carries references, Wd builds a real <ref> -- citation (Cite web / Cite Q) from them automatically — the same way -- gv.wiki's other Wd-based infoboxes already cite Wikidata data. `flags` -- is an optional array of extra Wd flags (e.g. {"linked"}). Returns nil -- when Wd isn't available, or the property has no value. local function getWdProperty(property, flags) if not wdOK or not Wd or not Wd._property then return nil end local callArgs = {} for _, f in ipairs(flags or {}) do table.insert(callArgs, f) end table.insert(callArgs, "reference") -- request an auto-built citation alongside the value table.insert(callArgs, "best") -- single best-ranked value, mirroring the old template's behaviour table.insert(callArgs, property) local ok, result = pcall(Wd._property, callArgs) if ok and result and result ~= "" then return result end return nil end -- Same as getWdProperty, but via Module:Wd's plural "properties" command, -- which joins EVERY matching value together (comma-separated by default) -- instead of just the single best one. Used for government type (P122 -- "basic form of government"), which Wikidata typically records as several -- separate statements on one country (e.g. "unitary state", "parliamentary -- system", "constitutional monarchy") rather than one combined phrase. local function getWdProperties(property, flags) if not wdOK or not Wd or not Wd._properties then return nil end local callArgs = {} for _, f in ipairs(flags or {}) do table.insert(callArgs, f) end table.insert(callArgs, "reference") table.insert(callArgs, property) local ok, result = pcall(Wd._properties, callArgs) if ok and result and result ~= "" then return result end return nil end -- Module:Wd's "linked" flag only produces a wikilink when the entity -- already has a gv sitelink (Config:getLabel returns the bare label, -- un-bracketed, otherwise — see Module:Wd source). For a leader whose -- article doesn't exist on gv.wiki yet, that means no link at all. Since -- an editor should still be able to click through (or see a redlink -- inviting the article to be written), this forces a wikilink around the -- label text when Wd didn't already supply one — without touching a -- trailing auto-built <ref>...</ref> citation, which Wd appends directly -- after the label/link text. local function ensureLinked(value) if not value or value == "" then return value end local label, refSuffix = value:match("^(.-)(<ref.*)$") if not label then label = value refSuffix = "" end if label:find("%[%[") then return value -- already a real link via a gv sitelink end label = mw.text.trim(label) if label == "" then return value end return "[[" .. label .. "]]" .. refSuffix end -- Label of the Wikidata PROPERTY itself (e.g. P35 -> "head of state"), used -- as a Wikidata-sourced fallback for a leader's title when no manual -- title/override is supplied. Deliberately uses getLabelByLang(property, -- "gv") rather than mw.wikibase.label(property): plain label() follows -- Wikidata's language-fallback chain and will happily hand back the -- English label when no Manx one exists (which is the common case for -- properties on Wikidata) — silently leaking English text like "head of -- state" into the Manx infobox. getLabelByLang only returns a value when a -- Manx label genuinely exists, so an untranslated property correctly falls -- through to the hardcoded Manx text below instead. local function getWikidataPropertyLabel(property) local ok, label = pcall(mw.wikibase.getLabelByLang, property, "gv") if ok and label and label ~= "" then return label end return nil end -- Raw QID (no linking/label formatting) of an entity-valued property on the -- CURRENT page's Wikidata item — e.g. P35's value (the head of state person) -- as a bare "Q..." id, so it can be used as the `eid` for a follow-up -- lookup on THAT person's own item (see getWdPositionTitle below). Uses -- Module:Wd's "raw" flag, which for an entity-id-valued statement returns -- the plain id instead of a formatted link/label. local function getWdRawPropertyId(property) if not wdOK or not Wd or not Wd._property then return nil end local ok, result = pcall(Wd._property, {"raw", "best", property}) if ok and result and type(result) == "string" and result:match("^Q%d+$") then return result end return nil end -- Raw QIDs of EVERY value of an entity-valued property on a FOREIGN -- Wikidata item (`eid`), not the current page's — e.g. the leader's own -- P39 ("position held") statements, which a real politician very often has -- several of at once (a parliamentary seat, a party leadership, AND a head- -- of-government office can all be simultaneously "current" -- see -- getWdPositionTitle below for why that matters). Uses Module:Wd's PLURAL -- "properties" command (not "property"), which -- unlike the singular -- command -- does not stop at a single "best" value, so every matching -- claim is returned, joined together; this extracts each "Q..." token from -- that joined string rather than relying on a specific separator, since -- Wd's separator choice isn't part of its documented contract. `eid` is -- passed the same way Module:Wd's own code does internally -- (`p._property{..., [p.args.eid] = id}`). `qualifiers` is an optional -- table of {qualifierPropertyId = requiredValue} pairs -- Module:Wd's -- claimCommand treats any hash key matching "P%d+" as a qualifier filter -- (see its `qualifierIDsAndValues`/`qualifierMatches` logic), letting a -- caller narrow the claims returned to just those with a matching -- qualifier (see getWdPositionTitle below, which uses this for P1001 -- "applies to jurisdiction"). Returns an empty table on any failure. local function getWdRawForeignPropertyIds(eid, property, extraFlags, qualifiers) if not wdOK or not Wd or not Wd._properties or not eid then return {} end local callArgs = {} for _, f in ipairs(extraFlags or {}) do table.insert(callArgs, f) end table.insert(callArgs, "raw") table.insert(callArgs, property) callArgs[Wd.args and Wd.args.eid or "eid"] = eid for qid, value in pairs(qualifiers or {}) do callArgs[qid] = value end local ok, result = pcall(Wd._properties, callArgs) if not ok or not result or type(result) ~= "string" or result == "" then return {} end local ids = {} for id in result:gmatch("Q%d+") do table.insert(ids, id) end return ids end -- The QID of the entity connected to the CURRENT page (e.g. the country the -- article is about), used to disambiguate a multi-realm head of state's P39 -- statements (see getWdPositionTitle below). Returns nil when the current -- page has no connected Wikidata item. local function getCurrentCountryQid() local ok, id = pcall(mw.wikibase.getEntityIdForCurrentPage) if ok and id and id ~= "" then return id end return nil end -- The exact Manx GENITIVE form of the CURRENT PAGE's own country/territory -- -- e.g. "Vannin" for the Isle of Man's own article, "y Reeriaght -- Unnaneysit" for the UK's -- looked up from Module:Ennym çheerey's shared, -- hand-curated table (see shortManxForm below for how this is used). -- Derived from the current page's own title, which -- for a country/ -- territory article -- IS that country's plain Manx name, the same key -- Module:Ennym çheerey's table is keyed on. Returns nil when -- Module:Ennym çheerey isn't available, the current page has no title -- (shouldn't happen in practice), or the lookup itself fails for any reason -- -- all pcall'd defensively so a missing/renamed dependency just falls -- through to shortManxForm's mechanical fallback rungs instead of erroring. local function getCurrentCountryGenitive() if not ennymOK or not EnnymCheerey or not EnnymCheerey.genitive then return nil end local okTitle, title = pcall(function() return mw.title.getCurrentTitle().text end) if not okTitle or not title or title == "" then return nil end local okGen, genitive = pcall(EnnymCheerey.genitive, title) if okGen and genitive and genitive ~= "" then return genitive end return nil end -- Manx country-specific office titles on gv.wiki attach the CURRENT page's -- own country name to a role, in one of two constructions -- e.g. "Monark y -- Reeriaght Unnaneysit" (a "y"/"of the" connector, for longer/multi-word -- country names) or "Ard-hirveishagh Vannin" (the country attached directly, -- often in a mutated genitive form, for shorter ones). Either way, this -- keeps just the leading role word(s) as the link's DISPLAY text while the -- link target stays the full title -- e.g. "[[Monark y Reeriaght -- Unnaneysit|Monark]]", "[[Ard-hirveishagh Vannin|Ard-hirveishagh]]". -- -- Rung 0 (linguistically correct, tried first): Module:Ennym çheerey already -- keeps a hand-curated table of exactly this -- each country's own Manx -- genitive form, "y "/"yn " prefix (or lack of one) and initial mutation -- included. getCurrentCountryGenitive() above resolves that for the CURRENT -- article's own country; if the office title ends with " " followed by that -- exact genitive form, this strips it with certainty, rather than guessing -- -- and adding a country to that ONE shared table (already documented -- there as extensible) benefits every module that uses it, not just this -- one. -- -- Rungs 1-2 (mechanical fallback, used only when rung 0 doesn't apply -- -- Module:Ennym çheerey unavailable, or this country/title isn't covered by -- its table yet): detach everything from the first " y " onward (rung 1), -- or, failing that, everything from the LAST remaining space onward (rung -- 2) -- a blind guess that happens to match the real construction in every -- case seen so far, but isn't linguistically guaranteed the way rung 0 is. -- -- A title with no space at all (already just a bare role name, e.g. -- "Ard-whaiyl") falls through every rung unchanged. -- -- Exceptions: full titles that should always be used as-is, unshortened, -- even though they'd otherwise match a rung above -- e.g. "Çhiarn Vannin" -- (Lord of Mann), where stripping " Vannin" would technically be correct per -- Module:Ennym çheerey's own genitive table, but that's not how this -- specific title should read. Checked before any rung is tried. local shortFormExceptions = { ["Çhiarn Vannin"] = true, } local function shortManxForm(title) if not title or title == "" then return title end if shortFormExceptions[title] then return title end local countryGenitive = getCurrentCountryGenitive() if countryGenitive then local suffix = " " .. countryGenitive if #title > #suffix and title:sub(-#suffix) == suffix then return title:sub(1, #title - #suffix) end end local short = title:match("^(.-)%sy%s") if short and short ~= "" then return short end short = title:match("^(.+)%s%S+$") if short and short ~= "" then return short end return title end -- A conservative cousin of shortManxForm, used ONLY for a PERSON's own name -- (see shortenLinkedCountryName below), never for an office title. A shared -- monarch is the one case where gv.wiki has to disambiguate a PERSON's own -- article per realm the same way office-title items are (e.g. an article -- titled "Çhalse III y Reeriaght Unnaneysit" for the UK's Charles III, -- distinct from his article for another realm) -- so this strips exactly -- that same country-genitive tail when it's genuinely present. Deliberately -- OMITS shortManxForm's rung 2 (blind last-space split): that rung is safe -- for an office title (which always ends in a country reference) but would -- be actively wrong for an ordinary two/three-word person's name with no -- country suffix at all -- e.g. it would mangle "Charse III" into "Charse", -- silently dropping the regnal numeral. Only the two rungs that require a -- genuine, identifiable country-genitive match are used here: Module:Ennym -- çheerey's exact genitive suffix (rung 0), or an explicit " y " token -- (rung 1) -- both of gv.wiki's known cases ("Çhalse III y Reeriaght -- Unnaneysit", "Louisagh IV y Rank") already contain a literal " y ", so -- rung 1 alone would catch them even without Module:Ennym çheerey data. local function shortenCountrySuffixedName(name) if not name or name == "" then return name end local countryGenitive = getCurrentCountryGenitive() if countryGenitive then local suffix = " " .. countryGenitive if #name > #suffix and name:sub(-#suffix) == suffix then return name:sub(1, #name - #suffix) end end local short = name:match("^(.-)%sy%s") if short and short ~= "" then return short end return name end -- Shortens the DISPLAY text of the head-of-state's own linked name when -- gv.wiki's article for them is a per-realm-disambiguated one (see -- shortenCountrySuffixedName above) -- e.g. turning the unpiped -- "[[Çhalse III y Reeriaght Unnaneysit]]" Module:Wd hands back (it has -- nothing else to use as display text there) into the piped -- "[[Çhalse III y Reeriaght Unnaneysit|Çhalse III]]", leaving the link -- target and any trailing manual/auto <ref> citation completely untouched. -- Deliberately scoped to the HEAD-OF-STATE slot only (see its call site in -- p.main) rather than a general-purpose name formatter: an ordinary head of -- government is never the same person across several countries, so their -- own gv article is never disambiguated this way in the first place -- -- structurally, only a shared monarch produces this shape of data at all, -- which is what "condition this on the head of state being a monarch" -- comes down to in practice, without a separate Wikidata lookup to confirm -- it. Only fires on a bare, unpiped "[[target]]" link with no existing -- custom display text (i.e. nothing this module or Wd itself already chose -- to show instead) -- a name that's already piped, or has no country suffix -- to strip at all, is returned completely unchanged. -- Handles BOTH a bare "[[target]]" link and an already-piped "[[target| -- display]]" one, shortening whichever text is CURRENTLY being displayed -- -- not just the bare-unpiped case. This is deliberately more permissive than -- checking only for an unpiped link: Module:Wd's own buildWikilink normally -- produces the unpiped form specifically when the Wikidata label and the gv -- sitelink title are identical, but relying on that always holding (rather -- than on what's actually visible to the reader) is exactly the kind of -- assumption that can quietly stop matching if Wd's output shape ever -- differs even slightly -- e.g. a piped link whose display text still -- happens to be the full disambiguated title. Working from whatever text is -- actually displayed, rather than assuming it must be unpiped, is more -- robust either way. local function shortenLinkedCountryName(value) if not value or value == "" then return value end local main, refSuffix = value:match("^(.-)(<ref.*)$") if not main then main = value refSuffix = "" end local target, display = main:match("^%[%[([^%[%]|]+)|([^%[%]|]+)%]%]$") if not target then target = main:match("^%[%[([^%[%]|]+)%]%]$") display = target end if not target then return value end local short = shortenCountrySuffixedName(display) if short ~= display then return "[[" .. target .. "|" .. short .. "]]" .. refSuffix end return value end -- Capitalizes the first letter the way the wiki itself would (respecting -- Manx-specific case folding, e.g. digraphs like "çh"), via the content -- language object's own ucfirst -- NOT a plain Lua upper() on byte 1, which -- would mangle multi-byte UTF-8 and wouldn't match gv.wiki's own title- -- capitalization rules. Needed because a raw Wikidata LABEL (unlike a real -- page title/sitelink) is conventionally stored all-lowercase (e.g. -- "monark"), but both a link's display text and a red-linked target should -- read the way an actual Manx Wikipedia article title would. local function wikiUcfirst(text) if not text or text == "" then return text end local ok, result = pcall(function() return mw.language.getContentLanguage():ucfirst(text) end) if ok and result and result ~= "" then return result end return text end -- Given a Wikidata item ID for a specific office/position (e.g. "King of -- the United Kingdom"), build a wikilink using the gv sitelink (when one -- exists) or, failing that, a verified gv LABEL as the link target -- ALWAYS -- as a real wikilink, even when that means a redlink inviting the article to -- be written (per explicit instruction: an unlinked office title is -- indistinguishable from an unsourced one, same reasoning as ensureLinked() -- above for leader names). The display text has the "y <country>" tail -- detached (see shortManxForm above), e.g. "[[Monark y Reeriaght -- Unnaneysit|Monark]]". Never uses mw.wikibase.label's English-fallback- -- prone version -- same leak this module already had to fix once for -- property labels. Returns nil only when NEITHER a sitelink nor a gv label -- exists at all, so callers fall through to the generic hardcoded Manx text. -- -- `shorten` defaults to true (every existing caller wants shortManxForm's -- "role + country" stripping). Pass `false` for an item whose title ISN'T -- structured that way -- e.g. a legislative CHAMBER's own name (see -- getWdChambers below), which is an ordinary proper name with no reliable -- "role attached to a country" shape, so shortManxForm's rung 2 (a blind -- last-space split) would risk mangling it the same way it would a person's -- plain name -- same reasoning as shortenCountrySuffixedName's deliberately -- narrower rung set above, just applied here by skipping shortManxForm -- entirely rather than substituting a conservative cousin of it. local function getWdItemManxLink(qid, shorten) if not qid then return nil end local okSite, sitelinkTitle = pcall(mw.wikibase.sitelink, qid) if not okSite then sitelinkTitle = nil end local title = (sitelinkTitle and sitelinkTitle ~= "") and sitelinkTitle or nil if not title then local okLabel, gvLabel = pcall(mw.wikibase.getLabelByLang, qid, "gv") if okLabel and gvLabel and gvLabel ~= "" then -- Wikidata labels are conventionally lowercase; capitalize so the -- redlink reads (and will resolve/redirect) like a real title. title = wikiUcfirst(gvLabel) end end if not title then -- Neither a Manx sitelink nor a Manx label exists at all -- rather -- than giving up silently (a caller like getWdChambers would then -- have nothing to show for a real, correctly-identified chamber, or -- a caller like getWdOfficeItemTitle would fall through to a -- generic hardcoded title), fall back to the shared ennym-wd -- helper: the best available label (usually English), wrapped in a -- plain external link straight to the item on Wikidata (renders in -- the skin's own distinct external-link colour, NOT a normal -- internal wikilink's blue/red -- there's no genuine Manx title -- here to wikilink to), tagged with the language it's actually in. -- See Module:Kishtey fys çheer/ennym-wd's own header comment for -- the full three-tier rationale (sitelink -> blue; gv label only -> -- red, inviting the article; neither -> this). if ennymWdOK and EnnymWd and EnnymWd.labelWithFallback then local ok, annotated = pcall(EnnymWd.labelWithFallback, qid) if ok and annotated then return annotated end end return nil end if shorten == false then return "[[" .. title .. "]]" end local short = shortManxForm(title) if short ~= title then return "[[" .. title .. "|" .. short .. "]]" end return "[[" .. title .. "]]" end -- Wikidata has two properties made specifically to solve this exact office- -- title problem, set directly on the COUNTRY's own item rather than on the -- office-holder: P1906 "office held by head of state" and P1313 "office held -- by head of government" (these two IDs are easy to transpose -- there's no -- mnemonic pattern distinguishing them -- and an earlier version of this -- module had them backwards; double-checked against wikidata.org's own -- property pages before fixing). Their value is the generic OFFICE item itself -- (e.g. "Chief Minister of the Isle of Man" / "Ard-hirveishagh Vannin") -- -- not a person, and not one of several roles a particular office-holder -- happens to hold right now. When a country's item has this property set, -- it sidesteps the multi-role-P39 ambiguity entirely (see getWdPositionTitle -- below): there's no need to guess which of a person's several concurrent -- "position held" statements is the right one, because Wikidata already -- names the office directly. Tried FIRST, before the person-chain fallback. local function getWdOfficeItemTitle(officeProperty) local officeQid = getWdRawPropertyId(officeProperty) if not officeQid then return nil end return getWdItemManxLink(officeQid) end -- FALLBACK ONLY (see getWdOfficeItemTitle above, tried first): the leader's -- own specific office title (e.g. "Monark y Reeriaght Unnaneysit" / -- "Ard-vinishter y Reeriaght Unnaneysit"), NOT the generic property -- description ("head of state"/"kione steat"), derived by chaining through -- the CURRENT OFFICE-HOLDER instead of a dedicated country-level property -- -- used only for a country whose Wikidata item doesn't have P1313/P1906 set. -- Wikidata attaches the country-specific title to the position-HOLDER's own -- "position held" (P39) statement, not to the country's P35/P6 statement — -- so this chains through the person: P35/P6 -> person's raw QID -> that -- person's current P39 value -> a Manx link/label for it. -- -- A head of state/government very often holds MULTIPLE simultaneous "current" -- P39 positions -- not just the classic shared-monarch case ("King of the -- United Kingdom", "King of Canada", "King of Australia", ... all current at -- once), but just as commonly a head of government who is ALSO, right now, a -- sitting member of their legislature AND the leader of their party. A brand -- new statement (e.g. someone who became PM only weeks ago) frequently has -- NO qualifier at all yet distinguishing "this is the state office" from -- "this is the party/parliamentary one" -- P1001 ("applies to jurisdiction") -- is the qualifier Wikidata uses for the shared-monarch case specifically, -- but isn't reliably present on every fresh statement, so it can't be -- trusted as the only signal. -- -- So rather than committing to a single "best" P39 value (which could just -- as easily be "Member of Parliament for ..." or "Leader of the ... Party" -- as the actual head-of-government office), this collects EVERY current P39 -- candidate -- ones matching a P1001 filter for this article's own country -- first (when the data has that qualifier, which correctly resolves a -- shared monarch to the right realm), then every other current candidate -- -- and tries each in turn, using the FIRST one that actually resolves to a -- real Manx sitelink or label via getWdItemManxLink. In practice an -- ancillary role (a parliamentary seat, a party leadership) is very unlikely -- to have a dedicated gv.wiki article of its own, while the formal head-of- -- state/government office is exactly the kind of article gv.wiki is likely -- to have -- so this reliably lands on the right one without needing -- Wikidata's qualifiers to be perfectly curated. -- -- Returns nil only when NONE of the current P39 candidates resolves to -- anything on gv.wiki (or Module:Wd is unavailable, or there's no current -- P39 at all), so callers fall back to the property-label / hardcoded rungs -- below. local function getWdPositionTitle(headProperty) local personQid = getWdRawPropertyId(headProperty) if not personQid then return nil end local countryQid = getCurrentCountryQid() local candidates = {} if countryQid then for _, id in ipairs(getWdRawForeignPropertyIds(personQid, "P39", {"current"}, {["P1001"] = countryQid})) do table.insert(candidates, id) end end for _, id in ipairs(getWdRawForeignPropertyIds(personQid, "P39", {"current"})) do table.insert(candidates, id) end local tried = {} for _, qid in ipairs(candidates) do if not tried[qid] then tried[qid] = true local link = getWdItemManxLink(qid) if link then return link end end end return nil end -- Wikidata's own class items for this concept: "upper house" (Q637846) and -- "lower house" (Q375928) -- verified directly against wikidata.org's own -- item pages before use, same discipline as the P1906/P1313 fix above, since -- these are exactly the kind of easily-confused-or-guessed IDs that bit this -- module once already. A bicameral legislature's own Wikidata item typically -- carries "has part(s)" (P527) statements pointing to its two chambers, each -- of which in turn usually carries its own "instance of" (P31) statement -- classifying it as one or the other (e.g. Parliament of the United Kingdom -- -P527-> House of Commons -P31-> lower house, House of Lords -P31-> upper -- house). -- -- Deliberately conservative: only acted on when the has-part list resolves -- to EXACTLY one item classified as the upper house and EXACTLY one -- classified as the lower house. A unicameral legislature with no P527 -- statements at all (by far the most common case among gv.wiki's country -- articles) correctly yields nothing from either side; two or more items -- matching the SAME slot (ambiguous/inconsistent data) is treated as -- unusable for that slot rather than guessing which one is right. Either way -- the manual |thie_heose=/|thie_heese= override remains the fix for any -- article where Wikidata's chamber data isn't good enough -- same safety -- valve as every other Wikidata-fallback field in this module. -- -- No auto-built <ref> citation is attached to either chamber name, matching -- the existing convention for every other CHAINED (multi-property-hop) -- Wikidata lookup in this module (getWdOfficeItemTitle/getWdPositionTitle's -- office titles above carry no citation either) -- only a single property -- fetched directly off the current page's own item (getWdProperty/ -- getWdProperties) can hand back one of Module:Wd's auto-built references. local UPPER_HOUSE_QID = "Q637846" local LOWER_HOUSE_QID = "Q375928" local function getWdChambers(legislatureQid) if not legislatureQid then return nil, nil end local partQids = getWdRawForeignPropertyIds(legislatureQid, "P527") local upperQid, lowerQid = nil, nil local upperAmbiguous, lowerAmbiguous = false, false for _, partQid in ipairs(partQids) do for _, classQid in ipairs(getWdRawForeignPropertyIds(partQid, "P31")) do if classQid == UPPER_HOUSE_QID then if upperQid and upperQid ~= partQid then upperAmbiguous = true end upperQid = partQid elseif classQid == LOWER_HOUSE_QID then if lowerQid and lowerQid ~= partQid then lowerAmbiguous = true end lowerQid = partQid end end end local upperLink = (upperQid and not upperAmbiguous) and getWdItemManxLink(upperQid, false) or nil local lowerLink = (lowerQid and not lowerAmbiguous) and getWdItemManxLink(lowerQid, false) or nil return upperLink, lowerLink end -- Row templates. Every row in this table is a plain 2-cell -- `<th>label</th><td>value</td>` row — exactly the grid every OTHER -- submodule in this system uses (Module:Kishtey fys çheer/çhengaghyn, -- /balley, /bratteeyn). The old HTML template used a 3-column grid instead -- (a narrow indent-spacer <td>, a label <td>, a value <td>, with -- colspan="2"/colspan="3" on label-only/header rows) — mixing that 3-column -- convention into a 2-column table was the actual cause of the reported -- "bunching"/"enormous gap" distortion: rows with different physical cell -- counts in the same table force the browser to reconcile column widths -- unpredictably. Sub-items (individual leaders/houses/founding events under -- one shared label) are distinguished with a "•" bullet + reduced font -- weight on the label cell instead of a separate spacer column — matching -- how English Wikipedia's infobox marks up a list of leaders under one -- "Leader" heading. local ROW = '<tr%s><th style="vertical-align:top; white-space:nowrap; text-align:left; font-weight:bold;">%s</th><td style="vertical-align:top;">%s</td></tr>' local SUBROW = '<tr%s><th style="vertical-align:top; white-space:nowrap; text-align:left; font-weight:normal; padding-left:0.5em;">•&nbsp;%s</th><td style="vertical-align:top;">%s</td></tr>' local HEADER = '<tr class="mergedtoprow"><th colspan="2" style="text-align:left;">%s</th></tr>' -- Builds a `class="..."` attribute (or an empty string), for the -- mergedrow/mergedbottomrow/mergedtoprow classes the old template uses to -- remove the double border between a header/label row and the indented -- sub-rows that visually belong under it. local function trClass(name) if name and name ~= "" then return ' class="' .. name .. '"' end return "" end -- Formats a run of bullet-prefixed sub-rows (leader pairs, house names, -- establishment events, ...) with the old template's merged-border -- convention: every row but the last is "mergedrow", the last is -- "mergedbottomrow" — so the whole run reads as one visually joined block -- under its header/label row. local function appendIndentRun(rows, items) for idx, item in ipairs(items) do local class = (idx == #items) and "mergedbottomrow" or "mergedrow" table.insert(rows, string.format(SUBROW, trClass(class), item[1], item[2])) end end -- Same divider the dispatcher module (Module:Kishtey fys çheer) uses BETWEEN -- whole submodules (see its own `dividerLine`/`appendModule`). Reused here, -- identically, to separate this module's own three internal sections -- (leaders/government, legislature, founding) the same visual way -- a -- divider is only inserted BETWEEN two sections that both actually produced -- rows, never before the first section or after the last, and never next to -- an empty/suppressed section (mirrors appendModule's own conditional). local dividerLine = '<tr><td colspan="2" style="border-top:1px solid #a2a9b1; padding:0; height:0px;"></td></tr>' local function appendSection(rows, sectionRows) if sectionRows and #sectionRows > 0 then if #rows > 0 then table.insert(rows, dividerLine) end for _, row in ipairs(sectionRows) do table.insert(rows, row) end end end function p.main(frame, args) -- Fallback verification to catch argument slots accurately if frame context shifts if not args then args = frame frame = mw.getCurrentFrame() end local rows = {} local govRows = {} local quaiylRows = {} local foundingRows = {} ---------------------------------------------------------------- -- 1-2. REILTYS (Government type) + FIR HOSHEE / TOSHEE (Leaders: -- head of state / head of government / etc.) -- `enmysN_fer-toshee` / `ennymN_fer-toshee` are the old, gendered -- param names, kept for backward compatibility with existing -- articles. `enmys_toshiaghN` / `ennym_toshiaghN` are the -- gender-neutral synonyms going forward ("toshiagh" = leader); -- either spelling works, and the new one takes priority when both -- are supplied for the same slot. Leaders are computed BEFORE the -- government-type row is emitted so that row can carry the right -- merged-border class when leader rows are going to follow it. ---------------------------------------------------------------- local govTypeRaw = getManual(args, {"sorçh_reiltys", "government_type"}) local govRef = getManual(args, {"imraa_reiltys"}) local govNote = getManual(args, {"noteyn_reiltys"}) if not govTypeRaw then -- Wikidata fallback via Module:Wd: basic form of government (P122), -- e.g. "unitary state, parliamentary system, constitutional -- monarchy" -- joins every value Wikidata records rather than just -- one, since this is normally split across several statements. -- Skipped entirely when the field was explicitly suppressed -- (`|sorçh_reiltys=none`), same as every other Wikidata-fallback -- field in this module. govTypeRaw = getWdProperties("P122", {"linked"}) end local govShown = govTypeRaw and not isNone(govTypeRaw) local leaderPairs = {} local manualLeaderGiven = false for i = 1, 5 do local title = getManual(args, {"enmys_toshiagh" .. i, "enmys" .. i .. "_fer-toshee"}) local name = getManual(args, {"ennym_toshiagh" .. i, "ennym" .. i .. "_fer-toshee"}) if title or name then manualLeaderGiven = true if not isNone(name) then table.insert(leaderPairs, {title = title or "", name = name or ""}) end end end local leaderRef = getManual(args, {"imraa_toshiagh", "imraa_fer-toshee"}) local leaderNote = getManual(args, {"noteyn_toshiagh", "noteyn_fer-toshee"}) local leadersSuppressed = isNone(getManual(args, {"fir_hoshee", "toshiaghyn"})) if not manualLeaderGiven and not leadersSuppressed then -- Wikidata fallback via Module:Wd: head of state (P35) / head of -- government (P6). Names are ALWAYS forced into a link (a redlink -- when gv.wiki has no article for that person yet) via -- ensureLinked, since an unlinked plain name is easy to mistake for -- a manual/unsourced value and gives editors nothing to click -- through to create the article. Titles try, in order: a manual -- override, the leader's own country-specific office (e.g. "Monark -- y Reeriaght Unnaneysit"), the Wikidata property's own label, then -- a hardcoded Manx fallback. local hos = shortenLinkedCountryName(ensureLinked(getWdProperty("P35", {"linked"}))) local hog = ensureLinked(getWdProperty("P6", {"linked"})) if hos then local hosTitle = getManual(args, {"sorçh_kione_steat"}) or getWdOfficeItemTitle("P1906") -- "office held by head of state" -- set directly on the country, no person-level ambiguity or getWdPositionTitle("P35") or getWikidataPropertyLabel("P35") or "Kione steat" table.insert(leaderPairs, {title = hosTitle, name = hos}) end if hog then local hogTitle = getManual(args, {"sorçh_kione_reiltys"}) or getWdOfficeItemTitle("P1313") -- "office held by head of government" -- same reasoning as P1906 above or getWdPositionTitle("P6") or getWikidataPropertyLabel("P6") or "Kione reiltys" table.insert(leaderPairs, {title = hogTitle, name = hog}) end end if govShown then local govClass = (#leaderPairs > 0) and "mergedtoprow" or "" table.insert(govRows, string.format(ROW, trClass(govClass), "[[Reiltys]]", applyRefNote(govTypeRaw, govRef, govNote, frame))) elseif #leaderPairs > 0 then table.insert(govRows, string.format(HEADER, "[[Reiltys]]")) end if #leaderPairs > 0 then -- The shared manual ref/note for the whole leaders block is -- attached to the last row, same convention as a single footnote -- covering a list. (A Wikidata-sourced name already carries its own -- auto-built citation from getWdProperty.) local last = leaderPairs[#leaderPairs] last.name = applyRefNote(last.name, leaderRef, leaderNote, frame) local items = {} for _, leader in ipairs(leaderPairs) do table.insert(items, {leader.title, leader.name}) end appendIndentRun(govRows, items) end ---------------------------------------------------------------- -- 3. QUAIYL / ÇHIONNAL (Legislature) -- `çhionnal` is a synonym for `quaiyl`; `thie_heose` / `thie_heese` -- are synonyms for `quaiyl_syrjey` / `quaiyl_s'inshley` (upper / -- lower house). New spellings take priority when both are given. -- Houses left completely unset (not even |thie_heose=none) get a -- Wikidata fallback of their own -- see getWdChambers above. ---------------------------------------------------------------- local quaiyl = getManual(args, {"çhionnal", "quaiyl"}) local quaiylSyrjey = getManual(args, {"thie_heose", "quaiyl_syrjey"}) local quaiylInshley = getManual(args, {"thie_heese", "quaiyl_s'inshley", "quaiyl_sinshley"}) local quaiylRef = getManual(args, {"imraa_çhionnal", "imraa_quaiyl"}) local quaiylNote = getManual(args, {"noteyn_çhionnal", "noteyn_quaiyl"}) if not quaiyl then -- "short" asks Module:Wd for the item's short name (Wikidata -- P1813) first, e.g. "Parliament" instead of the full official -- "Parliament of the United Kingdom of Great Britain and Northern -- Ireland" -- matching enwiki's own concise style. Falls back to -- the item's normal label when no short name is set. Deliberately -- gated on `quaiyl` ALONE, not bundled with the house params below -- -- an editor who suppressed just one house (|thie_heose=none) or -- named a house manually shouldn't lose the main body's own -- Wikidata fallback as a side effect. quaiyl = getWdProperty("P194", {"linked", "short"}) end if not quaiylSyrjey or not quaiylInshley then -- Wikidata fallback for the two chambers THEMSELVES (see -- getWdChambers above) -- resolved once, then applied -- INDEPENDENTLY to whichever side(s) are still nil, same as the -- head-of-state/head-of-government leader slots above: an explicit -- |thie_heose=none/|thie_heese=none suppression on one side (which -- leaves that variable as the literal string "none", not nil) -- always wins outright and is never overwritten, while the other, -- genuinely-omitted side still gets its own independent Wikidata -- value. Chained off the same legislative-body item as `quaiyl` -- above (P194's raw QID), not off whatever `quaiyl` itself resolved -- to, so this still works even when `quaiyl` was supplied manually. local legislatureQid = getWdRawPropertyId("P194") if legislatureQid then local wdUpper, wdLower = getWdChambers(legislatureQid) if not quaiylSyrjey then quaiylSyrjey = wdUpper end if not quaiylInshley then quaiylInshley = wdLower end end end if quaiyl and not isNone(quaiyl) then local houseItems = {} if quaiylSyrjey and not isNone(quaiylSyrjey) then table.insert(houseItems, {"[[Thie heose]]", quaiylSyrjey}) end if quaiylInshley and not isNone(quaiylInshley) then table.insert(houseItems, {"[[Thie heese]]", quaiylInshley}) end local quaiylClass = (#houseItems > 0) and "mergedtoprow" or "" table.insert(quaiylRows, string.format(ROW, trClass(quaiylClass), "[[Çhionnal slattyssagh]]", applyRefNote(quaiyl, quaiylRef, quaiylNote, frame))) appendIndentRun(quaiylRows, houseItems) end ---------------------------------------------------------------- -- 4. BUNNEEAGHT / KIONDEEAGHT (Founding / constitution) and -- historical establishment events — manual-only, ported -- directly from the old template's numbered slots (1-9). -- `kionedeeaght` is a synonym for `kiondeeaght` in the label/note -- param names. ---------------------------------------------------------------- local foundingLabel = getManual(args, {"sorçh_kionedeeaght", "sorçh_kiondeeaght"}) or "Bunneeaght" local foundingValue = getManual(args, {"bunnit"}) local foundingNote = getManual(args, {"note_kionedeeaght", "note_kiondeeaght"}) local foundingRef = getManual(args, {"imraa_kionedeeaght", "imraa_kiondeeaght"}) local establishmentRows = {} for i = 1, 9 do local event = getManual(args, {"taghyrt" .. i .. "_bunnit"}) local date = getManual(args, {"date" .. i .. "_bunnit"}) if event then table.insert(establishmentRows, {event, date or ""}) end end if foundingValue or #establishmentRows > 0 then if foundingValue and not isNone(foundingValue) then local foundingClass = (#establishmentRows > 0) and "mergedtoprow" or "" table.insert(foundingRows, string.format(ROW, trClass(foundingClass), "[[" .. foundingLabel .. "]]", applyRefNote(foundingValue, foundingRef, foundingNote, frame))) elseif #establishmentRows > 0 then table.insert(foundingRows, string.format(HEADER, "[[" .. foundingLabel .. "]]")) end appendIndentRun(foundingRows, establishmentRows) elseif not isNone(getManual(args, {"bunnit"})) then -- Wikidata fallback via Module:Wd: inception (P571) — only when the -- whole establishment block was left unset (not explicitly |bunnit=none). -- NOTE on date precision: Module:Wd's own time-value formatting (see -- Config:getValue's `datatype == 'time'` branch) already renders a -- FULL day-month-year date whenever the underlying Wikidata statement -- itself is stored at day precision -- there is no flag this call is -- missing, and no truncation happens on our side (confirmed by the -- test harness, which feeds a day-precision value straight through -- unchanged). When only a year is shown on a real article, that is -- because THAT COUNTRY's P571 statement on Wikidata itself is only -- recorded at year precision (very common for older founding dates) -- -- not a bug here. The manual |bunnit= override remains the fix for -- any article where the Wikidata precision isn't good enough. local inception = getWdProperty("P571") if inception then table.insert(foundingRows, string.format(ROW, "", "[[" .. foundingLabel .. "]]", applyRefNote(inception, foundingRef, foundingNote, frame))) end end appendSection(rows, govRows) appendSection(rows, quaiylRows) appendSection(rows, foundingRows) if #rows == 0 then return nil end return table.concat(rows) end return p hickbmerx7mtxoo8yrkbdn31lsu1ojo 393010 393006 2026-09-10T02:48:34Z MacTire02 219 ++ 393010 Scribunto text/plain local p = {} -- Module:Wd is gv.wiki's actual working Wikidata-fetch-and-cite module -- (confirmed by its localized /i18n submodule) — used instead of -- Module:WikidataIB, which has no working reference-building of its own. -- pcall so a wiki state where Wd (or its own Module:Wd/i18n) isn't set up -- degrades to "no Wikidata fallback" instead of breaking the infobox. local wdOK, Wd = pcall(require, "Module:Wd") -- Module:Ennym çheerey ("country names") already keeps a hand-curated table -- of each country's own Manx GENITIVE/mutated form (e.g. "Mannin" -> -- "Vannin", "Nalbin" -> "ny h-Albey", "Yn Reeriaght Unnaneysit" -> "y -- Reeriaght Unnaneysit") -- exactly the linguistic knowledge shortManxForm -- below otherwise has to guess at mechanically (see getCurrentCountryGenitive -- and shortManxForm further down for how this is used). pcall so a wiki -- state where this module isn't available degrades to the purely mechanical -- fallback instead of breaking the infobox. local ennymOK, EnnymCheerey = pcall(require, "Module:Ennym çheerey") -- Module:Kishtey fys çheer/ennym-wd -- the shared "Manx label, with a -- linked-to-Wikidata non-Manx fallback" helper (see its own header comment -- for the full three-tier rationale). Used as the LAST rung in -- getWdItemManxLink below, only once a genuine Manx sitelink/label has -- already been checked for and not found. pcall'd for the same reason as -- the two requires above: a wiki state missing this submodule just means -- this particular fallback rung is unavailable, not a broken infobox. local ennymWdOK, EnnymWd = pcall(require, "Module:Kishtey fys çheer/ennym-wd") -- Safely get manual parameters from priority list local function getManual(args, names) for _, name in ipairs(names) do local value = args[name] if value and mw.text.trim(value) ~= "" then return mw.text.trim(value) end end return nil end local function isNone(value) return value ~= nil and mw.text.trim(value):lower() == "none" end -- Append a manual reference (<ref>) and/or note ({{efn}}) to a value. This -- is the manual imraa_*/noteyn_* channel, same as Module:Kishtey fys -- çheer/çhengaghyn uses. It layers on top of a Wikidata-sourced value too -- (which already carries its own auto-built citation from getWdProperty -- below) in case an editor wants to add an extra citation or clarifying -- footnote of their own. local function applyRefNote(value, ref, note, frame) if not value then return value end if note and note ~= "" and frame then value = value .. frame:expandTemplate{ title = "efn", args = { note } } end if ref and ref ~= "" then value = value .. "<ref>" .. ref .. "</ref>" end return value end -- Fetch+format a single Wikidata property value via Module:Wd's "property" -- command, combined with its "reference" command so that, when the -- Wikidata statement itself carries references, Wd builds a real <ref> -- citation (Cite web / Cite Q) from them automatically — the same way -- gv.wiki's other Wd-based infoboxes already cite Wikidata data. `flags` -- is an optional array of extra Wd flags (e.g. {"linked"}). Returns nil -- when Wd isn't available, or the property has no value. local function getWdProperty(property, flags) if not wdOK or not Wd or not Wd._property then return nil end local callArgs = {} for _, f in ipairs(flags or {}) do table.insert(callArgs, f) end table.insert(callArgs, "reference") -- request an auto-built citation alongside the value table.insert(callArgs, "best") -- single best-ranked value, mirroring the old template's behaviour table.insert(callArgs, property) local ok, result = pcall(Wd._property, callArgs) if ok and result and result ~= "" then return result end return nil end -- Same as getWdProperty, but via Module:Wd's plural "properties" command, -- which joins EVERY matching value together (comma-separated by default) -- instead of just the single best one. Used for government type (P122 -- "basic form of government"), which Wikidata typically records as several -- separate statements on one country (e.g. "unitary state", "parliamentary -- system", "constitutional monarchy") rather than one combined phrase. local function getWdProperties(property, flags) if not wdOK or not Wd or not Wd._properties then return nil end local callArgs = {} for _, f in ipairs(flags or {}) do table.insert(callArgs, f) end table.insert(callArgs, "reference") table.insert(callArgs, property) local ok, result = pcall(Wd._properties, callArgs) if ok and result and result ~= "" then return result end return nil end -- Module:Wd's "linked" flag only produces a wikilink when the entity -- already has a gv sitelink (Config:getLabel returns the bare label, -- un-bracketed, otherwise — see Module:Wd source). For a leader whose -- article doesn't exist on gv.wiki yet, that means no link at all. Since -- an editor should still be able to click through (or see a redlink -- inviting the article to be written), this forces a wikilink around the -- label text when Wd didn't already supply one — without touching a -- trailing auto-built <ref>...</ref> citation, which Wd appends directly -- after the label/link text. local function ensureLinked(value) if not value or value == "" then return value end local label, refSuffix = value:match("^(.-)(<ref.*)$") if not label then label = value refSuffix = "" end if label:find("%[%[") then return value -- already a real link via a gv sitelink end label = mw.text.trim(label) if label == "" then return value end return "[[" .. label .. "]]" .. refSuffix end -- Label of the Wikidata PROPERTY itself (e.g. P35 -> "head of state"), used -- as a Wikidata-sourced fallback for a leader's title when no manual -- title/override is supplied. Deliberately uses getLabelByLang(property, -- "gv") rather than mw.wikibase.label(property): plain label() follows -- Wikidata's language-fallback chain and will happily hand back the -- English label when no Manx one exists (which is the common case for -- properties on Wikidata) — silently leaking English text like "head of -- state" into the Manx infobox. getLabelByLang only returns a value when a -- Manx label genuinely exists, so an untranslated property correctly falls -- through to the hardcoded Manx text below instead. local function getWikidataPropertyLabel(property) local ok, label = pcall(mw.wikibase.getLabelByLang, property, "gv") if ok and label and label ~= "" then return label end return nil end -- Raw QID (no linking/label formatting) of an entity-valued property on the -- CURRENT page's Wikidata item — e.g. P35's value (the head of state person) -- as a bare "Q..." id, so it can be used as the `eid` for a follow-up -- lookup on THAT person's own item (see getWdPositionTitle below). Uses -- Module:Wd's "raw" flag, which for an entity-id-valued statement returns -- the plain id instead of a formatted link/label. local function getWdRawPropertyId(property) if not wdOK or not Wd or not Wd._property then return nil end local ok, result = pcall(Wd._property, {"raw", "best", property}) if ok and result and type(result) == "string" and result:match("^Q%d+$") then return result end return nil end -- Raw QIDs of EVERY value of an entity-valued property on a FOREIGN -- Wikidata item (`eid`), not the current page's — e.g. the leader's own -- P39 ("position held") statements, which a real politician very often has -- several of at once (a parliamentary seat, a party leadership, AND a head- -- of-government office can all be simultaneously "current" -- see -- getWdPositionTitle below for why that matters). Uses Module:Wd's PLURAL -- "properties" command (not "property"), which -- unlike the singular -- command -- does not stop at a single "best" value, so every matching -- claim is returned, joined together; this extracts each "Q..." token from -- that joined string rather than relying on a specific separator, since -- Wd's separator choice isn't part of its documented contract. `eid` is -- passed the same way Module:Wd's own code does internally -- (`p._property{..., [p.args.eid] = id}`). `qualifiers` is an optional -- table of {qualifierPropertyId = requiredValue} pairs -- Module:Wd's -- claimCommand treats any hash key matching "P%d+" as a qualifier filter -- (see its `qualifierIDsAndValues`/`qualifierMatches` logic), letting a -- caller narrow the claims returned to just those with a matching -- qualifier (see getWdPositionTitle below, which uses this for P1001 -- "applies to jurisdiction"). Returns an empty table on any failure. local function getWdRawForeignPropertyIds(eid, property, extraFlags, qualifiers) if not wdOK or not Wd or not Wd._properties or not eid then return {} end local callArgs = {} for _, f in ipairs(extraFlags or {}) do table.insert(callArgs, f) end table.insert(callArgs, "raw") table.insert(callArgs, property) callArgs[Wd.args and Wd.args.eid or "eid"] = eid for qid, value in pairs(qualifiers or {}) do callArgs[qid] = value end local ok, result = pcall(Wd._properties, callArgs) if not ok or not result or type(result) ~= "string" or result == "" then return {} end local ids = {} for id in result:gmatch("Q%d+") do table.insert(ids, id) end return ids end -- The QID of the entity connected to the CURRENT page (e.g. the country the -- article is about), used to disambiguate a multi-realm head of state's P39 -- statements (see getWdPositionTitle below). Returns nil when the current -- page has no connected Wikidata item. local function getCurrentCountryQid() local ok, id = pcall(mw.wikibase.getEntityIdForCurrentPage) if ok and id and id ~= "" then return id end return nil end -- The exact Manx GENITIVE form of the CURRENT PAGE's own country/territory -- -- e.g. "Vannin" for the Isle of Man's own article, "y Reeriaght -- Unnaneysit" for the UK's -- looked up from Module:Ennym çheerey's shared, -- hand-curated table (see shortManxForm below for how this is used). -- Derived from the current page's own title, which -- for a country/ -- territory article -- IS that country's plain Manx name, the same key -- Module:Ennym çheerey's table is keyed on. Returns nil when -- Module:Ennym çheerey isn't available, the current page has no title -- (shouldn't happen in practice), or the lookup itself fails for any reason -- -- all pcall'd defensively so a missing/renamed dependency just falls -- through to shortManxForm's mechanical fallback rungs instead of erroring. local function getCurrentCountryGenitive() if not ennymOK or not EnnymCheerey or not EnnymCheerey.genitive then return nil end local okTitle, title = pcall(function() return mw.title.getCurrentTitle().text end) if not okTitle or not title or title == "" then return nil end local okGen, genitive = pcall(EnnymCheerey.genitive, title) if okGen and genitive and genitive ~= "" then return genitive end return nil end -- Manx country-specific office titles on gv.wiki attach the CURRENT page's -- own country name to a role, in one of two constructions -- e.g. "Monark y -- Reeriaght Unnaneysit" (a "y"/"of the" connector, for longer/multi-word -- country names) or "Ard-hirveishagh Vannin" (the country attached directly, -- often in a mutated genitive form, for shorter ones). Either way, this -- keeps just the leading role word(s) as the link's DISPLAY text while the -- link target stays the full title -- e.g. "[[Monark y Reeriaght -- Unnaneysit|Monark]]", "[[Ard-hirveishagh Vannin|Ard-hirveishagh]]". -- -- Rung 0 (linguistically correct, tried first): Module:Ennym çheerey already -- keeps a hand-curated table of exactly this -- each country's own Manx -- genitive form, "y "/"yn " prefix (or lack of one) and initial mutation -- included. getCurrentCountryGenitive() above resolves that for the CURRENT -- article's own country; if the office title ends with " " followed by that -- exact genitive form, this strips it with certainty, rather than guessing -- -- and adding a country to that ONE shared table (already documented -- there as extensible) benefits every module that uses it, not just this -- one. -- -- Rungs 1-2 (mechanical fallback, used only when rung 0 doesn't apply -- -- Module:Ennym çheerey unavailable, or this country/title isn't covered by -- its table yet): detach everything from the first " y " onward (rung 1), -- or, failing that, everything from the LAST remaining space onward (rung -- 2) -- a blind guess that happens to match the real construction in every -- case seen so far, but isn't linguistically guaranteed the way rung 0 is. -- -- A title with no space at all (already just a bare role name, e.g. -- "Ard-whaiyl") falls through every rung unchanged. -- -- Exceptions: full titles that should always be used as-is, unshortened, -- even though they'd otherwise match a rung above -- e.g. "Çhiarn Vannin" -- (Lord of Mann), where stripping " Vannin" would technically be correct per -- Module:Ennym çheerey's own genitive table, but that's not how this -- specific title should read. Checked before any rung is tried. local shortFormExceptions = { ["Çhiarn Vannin"] = true, } local function shortManxForm(title) if not title or title == "" then return title end if shortFormExceptions[title] then return title end local countryGenitive = getCurrentCountryGenitive() if countryGenitive then local suffix = " " .. countryGenitive if #title > #suffix and title:sub(-#suffix) == suffix then return title:sub(1, #title - #suffix) end end local short = title:match("^(.-)%sy%s") if short and short ~= "" then return short end short = title:match("^(.+)%s%S+$") if short and short ~= "" then return short end return title end -- A conservative cousin of shortManxForm, used ONLY for a PERSON's own name -- (see shortenLinkedCountryName below), never for an office title. A shared -- monarch is the one case where gv.wiki has to disambiguate a PERSON's own -- article per realm the same way office-title items are (e.g. an article -- titled "Çhalse III y Reeriaght Unnaneysit" for the UK's Charles III, -- distinct from his article for another realm) -- so this strips exactly -- that same country-genitive tail when it's genuinely present. Deliberately -- OMITS shortManxForm's rung 2 (blind last-space split): that rung is safe -- for an office title (which always ends in a country reference) but would -- be actively wrong for an ordinary two/three-word person's name with no -- country suffix at all -- e.g. it would mangle "Charse III" into "Charse", -- silently dropping the regnal numeral. Only the two rungs that require a -- genuine, identifiable country-genitive match are used here: Module:Ennym -- çheerey's exact genitive suffix (rung 0), or an explicit " y " token -- (rung 1) -- both of gv.wiki's known cases ("Çhalse III y Reeriaght -- Unnaneysit", "Louisagh IV y Rank") already contain a literal " y ", so -- rung 1 alone would catch them even without Module:Ennym çheerey data. local function shortenCountrySuffixedName(name) if not name or name == "" then return name end local countryGenitive = getCurrentCountryGenitive() if countryGenitive then local suffix = " " .. countryGenitive if #name > #suffix and name:sub(-#suffix) == suffix then return name:sub(1, #name - #suffix) end end local short = name:match("^(.-)%sy%s") if short and short ~= "" then return short end return name end -- Shortens the DISPLAY text of the head-of-state's own linked name when -- gv.wiki's article for them is a per-realm-disambiguated one (see -- shortenCountrySuffixedName above) -- e.g. turning the unpiped -- "[[Çhalse III y Reeriaght Unnaneysit]]" Module:Wd hands back (it has -- nothing else to use as display text there) into the piped -- "[[Çhalse III y Reeriaght Unnaneysit|Çhalse III]]", leaving the link -- target and any trailing manual/auto <ref> citation completely untouched. -- Deliberately scoped to the HEAD-OF-STATE slot only (see its call site in -- p.main) rather than a general-purpose name formatter: an ordinary head of -- government is never the same person across several countries, so their -- own gv article is never disambiguated this way in the first place -- -- structurally, only a shared monarch produces this shape of data at all, -- which is what "condition this on the head of state being a monarch" -- comes down to in practice, without a separate Wikidata lookup to confirm -- it. Only fires on a bare, unpiped "[[target]]" link with no existing -- custom display text (i.e. nothing this module or Wd itself already chose -- to show instead) -- a name that's already piped, or has no country suffix -- to strip at all, is returned completely unchanged. -- Handles BOTH a bare "[[target]]" link and an already-piped "[[target| -- display]]" one, shortening whichever text is CURRENTLY being displayed -- -- not just the bare-unpiped case. This is deliberately more permissive than -- checking only for an unpiped link: Module:Wd's own buildWikilink normally -- produces the unpiped form specifically when the Wikidata label and the gv -- sitelink title are identical, but relying on that always holding (rather -- than on what's actually visible to the reader) is exactly the kind of -- assumption that can quietly stop matching if Wd's output shape ever -- differs even slightly -- e.g. a piped link whose display text still -- happens to be the full disambiguated title. Working from whatever text is -- actually displayed, rather than assuming it must be unpiped, is more -- robust either way. local function shortenLinkedCountryName(value) if not value or value == "" then return value end local main, refSuffix = value:match("^(.-)(<ref.*)$") if not main then main = value refSuffix = "" end local target, display = main:match("^%[%[([^%[%]|]+)|([^%[%]|]+)%]%]$") if not target then target = main:match("^%[%[([^%[%]|]+)%]%]$") display = target end if not target then return value end local short = shortenCountrySuffixedName(display) if short ~= display then return "[[" .. target .. "|" .. short .. "]]" .. refSuffix end return value end -- Capitalizes the first letter the way the wiki itself would (respecting -- Manx-specific case folding, e.g. digraphs like "çh"), via the content -- language object's own ucfirst -- NOT a plain Lua upper() on byte 1, which -- would mangle multi-byte UTF-8 and wouldn't match gv.wiki's own title- -- capitalization rules. Needed because a raw Wikidata LABEL (unlike a real -- page title/sitelink) is conventionally stored all-lowercase (e.g. -- "monark"), but both a link's display text and a red-linked target should -- read the way an actual Manx Wikipedia article title would. local function wikiUcfirst(text) if not text or text == "" then return text end local ok, result = pcall(function() return mw.language.getContentLanguage():ucfirst(text) end) if ok and result and result ~= "" then return result end return text end -- Given a Wikidata item ID for a specific office/position (e.g. "King of -- the United Kingdom"), build a wikilink using the gv sitelink (when one -- exists) or, failing that, a verified gv LABEL as the link target -- ALWAYS -- as a real wikilink, even when that means a redlink inviting the article to -- be written (per explicit instruction: an unlinked office title is -- indistinguishable from an unsourced one, same reasoning as ensureLinked() -- above for leader names). The display text has the "y <country>" tail -- detached (see shortManxForm above), e.g. "[[Monark y Reeriaght -- Unnaneysit|Monark]]". Never uses mw.wikibase.label's English-fallback- -- prone version -- same leak this module already had to fix once for -- property labels. Returns nil only when NEITHER a sitelink nor a gv label -- exists at all, so callers fall through to the generic hardcoded Manx text. -- -- The link TARGET and the DISPLAY text are resolved SEPARATELY, and can -- come from different sources: -- - Target: the real sitelink when the article exists, otherwise the gv -- LABEL itself (which is what makes this a redlink, inviting the -- article to be written at that title). -- - Display: the gv LABEL whenever one exists -- even when a sitelink/ -- article ALSO exists, and even if its title reads differently (an -- older article title, a disambiguator, different capitalization) -- -- because the label is Wikidata's own record of what this entity -- should actually be CALLED in Manx, and that's what belongs in the -- infobox text. Only when no gv label exists at all does the sitelink -- title double as the display basis too. -- The two are then only piped together (`[[target|display]]`) when they -- actually differ after shortening; otherwise a plain `[[target]]`. -- -- `shorten` defaults to true (every existing caller wants shortManxForm's -- "role + country" stripping, applied to the display text). Pass `false` -- for an item whose title ISN'T structured that way -- e.g. a legislative -- CHAMBER's own name (see getWdChambers below), which is an ordinary proper -- name with no reliable "role attached to a country" shape, so -- shortManxForm's rung 2 (a blind last-space split) would risk mangling it -- the same way it would a person's plain name -- same reasoning as -- shortenCountrySuffixedName's deliberately narrower rung set above, just -- applied here by skipping shortManxForm entirely rather than substituting -- a conservative cousin of it. local function getWdItemManxLink(qid, shorten) if not qid then return nil end local okSite, sitelinkTitle = pcall(mw.wikibase.sitelink, qid) if not okSite then sitelinkTitle = nil end sitelinkTitle = (sitelinkTitle and sitelinkTitle ~= "") and sitelinkTitle or nil local okLabel, gvLabel = pcall(mw.wikibase.getLabelByLang, qid, "gv") if okLabel and gvLabel and gvLabel ~= "" then -- Wikidata labels are conventionally lowercase; capitalize so it -- reads (and, if used as a redlink target, will resolve/redirect) -- like a real title. gvLabel = wikiUcfirst(gvLabel) else gvLabel = nil end if not sitelinkTitle and not gvLabel then -- Neither a Manx sitelink nor a Manx label exists at all -- rather -- than giving up silently (a caller like getWdChambers would then -- have nothing to show for a real, correctly-identified chamber, or -- a caller like getWdOfficeItemTitle would fall through to a -- generic hardcoded title), fall back to the shared ennym-wd -- helper: the best available label (usually English), wrapped in a -- plain external link straight to the item on Wikidata (renders in -- the skin's own distinct external-link colour, NOT a normal -- internal wikilink's blue/red -- there's no genuine Manx title -- here to wikilink to), tagged with the language it's actually in. -- See Module:Kishtey fys çheer/ennym-wd's own header comment for -- the full three-tier rationale (sitelink -> blue; gv label only -> -- red, inviting the article; neither -> this). if ennymWdOK and EnnymWd and EnnymWd.labelWithFallback then local ok, annotated = pcall(EnnymWd.labelWithFallback, qid) if ok and annotated then return annotated end end return nil end local target = sitelinkTitle or gvLabel local displayBase = gvLabel or sitelinkTitle if shorten == false then if target == displayBase then return "[[" .. target .. "]]" end return "[[" .. target .. "|" .. displayBase .. "]]" end local short = shortManxForm(displayBase) if short ~= target then return "[[" .. target .. "|" .. short .. "]]" end return "[[" .. target .. "]]" end -- Wikidata has two properties made specifically to solve this exact office- -- title problem, set directly on the COUNTRY's own item rather than on the -- office-holder: P1906 "office held by head of state" and P1313 "office held -- by head of government" (these two IDs are easy to transpose -- there's no -- mnemonic pattern distinguishing them -- and an earlier version of this -- module had them backwards; double-checked against wikidata.org's own -- property pages before fixing). Their value is the generic OFFICE item itself -- (e.g. "Chief Minister of the Isle of Man" / "Ard-hirveishagh Vannin") -- -- not a person, and not one of several roles a particular office-holder -- happens to hold right now. When a country's item has this property set, -- it sidesteps the multi-role-P39 ambiguity entirely (see getWdPositionTitle -- below): there's no need to guess which of a person's several concurrent -- "position held" statements is the right one, because Wikidata already -- names the office directly. Tried FIRST, before the person-chain fallback. local function getWdOfficeItemTitle(officeProperty) local officeQid = getWdRawPropertyId(officeProperty) if not officeQid then return nil end return getWdItemManxLink(officeQid) end -- FALLBACK ONLY (see getWdOfficeItemTitle above, tried first): the leader's -- own specific office title (e.g. "Monark y Reeriaght Unnaneysit" / -- "Ard-vinishter y Reeriaght Unnaneysit"), NOT the generic property -- description ("head of state"/"kione steat"), derived by chaining through -- the CURRENT OFFICE-HOLDER instead of a dedicated country-level property -- -- used only for a country whose Wikidata item doesn't have P1313/P1906 set. -- Wikidata attaches the country-specific title to the position-HOLDER's own -- "position held" (P39) statement, not to the country's P35/P6 statement — -- so this chains through the person: P35/P6 -> person's raw QID -> that -- person's current P39 value -> a Manx link/label for it. -- -- A head of state/government very often holds MULTIPLE simultaneous "current" -- P39 positions -- not just the classic shared-monarch case ("King of the -- United Kingdom", "King of Canada", "King of Australia", ... all current at -- once), but just as commonly a head of government who is ALSO, right now, a -- sitting member of their legislature AND the leader of their party. A brand -- new statement (e.g. someone who became PM only weeks ago) frequently has -- NO qualifier at all yet distinguishing "this is the state office" from -- "this is the party/parliamentary one" -- P1001 ("applies to jurisdiction") -- is the qualifier Wikidata uses for the shared-monarch case specifically, -- but isn't reliably present on every fresh statement, so it can't be -- trusted as the only signal. -- -- So rather than committing to a single "best" P39 value (which could just -- as easily be "Member of Parliament for ..." or "Leader of the ... Party" -- as the actual head-of-government office), this collects EVERY current P39 -- candidate -- ones matching a P1001 filter for this article's own country -- first (when the data has that qualifier, which correctly resolves a -- shared monarch to the right realm), then every other current candidate -- -- and tries each in turn, using the FIRST one that actually resolves to a -- real Manx sitelink or label via getWdItemManxLink. In practice an -- ancillary role (a parliamentary seat, a party leadership) is very unlikely -- to have a dedicated gv.wiki article of its own, while the formal head-of- -- state/government office is exactly the kind of article gv.wiki is likely -- to have -- so this reliably lands on the right one without needing -- Wikidata's qualifiers to be perfectly curated. -- -- Returns nil only when NONE of the current P39 candidates resolves to -- anything on gv.wiki (or Module:Wd is unavailable, or there's no current -- P39 at all), so callers fall back to the property-label / hardcoded rungs -- below. local function getWdPositionTitle(headProperty) local personQid = getWdRawPropertyId(headProperty) if not personQid then return nil end local countryQid = getCurrentCountryQid() local candidates = {} if countryQid then for _, id in ipairs(getWdRawForeignPropertyIds(personQid, "P39", {"current"}, {["P1001"] = countryQid})) do table.insert(candidates, id) end end for _, id in ipairs(getWdRawForeignPropertyIds(personQid, "P39", {"current"})) do table.insert(candidates, id) end local tried = {} for _, qid in ipairs(candidates) do if not tried[qid] then tried[qid] = true local link = getWdItemManxLink(qid) if link then return link end end end return nil end -- Wikidata's own class items for this concept: "upper house" (Q637846) and -- "lower house" (Q375928) -- verified directly against wikidata.org's own -- item pages before use, same discipline as the P1906/P1313 fix above, since -- these are exactly the kind of easily-confused-or-guessed IDs that bit this -- module once already. A bicameral legislature's own Wikidata item typically -- carries "has part(s)" (P527) statements pointing to its two chambers, each -- of which in turn usually carries its own "instance of" (P31) statement -- classifying it as one or the other (e.g. Parliament of the United Kingdom -- -P527-> House of Commons -P31-> lower house, House of Lords -P31-> upper -- house). -- -- Deliberately conservative: only acted on when the has-part list resolves -- to EXACTLY one item classified as the upper house and EXACTLY one -- classified as the lower house. A unicameral legislature with no P527 -- statements at all (by far the most common case among gv.wiki's country -- articles) correctly yields nothing from either side; two or more items -- matching the SAME slot (ambiguous/inconsistent data) is treated as -- unusable for that slot rather than guessing which one is right. Either way -- the manual |thie_heose=/|thie_heese= override remains the fix for any -- article where Wikidata's chamber data isn't good enough -- same safety -- valve as every other Wikidata-fallback field in this module. -- -- No auto-built <ref> citation is attached to either chamber name, matching -- the existing convention for every other CHAINED (multi-property-hop) -- Wikidata lookup in this module (getWdOfficeItemTitle/getWdPositionTitle's -- office titles above carry no citation either) -- only a single property -- fetched directly off the current page's own item (getWdProperty/ -- getWdProperties) can hand back one of Module:Wd's auto-built references. local UPPER_HOUSE_QID = "Q637846" local LOWER_HOUSE_QID = "Q375928" local function getWdChambers(legislatureQid) if not legislatureQid then return nil, nil end local partQids = getWdRawForeignPropertyIds(legislatureQid, "P527") local upperQid, lowerQid = nil, nil local upperAmbiguous, lowerAmbiguous = false, false for _, partQid in ipairs(partQids) do for _, classQid in ipairs(getWdRawForeignPropertyIds(partQid, "P31")) do if classQid == UPPER_HOUSE_QID then if upperQid and upperQid ~= partQid then upperAmbiguous = true end upperQid = partQid elseif classQid == LOWER_HOUSE_QID then if lowerQid and lowerQid ~= partQid then lowerAmbiguous = true end lowerQid = partQid end end end local upperLink = (upperQid and not upperAmbiguous) and getWdItemManxLink(upperQid, false) or nil local lowerLink = (lowerQid and not lowerAmbiguous) and getWdItemManxLink(lowerQid, false) or nil return upperLink, lowerLink end -- Row templates. Every row in this table is a plain 2-cell -- `<th>label</th><td>value</td>` row — exactly the grid every OTHER -- submodule in this system uses (Module:Kishtey fys çheer/çhengaghyn, -- /balley, /bratteeyn). The old HTML template used a 3-column grid instead -- (a narrow indent-spacer <td>, a label <td>, a value <td>, with -- colspan="2"/colspan="3" on label-only/header rows) — mixing that 3-column -- convention into a 2-column table was the actual cause of the reported -- "bunching"/"enormous gap" distortion: rows with different physical cell -- counts in the same table force the browser to reconcile column widths -- unpredictably. Sub-items (individual leaders/houses/founding events under -- one shared label) are distinguished with a "•" bullet + reduced font -- weight on the label cell instead of a separate spacer column — matching -- how English Wikipedia's infobox marks up a list of leaders under one -- "Leader" heading. local ROW = '<tr%s><th style="vertical-align:top; white-space:nowrap; text-align:left; font-weight:bold;">%s</th><td style="vertical-align:top;">%s</td></tr>' local SUBROW = '<tr%s><th style="vertical-align:top; white-space:nowrap; text-align:left; font-weight:normal; padding-left:0.5em;">•&nbsp;%s</th><td style="vertical-align:top;">%s</td></tr>' local HEADER = '<tr class="mergedtoprow"><th colspan="2" style="text-align:left;">%s</th></tr>' -- Builds a `class="..."` attribute (or an empty string), for the -- mergedrow/mergedbottomrow/mergedtoprow classes the old template uses to -- remove the double border between a header/label row and the indented -- sub-rows that visually belong under it. local function trClass(name) if name and name ~= "" then return ' class="' .. name .. '"' end return "" end -- Formats a run of bullet-prefixed sub-rows (leader pairs, house names, -- establishment events, ...) with the old template's merged-border -- convention: every row but the last is "mergedrow", the last is -- "mergedbottomrow" — so the whole run reads as one visually joined block -- under its header/label row. local function appendIndentRun(rows, items) for idx, item in ipairs(items) do local class = (idx == #items) and "mergedbottomrow" or "mergedrow" table.insert(rows, string.format(SUBROW, trClass(class), item[1], item[2])) end end -- Same divider the dispatcher module (Module:Kishtey fys çheer) uses BETWEEN -- whole submodules (see its own `dividerLine`/`appendModule`). Reused here, -- identically, to separate this module's own three internal sections -- (leaders/government, legislature, founding) the same visual way -- a -- divider is only inserted BETWEEN two sections that both actually produced -- rows, never before the first section or after the last, and never next to -- an empty/suppressed section (mirrors appendModule's own conditional). local dividerLine = '<tr><td colspan="2" style="border-top:1px solid #a2a9b1; padding:0; height:0px;"></td></tr>' local function appendSection(rows, sectionRows) if sectionRows and #sectionRows > 0 then if #rows > 0 then table.insert(rows, dividerLine) end for _, row in ipairs(sectionRows) do table.insert(rows, row) end end end function p.main(frame, args) -- Fallback verification to catch argument slots accurately if frame context shifts if not args then args = frame frame = mw.getCurrentFrame() end local rows = {} local govRows = {} local quaiylRows = {} local foundingRows = {} ---------------------------------------------------------------- -- 1-2. REILTYS (Government type) + FIR HOSHEE / TOSHEE (Leaders: -- head of state / head of government / etc.) -- `enmysN_fer-toshee` / `ennymN_fer-toshee` are the old, gendered -- param names, kept for backward compatibility with existing -- articles. `enmys_toshiaghN` / `ennym_toshiaghN` are the -- gender-neutral synonyms going forward ("toshiagh" = leader); -- either spelling works, and the new one takes priority when both -- are supplied for the same slot. Leaders are computed BEFORE the -- government-type row is emitted so that row can carry the right -- merged-border class when leader rows are going to follow it. ---------------------------------------------------------------- local govTypeRaw = getManual(args, {"sorçh_reiltys", "government_type"}) local govRef = getManual(args, {"imraa_reiltys"}) local govNote = getManual(args, {"noteyn_reiltys"}) if not govTypeRaw then -- Wikidata fallback via Module:Wd: basic form of government (P122), -- e.g. "unitary state, parliamentary system, constitutional -- monarchy" -- joins every value Wikidata records rather than just -- one, since this is normally split across several statements. -- Skipped entirely when the field was explicitly suppressed -- (`|sorçh_reiltys=none`), same as every other Wikidata-fallback -- field in this module. govTypeRaw = getWdProperties("P122", {"linked"}) end local govShown = govTypeRaw and not isNone(govTypeRaw) local leaderPairs = {} local manualLeaderGiven = false for i = 1, 5 do local title = getManual(args, {"enmys_toshiagh" .. i, "enmys" .. i .. "_fer-toshee"}) local name = getManual(args, {"ennym_toshiagh" .. i, "ennym" .. i .. "_fer-toshee"}) if title or name then manualLeaderGiven = true if not isNone(name) then table.insert(leaderPairs, {title = title or "", name = name or ""}) end end end local leaderRef = getManual(args, {"imraa_toshiagh", "imraa_fer-toshee"}) local leaderNote = getManual(args, {"noteyn_toshiagh", "noteyn_fer-toshee"}) local leadersSuppressed = isNone(getManual(args, {"fir_hoshee", "toshiaghyn"})) if not manualLeaderGiven and not leadersSuppressed then -- Wikidata fallback via Module:Wd: head of state (P35) / head of -- government (P6). Names are ALWAYS forced into a link (a redlink -- when gv.wiki has no article for that person yet) via -- ensureLinked, since an unlinked plain name is easy to mistake for -- a manual/unsourced value and gives editors nothing to click -- through to create the article. Titles try, in order: a manual -- override, the leader's own country-specific office (e.g. "Monark -- y Reeriaght Unnaneysit"), the Wikidata property's own label, then -- a hardcoded Manx fallback. local hos = shortenLinkedCountryName(ensureLinked(getWdProperty("P35", {"linked"}))) local hog = ensureLinked(getWdProperty("P6", {"linked"})) if hos then local hosTitle = getManual(args, {"sorçh_kione_steat"}) or getWdOfficeItemTitle("P1906") -- "office held by head of state" -- set directly on the country, no person-level ambiguity or getWdPositionTitle("P35") or getWikidataPropertyLabel("P35") or "Kione steat" table.insert(leaderPairs, {title = hosTitle, name = hos}) end if hog then local hogTitle = getManual(args, {"sorçh_kione_reiltys"}) or getWdOfficeItemTitle("P1313") -- "office held by head of government" -- same reasoning as P1906 above or getWdPositionTitle("P6") or getWikidataPropertyLabel("P6") or "Kione reiltys" table.insert(leaderPairs, {title = hogTitle, name = hog}) end end if govShown then local govClass = (#leaderPairs > 0) and "mergedtoprow" or "" table.insert(govRows, string.format(ROW, trClass(govClass), "[[Reiltys]]", applyRefNote(govTypeRaw, govRef, govNote, frame))) elseif #leaderPairs > 0 then table.insert(govRows, string.format(HEADER, "[[Reiltys]]")) end if #leaderPairs > 0 then -- The shared manual ref/note for the whole leaders block is -- attached to the last row, same convention as a single footnote -- covering a list. (A Wikidata-sourced name already carries its own -- auto-built citation from getWdProperty.) local last = leaderPairs[#leaderPairs] last.name = applyRefNote(last.name, leaderRef, leaderNote, frame) local items = {} for _, leader in ipairs(leaderPairs) do table.insert(items, {leader.title, leader.name}) end appendIndentRun(govRows, items) end ---------------------------------------------------------------- -- 3. QUAIYL / ÇHIONNAL (Legislature) -- `çhionnal` is a synonym for `quaiyl`; `thie_heose` / `thie_heese` -- are synonyms for `quaiyl_syrjey` / `quaiyl_s'inshley` (upper / -- lower house). New spellings take priority when both are given. -- Houses left completely unset (not even |thie_heose=none) get a -- Wikidata fallback of their own -- see getWdChambers above. ---------------------------------------------------------------- local quaiyl = getManual(args, {"çhionnal", "quaiyl"}) local quaiylSyrjey = getManual(args, {"thie_heose", "quaiyl_syrjey"}) local quaiylInshley = getManual(args, {"thie_heese", "quaiyl_s'inshley", "quaiyl_sinshley"}) local quaiylRef = getManual(args, {"imraa_çhionnal", "imraa_quaiyl"}) local quaiylNote = getManual(args, {"noteyn_çhionnal", "noteyn_quaiyl"}) if not quaiyl then -- "short" asks Module:Wd for the item's short name (Wikidata -- P1813) first, e.g. "Parliament" instead of the full official -- "Parliament of the United Kingdom of Great Britain and Northern -- Ireland" -- matching enwiki's own concise style. Falls back to -- the item's normal label when no short name is set. Deliberately -- gated on `quaiyl` ALONE, not bundled with the house params below -- -- an editor who suppressed just one house (|thie_heose=none) or -- named a house manually shouldn't lose the main body's own -- Wikidata fallback as a side effect. quaiyl = getWdProperty("P194", {"linked", "short"}) end if not quaiylSyrjey or not quaiylInshley then -- Wikidata fallback for the two chambers THEMSELVES (see -- getWdChambers above) -- resolved once, then applied -- INDEPENDENTLY to whichever side(s) are still nil, same as the -- head-of-state/head-of-government leader slots above: an explicit -- |thie_heose=none/|thie_heese=none suppression on one side (which -- leaves that variable as the literal string "none", not nil) -- always wins outright and is never overwritten, while the other, -- genuinely-omitted side still gets its own independent Wikidata -- value. Chained off the same legislative-body item as `quaiyl` -- above (P194's raw QID), not off whatever `quaiyl` itself resolved -- to, so this still works even when `quaiyl` was supplied manually. local legislatureQid = getWdRawPropertyId("P194") if legislatureQid then local wdUpper, wdLower = getWdChambers(legislatureQid) if not quaiylSyrjey then quaiylSyrjey = wdUpper end if not quaiylInshley then quaiylInshley = wdLower end end end if quaiyl and not isNone(quaiyl) then local houseItems = {} if quaiylSyrjey and not isNone(quaiylSyrjey) then table.insert(houseItems, {"[[Thie heose]]", quaiylSyrjey}) end if quaiylInshley and not isNone(quaiylInshley) then table.insert(houseItems, {"[[Thie heese]]", quaiylInshley}) end local quaiylClass = (#houseItems > 0) and "mergedtoprow" or "" table.insert(quaiylRows, string.format(ROW, trClass(quaiylClass), "[[Çhionnal slattyssagh]]", applyRefNote(quaiyl, quaiylRef, quaiylNote, frame))) appendIndentRun(quaiylRows, houseItems) end ---------------------------------------------------------------- -- 4. BUNNEEAGHT / KIONDEEAGHT (Founding / constitution) and -- historical establishment events — manual-only, ported -- directly from the old template's numbered slots (1-9). -- `kionedeeaght` is a synonym for `kiondeeaght` in the label/note -- param names. ---------------------------------------------------------------- local foundingLabel = getManual(args, {"sorçh_kionedeeaght", "sorçh_kiondeeaght"}) or "Bunneeaght" local foundingValue = getManual(args, {"bunnit"}) local foundingNote = getManual(args, {"note_kionedeeaght", "note_kiondeeaght"}) local foundingRef = getManual(args, {"imraa_kionedeeaght", "imraa_kiondeeaght"}) local establishmentRows = {} for i = 1, 9 do local event = getManual(args, {"taghyrt" .. i .. "_bunnit"}) local date = getManual(args, {"date" .. i .. "_bunnit"}) if event then table.insert(establishmentRows, {event, date or ""}) end end if foundingValue or #establishmentRows > 0 then if foundingValue and not isNone(foundingValue) then local foundingClass = (#establishmentRows > 0) and "mergedtoprow" or "" table.insert(foundingRows, string.format(ROW, trClass(foundingClass), "[[" .. foundingLabel .. "]]", applyRefNote(foundingValue, foundingRef, foundingNote, frame))) elseif #establishmentRows > 0 then table.insert(foundingRows, string.format(HEADER, "[[" .. foundingLabel .. "]]")) end appendIndentRun(foundingRows, establishmentRows) elseif not isNone(getManual(args, {"bunnit"})) then -- Wikidata fallback via Module:Wd: inception (P571) — only when the -- whole establishment block was left unset (not explicitly |bunnit=none). -- NOTE on date precision: Module:Wd's own time-value formatting (see -- Config:getValue's `datatype == 'time'` branch) already renders a -- FULL day-month-year date whenever the underlying Wikidata statement -- itself is stored at day precision -- there is no flag this call is -- missing, and no truncation happens on our side (confirmed by the -- test harness, which feeds a day-precision value straight through -- unchanged). When only a year is shown on a real article, that is -- because THAT COUNTRY's P571 statement on Wikidata itself is only -- recorded at year precision (very common for older founding dates) -- -- not a bug here. The manual |bunnit= override remains the fix for -- any article where the Wikidata precision isn't good enough. local inception = getWdProperty("P571") if inception then table.insert(foundingRows, string.format(ROW, "", "[[" .. foundingLabel .. "]]", applyRefNote(inception, foundingRef, foundingNote, frame))) end end appendSection(rows, govRows) appendSection(rows, quaiylRows) appendSection(rows, foundingRows) if #rows == 0 then return nil end return table.concat(rows) end return p or7qe49xy3hsu1qr50zc4b8sas4fup5 393011 393010 2026-09-10T03:13:01Z MacTire02 219 ++ 393011 Scribunto text/plain local p = {} -- Module:Wd is gv.wiki's actual working Wikidata-fetch-and-cite module -- (confirmed by its localized /i18n submodule) — used instead of -- Module:WikidataIB, which has no working reference-building of its own. -- pcall so a wiki state where Wd (or its own Module:Wd/i18n) isn't set up -- degrades to "no Wikidata fallback" instead of breaking the infobox. local wdOK, Wd = pcall(require, "Module:Wd") -- Module:Enmyn çheerey ("country names") already keeps a hand-curated table -- of each country's own Manx GENITIVE/mutated form (e.g. "Mannin" -> -- "Vannin", "Nalbin" -> "ny h-Albey", "Yn Reeriaght Unnaneysit" -> "y -- Reeriaght Unnaneysit") -- exactly the linguistic knowledge shortManxForm -- below otherwise has to guess at mechanically (see getCurrentCountryGenitive -- and shortManxForm further down for how this is used). pcall so a wiki -- state where this module isn't available degrades to the purely mechanical -- fallback instead of breaking the infobox. local enmynOK, EnmynCheerey = pcall(require, "Module:Enmyn çheerey") -- Module:Kishtey fys çheer/ennym-wd -- the shared "Manx label, with a -- linked-to-Wikidata non-Manx fallback" helper (see its own header comment -- for the full three-tier rationale). Used as the LAST rung in -- getWdItemManxLink below, only once a genuine Manx sitelink/label has -- already been checked for and not found. pcall'd for the same reason as -- the two requires above: a wiki state missing this submodule just means -- this particular fallback rung is unavailable, not a broken infobox. local ennymWdOK, EnnymWd = pcall(require, "Module:Kishtey fys çheer/ennym-wd") -- Safely get manual parameters from priority list local function getManual(args, names) for _, name in ipairs(names) do local value = args[name] if value and mw.text.trim(value) ~= "" then return mw.text.trim(value) end end return nil end local function isNone(value) return value ~= nil and mw.text.trim(value):lower() == "none" end -- Append a manual reference (<ref>) and/or note ({{efn}}) to a value. This -- is the manual imraa_*/noteyn_* channel, same as Module:Kishtey fys -- çheer/çhengaghyn uses. It layers on top of a Wikidata-sourced value too -- (which already carries its own auto-built citation from getWdProperty -- below) in case an editor wants to add an extra citation or clarifying -- footnote of their own. local function applyRefNote(value, ref, note, frame) if not value then return value end if note and note ~= "" and frame then value = value .. frame:expandTemplate{ title = "efn", args = { note } } end if ref and ref ~= "" then value = value .. "<ref>" .. ref .. "</ref>" end return value end -- Fetch+format a single Wikidata property value via Module:Wd's "property" -- command, combined with its "reference" command so that, when the -- Wikidata statement itself carries references, Wd builds a real <ref> -- citation (Cite web / Cite Q) from them automatically — the same way -- gv.wiki's other Wd-based infoboxes already cite Wikidata data. `flags` -- is an optional array of extra Wd flags (e.g. {"linked"}). Returns nil -- when Wd isn't available, or the property has no value. local function getWdProperty(property, flags) if not wdOK or not Wd or not Wd._property then return nil end local callArgs = {} for _, f in ipairs(flags or {}) do table.insert(callArgs, f) end table.insert(callArgs, "reference") -- request an auto-built citation alongside the value table.insert(callArgs, "best") -- single best-ranked value, mirroring the old template's behaviour table.insert(callArgs, property) local ok, result = pcall(Wd._property, callArgs) if ok and result and result ~= "" then return result end return nil end -- Same as getWdProperty, but via Module:Wd's plural "properties" command, -- which joins EVERY matching value together (comma-separated by default) -- instead of just the single best one. Used for government type (P122 -- "basic form of government"), which Wikidata typically records as several -- separate statements on one country (e.g. "unitary state", "parliamentary -- system", "constitutional monarchy") rather than one combined phrase. local function getWdProperties(property, flags) if not wdOK or not Wd or not Wd._properties then return nil end local callArgs = {} for _, f in ipairs(flags or {}) do table.insert(callArgs, f) end table.insert(callArgs, "reference") table.insert(callArgs, property) local ok, result = pcall(Wd._properties, callArgs) if ok and result and result ~= "" then return result end return nil end -- Module:Wd's "linked" flag only produces a wikilink when the entity -- already has a gv sitelink (Config:getLabel returns the bare label, -- un-bracketed, otherwise — see Module:Wd source). For a leader whose -- article doesn't exist on gv.wiki yet, that means no link at all. Since -- an editor should still be able to click through (or see a redlink -- inviting the article to be written), this forces a wikilink around the -- label text when Wd didn't already supply one — without touching a -- trailing auto-built <ref>...</ref> citation, which Wd appends directly -- after the label/link text. local function ensureLinked(value) if not value or value == "" then return value end local label, refSuffix = value:match("^(.-)(<ref.*)$") if not label then label = value refSuffix = "" end if label:find("%[%[") then return value -- already a real link via a gv sitelink end label = mw.text.trim(label) if label == "" then return value end return "[[" .. label .. "]]" .. refSuffix end -- Label of the Wikidata PROPERTY itself (e.g. P35 -> "head of state"), used -- as a Wikidata-sourced fallback for a leader's title when no manual -- title/override is supplied. Deliberately uses getLabelByLang(property, -- "gv") rather than mw.wikibase.label(property): plain label() follows -- Wikidata's language-fallback chain and will happily hand back the -- English label when no Manx one exists (which is the common case for -- properties on Wikidata) — silently leaking English text like "head of -- state" into the Manx infobox. getLabelByLang only returns a value when a -- Manx label genuinely exists, so an untranslated property correctly falls -- through to the hardcoded Manx text below instead. local function getWikidataPropertyLabel(property) local ok, label = pcall(mw.wikibase.getLabelByLang, property, "gv") if ok and label and label ~= "" then return label end return nil end -- Raw QID (no linking/label formatting) of an entity-valued property on the -- CURRENT page's Wikidata item — e.g. P35's value (the head of state person) -- as a bare "Q..." id, so it can be used as the `eid` for a follow-up -- lookup on THAT person's own item (see getWdPositionTitle below). Uses -- Module:Wd's "raw" flag, which for an entity-id-valued statement returns -- the plain id instead of a formatted link/label. local function getWdRawPropertyId(property) if not wdOK or not Wd or not Wd._property then return nil end local ok, result = pcall(Wd._property, {"raw", "best", property}) if ok and result and type(result) == "string" and result:match("^Q%d+$") then return result end return nil end -- The raw QID of a QUALIFIER attached to the CURRENT PAGE's own "best" -- statement of `property` -- e.g. the "proxy" (P1393) qualifier recorded on -- a country's own P35 ("head of state") statement (see the proxy leader row -- in p.main below). This is a DIFFERENT claim command from getWdRawPropertyId -- above: Module:Wd's `_qualifier` (not `_property`) reads the MAIN -- statement's property first, then reads a nested qualifier of that same -- statement, rather than a second independent top-level property. Per -- Module:Wd's own `claimCommand` internals (its `nextArg`/`getEntityId` -- argument consumption order), the positional call shape is -- {"raw", "best", mainProperty, qualifierProperty} -- flags first, then the -- statement's own property, then the qualifier's property; with no `eid` -- given it defaults to the current page's own entity, exactly as -- getWdRawPropertyId does. Returns nil on any failure, a missing qualifier, -- or a non-entity-valued qualifier. local function getWdQualifierRawId(property, qualifierProperty) if not wdOK or not Wd or not Wd._qualifier then return nil end local ok, result = pcall(Wd._qualifier, {"raw", "best", property, qualifierProperty}) if ok and result and type(result) == "string" and result:match("^Q%d+$") then return result end return nil end -- Raw QIDs of EVERY value of an entity-valued property on a FOREIGN -- Wikidata item (`eid`), not the current page's — e.g. the leader's own -- P39 ("position held") statements, which a real politician very often has -- several of at once (a parliamentary seat, a party leadership, AND a head- -- of-government office can all be simultaneously "current" -- see -- getWdPositionTitle below for why that matters). Uses Module:Wd's PLURAL -- "properties" command (not "property"), which -- unlike the singular -- command -- does not stop at a single "best" value, so every matching -- claim is returned, joined together; this extracts each "Q..." token from -- that joined string rather than relying on a specific separator, since -- Wd's separator choice isn't part of its documented contract. `eid` is -- passed the same way Module:Wd's own code does internally -- (`p._property{..., [p.args.eid] = id}`). `qualifiers` is an optional -- table of {qualifierPropertyId = requiredValue} pairs -- Module:Wd's -- claimCommand treats any hash key matching "P%d+" as a qualifier filter -- (see its `qualifierIDsAndValues`/`qualifierMatches` logic), letting a -- caller narrow the claims returned to just those with a matching -- qualifier (see getWdPositionTitle below, which uses this for P1001 -- "applies to jurisdiction"). Returns an empty table on any failure. local function getWdRawForeignPropertyIds(eid, property, extraFlags, qualifiers) if not wdOK or not Wd or not Wd._properties or not eid then return {} end local callArgs = {} for _, f in ipairs(extraFlags or {}) do table.insert(callArgs, f) end table.insert(callArgs, "raw") table.insert(callArgs, property) callArgs[Wd.args and Wd.args.eid or "eid"] = eid for qid, value in pairs(qualifiers or {}) do callArgs[qid] = value end local ok, result = pcall(Wd._properties, callArgs) if not ok or not result or type(result) ~= "string" or result == "" then return {} end local ids = {} for id in result:gmatch("Q%d+") do table.insert(ids, id) end return ids end -- The QID of the entity connected to the CURRENT page (e.g. the country the -- article is about), used to disambiguate a multi-realm head of state's P39 -- statements (see getWdPositionTitle below). Returns nil when the current -- page has no connected Wikidata item. local function getCurrentCountryQid() local ok, id = pcall(mw.wikibase.getEntityIdForCurrentPage) if ok and id and id ~= "" then return id end return nil end -- The exact Manx GENITIVE form of the CURRENT PAGE's own country/territory -- -- e.g. "Vannin" for the Isle of Man's own article, "y Reeriaght -- Unnaneysit" for the UK's -- looked up from Module:Enmyn çheerey's shared, -- hand-curated table (see shortManxForm below for how this is used). -- Derived from the current page's own title, which -- for a country/ -- territory article -- IS that country's plain Manx name, the same key -- Module:Enmyn çheerey's table is keyed on. Returns nil when -- Module:Enmyn çheerey isn't available, the current page has no title -- (shouldn't happen in practice), or the lookup itself fails for any reason -- -- all pcall'd defensively so a missing/renamed dependency just falls -- through to shortManxForm's mechanical fallback rungs instead of erroring. local function getCurrentCountryGenitive() if not enmynOK or not EnmynCheerey or not EnmynCheerey.genitive then return nil end local okTitle, title = pcall(function() return mw.title.getCurrentTitle().text end) if not okTitle or not title or title == "" then return nil end local okGen, genitive = pcall(EnmynCheerey.genitive, title) if okGen and genitive and genitive ~= "" then return genitive end return nil end -- Manx country-specific office titles on gv.wiki attach the CURRENT page's -- own country name to a role, in one of two constructions -- e.g. "Monark y -- Reeriaght Unnaneysit" (a "y"/"of the" connector, for longer/multi-word -- country names) or "Ard-hirveishagh Vannin" (the country attached directly, -- often in a mutated genitive form, for shorter ones). Either way, this -- keeps just the leading role word(s) as the link's DISPLAY text while the -- link target stays the full title -- e.g. "[[Monark y Reeriaght -- Unnaneysit|Monark]]", "[[Ard-hirveishagh Vannin|Ard-hirveishagh]]". -- -- Rung 0 (linguistically correct, tried first): Module:Enmyn çheerey already -- keeps a hand-curated table of exactly this -- each country's own Manx -- genitive form, "y "/"yn " prefix (or lack of one) and initial mutation -- included. getCurrentCountryGenitive() above resolves that for the CURRENT -- article's own country; if the office title ends with " " followed by that -- exact genitive form, this strips it with certainty, rather than guessing -- -- and adding a country to that ONE shared table (already documented -- there as extensible) benefits every module that uses it, not just this -- one. -- -- Rungs 1-2 (mechanical fallback, used only when rung 0 doesn't apply -- -- Module:Enmyn çheerey unavailable, or this country/title isn't covered by -- its table yet): detach everything from the first " y " onward (rung 1), -- or, failing that, everything from the LAST remaining space onward (rung -- 2) -- a blind guess that happens to match the real construction in every -- case seen so far, but isn't linguistically guaranteed the way rung 0 is. -- -- A title with no space at all (already just a bare role name, e.g. -- "Ard-whaiyl") falls through every rung unchanged. -- -- Exceptions: full titles that should always be used as-is, unshortened, -- even though they'd otherwise match a rung above -- e.g. "Çhiarn Vannin" -- (Lord of Mann), where stripping " Vannin" would technically be correct per -- Module:Enmyn çheerey's own genitive table, but that's not how this -- specific title should read. Checked before any rung is tried. local shortFormExceptions = { ["Çhiarn Vannin"] = true, } local function shortManxForm(title) if not title or title == "" then return title end if shortFormExceptions[title] then return title end local countryGenitive = getCurrentCountryGenitive() if countryGenitive then local suffix = " " .. countryGenitive if #title > #suffix and title:sub(-#suffix) == suffix then return title:sub(1, #title - #suffix) end end local short = title:match("^(.-)%sy%s") if short and short ~= "" then return short end short = title:match("^(.+)%s%S+$") if short and short ~= "" then return short end return title end -- A conservative cousin of shortManxForm, used ONLY for a PERSON's own name -- (see shortenLinkedCountryName below), never for an office title. A shared -- monarch is the one case where gv.wiki has to disambiguate a PERSON's own -- article per realm the same way office-title items are (e.g. an article -- titled "Çhalse III y Reeriaght Unnaneysit" for the UK's Charles III, -- distinct from his article for another realm) -- so this strips exactly -- that same country-genitive tail when it's genuinely present. Deliberately -- OMITS shortManxForm's rung 2 (blind last-space split): that rung is safe -- for an office title (which always ends in a country reference) but would -- be actively wrong for an ordinary two/three-word person's name with no -- country suffix at all -- e.g. it would mangle "Charse III" into "Charse", -- silently dropping the regnal numeral. Only the two rungs that require a -- genuine, identifiable country-genitive match are used here: Module:Enmyn -- çheerey's exact genitive suffix (rung 0), or an explicit " y " token -- (rung 1) -- both of gv.wiki's known cases ("Çhalse III y Reeriaght -- Unnaneysit", "Louisagh IV y Rank") already contain a literal " y ", so -- rung 1 alone would catch them even without Module:Enmyn çheerey data. local function shortenCountrySuffixedName(name) if not name or name == "" then return name end local countryGenitive = getCurrentCountryGenitive() if countryGenitive then local suffix = " " .. countryGenitive if #name > #suffix and name:sub(-#suffix) == suffix then return name:sub(1, #name - #suffix) end end local short = name:match("^(.-)%sy%s") if short and short ~= "" then return short end return name end -- Shortens the DISPLAY text of the head-of-state's own linked name when -- gv.wiki's article for them is a per-realm-disambiguated one (see -- shortenCountrySuffixedName above) -- e.g. turning the unpiped -- "[[Çhalse III y Reeriaght Unnaneysit]]" Module:Wd hands back (it has -- nothing else to use as display text there) into the piped -- "[[Çhalse III y Reeriaght Unnaneysit|Çhalse III]]", leaving the link -- target and any trailing manual/auto <ref> citation completely untouched. -- Deliberately scoped to the HEAD-OF-STATE slot only (see its call site in -- p.main) rather than a general-purpose name formatter: an ordinary head of -- government is never the same person across several countries, so their -- own gv article is never disambiguated this way in the first place -- -- structurally, only a shared monarch produces this shape of data at all, -- which is what "condition this on the head of state being a monarch" -- comes down to in practice, without a separate Wikidata lookup to confirm -- it. Only fires on a bare, unpiped "[[target]]" link with no existing -- custom display text (i.e. nothing this module or Wd itself already chose -- to show instead) -- a name that's already piped, or has no country suffix -- to strip at all, is returned completely unchanged. -- Handles BOTH a bare "[[target]]" link and an already-piped "[[target| -- display]]" one, shortening whichever text is CURRENTLY being displayed -- -- not just the bare-unpiped case. This is deliberately more permissive than -- checking only for an unpiped link: Module:Wd's own buildWikilink normally -- produces the unpiped form specifically when the Wikidata label and the gv -- sitelink title are identical, but relying on that always holding (rather -- than on what's actually visible to the reader) is exactly the kind of -- assumption that can quietly stop matching if Wd's output shape ever -- differs even slightly -- e.g. a piped link whose display text still -- happens to be the full disambiguated title. Working from whatever text is -- actually displayed, rather than assuming it must be unpiped, is more -- robust either way. local function shortenLinkedCountryName(value) if not value or value == "" then return value end local main, refSuffix = value:match("^(.-)(<ref.*)$") if not main then main = value refSuffix = "" end local target, display = main:match("^%[%[([^%[%]|]+)|([^%[%]|]+)%]%]$") if not target then target = main:match("^%[%[([^%[%]|]+)%]%]$") display = target end if not target then return value end local short = shortenCountrySuffixedName(display) if short ~= display then return "[[" .. target .. "|" .. short .. "]]" .. refSuffix end return value end -- Capitalizes the first letter the way the wiki itself would (respecting -- Manx-specific case folding, e.g. digraphs like "çh"), via the content -- language object's own ucfirst -- NOT a plain Lua upper() on byte 1, which -- would mangle multi-byte UTF-8 and wouldn't match gv.wiki's own title- -- capitalization rules. Needed because a raw Wikidata LABEL (unlike a real -- page title/sitelink) is conventionally stored all-lowercase (e.g. -- "monark"), but both a link's display text and a red-linked target should -- read the way an actual Manx Wikipedia article title would. local function wikiUcfirst(text) if not text or text == "" then return text end local ok, result = pcall(function() return mw.language.getContentLanguage():ucfirst(text) end) if ok and result and result ~= "" then return result end return text end -- Given a Wikidata item ID for a specific office/position (e.g. "King of -- the United Kingdom"), build a wikilink using the gv sitelink (when one -- exists) or, failing that, a verified gv LABEL as the link target -- ALWAYS -- as a real wikilink, even when that means a redlink inviting the article to -- be written (per explicit instruction: an unlinked office title is -- indistinguishable from an unsourced one, same reasoning as ensureLinked() -- above for leader names). The display text has the "y <country>" tail -- detached (see shortManxForm above), e.g. "[[Monark y Reeriaght -- Unnaneysit|Monark]]". Never uses mw.wikibase.label's English-fallback- -- prone version -- same leak this module already had to fix once for -- property labels. Returns nil only when NEITHER a sitelink nor a gv label -- exists at all, so callers fall through to the generic hardcoded Manx text. -- -- The link TARGET and the DISPLAY text are resolved SEPARATELY, and can -- come from different sources: -- - Target: the real sitelink when the article exists, otherwise the gv -- LABEL itself (which is what makes this a redlink, inviting the -- article to be written at that title). -- - Display: the gv LABEL whenever one exists -- even when a sitelink/ -- article ALSO exists, and even if its title reads differently (an -- older article title, a disambiguator, different capitalization) -- -- because the label is Wikidata's own record of what this entity -- should actually be CALLED in Manx, and that's what belongs in the -- infobox text. Only when no gv label exists at all does the sitelink -- title double as the display basis too. -- The two are then only piped together (`[[target|display]]`) when they -- actually differ after shortening; otherwise a plain `[[target]]`. -- -- `shorten` defaults to true (every existing caller wants shortManxForm's -- "role + country" stripping, applied to the display text). Pass `false` -- for an item whose title ISN'T structured that way -- e.g. a legislative -- CHAMBER's own name (see getWdChambers below), which is an ordinary proper -- name with no reliable "role attached to a country" shape, so -- shortManxForm's rung 2 (a blind last-space split) would risk mangling it -- the same way it would a person's plain name -- same reasoning as -- shortenCountrySuffixedName's deliberately narrower rung set above, just -- applied here by skipping shortManxForm entirely rather than substituting -- a conservative cousin of it. local function getWdItemManxLink(qid, shorten) if not qid then return nil end local okSite, sitelinkTitle = pcall(mw.wikibase.sitelink, qid) if not okSite then sitelinkTitle = nil end sitelinkTitle = (sitelinkTitle and sitelinkTitle ~= "") and sitelinkTitle or nil local okLabel, gvLabel = pcall(mw.wikibase.getLabelByLang, qid, "gv") if okLabel and gvLabel and gvLabel ~= "" then -- Wikidata labels are conventionally lowercase; capitalize so it -- reads (and, if used as a redlink target, will resolve/redirect) -- like a real title. gvLabel = wikiUcfirst(gvLabel) else gvLabel = nil end if not sitelinkTitle and not gvLabel then -- Neither a Manx sitelink nor a Manx label exists at all -- rather -- than giving up silently (a caller like getWdChambers would then -- have nothing to show for a real, correctly-identified chamber, or -- a caller like getWdOfficeItemTitle would fall through to a -- generic hardcoded title), fall back to the shared ennym-wd -- helper: the best available label (usually English), wrapped in a -- plain external link straight to the item on Wikidata (renders in -- the skin's own distinct external-link colour, NOT a normal -- internal wikilink's blue/red -- there's no genuine Manx title -- here to wikilink to), tagged with the language it's actually in. -- See Module:Kishtey fys çheer/ennym-wd's own header comment for -- the full three-tier rationale (sitelink -> blue; gv label only -> -- red, inviting the article; neither -> this). if ennymWdOK and EnnymWd and EnnymWd.labelWithFallback then local ok, annotated = pcall(EnnymWd.labelWithFallback, qid) if ok and annotated then return annotated end end return nil end local target = sitelinkTitle or gvLabel local displayBase = gvLabel or sitelinkTitle if shorten == false then if target == displayBase then return "[[" .. target .. "]]" end return "[[" .. target .. "|" .. displayBase .. "]]" end local short = shortManxForm(displayBase) if short ~= target then return "[[" .. target .. "|" .. short .. "]]" end return "[[" .. target .. "]]" end -- Wikidata has two properties made specifically to solve this exact office- -- title problem, set directly on the COUNTRY's own item rather than on the -- office-holder: P1906 "office held by head of state" and P1313 "office held -- by head of government" (these two IDs are easy to transpose -- there's no -- mnemonic pattern distinguishing them -- and an earlier version of this -- module had them backwards; double-checked against wikidata.org's own -- property pages before fixing). Their value is the generic OFFICE item itself -- (e.g. "Chief Minister of the Isle of Man" / "Ard-hirveishagh Vannin") -- -- not a person, and not one of several roles a particular office-holder -- happens to hold right now. When a country's item has this property set, -- it sidesteps the multi-role-P39 ambiguity entirely (see getWdPositionTitle -- below): there's no need to guess which of a person's several concurrent -- "position held" statements is the right one, because Wikidata already -- names the office directly. Tried FIRST, before the person-chain fallback. local function getWdOfficeItemTitle(officeProperty) local officeQid = getWdRawPropertyId(officeProperty) if not officeQid then return nil end return getWdItemManxLink(officeQid) end -- FALLBACK ONLY (see getWdOfficeItemTitle above, tried first): the leader's -- own specific office title (e.g. "Monark y Reeriaght Unnaneysit" / -- "Ard-vinishter y Reeriaght Unnaneysit"), NOT the generic property -- description ("head of state"/"kione steat"), derived by chaining through -- the CURRENT OFFICE-HOLDER instead of a dedicated country-level property -- -- used only for a country whose Wikidata item doesn't have P1313/P1906 set. -- Wikidata attaches the country-specific title to the position-HOLDER's own -- "position held" (P39) statement, not to the country's P35/P6 statement — -- so this chains through the person: P35/P6 -> person's raw QID -> that -- person's current P39 value -> a Manx link/label for it. -- -- A head of state/government very often holds MULTIPLE simultaneous "current" -- P39 positions -- not just the classic shared-monarch case ("King of the -- United Kingdom", "King of Canada", "King of Australia", ... all current at -- once), but just as commonly a head of government who is ALSO, right now, a -- sitting member of their legislature AND the leader of their party. A brand -- new statement (e.g. someone who became PM only weeks ago) frequently has -- NO qualifier at all yet distinguishing "this is the state office" from -- "this is the party/parliamentary one" -- P1001 ("applies to jurisdiction") -- is the qualifier Wikidata uses for the shared-monarch case specifically, -- but isn't reliably present on every fresh statement, so it can't be -- trusted as the only signal. -- -- So rather than committing to a single "best" P39 value (which could just -- as easily be "Member of Parliament for ..." or "Leader of the ... Party" -- as the actual head-of-government office), this collects EVERY current P39 -- candidate -- ones matching a P1001 filter for this article's own country -- first (when the data has that qualifier, which correctly resolves a -- shared monarch to the right realm), then every other current candidate -- -- and tries each in turn, using the FIRST one that actually resolves to a -- real Manx sitelink or label via getWdItemManxLink. In practice an -- ancillary role (a parliamentary seat, a party leadership) is very unlikely -- to have a dedicated gv.wiki article of its own, while the formal head-of- -- state/government office is exactly the kind of article gv.wiki is likely -- to have -- so this reliably lands on the right one without needing -- Wikidata's qualifiers to be perfectly curated. -- -- Returns nil only when NONE of the current P39 candidates resolves to -- anything on gv.wiki (or Module:Wd is unavailable, or there's no current -- P39 at all), so callers fall back to the property-label / hardcoded rungs -- below. local function getWdPositionTitle(headProperty) local personQid = getWdRawPropertyId(headProperty) if not personQid then return nil end local countryQid = getCurrentCountryQid() local candidates = {} if countryQid then for _, id in ipairs(getWdRawForeignPropertyIds(personQid, "P39", {"current"}, {["P1001"] = countryQid})) do table.insert(candidates, id) end end for _, id in ipairs(getWdRawForeignPropertyIds(personQid, "P39", {"current"})) do table.insert(candidates, id) end local tried = {} for _, qid in ipairs(candidates) do if not tried[qid] then tried[qid] = true local link = getWdItemManxLink(qid) if link then return link end end end return nil end -- Wikidata's own class items for this concept: "upper house" (Q637846) and -- "lower house" (Q375928) -- verified directly against wikidata.org's own -- item pages before use, same discipline as the P1906/P1313 fix above, since -- these are exactly the kind of easily-confused-or-guessed IDs that bit this -- module once already. A bicameral legislature's own Wikidata item typically -- carries "has part(s)" (P527) statements pointing to its two chambers, each -- of which in turn usually carries its own "instance of" (P31) statement -- classifying it as one or the other (e.g. Parliament of the United Kingdom -- -P527-> House of Commons -P31-> lower house, House of Lords -P31-> upper -- house). -- -- Deliberately conservative: only acted on when the has-part list resolves -- to EXACTLY one item classified as the upper house and EXACTLY one -- classified as the lower house. A unicameral legislature with no P527 -- statements at all (by far the most common case among gv.wiki's country -- articles) correctly yields nothing from either side; two or more items -- matching the SAME slot (ambiguous/inconsistent data) is treated as -- unusable for that slot rather than guessing which one is right. Either way -- the manual |thie_heose=/|thie_heese= override remains the fix for any -- article where Wikidata's chamber data isn't good enough -- same safety -- valve as every other Wikidata-fallback field in this module. -- -- No auto-built <ref> citation is attached to either chamber name, matching -- the existing convention for every other CHAINED (multi-property-hop) -- Wikidata lookup in this module (getWdOfficeItemTitle/getWdPositionTitle's -- office titles above carry no citation either) -- only a single property -- fetched directly off the current page's own item (getWdProperty/ -- getWdProperties) can hand back one of Module:Wd's auto-built references. local UPPER_HOUSE_QID = "Q637846" local LOWER_HOUSE_QID = "Q375928" local function getWdChambers(legislatureQid) if not legislatureQid then return nil, nil end local partQids = getWdRawForeignPropertyIds(legislatureQid, "P527") local upperQid, lowerQid = nil, nil local upperAmbiguous, lowerAmbiguous = false, false for _, partQid in ipairs(partQids) do for _, classQid in ipairs(getWdRawForeignPropertyIds(partQid, "P31")) do if classQid == UPPER_HOUSE_QID then if upperQid and upperQid ~= partQid then upperAmbiguous = true end upperQid = partQid elseif classQid == LOWER_HOUSE_QID then if lowerQid and lowerQid ~= partQid then lowerAmbiguous = true end lowerQid = partQid end end end local upperLink = (upperQid and not upperAmbiguous) and getWdItemManxLink(upperQid, false) or nil local lowerLink = (lowerQid and not lowerAmbiguous) and getWdItemManxLink(lowerQid, false) or nil return upperLink, lowerLink end -- Row templates. Every row in this table is a plain 2-cell -- `<th>label</th><td>value</td>` row — exactly the grid every OTHER -- submodule in this system uses (Module:Kishtey fys çheer/çhengaghyn, -- /balley, /bratteeyn). The old HTML template used a 3-column grid instead -- (a narrow indent-spacer <td>, a label <td>, a value <td>, with -- colspan="2"/colspan="3" on label-only/header rows) — mixing that 3-column -- convention into a 2-column table was the actual cause of the reported -- "bunching"/"enormous gap" distortion: rows with different physical cell -- counts in the same table force the browser to reconcile column widths -- unpredictably. Sub-items (individual leaders/houses/founding events under -- one shared label) are distinguished with a "•" bullet + reduced font -- weight on the label cell instead of a separate spacer column — matching -- how English Wikipedia's infobox marks up a list of leaders under one -- "Leader" heading. local ROW = '<tr%s><th style="vertical-align:top; white-space:nowrap; text-align:left; font-weight:bold;">%s</th><td style="vertical-align:top;">%s</td></tr>' local SUBROW = '<tr%s><th style="vertical-align:top; white-space:nowrap; text-align:left; font-weight:normal; padding-left:0.5em;">•&nbsp;%s</th><td style="vertical-align:top;">%s</td></tr>' local HEADER = '<tr class="mergedtoprow"><th colspan="2" style="text-align:left;">%s</th></tr>' -- Builds a `class="..."` attribute (or an empty string), for the -- mergedrow/mergedbottomrow/mergedtoprow classes the old template uses to -- remove the double border between a header/label row and the indented -- sub-rows that visually belong under it. local function trClass(name) if name and name ~= "" then return ' class="' .. name .. '"' end return "" end -- Formats a run of bullet-prefixed sub-rows (leader pairs, house names, -- establishment events, ...) with the old template's merged-border -- convention: every row but the last is "mergedrow", the last is -- "mergedbottomrow" — so the whole run reads as one visually joined block -- under its header/label row. local function appendIndentRun(rows, items) for idx, item in ipairs(items) do local class = (idx == #items) and "mergedbottomrow" or "mergedrow" table.insert(rows, string.format(SUBROW, trClass(class), item[1], item[2])) end end -- Same divider the dispatcher module (Module:Kishtey fys çheer) uses BETWEEN -- whole submodules (see its own `dividerLine`/`appendModule`). Reused here, -- identically, to separate this module's own three internal sections -- (leaders/government, legislature, founding) the same visual way -- a -- divider is only inserted BETWEEN two sections that both actually produced -- rows, never before the first section or after the last, and never next to -- an empty/suppressed section (mirrors appendModule's own conditional). local dividerLine = '<tr><td colspan="2" style="border-top:1px solid #a2a9b1; padding:0; height:0px;"></td></tr>' local function appendSection(rows, sectionRows) if sectionRows and #sectionRows > 0 then if #rows > 0 then table.insert(rows, dividerLine) end for _, row in ipairs(sectionRows) do table.insert(rows, row) end end end function p.main(frame, args) -- Fallback verification to catch argument slots accurately if frame context shifts if not args then args = frame frame = mw.getCurrentFrame() end local rows = {} local govRows = {} local quaiylRows = {} local foundingRows = {} ---------------------------------------------------------------- -- 1-2. REILTYS (Government type) + FIR HOSHEE / TOSHEE (Leaders: -- head of state / head of government / etc.) -- `enmysN_fer-toshee` / `ennymN_fer-toshee` are the old, gendered -- param names, kept for backward compatibility with existing -- articles. `enmys_toshiaghN` / `ennym_toshiaghN` are the -- gender-neutral synonyms going forward ("toshiagh" = leader); -- either spelling works, and the new one takes priority when both -- are supplied for the same slot. Leaders are computed BEFORE the -- government-type row is emitted so that row can carry the right -- merged-border class when leader rows are going to follow it. ---------------------------------------------------------------- local govTypeRaw = getManual(args, {"sorçh_reiltys", "government_type"}) local govRef = getManual(args, {"imraa_reiltys"}) local govNote = getManual(args, {"noteyn_reiltys"}) if not govTypeRaw then -- Wikidata fallback via Module:Wd: basic form of government (P122), -- e.g. "unitary state, parliamentary system, constitutional -- monarchy" -- joins every value Wikidata records rather than just -- one, since this is normally split across several statements. -- Skipped entirely when the field was explicitly suppressed -- (`|sorçh_reiltys=none`), same as every other Wikidata-fallback -- field in this module. govTypeRaw = getWdProperties("P122", {"linked"}) end local govShown = govTypeRaw and not isNone(govTypeRaw) local leaderPairs = {} local manualLeaderGiven = false for i = 1, 5 do local title = getManual(args, {"enmys_toshiagh" .. i, "enmys" .. i .. "_fer-toshee"}) local name = getManual(args, {"ennym_toshiagh" .. i, "ennym" .. i .. "_fer-toshee"}) if title or name then manualLeaderGiven = true if not isNone(name) then table.insert(leaderPairs, {title = title or "", name = name or ""}) end end end local leaderRef = getManual(args, {"imraa_toshiagh", "imraa_fer-toshee"}) local leaderNote = getManual(args, {"noteyn_toshiagh", "noteyn_fer-toshee"}) local leadersSuppressed = isNone(getManual(args, {"fir_hoshee", "toshiaghyn"})) if not manualLeaderGiven and not leadersSuppressed then -- Wikidata fallback via Module:Wd: head of state (P35) / head of -- government (P6). Names are ALWAYS forced into a link (a redlink -- when gv.wiki has no article for that person yet) via -- ensureLinked, since an unlinked plain name is easy to mistake for -- a manual/unsourced value and gives editors nothing to click -- through to create the article. Titles try, in order: a manual -- override, the leader's own country-specific office (e.g. "Monark -- y Reeriaght Unnaneysit"), the Wikidata property's own label, then -- a hardcoded Manx fallback. local hos = shortenLinkedCountryName(ensureLinked(getWdProperty("P35", {"linked"}))) local hog = ensureLinked(getWdProperty("P6", {"linked"})) if hos then local hosTitle = getManual(args, {"sorçh_kione_steat"}) or getWdOfficeItemTitle("P1906") -- "office held by head of state" -- set directly on the country, no person-level ambiguity or getWdPositionTitle("P35") or getWikidataPropertyLabel("P35") or "Kione steat" table.insert(leaderPairs, {title = hosTitle, name = hos}) -- A head of state's "proxy" -- a separate office that formally -- stands in for them on the ground (e.g. the Isle of Man's -- Lieutenant Governor standing in for the Monarch) -- shown as -- its own row directly BETWEEN the head of state and the head -- of government, but only when Wikidata actually records one -- for the current page's own P35 statement. This entire block -- is new (the old HTML template had no equivalent concept at -- all), so there's no old-parameter backward compatibility to -- preserve here -- only the usual `none`-suppression safety -- valve, same as every other Wikidata-fallback field. -- -- `ynnydee_kione_steat` (suppression), `sorçh_ynnydee` (title -- override) and the hardcoded "Ynnydee" fallback word all use -- your own chosen Manx term for this concept -- a REPRESENTATIVE -- of the head of state (e.g. a Lieutenant Governor), which you've -- distinguished from a "deputy"/vice-head-of-state (built instead -- via a "Lhiass-" prefix on the base office word, e.g. "Lhiass- -- eaghtyrane" for a deputy president) -- a separate concept this -- module doesn't currently model at all, since Wikidata's P1393 -- ("proxy") is specifically the representative relationship, not -- the deputy one. if not isNone(getManual(args, {"ynnydee_kione_steat"})) then -- P1393 ("proxy") is recorded as a QUALIFIER on the -- country's own P35 statement (not a top-level property of -- any entity), whose value is the generic OFFICE item -- itself (e.g. Q1790061, "Lieutenant Governor of the Isle -- of Man") -- not a person. The actual current person is a -- separate, ordinary top-level P1308 ("officeholder") -- lookup on THAT office item. local proxyOfficeQid = getWdQualifierRawId("P35", "P1393") if proxyOfficeQid then local proxyPersonIds = getWdRawForeignPropertyIds(proxyOfficeQid, "P1308", {"best"}) local proxyPersonQid = proxyPersonIds[1] local proxyName = proxyPersonQid and ensureLinked(getWdItemManxLink(proxyPersonQid, false)) or nil if proxyName then -- Title: a manual override, else the office item's -- own Manx name/link (default shorten=true, same -- office-title-style treatment as every other -- office title in this module), else the tentative -- hardcoded fallback word. local proxyTitle = getManual(args, {"sorçh_ynnydee"}) or getWdItemManxLink(proxyOfficeQid) or "Ynnydee" table.insert(leaderPairs, {title = proxyTitle, name = proxyName}) end end end end if hog then local hogTitle = getManual(args, {"sorçh_kione_reiltys"}) or getWdOfficeItemTitle("P1313") -- "office held by head of government" -- same reasoning as P1906 above or getWdPositionTitle("P6") or getWikidataPropertyLabel("P6") or "Kione reiltys" table.insert(leaderPairs, {title = hogTitle, name = hog}) end end if govShown then local govClass = (#leaderPairs > 0) and "mergedtoprow" or "" table.insert(govRows, string.format(ROW, trClass(govClass), "[[Reiltys]]", applyRefNote(govTypeRaw, govRef, govNote, frame))) elseif #leaderPairs > 0 then table.insert(govRows, string.format(HEADER, "[[Reiltys]]")) end if #leaderPairs > 0 then -- The shared manual ref/note for the whole leaders block is -- attached to the last row, same convention as a single footnote -- covering a list. (A Wikidata-sourced name already carries its own -- auto-built citation from getWdProperty.) local last = leaderPairs[#leaderPairs] last.name = applyRefNote(last.name, leaderRef, leaderNote, frame) local items = {} for _, leader in ipairs(leaderPairs) do table.insert(items, {leader.title, leader.name}) end appendIndentRun(govRows, items) end ---------------------------------------------------------------- -- 3. QUAIYL / ÇHIONNAL (Legislature) -- `çhionnal` is a synonym for `quaiyl`; `thie_heose` / `thie_heese` -- are synonyms for `quaiyl_syrjey` / `quaiyl_s'inshley` (upper / -- lower house). New spellings take priority when both are given. -- Houses left completely unset (not even |thie_heose=none) get a -- Wikidata fallback of their own -- see getWdChambers above. ---------------------------------------------------------------- local quaiyl = getManual(args, {"çhionnal", "quaiyl"}) local quaiylSyrjey = getManual(args, {"thie_heose", "quaiyl_syrjey"}) local quaiylInshley = getManual(args, {"thie_heese", "quaiyl_s'inshley", "quaiyl_sinshley"}) local quaiylRef = getManual(args, {"imraa_çhionnal", "imraa_quaiyl"}) local quaiylNote = getManual(args, {"noteyn_çhionnal", "noteyn_quaiyl"}) if not quaiyl then -- "short" asks Module:Wd for the item's short name (Wikidata -- P1813) first, e.g. "Parliament" instead of the full official -- "Parliament of the United Kingdom of Great Britain and Northern -- Ireland" -- matching enwiki's own concise style. Falls back to -- the item's normal label when no short name is set. Deliberately -- gated on `quaiyl` ALONE, not bundled with the house params below -- -- an editor who suppressed just one house (|thie_heose=none) or -- named a house manually shouldn't lose the main body's own -- Wikidata fallback as a side effect. quaiyl = getWdProperty("P194", {"linked", "short"}) end if not quaiylSyrjey or not quaiylInshley then -- Wikidata fallback for the two chambers THEMSELVES (see -- getWdChambers above) -- resolved once, then applied -- INDEPENDENTLY to whichever side(s) are still nil, same as the -- head-of-state/head-of-government leader slots above: an explicit -- |thie_heose=none/|thie_heese=none suppression on one side (which -- leaves that variable as the literal string "none", not nil) -- always wins outright and is never overwritten, while the other, -- genuinely-omitted side still gets its own independent Wikidata -- value. Chained off the same legislative-body item as `quaiyl` -- above (P194's raw QID), not off whatever `quaiyl` itself resolved -- to, so this still works even when `quaiyl` was supplied manually. local legislatureQid = getWdRawPropertyId("P194") if legislatureQid then local wdUpper, wdLower = getWdChambers(legislatureQid) if not quaiylSyrjey then quaiylSyrjey = wdUpper end if not quaiylInshley then quaiylInshley = wdLower end end end if quaiyl and not isNone(quaiyl) then local houseItems = {} if quaiylSyrjey and not isNone(quaiylSyrjey) then table.insert(houseItems, {"[[Thie heose]]", quaiylSyrjey}) end if quaiylInshley and not isNone(quaiylInshley) then table.insert(houseItems, {"[[Thie heese]]", quaiylInshley}) end local quaiylClass = (#houseItems > 0) and "mergedtoprow" or "" table.insert(quaiylRows, string.format(ROW, trClass(quaiylClass), "[[Çhionnal slattyssagh]]", applyRefNote(quaiyl, quaiylRef, quaiylNote, frame))) appendIndentRun(quaiylRows, houseItems) end ---------------------------------------------------------------- -- 4. BUNNEEAGHT / KIONDEEAGHT (Founding / constitution) and -- historical establishment events — manual-only, ported -- directly from the old template's numbered slots (1-9). -- `kionedeeaght` is a synonym for `kiondeeaght` in the label/note -- param names. ---------------------------------------------------------------- local foundingLabel = getManual(args, {"sorçh_kionedeeaght", "sorçh_kiondeeaght"}) or "Bunneeaght" local foundingValue = getManual(args, {"bunnit"}) local foundingNote = getManual(args, {"note_kionedeeaght", "note_kiondeeaght"}) local foundingRef = getManual(args, {"imraa_kionedeeaght", "imraa_kiondeeaght"}) local establishmentRows = {} for i = 1, 9 do local event = getManual(args, {"taghyrt" .. i .. "_bunnit"}) local date = getManual(args, {"date" .. i .. "_bunnit"}) if event then table.insert(establishmentRows, {event, date or ""}) end end if foundingValue or #establishmentRows > 0 then if foundingValue and not isNone(foundingValue) then local foundingClass = (#establishmentRows > 0) and "mergedtoprow" or "" table.insert(foundingRows, string.format(ROW, trClass(foundingClass), "[[" .. foundingLabel .. "]]", applyRefNote(foundingValue, foundingRef, foundingNote, frame))) elseif #establishmentRows > 0 then table.insert(foundingRows, string.format(HEADER, "[[" .. foundingLabel .. "]]")) end appendIndentRun(foundingRows, establishmentRows) elseif not isNone(getManual(args, {"bunnit"})) then -- Wikidata fallback via Module:Wd: inception (P571) — only when the -- whole establishment block was left unset (not explicitly |bunnit=none). -- NOTE on date precision: Module:Wd's own time-value formatting (see -- Config:getValue's `datatype == 'time'` branch) already renders a -- FULL day-month-year date whenever the underlying Wikidata statement -- itself is stored at day precision -- there is no flag this call is -- missing, and no truncation happens on our side (confirmed by the -- test harness, which feeds a day-precision value straight through -- unchanged). When only a year is shown on a real article, that is -- because THAT COUNTRY's P571 statement on Wikidata itself is only -- recorded at year precision (very common for older founding dates) -- -- not a bug here. The manual |bunnit= override remains the fix for -- any article where the Wikidata precision isn't good enough. local inception = getWdProperty("P571") if inception then table.insert(foundingRows, string.format(ROW, "", "[[" .. foundingLabel .. "]]", applyRefNote(inception, foundingRef, foundingNote, frame))) end end appendSection(rows, govRows) appendSection(rows, quaiylRows) appendSection(rows, foundingRows) if #rows == 0 then return nil end return table.concat(rows) end return p k51f7e45n8r4l7s034ymmokpejr8uuj Ronney:Rheynn çheet-stiagh 14 55848 392990 2026-09-09T13:42:47Z MacTire02 219 ronney noa 392990 wikitext text/x-wiki {{Cat main}} {{Commons category|Income distribution|Rheynn çheet-stiagh}} {{Cat see also|Berçhys rere çheer|Boghtinys rere çheer}} [[Ronney:Myn-tarmaynys]] [[Ronney:Çheet-stiagh]] [[Ronney:Tarmaynys deyn-oaylleeagh]] [[Ronney:Rheynn y verçhys]] [[Ronney:Sheshoaylleeaght harmaynagh]] 04qm213a7uxo7zi0i8ta3vti7ynyuq1 392991 392990 2026-09-09T13:42:59Z MacTire02 219 catsort 392991 wikitext text/x-wiki {{Cat main}} {{Commons category|Income distribution|Rheynn çheet-stiagh}} {{Cat see also|Berçhys rere çheer|Boghtinys rere çheer}} [[Ronney:Myn-tarmaynys]] [[Ronney:Çheet-stiagh]] [[Ronney:Tarmaynys deyn-oaylleeagh]] [[Ronney:Rheynn y verçhys|Cheet-stiagh]] [[Ronney:Sheshoaylleeaght harmaynagh]] 0y776ca4876iy3ag8t44hxfhcvgj888 Ronney:Sheshoaylleeaght harmaynagh 14 55849 392992 2026-09-09T13:44:21Z MacTire02 219 r 392992 wikitext text/x-wiki {{Cat main}} {{Commons category|Economic sociology|Sheshoaylleeaght harmaynagh}} [[Ronney:Fo-vagheryn eddyr-cheirdagh y tarmaynys]] [[Ronney:Fo-vagheryn y çheshoaylleeaght|Harmaynagh]] [[Ronney:Sheiltynys reireydys]] 3f4leojty29omn2lh6ylsydht2ge431 Ronney:Cowreyderyn tarmaynagh 14 55850 392994 2026-09-09T13:48:35Z MacTire02 219 ronney noa 392994 wikitext text/x-wiki {{Commons category|Economic indicators|Cowreyderyn tarmaynagh}} {{Cat main|Cowreyder tarmaynagh}} [[Ronney:Fysseree harmaynagh]] [[Ronney:Earooyn ayndagh|Tarmaynagh]] [[Ronney:Cowreyderyn|Tarmaynagh]] [[Ronney:Ayndaghyn sheanse sheshoil]] if460dbcdhsifo8b9ydgybrokre2nxw Module:Kishtey fys çheer/ennym-wd 828 55851 393005 2026-09-10T02:33:16Z MacTire02 219 moddyl noa 393005 Scribunto text/plain local p = {} -- Module:Kishtey fys çheer/ennym-wd ("Wikidata name") — a small, SHARED -- helper for every Kishtey fys çheer submodule (not just /reiltys), for one -- specific, recurring problem: a Wikidata ITEM (as opposed to a plain -- property value) often has no Manx (gv) label or sitelink at all, only an -- English one (or some other language). Two bad things can currently happen -- when that's the case, depending on the submodule: -- 1. The value is silently DROPPED (see /reiltys's chamber-name lookup -- before this module existed — an upper/lower house with no Manx -- label simply never appeared, with no indication anything was even -- there). -- 2. English text LEAKS into the infobox with no indication it isn't -- Manx (the exact "head of state"/"head of government" bug fixed -- earlier in /reiltys, worked around there with a hardcoded Manx -- placeholder string — fine when a good one exists, but not every -- field has one). -- -- The three-tier link behaviour this module implements (per your reference -- screenshot of an existing gv.wiki infobox) is: -- 1. A gv SITELINK exists -> a normal internal wikilink, [[Title]] -- -- renders blue (the article exists). -- 2. No sitelink, but a genuine -- gv LABEL exists -> still a normal internal wikilink, -- [[Label]] -- renders RED, since the article doesn't exist yet at -- that title. This is exactly what a redlink is FOR: it invites -- someone to write the (correctly-titled, Manx) article. -- 3. Neither exists at all -> the best available label (usually -- English) tagged with the language it's actually in, with the LABEL -- ITSELF wrapped in a plain external link straight to that item on -- Wikidata (in Manx UI language, `?uselang=gv`). This is NOT a -- wikilink -- MediaWiki renders a bare `[url text]` external link in -- its own distinct colour/icon (a different shade of blue from a -- normal internal link, with the skin's usual external-link -- decoration) precisely because it's leaving the wiki -- exactly the -- "different shade of blue, which when clicked also brings you to the -- entity's entry on Wikidata" behaviour asked for. No custom icon -- needs to be hand-built for this: it's what an external link already -- looks like. -- -- Tiers 1 and 2 are ordinary wikilinks a CALLER already builds itself -- (e.g. /reiltys's getWdItemManxLink, which tries a sitelink then a gv -- label before ever reaching this module) — this module supplies ONLY tier -- 3, the final rung once neither of those exists. -- -- USAGE (see /reiltys's getWdItemManxLink for the reference integration): -- call p.labelWithFallback(qid) for an item you already have the raw QID -- for (e.g. chained through P1906/P1313/P39/P527/P31 the way /reiltys -- does), AFTER already checking for a gv sitelink/label yourself and -- finding neither. -- Wraps mw.wikibase.getLabelWithLang(id) -- the real Wikibase Lua API for -- this, distinct from plain mw.wikibase.getLabel/label, which silently -- follows Wikidata's language-fallback chain with NO way to tell which -- language you actually got (the exact ambiguity that caused the original -- "head of state" English-leak bug). getLabelWithLang returns the label -- text together with the language code it was actually found in, so a -- genuine Manx (gv) label can be told apart from a same-shaped fallback in -- some other language. pcall'd defensively; returns nil, nil on any -- failure or when the entity has no label in any language at all. local function labelWithLang(entityID) local ok, label, lang = pcall(mw.wikibase.getLabelWithLang, entityID) if ok and label and label ~= "" then return label, lang end return nil, nil end -- The Wikidata URL for an entity, in Manx UI language (`?uselang=gv`, so -- the Wikidata edit form itself prompts in Manx rather than whatever -- language the visiting editor's browser happens to be in) -- properties -- (P-ids) live under a "Property:" prefix on Wikidata, items (Q-ids) -- don't. `propertyID`, when given, jumps straight to that specific -- statement rather than just the item's own page (not currently used by -- any caller, but kept for a future one annotating a missing STATEMENT -- rather than a missing LABEL). local function wikidataUrl(entityID, propertyID) local prefix = (entityID:sub(1, 1) == "P") and "Property:" or "" local url = "https://www.wikidata.org/wiki/" .. prefix .. entityID .. "?uselang=gv" if propertyID and propertyID ~= "" then url = url .. "#" .. propertyID end return url end -- Public entry point. Given a Wikidata entity ID (a Q-item, typically) and -- an optional property ID (see wikidataUrl above), returns THREE values: -- 1. `display` — nil if the entity has no label in any language at all; -- otherwise the label text, PLAIN and unannotated if -- it's a genuine Manx (gv) label (tier 2 above is the -- caller's job, not this module's — see `isManx` below), -- or, if it's a fallback from some other language -- (usually, but not always, English), that label wrapped -- in a plain external link straight to the item on -- Wikidata, followed by a small "(<language code>)" tag -- (tier 3 above). -- 2. `isManx` — true only when `display` is a genuine, unannotated -- Manx label — lets a caller decide whether it's safe to -- treat `display` as a real Manx title to wikilink -- itself (tier 2: still a normal `[[wikilink]]`, which -- will render red since no article exists yet at that -- title — this module deliberately does NOT build that -- link itself, since a caller like /reiltys's -- getWdItemManxLink already has its own, tested wikilink- -- building logic, e.g. shortManxForm's short-display-text -- handling, that a genuine Manx label should go through -- instead of being wrapped identically here). -- 3. `rawLabel` — the bare label text alone, with no link/annotation -- attached either way — for a caller that wants to build -- something else around it. function p.labelWithFallback(entityID, propertyID) if not entityID or entityID == "" then return nil, false, nil end local label, lang = labelWithLang(entityID) if not label then return nil, false, nil end if lang == "gv" then return label, true, label end local safeLabel = mw.text.nowiki(label) -- a raw Wikidata label could otherwise contain "]" or other wikitext-breaking characters local linked = "[" .. wikidataUrl(entityID, propertyID) .. " " .. safeLabel .. "]" local annotated = linked .. " <sup>(" .. tostring(lang) .. ")</sup>" return annotated, false, label end return p qgvzjyq3xhjismsx6y6e2a9o7ze4za1 Coonseil Slattyssagh Vannin 0 55852 393008 2026-09-10T02:36:38Z MacTire02 219 MacTire02 moved page [[Coonseil Slattyssagh Vannin]] to [[Yn Choonceil Slattyssagh (Mannin)]] 393008 wikitext text/x-wiki #REDIRECT [[Yn Choonceil Slattyssagh (Mannin)]] iftztpkfzv8t118j1xuhh1kgnycc740