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
Yn Rank
0
1887
393181
363956
2026-09-14T01:54:19Z
MacTire02
219
-G8
393181
wikitext
text/x-wiki
{{Art reiht rollage}}
{{Kishtey fys çheer
|ennym_dooghyssagh = Pobblaght y Rank
|ennym_foddey_cadjincliaghtagh= {{nobold|République française {{small|([[Frangish]])}}}}
|ennym_gienneydagh = y Rank
|jalloo_brattagh = Flag of France (1794–1815, 1830–1974, 2020–present).svg
|jalloo_cleinney = Arms_of_the_French_Republic.svg
|sorçh_cowrey = Cowrey ashoonagh
|jalloo_caslys = EU-France_(orthographic_projection).svg
|jarroo-raa = "[[Liberté, égalité, fraternité]]"<br/>"Seyrsnys, co-chormid, co-vraaraghys"
|arrane_ashoonagh = "[[La Marseillaise]]"{{parabr}}{{center|[[Coadan:La Marseillaise.ogg]]}}
|çhengaghyn_oikoil = [[Frangish]]
|preeu-valley = [[Paarys]]
|latd=48 |latm=52 |latNS=N |longd=2 |longm=19.59 |longEW=E |latNSgael=Hwoaie |longEWgael=Hiar
|balley_smoo = preeu-valley
|sorçh_reiltys = [[Pobblaght lieh-eaghtyraneagh]] unnaneagh
|enmys1_fer-toshee = [[Eaghtyrane y Rank|Eaghtyrane]]
|ennym1_fer-toshee = [[Emmanuel Macron]]
|enmys2_fer-toshee = [[Ard-vinishter y Rank|Ard-vinishter]]
|ennym2_fer-toshee = [[Sébastien Lecornu]]
|dateEUentreilys = 25 Mayrnt 1957
|eaghtyr_km2 = 632,702.3
|eaghtyr_mi_ker = 244,287.7{{efn|Goaill stiagh y [[Yn Rank vooarheeragh|Rank vooarheeragh]] as y [[Yn Rank Harrish Mooir|Rank Harrish Mooir]] agh goaill magh [[Terre Adélie]].}}
|eaghtyr_rhenk = 47oo
|ushtey_sy_cheead =
|pobble_ooley = 62,448,977<ref>{{cite web|url=http://www.insee.fr/fr/themes/detail.asp?reg_id=99&ref_id=bilan-demo&page=donnees-detaillees/bilan-demo/pop_age2.htm|title=Population totale par sexe et âge au 1er janvier 2009, France métropolitaine|first=[[Reiltys ny Frank]]|last=[[INSEE]]|accessdate=13-01-2009|language=Frangish}}</ref>
|blein_ooley_pobble = 2009
|rhenk_ooley_pobble = 22h
|pobble_coontey = {{WD Earroo yn Phobble cour Kishtey Fys}}
|blein_coontey_pobble =
|rhenk_coontey_pobble =
|glooaght_pobble_km2 = 115
|glooaght_pobble_mi_ker = 297
|rhenk_glooaght_pobble = 89oo
|possanyn_kynneeagh =
|blein_LTS_CCK = 2008
|LTS_CCK = $2.130 trillioon<ref name=imf2>{{cite web|url=http://www.imf.org/external/pubs/ft/weo/2009/02/weodata/weorept.aspx?sy=2006&ey=2009&scsm=1&ssd=1&sort=country&ds=.&br=1&c=132&s=NGDPD%2CNGDPDPC%2CPPPGDP%2CPPPPC%2CLP&grp=0&a=&pr.x=70&pr.y=19 |title=France|publisher=International Monetary Fund|accessdate=01-10-2009|language=Baarle}}</ref>
|rhenk_LTS_CCK = 8oo
|LTS_CCK_yn_dooinney = $34,205<ref name=imf2/>
|rhenk_LTS_CCK_yn_dooinney = 18oo
|LTS_ennymagh = $2.867 trillioon<ref name=imf2/>
|rhenk_LTS_ennymagh = 5oo
|blein_LTS_ennymagh = 2009
|LTS_ennymagh_yn_dooinney = $46,037<ref name=imf2/>
|rhenk_LTS_ennymagh_yn_dooinney = 16oo
|Gini = 26.7
|blein_Gini = 2002
|blein_ALD = 2007
|ALD = {{bishaghey}} 0.961<ref>{{en jalloo}} [http://hdr.undp.org/en/media/HDR_2009_EN_Complete.pdf Human Development Report 2009]. Ny h-Ashoonyn Unnaneysit. Feddynit magh er 5 Jerrey Fouyir 2009</ref>
|rhenk_ALD = 8oo
|ronney_ALD = <span style="color:#090">feer ard</span>
|sorçh_kiondeeaght = [[Shennaghys y Rank|Bunneeaght]]
|note_kiondeeaght =
|taghyrt1_bunnit = [[Reeriaght ny Frankee Heear]] – [[Conaant Verdun]]
|date1_bunnit = 10 Luanistyn 843
|taghyrt2_bunnit = [[Fogrey mysh scryssey magh y vonarkaght|Pobblaght y Rank]] – [[Kied Phobblaght y Rank]]
|date2_bunnit = 22 Mean Fouyir 1792
|taghyrt3_bunnit = [[Bunraght y Rank|Bunraght roie]] – [[Queiggoo Pobblaght y Rank]]
|date3_bunnit = 4 Jerrey Fouyir 1958
|argid = [[euro]] ([[Cowrey euro|€]]){{efn|Va'n [[franc]] ymmydit 'sy Rank roish çheet-stiagh yn [[euro]] 'sy vlein 1999.}}
|coad_argid = EUR
|traa_ynnydagh = [[Traa ynnydagh yn Oarpey Meanagh|CET]]
|ashchur_utc = +1
|traa_ynnydagh_TTLS = [[Traa souree yn Oarpey Meanagh|CEST]]
|ashchur_utc_TTLS = +2
|cctld = [[.fr]]
|coad_çhellvane = 33
}}
Ta'n '''Rank''' ({{lang-fr|La France}}, {{Audio|Fr-France.oga|Fockley magh ayns Frangish}}: {{ASE-fr|fʁɑ̃s|}}), ny '''Pobblaght y Rank''' dy h-oikoil ({{lang-fr|République française}}, {{ASE-fr|ʁepyblik fʁɑ̃sɛz|pron}}), ny çheer ta soit 'syn [[Yn Oarpey Heear|Oarpey Heear]], lesh shiartanse dy chroghaneyn as thallooyn harrish mooir as ad nyn soie er mooar-rheynnyn elley.{{efn|Son tooilley oayllys, jeeagh-shiu er [[:Ronney:Yn Rank Harrish Mooir]].}} Ta'n Rank Vooarheeragh sheeyney veih'n [[Yn Veanvooir|Veanvooir]] dys [[Mooir yn Eeaght]] as [[Mooir Hostyn]], as veih'n [[Yn Rhine|Rhine]] dys [[Yn Keayn Sheear|y Cheayn Sheear]]. Ta'n ennym ''L’Hexagone'' ("Y [[Shey-Lhiattaghan]]") currit urree dy mennick er oyr cummey towse-oaylleeagh y thalloo eck. Ta'n Rank ny [[pobblaght]] [[corys lieh-eaghtyraneagh|lieh-eaghtyraneagh]] [[steat unnaneagh|unnaneagh]] as ny preeu ard-smooinaghtyn focklit magh ayns [[Fogrey ry hoi Cairyn Sheelnaue as y Teyraanagh]].
Ta'n [[Yn Rank Vooarheeragh|Rank Vooarheeragh]] çhemmit (lesh y chlag veih'n twoaie) liorish [[Yn Velg|y Velg]], [[Lucsemburg]], [[Yn Ghermaan|y Ghermaan]], [[yn Elveeish]], [[yn Iddaal]], [[Monaco]], [[Andorra]], as [[Yn Spaainey|y Spaainey]]. Ta joaraghyn thallooin ec rheynnyn as co-chadjinyssyn harrish mooir y Rank myrgeddin. Ta [[Geeaaney Rangagh]] ayns [[America Yiass]] çhemmit liorish [[Yn Vrasseel|y Vrasseel]] da'n shiar as y jiass, as liorish [[Yn Toorinam|y Toorinam]] da'n sheear. Ta [[Co-chadjinys Noo Martyn]] çhemmit rish [[Sint Maarten]] 'sy [[Yn Vooir Charibagh|Vooir Charibagh]] chammah. Ta'n Rank kianglt rish y [[Reeriaght Unnaneysit]] liorish [[Thiollane Vooir Eeaght]], as eh goll fo Mooir yn Eeaght.
Ta'n Rank ny çheer smoo 'syn [[Yn Unnaneys Oarpagh|Unnaneys Oarpagh]] er eaghtyr. Va'n Rank ny pooar mooar feie ram eashyn lesh cleayney tarmaynagh, cultooragh, cahnagh as politickagh niartal eck. Car y 17-oo as y 18-oo eash, ren y Rank coloinagh er ayrnyn mooarey jeh [[America Hwoaie]]; car y 19-oo as y 20-oo eash, va'n nah impiraght smoo jeh'n traa eck er ny hroggal ec y Rank, as ee goaill stiagh ayrnyn mooarey jeh'n [[Yn Affrick Hwoaie|Affrick Hwoaie]], [[yn Affrick Heear|Heear]] as [[Yn Affrick Veanagh|Veanagh]], [[yn Aishey Hiar Yiass]], as ram [[ellanyn y Cheayn Sheealtagh]].
Ta'n Rank ny çheer lhiasit as ta'n queigoo harmaynys smoo 'sy theihll eck rere [[Rolley çheeraghyn rere LTS (ennymagh)|LTS ennymagh]]<ref>{{en jalloo}} [https://web.archive.org/web/20181227071047/https://www.cia.gov/library/publications/the-world-factbook/fields/2195.html Field listing - GDP (official exchange rate)], CIA World Factbook</ref> Ta'n Rank ny bun-oltey jeh'n [[Unnaneys Oarpagh]] as [[ny h-Ashoonyn Unnaneysit]] as t'ee ny h-holtey jeh'n [[Francophonie]] y [[G8]], yn [[RCAH]], yn [[RCTL]], yn [[Reagheydys Traghtee yn Theihill|RTT]] as [[yn Unnaneys Ladjynagh]]. T'ee ny h-oltey beayn jeh [[Coonseil Hickyrys ny h-Ashoonyn Unnaneysit]].
==Noteyn==
{{notelist}}
==Imraaghyn==
{{reflist}}
{{commonscat|France|yn Rank}}
{{Yn Europey}}
{{Çheeraghyn yn Unnaneys Oarpagh}}
{{RCAH}}
{{gurneil eaghtyrys}}
{{Coord|47|N|2|E|type:country_region:FR|display=inline}}
{{DEFAULTSORT:Rank, Yn}}
{{bun}}
[[Ronney:Yn Rank| ]]
[[Ronney:Bunneeaghtyn 'sy Rank 'sy vlein 1792]]
[[Ronney:Bunneeaghtyn 'syn Oarpey 'sy vlein 1792]]
[[Ronney:Çheeraghyn yn Oarpey]]
[[Ronney:Çheeraghyn y G20]]
[[Ronney:Çheeraghyn-oltey Reagheydys Chonaant yn Atlantagh Hwoaie]]
[[Ronney:Çheeraghyn-oltey Choonseil yn Oarpey]]
[[Ronney:Çheeraghyn-oltey yn Unnaneys Oarpagh]]
[[Ronney:Çheeraghyn-oltey Organisation internationale de la Francophonie]]
[[Ronney:Çheeraghyn-oltey Unnaneys y Veanvooir]]
[[Ronney:Çheeraghyn-oltey ny h-Ashoonyn Unnaneysit]]
[[Ronney:Çheeraghyn-oltey yn RCTL]]
[[Ronney:Pobblaghtyn]]
[[Ronney:Steatyn as thallooyn bunnit 'sy vlein 1792]]
[[Ronney:Ny çheeraghyn Alpagh]]
lxjzbtc4eutonfl7kxle56p0mk8vrsa
393182
393181
2026-09-14T01:54:50Z
MacTire02
219
++
393182
wikitext
text/x-wiki
{{Art reiht rollage}}
{{Kishtey fys çheer
|ennym_dooghyssagh = Pobblaght y Rank
|ennym_foddey_cadjincliaghtagh= {{nobold|République française {{small|([[Frangish]])}}}}
|ennym_gienneydagh = y Rank
|jalloo_brattagh = Flag of France (1794–1815, 1830–1974, 2020–present).svg
|jalloo_cleinney = Arms_of_the_French_Republic.svg
|sorçh_cowrey = Cowrey ashoonagh
|jalloo_caslys = EU-France_(orthographic_projection).svg
|jarroo-raa = "[[Liberté, égalité, fraternité]]"<br/>"Seyrsnys, co-chormid, co-vraaraghys"
|arrane_ashoonagh = "[[La Marseillaise]]"{{parabr}}{{center|[[Coadan:La Marseillaise.ogg]]}}
|çhengaghyn_oikoil = [[Frangish]]
|preeu-valley = [[Paarys]]
|latd=48 |latm=52 |latNS=N |longd=2 |longm=19.59 |longEW=E |latNSgael=Hwoaie |longEWgael=Hiar
|balley_smoo = preeu-valley
|sorçh_reiltys = [[Pobblaght lieh-eaghtyraneagh]] unnaneagh
|enmys1_fer-toshee = [[Eaghtyrane y Rank|Eaghtyrane]]
|ennym1_fer-toshee = [[Emmanuel Macron]]
|enmys2_fer-toshee = [[Ard-vinishter y Rank|Ard-vinishter]]
|ennym2_fer-toshee = [[Sébastien Lecornu]]
|dateEUentreilys = 25 Mayrnt 1957
|eaghtyr_km2 = 632,702.3
|eaghtyr_mi_ker = 244,287.7{{efn|Goaill stiagh y [[Yn Rank vooarheeragh|Rank vooarheeragh]] as y [[Yn Rank Harrish Mooir|Rank Harrish Mooir]] agh goaill magh [[Terre Adélie]].}}
|eaghtyr_rhenk = 47oo
|ushtey_sy_cheead =
|pobble_ooley = 62,448,977<ref>{{cite web|url=http://www.insee.fr/fr/themes/detail.asp?reg_id=99&ref_id=bilan-demo&page=donnees-detaillees/bilan-demo/pop_age2.htm|title=Population totale par sexe et âge au 1er janvier 2009, France métropolitaine|first=[[Reiltys ny Frank]]|last=[[INSEE]]|accessdate=13-01-2009|language=Frangish}}</ref>
|blein_ooley_pobble = 2009
|rhenk_ooley_pobble = 22h
|pobble_coontey = {{WD Earroo yn Phobble cour Kishtey Fys}}
|blein_coontey_pobble =
|rhenk_coontey_pobble =
|glooaght_pobble_km2 = 115
|glooaght_pobble_mi_ker = 297
|rhenk_glooaght_pobble = 89oo
|possanyn_kynneeagh =
|blein_LTS_CCK = 2008
|LTS_CCK = $2.130 trillioon<ref name=imf2>{{cite web|url=http://www.imf.org/external/pubs/ft/weo/2009/02/weodata/weorept.aspx?sy=2006&ey=2009&scsm=1&ssd=1&sort=country&ds=.&br=1&c=132&s=NGDPD%2CNGDPDPC%2CPPPGDP%2CPPPPC%2CLP&grp=0&a=&pr.x=70&pr.y=19 |title=France|publisher=International Monetary Fund|accessdate=01-10-2009|language=Baarle}}</ref>
|rhenk_LTS_CCK = 8oo
|LTS_CCK_yn_dooinney = $34,205<ref name=imf2/>
|rhenk_LTS_CCK_yn_dooinney = 18oo
|LTS_ennymagh = $2.867 trillioon<ref name=imf2/>
|rhenk_LTS_ennymagh = 5oo
|blein_LTS_ennymagh = 2009
|LTS_ennymagh_yn_dooinney = $46,037<ref name=imf2/>
|rhenk_LTS_ennymagh_yn_dooinney = 16oo
|Gini = 26.7
|blein_Gini = 2002
|blein_ALD = 2007
|ALD = {{bishaghey}} 0.961<ref>{{en jalloo}} [http://hdr.undp.org/en/media/HDR_2009_EN_Complete.pdf Human Development Report 2009]. Ny h-Ashoonyn Unnaneysit. Feddynit magh er 5 Jerrey Fouyir 2009</ref>
|rhenk_ALD = 8oo
|ronney_ALD = <span style="color:#090">feer ard</span>
|sorçh_kiondeeaght = [[Shennaghys y Rank|Bunneeaght]]
|note_kiondeeaght =
|taghyrt1_bunnit = [[Reeriaght ny Frankee Heear]] – [[Conaant Verdun]]
|date1_bunnit = 10 Luanistyn 843
|taghyrt2_bunnit = [[Fogrey mysh scryssey magh y vonarkaght|Pobblaght y Rank]] – [[Kied Phobblaght y Rank]]
|date2_bunnit = 22 Mean Fouyir 1792
|taghyrt3_bunnit = [[Bunraght y Rank|Bunraght roie]] – [[Queiggoo Pobblaght y Rank]]
|date3_bunnit = 4 Jerrey Fouyir 1958
|argid = [[euro]] ([[Cowrey euro|€]]){{efn|Va'n [[franc]] ymmydit 'sy Rank roish çheet-stiagh yn [[euro]] 'sy vlein 1999.}}
|coad_argid = EUR
|traa_ynnydagh = [[Traa ynnydagh yn Oarpey Meanagh|CET]]
|ashchur_utc = +1
|traa_ynnydagh_TTLS = [[Traa souree yn Oarpey Meanagh|CEST]]
|ashchur_utc_TTLS = +2
|cctld = [[.fr]]
|coad_çhellvane = 33
}}
Ta'n '''Rank''' ({{lang-fr|La France}}, {{Audio|Fr-France.oga|Fockley magh ayns Frangish}}: {{ASE-fr|fʁɑ̃s|}}), ny '''Pobblaght y Rank''' dy h-oikoil ({{lang-fr|République française}}, {{ASE-fr|ʁepyblik fʁɑ̃sɛz|pron}}), ny çheer ta soit 'syn [[Yn Oarpey Heear|Oarpey Heear]], lesh shiartanse dy chroghaneyn as thallooyn harrish mooir as ad nyn soie er mooar-rheynnyn elley.{{efn|Son tooilley oayllys, jeeagh-shiu er [[:Ronney:Yn Rank Harrish Mooir]].}} Ta'n Rank Vooarheeragh sheeyney veih'n [[Yn Veanvooir|Veanvooir]] dys [[Mooir yn Eeaght]] as [[Mooir Hostyn]], as veih'n [[Yn Rhine|Rhine]] dys [[Yn Keayn Sheear|y Cheayn Sheear]]. Ta'n ennym ''L’Hexagone'' ("Y [[Shey-Lhiattaghan]]") currit urree dy mennick er oyr cummey towse-oaylleeagh y thalloo eck. Ta'n Rank ny [[pobblaght]] [[corys lieh-eaghtyraneagh|lieh-eaghtyraneagh]] [[steat unnaneagh|unnaneagh]] as ny preeu ard-smooinaghtyn focklit magh ayns [[Fogrey ry hoi Cairyn Sheelnaue as y Teyraanagh]].
Ta'n [[Yn Rank Vooarheeragh|Rank Vooarheeragh]] çhemmit (lesh y chlag veih'n twoaie) liorish [[Yn Velg|y Velg]], [[Lucsemburg]], [[Yn Ghermaan|y Ghermaan]], [[yn Elveeish]], [[yn Iddaal]], [[Monaco]], [[Andorra]], as [[Yn Spaainey|y Spaainey]]. Ta joaraghyn thallooin ec rheynnyn as co-chadjinyssyn harrish mooir y Rank myrgeddin. Ta [[Geeaaney Rangagh]] ayns [[America Yiass]] çhemmit liorish [[Yn Vrasseel|y Vrasseel]] da'n shiar as y jiass, as liorish [[Yn Toorinam|y Toorinam]] da'n sheear. Ta [[Co-chadjinys Noo Martyn]] çhemmit rish [[Sint Maarten]] 'sy [[Yn Vooir Charibagh|Vooir Charibagh]] chammah. Ta'n Rank kianglt rish y [[Reeriaght Unnaneysit]] liorish [[Thiollane Vooir Eeaght]], as eh goll fo Mooir yn Eeaght.
Ta'n Rank ny çheer smoo 'syn [[Yn Unnaneys Oarpagh|Unnaneys Oarpagh]] er eaghtyr. Va'n Rank ny pooar mooar feie ram eashyn lesh cleayney tarmaynagh, cultooragh, cahnagh as politickagh niartal eck. Car y 17-oo as y 18-oo eash, ren y Rank coloinagh er ayrnyn mooarey jeh [[America Hwoaie]]; car y 19-oo as y 20-oo eash, va'n nah impiraght smoo jeh'n traa eck er ny hroggal ec y Rank, as ee goaill stiagh ayrnyn mooarey jeh'n [[Yn Affrick Hwoaie|Affrick Hwoaie]], [[yn Affrick Heear|Heear]] as [[Yn Affrick Veanagh|Veanagh]], [[yn Aishey Hiar Yiass]], as ram [[ellanyn y Cheayn Sheealtagh]].
Ta'n Rank ny çheer lhiasit as ta'n queigoo harmaynys smoo 'sy theihll eck rere [[Rolley çheeraghyn rere LTS (ennymagh)|LTS ennymagh]]<ref>{{en jalloo}} [https://web.archive.org/web/20181227071047/https://www.cia.gov/library/publications/the-world-factbook/fields/2195.html Field listing - GDP (official exchange rate)], CIA World Factbook</ref> Ta'n Rank ny bun-oltey jeh'n [[Unnaneys Oarpagh]] as [[ny h-Ashoonyn Unnaneysit]] as t'ee ny h-holtey jeh'n [[Francophonie]] y [[G8]], yn [[RCAH]], yn [[RCTL]], yn [[Reagheydys Traghtee yn Theihill|RTT]] as [[yn Unnaneys Ladjynagh]]. T'ee ny h-oltey beayn jeh [[Coonseil Hickyrys ny h-Ashoonyn Unnaneysit]].
==Noteyn==
{{notelist}}
==Imraaghyn==
{{reflist}}
{{commonscat|France|yn Rank}}
{{Yn Europey}}
{{Çheeraghyn yn Unnaneys Oarpagh}}
{{RCAH}}
{{gurneil eaghtyrys}}
{{Coord|47|N|2|E|type:country_region:FR|display=title}}
{{DEFAULTSORT:Rank, Yn}}
{{bun}}
[[Ronney:Yn Rank| ]]
[[Ronney:Bunneeaghtyn 'sy Rank 'sy vlein 1792]]
[[Ronney:Bunneeaghtyn 'syn Oarpey 'sy vlein 1792]]
[[Ronney:Çheeraghyn yn Oarpey]]
[[Ronney:Çheeraghyn y G20]]
[[Ronney:Çheeraghyn-oltey Reagheydys Chonaant yn Atlantagh Hwoaie]]
[[Ronney:Çheeraghyn-oltey Choonseil yn Oarpey]]
[[Ronney:Çheeraghyn-oltey yn Unnaneys Oarpagh]]
[[Ronney:Çheeraghyn-oltey Organisation internationale de la Francophonie]]
[[Ronney:Çheeraghyn-oltey Unnaneys y Veanvooir]]
[[Ronney:Çheeraghyn-oltey ny h-Ashoonyn Unnaneysit]]
[[Ronney:Çheeraghyn-oltey yn RCTL]]
[[Ronney:Pobblaghtyn]]
[[Ronney:Steatyn as thallooyn bunnit 'sy vlein 1792]]
[[Ronney:Ny çheeraghyn Alpagh]]
hlzvhi8ymata1aumegnftxh13azxgcz
Ny Steatyn Unnaneysit
0
1893
393178
393138
2026-09-14T01:42:14Z
MacTire02
219
++
393178
wikitext
text/x-wiki
{{Kishtey fys çheer/noa
|jarroo-raa = [[In God We Trust]]
|çhyndaa_jarroo-raa = Ta Shin Treishteil ayns Jee
|noteyn_jarroo-raa = {{USC|36|302}}
|çhyndaa_arrane_ashoonagh= Y Brattagh Gialrollageagh
|imraa_arrane_ashoonagh = {{cite web |date=3 Mayrnt 1931 |title=An Act To make The Star-Spangled Banner the national anthem of the United States of America |url=https://uscode.house.gov/statviewer.htm?volume=46&page=1508}}
|jalloo_caslys-çheerey = United States (orthographic projection).svg
|çhengaghyn_oikoil = [[Baarle]]
|noteyn_çhengaghyn_oikoil=Rere [[Executive Order 14224]].<ref name="EOWP">{{cite news |url=https://www.washingtonpost.com/nation/2025/03/01/trump-english-official-language-explainer/ |title=A Trump order made English the official language of the U.S. What does that mean? |newspaper=[[The Washington Post]] |author1=Vivian Ho |author2=Rachel Pannett |date=1 Mayrnt 2025}}</ref><ref name="EONYT">{{Cite news |last=Broadwater |first=Luke |date=1 Mayrnt 2025 |title=Trump Signs Order to Designate English as Official Language of the U.S. |url=https://www.nytimes.com/2025/03/01/us/politics/trump-order-english-official-language.html |access-date=1 Mayrnt 2025 |work=[[The New York Times]] |archive-date=2 Mayrnt 2025 |archive-url=https://web.archive.org/web/20250302005819/https://www.nytimes.com/2025/03/01/us/politics/trump-order-english-official-language.html |url-status=live}}</ref> Ta steatyn as thallooyn eigsoylagh cur enney er Baarle ny lomarcan, er Baarle as çhengey ny çhengaghyn ynnydagh elley, as cha nel fir elley cur enney er çhengey oikoil erbee. Jeeagh er [[#Çhengey|§ Çhengey]]. Cha ren [[Cohionnal ny Steatyn Unnaneysit]] rieau shickyraghey slattys erbee chur enney er çhengey oikoil erbee ec y cheim chonastagh as cha nel [[Bunraght ny Steatyn Unnaneysit]] genmyssey çhengey oikoil erbee.<ref>{{cite web |url=https://edition.cnn.com/2018/05/20/us/english-us-official-language-trnd/index.html |title=FYI: English isn't the official language of the United States |date=20 Boaldyn 2018 |publisher=CNN |access-date=19 Mayrnt 2025 |archive-date=19 Mee ny Nollick 2021 |archive-url=https://web.archive.org/web/20211219223355/https://edition.cnn.com/2018/05/20/us/english-us-official-language-trnd/index.html |url-status=live}}</ref><ref>{{Harvnb|Faingold|2018|p=8}}. "The United States has never had an official language and attempts to declare English its official language have been unsuccessful in the U.S. Congress."</ref>
|possanyn_kynneeagh = {{plainlist|'''Rere kynney:'''
*61.6% [[Americaanee Vaney|Baney]]
*12.4% [[Affro-Americaanee|Gorrym]]
*6% [[Americaanee Aishanagh|Aishanagh]]
*1.1% [[Bun-dooghyssee ayns ny Steatyn Unnaneysit|Bun-dooghyssee]]
*0.2% [[Americaanee Ellanagh Heealtagh|Ellanee Heealtagh]]
*10.2% [[Americaanee Yl-chynneeagh|Daa chynney ny ny smoo]]
*8.4% [[Kynney as kynneeaght ayns coontey-pobble ny Steatyn Unnaneysit|elley]]
}}
----
{{plainlist|'''Rere bun:'''
* 81.3% [[Americaanee Hispaainagh as Ladjynagh|{{nowrap|Neu-Hispaainee}} as Ladjynee]]
* 18.7% Hispaainee ny Ladjynee
}}
|sorçh_reiltys = Pobblaght eaghtyraneagh [[Conastaghys ayns ny Steatyn Unnaneysit|chonastagh]] fo corys [[Smaghtaght|smaghtagh]] [[corys mestit|mestit]]
|imraa_reiltys = <ref>{{cite web| title = The Price of American Authoritarianism: What Can Reverse Democratic Decline? | url=https://www.foreignaffairs.com/united-states/american-authoritarianism-levitsky-way-ziblatt | last1=Levitsky | first1=Steven |last2=Way |first2 = Lucan A. |last3=Ziblatt |first3=Daniel | date= 11 Mee ny Nollick 2025 |accessdate=14 Jerrey Geuree 2026 | language = Baarle | work = [[Foreign Affairs (earishlioar)|Foreign Affairs]]}}</ref><ref>{{cite web| url= https://www.thenation.com/article/politics/trump-miller-authoritarianism-imperialism-venezuela/|title= The Ugly Beast of American Authoritarianism |lang=Baarle |last=Abramsky |first=Sasha |date=8 Jerrey Geuree 2026 |accessdate=14 Jerrey Geuree 2026 |work = The Nation}}</ref><ref>{{cite web|url = https://www.newyorker.com/podcast/political-scene/how-bad-is-it-three-political-scientists-say-america-is-no-longer-a-democracy |title=How Bad Is It?: Three Political Scientists Say America Is No Longer a Democracy |first = Tyler|last=Foggatt| lang=Baarle |date=11 Mee ny Nollick 2025 |accessdate=14 Jerrey Geuree 2026 | work = The New Yorker}}</ref><ref>{{cite web|url=https://news.berkeley.edu/2025/01/21/theres-a-term-for-trumps-political-style-authoritarian-populism/|title=There’s a term for Trump’s political style: authoritarian populism |last=Thulin |first=Lila |work = UC Berkeley News |date=21 Jerrey Geuree 2025 |accessdate=14 Jerrey Geuree 2026}}</ref>
|enmys_toshiagh1 = [[Eaghtyrane ny Steatyn Unnaneysit|Eaghtyrane]]
|ennym_toshiagh1 = [[Donald Trump]]
|enmys_toshiagh2 = [[Lhiass-eaghtyrane ny Steatyn Unnaneysit|Lhiass-eaghtyrane]]
|ennym_toshiagh2 = [[JD Vance]]
|enmys_toshiagh3 = [[Loayreyder Whaiyl ny Steatyn Unnaneysit|Loayreyder y Whaiyl]]
|ennym_toshiagh3 = [[Mike Johnson]]
|enmys_toshiagh4 = [[Ard-vriw ny Steatyn Unnaneysit|Ard-vriw]]
|ennym_toshiagh4 = [[John G. Roberts|John Roberts]]
|sorçh_kiondeeaght = [[Shennaghys ny Steatyn Unnaneysit|Neuchrogheydys]]
|note_kiondeeaght = veih [[Reeriaght y Vretyn Vooar]]
|taghyrt1_bunnit = [[Fogrey Neuchrogheydys ny Steatyn Unnaneysit|Fogrey neuchrogheydys]]
|date1_bunnit = 4 Jerrey Souree 1776
|taghyrt2_bunnit = [[Eash y Chochiangle|Cochiangle]]
|date2_bunnit = 1 Mayrnt 1781
|taghyrt3_bunnit = [[Conaant Phaarys (1783)|Hooar enney]]
|date3_bunnit = 3 Mean Fouyir 1783
|taghyrt4_bunnit = [[Bunraght ny Steatyn Unnaneysit|Bunraght]]
|date4_bunnit = 21 Mean Fouyir 1788
|eaghtyr_km2 = 9,833,520
}}
<!--
|pobble_coontey = {{WD Earroo yn Phobble cour Kishtey Fys}}
|blein_LTS_CCK = 2024
|LTS_CCK = $29.168 trillioon
|rhenk_LTS_CCK = 2h
|LTS_CCK_yn_dooinney = $86,601
|rhenk_LTS_CCK_yn_dooinney = 8oo
|LTS_ennymagh = $29.168 trillioon
|rhenk_LTS_ennymagh = 1d
|blein_LTS_ennymagh = 2024
|LTS_ennymagh_yn_dooinney = $86,601
|rhenk_LTS_ennymagh_yn_dooinney = 6oo
|Gini = 41.6
|blein_Gini = 2023
|ronney_Gini =
|blein_ALD = 2023
|ALD = {{increase}} 0.938
|rhenk_ALD = 17oo
|ronney_ALD = <span style="color:#090">feer ard</span>
|coad_argid = USD
|traa_ynnydagh =
|ashchur_utc = -5 gys -10
|traa_ynnydagh_TTLS =
|ashchur_utc_TTLS = -4 gys -10
|cctld = [[.us]]
|coad_çhellvane = 1
}}-->
She [[pobblaght chonastagh]] [[corys eaghtyraneagh|eaghtyraneagh]] ad '''Steatyn Unnaneysit America''' ({{langx|en|United States of America}}), ta enmyssit '''ny Steatyn Unnaneysit''' ({{lang|en|United States}}), '''S.U.A.''' ({{lang|en|U.S.A.}}) as '''America''' chammah. Ta'n çheer jeant seose ass jeih steat as daeed cur liorish [[slyst chonastagh]]. Er y chooid smoo, ta'n çheer soit ayns [[America Hwoaie]] veanagh, raad dy vel [[ny Steatyn Unnaneysit colhiantagh|hoght steatyn as daeed]], chammah as y clyst chonastagh, soit eddyr y [[Yn Keayn Sheear|Cheayn Sheear]] as y [[Yn Keayn Sheealtagh|Cheayn Sheealtagh]]. T'ad çhemmal rish [[Yn Chanadey|y Chanadey]] 'sy twoaie as [[Meksico]] 'sy jiass. Ta [[Alaska]] soit ayns sheear hwoaie yn vooar-rheynn as raad t'eh çhemmit rish y Chanadey 'sy niar echey as rish [[Yn Roosh|y Roosh]] 'sy neear tessen [[Mooir Bering]]. Ta [[Hawaii]] ny ellanragh soit 'sy Cheayn Sheealtagh Meanagh. Ta shiartanse dy [[Thallooyn ny Steatyn Unnaneysit|hallooyn]] echey ta skeaylt magh mygeayrt y [[Yn Vooir Charibagh|Vooir Charibagh]] as y Cheayn Sheealtagh.
==Steatyn ny Steatyn Unnaneysit==
{{Main|Steatyn ny Steatyn Unnaneysit}}
[[Coadan:Map of USA with state names.svg|thumbnail|400px|left|Steatyn ny Steatyn Unnaneysit]]
{|
|-
|
* [[Alabama]]
* [[Alaska]]
* [[Arizona]]
* [[Arkansas]]
* [[California]]
* [[Carolina Hwoaie]]
* [[Carolina Yiass]]
* [[Colorado]]
* [[Connecticut]]
* [[Dakota Hwoaie]]
* [[Dakota Yiass]]
* [[Delaware]]
* [[Ellan Rhode]]
* [[Florida]]
* [[Yn Çhorshey (steat)|Yn Çhorshey]]
* [[Hawaii]]
* [[Idaho]]
|
* [[Illinois]]
* [[Indiana]]
* [[Iowa]]
* [[Kansas]]
* [[Kentucky]]
* [[Louisiana]]
* [[Maine]]
* [[Maryland]]
* [[Massachusetts]]
* [[Michigan]]
* [[Minnesota]]
* [[Mississippi]]
* [[Missouri]]
* [[Montana]]
* [[Nebraska]]
* [[Nevada]]
* [[New Hampshire]]
|
* [[New Jersey]]
* [[New Mexico]]
* [[Ohio]]
* [[Oklahoma]]
* [[Oregon]]
* [[Pennsylvania]]
* [[Tennessee]]
* [[Texas]]
* [[Utah]]
* [[Vermont]]
* [[Yn Virjeeney]]
* [[Yn Virjeeney Heear]]
* [[Washington (steat)|Washington]]
* [[Wisconsin]]
* [[Wyoming]]
* [[York Noa (steat)|York Noa]]
|}
==Noteyn==
{{notelist}}
==Imraaghyn==
===Symnaghyn===
{{reflist}}
===Farraneyn-fys===
{{refbegin}}
* {{cite book |last=Faingold |first=Eduardo D. |date=2018 |title=Language Rights and the Law in the United States and Its Territories |publisher=Lexington Books}}
{{refend}}
{{Yn Americkey Hwoaie}}
{{G8}}
{{RCAH}}
{{Gurneil eaghtyrys}}
{{bun}}
{{Coord|40|-100|dim:10000000_region:region:US_type:country|name=United States of America|display=title}}
[[Ronney:Ny Steatyn Unnaneysit| ]]
[[Ronney:Çheeraghyn America Hwoaie]]
[[Ronney:Pobblaghtyn bunraghtoil conastagh]]
[[Ronney:Eear-choloinyn as eear-choadanyssyn Goaldagh ayns ny h-Americkyn]]
[[Ronney:Eear-chochianglaghyn]]
[[Ronney:Çheeraghyn y G20]]
[[Ronney:Çheeraghyn-oltey Reagheydys Chonaant yn Atlantagh Hwoaie]]
[[Ronney:Çheeraghyn-oltey ny h-Ashoonyn Unnaneysit]]
[[Ronney:Steatyn as thallooyn bunnit 'sy vlein 1776]]
l71byjvyurvvcllh0h5fud9g2qs6pq7
393179
393178
2026-09-14T01:47:47Z
MacTire02
219
++
393179
wikitext
text/x-wiki
{{Kishtey fys çheer/noa
|jarroo-raa = [[In God We Trust]]
|çhyndaa_jarroo-raa = Ta Shin Treishteil ayns Jee
|noteyn_jarroo-raa = {{USC|36|302}}
|çhyndaa_arrane_ashoonagh= Y Brattagh Gialrollageagh
|imraa_arrane_ashoonagh = {{cite web |date=3 Mayrnt 1931 |title=An Act To make The Star-Spangled Banner the national anthem of the United States of America |url=https://uscode.house.gov/statviewer.htm?volume=46&page=1508}}
|jalloo_caslys-çheerey = United States (orthographic projection).svg
|çhengaghyn_oikoil = [[Baarle]]
|noteyn_çhengaghyn_oikoil=Rere [[Executive Order 14224]].<ref name="EOWP">{{cite news |url=https://www.washingtonpost.com/nation/2025/03/01/trump-english-official-language-explainer/ |title=A Trump order made English the official language of the U.S. What does that mean? |newspaper=[[The Washington Post]] |author1=Vivian Ho |author2=Rachel Pannett |date=1 Mayrnt 2025}}</ref><ref name="EONYT">{{Cite news |last=Broadwater |first=Luke |date=1 Mayrnt 2025 |title=Trump Signs Order to Designate English as Official Language of the U.S. |url=https://www.nytimes.com/2025/03/01/us/politics/trump-order-english-official-language.html |access-date=1 Mayrnt 2025 |work=[[The New York Times]] |archive-date=2 Mayrnt 2025 |archive-url=https://web.archive.org/web/20250302005819/https://www.nytimes.com/2025/03/01/us/politics/trump-order-english-official-language.html |url-status=live}}</ref> Ta steatyn as thallooyn eigsoylagh cur enney er Baarle ny lomarcan, er Baarle as çhengey ny çhengaghyn ynnydagh elley, as cha nel fir elley cur enney er çhengey oikoil erbee. Jeeagh er [[#Çhengey|§ Çhengey]]. Cha ren [[Cohionnal ny Steatyn Unnaneysit]] rieau shickyraghey slattys erbee chur enney er çhengey oikoil erbee ec y cheim chonastagh as cha nel [[Bunraght ny Steatyn Unnaneysit]] genmyssey çhengey oikoil erbee.<ref>{{cite web |url=https://edition.cnn.com/2018/05/20/us/english-us-official-language-trnd/index.html |title=FYI: English isn't the official language of the United States |date=20 Boaldyn 2018 |publisher=CNN |access-date=19 Mayrnt 2025 |archive-date=19 Mee ny Nollick 2021 |archive-url=https://web.archive.org/web/20211219223355/https://edition.cnn.com/2018/05/20/us/english-us-official-language-trnd/index.html |url-status=live}}</ref><ref>{{Harvnb|Faingold|2018|p=8}}. "The United States has never had an official language and attempts to declare English its official language have been unsuccessful in the U.S. Congress."</ref>
|possanyn_kynneeagh = {{plainlist|'''Rere kynney:'''
*61.6% [[Americaanee Vaney|Baney]]
*12.4% [[Affro-Americaanee|Gorrym]]
*6% [[Americaanee Aishanagh|Aishanagh]]
*1.1% [[Bun-dooghyssee ayns ny Steatyn Unnaneysit|Bun-dooghyssee]]
*0.2% [[Americaanee Ellanagh Heealtagh|Ellanee Heealtagh]]
*10.2% [[Americaanee Yl-chynneeagh|Daa chynney ny ny smoo]]
*8.4% [[Kynney as kynneeaght ayns coontey-pobble ny Steatyn Unnaneysit|elley]]
}}
----
{{plainlist|'''Rere bun:'''
* 81.3% [[Americaanee Hispaainagh as Ladjynagh|{{nowrap|Neu-Hispaainee}} as Ladjynee]]
* 18.7% Hispaainee ny Ladjynee
}}
|sorçh_reiltys = Pobblaght eaghtyraneagh [[Conastaghys ayns ny Steatyn Unnaneysit|chonastagh]] fo corys [[Smaghtaght|smaghtagh]] [[corys mestit|mestit]]
|imraa_reiltys = <ref>{{cite web| title = The Price of American Authoritarianism: What Can Reverse Democratic Decline? | url=https://www.foreignaffairs.com/united-states/american-authoritarianism-levitsky-way-ziblatt | last1=Levitsky | first1=Steven |last2=Way |first2 = Lucan A. |last3=Ziblatt |first3=Daniel | date= 11 Mee ny Nollick 2025 |accessdate=14 Jerrey Geuree 2026 | language = Baarle | work = [[Foreign Affairs (earishlioar)|Foreign Affairs]]}}</ref><ref>{{cite web| url= https://www.thenation.com/article/politics/trump-miller-authoritarianism-imperialism-venezuela/|title= The Ugly Beast of American Authoritarianism |lang=Baarle |last=Abramsky |first=Sasha |date=8 Jerrey Geuree 2026 |accessdate=14 Jerrey Geuree 2026 |work = The Nation}}</ref><ref>{{cite web|url = https://www.newyorker.com/podcast/political-scene/how-bad-is-it-three-political-scientists-say-america-is-no-longer-a-democracy |title=How Bad Is It?: Three Political Scientists Say America Is No Longer a Democracy |first = Tyler|last=Foggatt| lang=Baarle |date=11 Mee ny Nollick 2025 |accessdate=14 Jerrey Geuree 2026 | work = The New Yorker}}</ref><ref>{{cite web|url=https://news.berkeley.edu/2025/01/21/theres-a-term-for-trumps-political-style-authoritarian-populism/|title=There’s a term for Trump’s political style: authoritarian populism |last=Thulin |first=Lila |work = UC Berkeley News |date=21 Jerrey Geuree 2025 |accessdate=14 Jerrey Geuree 2026}}</ref>
|enmys_toshiagh1 = [[Eaghtyrane ny Steatyn Unnaneysit|Eaghtyrane]]
|ennym_toshiagh1 = [[Donald Trump]]
|enmys_toshiagh2 = [[Lhiass-eaghtyrane ny Steatyn Unnaneysit|Lhiass-eaghtyrane]]
|ennym_toshiagh2 = [[JD Vance]]
|enmys_toshiagh3 = [[Loayreyder Whaiyl ny Steatyn Unnaneysit|Loayreyder y Whaiyl]]
|ennym_toshiagh3 = [[Mike Johnson]]
|enmys_toshiagh4 = [[Ard-vriw ny Steatyn Unnaneysit|Ard-vriw]]
|ennym_toshiagh4 = [[John G. Roberts|John Roberts]]
|sorçh_kiondeeaght = [[Shennaghys ny Steatyn Unnaneysit|Neuchrogheydys]]
|note_kiondeeaght = veih [[Reeriaght y Vretyn Vooar]]
|taghyrt1_bunnit = [[Fogrey Neuchrogheydys ny Steatyn Unnaneysit|Fogrey neuchrogheydys]]
|date1_bunnit = 4 Jerrey Souree 1776
|taghyrt2_bunnit = [[Eash y Chochiangle|Cochiangle]]
|date2_bunnit = 1 Mayrnt 1781
|taghyrt3_bunnit = [[Conaant Phaarys (1783)|Hooar enney]]
|date3_bunnit = 3 Mean Fouyir 1783
|taghyrt4_bunnit = [[Bunraght ny Steatyn Unnaneysit|Bunraght]]
|date4_bunnit = 21 Mean Fouyir 1788
|eaghtyr_km2 = 9,833,520
}}
<!--
|pobble_coontey = {{WD Earroo yn Phobble cour Kishtey Fys}}
|blein_LTS_CCK = 2024
|LTS_CCK = $29.168 trillioon
|rhenk_LTS_CCK = 2h
|LTS_CCK_yn_dooinney = $86,601
|rhenk_LTS_CCK_yn_dooinney = 8oo
|LTS_ennymagh = $29.168 trillioon
|rhenk_LTS_ennymagh = 1d
|blein_LTS_ennymagh = 2024
|LTS_ennymagh_yn_dooinney = $86,601
|rhenk_LTS_ennymagh_yn_dooinney = 6oo
|Gini = 41.6
|blein_Gini = 2023
|ronney_Gini =
|blein_ALD = 2023
|ALD = {{increase}} 0.938
|rhenk_ALD = 17oo
|ronney_ALD = <span style="color:#090">feer ard</span>
|coad_argid = USD
|traa_ynnydagh =
|ashchur_utc = -5 gys -10
|traa_ynnydagh_TTLS =
|ashchur_utc_TTLS = -4 gys -10
|cctld = [[.us]]
|coad_çhellvane = 1
}}-->
She [[pobblaght chonastagh]] [[corys eaghtyraneagh|eaghtyraneagh]] ad '''Steatyn Unnaneysit America''' ({{langx|en|United States of America}}), ta enmyssit '''ny Steatyn Unnaneysit''' ({{lang|en|United States}}), '''S.U.A.''' ({{lang|en|U.S.A.}}) as '''America''' chammah. Ta'n çheer jeant seose ass jeih steat as daeed cur liorish [[slyst chonastagh]]. Er y chooid smoo, ta'n çheer soit ayns [[America Hwoaie]] veanagh, raad dy vel [[ny Steatyn Unnaneysit colhiantagh|hoght steatyn as daeed]], chammah as y clyst chonastagh, soit eddyr y [[Yn Keayn Sheear|Cheayn Sheear]] as y [[Yn Keayn Sheealtagh|Cheayn Sheealtagh]]. T'ad çhemmal rish [[Yn Chanadey|y Chanadey]] 'sy twoaie as [[Meksico]] 'sy jiass. Ta [[Alaska]] soit ayns sheear hwoaie yn vooar-rheynn as raad t'eh çhemmit rish y Chanadey 'sy niar echey as rish [[Yn Roosh|y Roosh]] 'sy neear tessen [[Mooir Bering]]. Ta [[Hawaii]] ny ellanragh soit 'sy Cheayn Sheealtagh Meanagh. Ta shiartanse dy [[Thallooyn ny Steatyn Unnaneysit|hallooyn]] echey ta skeaylt magh mygeayrt y [[Yn Vooir Charibagh|Vooir Charibagh]] as y Cheayn Sheealtagh.
==Steatyn ny Steatyn Unnaneysit==
{{Main|Steatyn ny Steatyn Unnaneysit}}
[[Coadan:Map of USA with state names.svg|thumbnail|400px|left|Steatyn ny Steatyn Unnaneysit]]
{|
|-
|
* [[Alabama]]
* [[Alaska]]
* [[Arizona]]
* [[Arkansas]]
* [[California]]
* [[Carolina Hwoaie]]
* [[Carolina Yiass]]
* [[Colorado]]
* [[Connecticut]]
* [[Dakota Hwoaie]]
* [[Dakota Yiass]]
* [[Delaware]]
* [[Ellan Rhode]]
* [[Florida]]
* [[Yn Çhorshey (steat)|Yn Çhorshey]]
* [[Hawaii]]
* [[Idaho]]
|
* [[Illinois]]
* [[Indiana]]
* [[Iowa]]
* [[Kansas]]
* [[Kentucky]]
* [[Louisiana]]
* [[Maine]]
* [[Maryland]]
* [[Massachusetts]]
* [[Michigan]]
* [[Minnesota]]
* [[Mississippi]]
* [[Missouri]]
* [[Montana]]
* [[Nebraska]]
* [[Nevada]]
* [[New Hampshire]]
|
* [[New Jersey]]
* [[New Mexico]]
* [[Ohio]]
* [[Oklahoma]]
* [[Oregon]]
* [[Pennsylvania]]
* [[Tennessee]]
* [[Texas]]
* [[Utah]]
* [[Vermont]]
* [[Yn Virjeeney]]
* [[Yn Virjeeney Heear]]
* [[Washington (steat)|Washington]]
* [[Wisconsin]]
* [[Wyoming]]
* [[York Noa (steat)|York Noa]]
|}
==Noteyn==
{{notelist}}
==Imraaghyn==
===Symnaghyn===
{{reflist}}
===Farraneyn-fys===
{{refbegin}}
* {{cite book |last=Faingold |first=Eduardo D. |date=2018 |title=Language Rights and the Law in the United States and Its Territories |publisher=Lexington Books}}
{{refend}}
{{Yn Americkey Hwoaie}}
{{RCAH}}
{{Gurneil eaghtyrys}}
{{bun}}
{{Coord|40|-100|dim:10000000_region:region:US_type:country|name=United States of America|display=title}}
[[Ronney:Ny Steatyn Unnaneysit| ]]
[[Ronney:Çheeraghyn America Hwoaie]]
[[Ronney:Pobblaghtyn bunraghtoil conastagh]]
[[Ronney:Eear-choloinyn as eear-choadanyssyn Goaldagh ayns ny h-Americkyn]]
[[Ronney:Eear-chochianglaghyn]]
[[Ronney:Çheeraghyn y G20]]
[[Ronney:Çheeraghyn-oltey Reagheydys Chonaant yn Atlantagh Hwoaie]]
[[Ronney:Çheeraghyn-oltey ny h-Ashoonyn Unnaneysit]]
[[Ronney:Steatyn as thallooyn bunnit 'sy vlein 1776]]
s0mv09gs61brsb18nyc6xpvksyjm8q2
Clowan:America Hwoaie
10
2422
393183
327488
2026-09-14T02:12:04Z
MacTire02
219
++
393183
wikitext
text/x-wiki
{{Navbox
|name = America Hwoaie
|title = [[Çheeraghyn]] [[America Hwoaie]]
|state = {{{state|autocollapse}}}
|bodyclass = hlist
| group1 = Steatyn kionedeeagh
| list1 = [[Antigua as Barbuda]]{{·}} [[Ny Bahamaghyn|Bahamaghyn, ny]]{{·}} [[Barbados]]{{·}} [[Yn Chanadey|Chanadey, y]]{{·}} [[Yn Choobey|Choobey, y]]{{·}} [[Yn Coose Berçhagh|Coose Berçhagh, y]]{{·}} [[Dominica]]{{·}} [[Yn Ghuatemaley|Ghuatemaley, y]]{{·}} [[Grenada]]{{·}} [[Haiti]]{{·}} [[Ny Hondooraghyn|Hondooraghyn, ny]]{{·}} [[Yn Jamaicey|Jamaicey, y]]{{·}} [[Meksico]]{{·}} [[Yn Nickeraag|Nickeraag, y]]{{·}} [[Noo Kitts as Nevis]]{{·}} [[Noo Lucia]]{{·}} [[Noo Winsen as ny Grenadeenyn]]{{·}} [[Yn Phanamaa|Phanamaa, y]]{{·}} [[Yn Phobblaght Ghominicagh|Phobblaght Ghominicagh, y]]{{·}} [[Yn Salvador|Salvador, y]]{{·}} [[Ny Steatyn Unnaneysit|Steatyn Unnaneysit]]{{·}} [[Ellan y Trinaid as Tobago|Trinaid as Tobago, Ellan y]]{{·}} [[Yn Veleesh|Veleesh, y]]
|group2 = Croghaneyn as thallooyn elley
|list2 =
* [[Anguilla]]
* [[Aruba]]
* [[Ny Bermioodee|Bermioodee, ny]]
* [[Bonaire]]
* [[Ellanyn Cayman]]
* [[Curaçao]]
* [[Greenlynn]]
* [[Guadeloupe]]
* [[Martinique]]
* [[Montserrat]]
* [[Yn Phurt Verçhagh|Phurt Verçhagh, y]]
* [[Saint Barthélemy]]
* [[Co-chadjinys Saint-Martin|Saint-Martin]]
* [[Saint-Pierre-et-Miquelon]]
* [[Saba (ellan)|Saba]]
* [[Sint Eustatius]]
* [[Sint Maarten]]
* [[Ellanyn ny Turkee as Caicos]]
* [[Ellanyn Americaanagh y Voidyn|Voidyn, Ellanyn Americaanagh y]]
* [[Ellanyn Goaldagh y Voidyn|Voidyn, Ellanyn Goaldagh y]]
}}<noinclude>
[[Ronney:Clowanyn stiurey|America Hwoaie]]
</noinclude>
3vt3bhycnjf0991bsg7curbl6rbzroc
393184
393183
2026-09-14T02:12:26Z
MacTire02
219
MacTire02 moved page [[Clowan:Yn Americkey Hwoaie]] to [[Clowan:America Hwoaie]] over redirect
393183
wikitext
text/x-wiki
{{Navbox
|name = America Hwoaie
|title = [[Çheeraghyn]] [[America Hwoaie]]
|state = {{{state|autocollapse}}}
|bodyclass = hlist
| group1 = Steatyn kionedeeagh
| list1 = [[Antigua as Barbuda]]{{·}} [[Ny Bahamaghyn|Bahamaghyn, ny]]{{·}} [[Barbados]]{{·}} [[Yn Chanadey|Chanadey, y]]{{·}} [[Yn Choobey|Choobey, y]]{{·}} [[Yn Coose Berçhagh|Coose Berçhagh, y]]{{·}} [[Dominica]]{{·}} [[Yn Ghuatemaley|Ghuatemaley, y]]{{·}} [[Grenada]]{{·}} [[Haiti]]{{·}} [[Ny Hondooraghyn|Hondooraghyn, ny]]{{·}} [[Yn Jamaicey|Jamaicey, y]]{{·}} [[Meksico]]{{·}} [[Yn Nickeraag|Nickeraag, y]]{{·}} [[Noo Kitts as Nevis]]{{·}} [[Noo Lucia]]{{·}} [[Noo Winsen as ny Grenadeenyn]]{{·}} [[Yn Phanamaa|Phanamaa, y]]{{·}} [[Yn Phobblaght Ghominicagh|Phobblaght Ghominicagh, y]]{{·}} [[Yn Salvador|Salvador, y]]{{·}} [[Ny Steatyn Unnaneysit|Steatyn Unnaneysit]]{{·}} [[Ellan y Trinaid as Tobago|Trinaid as Tobago, Ellan y]]{{·}} [[Yn Veleesh|Veleesh, y]]
|group2 = Croghaneyn as thallooyn elley
|list2 =
* [[Anguilla]]
* [[Aruba]]
* [[Ny Bermioodee|Bermioodee, ny]]
* [[Bonaire]]
* [[Ellanyn Cayman]]
* [[Curaçao]]
* [[Greenlynn]]
* [[Guadeloupe]]
* [[Martinique]]
* [[Montserrat]]
* [[Yn Phurt Verçhagh|Phurt Verçhagh, y]]
* [[Saint Barthélemy]]
* [[Co-chadjinys Saint-Martin|Saint-Martin]]
* [[Saint-Pierre-et-Miquelon]]
* [[Saba (ellan)|Saba]]
* [[Sint Eustatius]]
* [[Sint Maarten]]
* [[Ellanyn ny Turkee as Caicos]]
* [[Ellanyn Americaanagh y Voidyn|Voidyn, Ellanyn Americaanagh y]]
* [[Ellanyn Goaldagh y Voidyn|Voidyn, Ellanyn Goaldagh y]]
}}<noinclude>
[[Ronney:Clowanyn stiurey|America Hwoaie]]
</noinclude>
3vt3bhycnjf0991bsg7curbl6rbzroc
393186
393184
2026-09-14T02:12:42Z
MacTire02
219
+ny
393186
wikitext
text/x-wiki
{{Navbox
|name = America Hwoaie
|title = [[Çheeraghyn]] [[America Hwoaie]]
|state = {{{state|autocollapse}}}
|bodyclass = hlist
| group1 = Steatyn kionedeeagh
| list1 = [[Antigua as Barbuda]]{{·}} [[Ny Bahamaghyn|Bahamaghyn, ny]]{{·}} [[Barbados]]{{·}} [[Yn Chanadey|Chanadey, y]]{{·}} [[Yn Choobey|Choobey, y]]{{·}} [[Yn Coose Berçhagh|Coose Berçhagh, y]]{{·}} [[Dominica]]{{·}} [[Yn Ghuatemaley|Ghuatemaley, y]]{{·}} [[Grenada]]{{·}} [[Haiti]]{{·}} [[Ny Hondooraghyn|Hondooraghyn, ny]]{{·}} [[Yn Jamaicey|Jamaicey, y]]{{·}} [[Meksico]]{{·}} [[Yn Nickeraag|Nickeraag, y]]{{·}} [[Noo Kitts as Nevis]]{{·}} [[Noo Lucia]]{{·}} [[Noo Winsen as ny Grenadeenyn]]{{·}} [[Yn Phanamaa|Phanamaa, y]]{{·}} [[Yn Phobblaght Ghominicagh|Phobblaght Ghominicagh, y]]{{·}} [[Yn Salvador|Salvador, y]]{{·}} [[Ny Steatyn Unnaneysit|Steatyn Unnaneysit, ny]]{{·}} [[Ellan y Trinaid as Tobago|Trinaid as Tobago, Ellan y]]{{·}} [[Yn Veleesh|Veleesh, y]]
|group2 = Croghaneyn as thallooyn elley
|list2 =
* [[Anguilla]]
* [[Aruba]]
* [[Ny Bermioodee|Bermioodee, ny]]
* [[Bonaire]]
* [[Ellanyn Cayman]]
* [[Curaçao]]
* [[Greenlynn]]
* [[Guadeloupe]]
* [[Martinique]]
* [[Montserrat]]
* [[Yn Phurt Verçhagh|Phurt Verçhagh, y]]
* [[Saint Barthélemy]]
* [[Co-chadjinys Saint-Martin|Saint-Martin]]
* [[Saint-Pierre-et-Miquelon]]
* [[Saba (ellan)|Saba]]
* [[Sint Eustatius]]
* [[Sint Maarten]]
* [[Ellanyn ny Turkee as Caicos]]
* [[Ellanyn Americaanagh y Voidyn|Voidyn, Ellanyn Americaanagh y]]
* [[Ellanyn Goaldagh y Voidyn|Voidyn, Ellanyn Goaldagh y]]
}}<noinclude>
[[Ronney:Clowanyn stiurey|America Hwoaie]]
</noinclude>
h5a7ry4xt04ol2c31d3n9md1qd2rtyr
Ard-valley yn Phanamaa
0
2797
393190
356941
2026-09-14T11:49:01Z
MacTire02
219
++
393190
wikitext
text/x-wiki
{{Kishtey fys boayl
| ennym_gienneydagh = Ard-valley yn Phanamaa
| ennym = Ard-valley yn Phanamaa
| ennym_elley = ''Ciudad de Panamá''
| ennym_dooghyssagh =
| ennym_oikoil =
| sorçh_balley = [[Preeu-valley]]
| jalloo_armys = Escudo de Ciudad de Panamá.svg
| mooadys_armys = 70px
| jalloo_brattagh = Bandera de Ciudad de Panamá.svg
| mooadys_brattagh = 135px
| jarroo-raa =
| far-ennym =
| jalloo_bun_speyrey =
| mooadys_jalloo = 250px
| fo-heidyl_jalloo = Veih'n vaare gys y vun: Y ''Cinta Costera'', Keeill Frank Noo 'sy çhenn cherroo, lhong ayns [[Ammyr y Phanamaa]], jalloo da [[Vasco Núñez de Balboa]], [[Droghad America]], as brattagh er baare [[Cerro Ancón]]
| caslys-çheerey_broo-freeney = ny Panamaa
| soiaghey_lipaid_broo-freeney =
| fo-heidyl_caslys-çheerey_broo-freeney = Soiaghey Ard-valley yn Phanamaa 'sy Phanamaa
| mooadys_caslys-çheerey_broo-freeney =
| ard_coordnaidyn = PA
| taishbyney_coordnaidyn = inline, title
| sorçh_aarheynn = [[Rolley çheeraghyn y theihll|Çheer]]
| ennym_aarheynn = {{brattagh|Panama|Yn Phanamaa{{!}}Y Phanamaa}}
| sorçh_aarheynn1 = [[Queiggaghyn y Phanamaa|Queiggey]]
| ennym_aarheynn1 = [[Queiggey yn Phanamaa]]
| sorçh_aarheynn2 = [[Slystyn y Phanamaa|Slyst]]
| ennym_aarheynn2 = [[Slyst y Phanamaa]]
| sorçh_aarheynn3 =
| ennym_aarheynn3 =
| enmys_bunneeaght= Bunnit
| date_bunneeaght = 15 Luanistyn 1519
| enmys_bunneeaght1= Bunneyder
| date_bunneeaght1= [[Pedro Arias de Ávila]]
| sorçh_slane = Ard-valley
| enmys_fer-toshee = Meoir
| ennym_fer-toshee = Bosco Vallarino
| enmys_fer-toshee1 =
| ennym_fer-toshee1 =
| enmys_fer-toshee2 =
| ennym_fer-toshee2 =
| slane_earroo_yn_phobble = 880691
| earroo_yn_phobble_er = 2010
| earroo_yn_phobble_baljagh =
| earroo_yn_phobble_moir = 1272672
| fo-noteyn_earroo_yn_phobble =
| glooaght_y_phobble_km2 = 2750
| glooaght_y_phobble_baljagh_km2 =
| glooaght_y_phobble_moir_km2 = 497
| slane_eaghtyr_km2 = 275
| eaghtyr_ushtey_km2 =
| eaghtyr_thalloo_km2 =
| eaghtyr_baljagh_km2 =
| eaghtyr_moir_km2 = 2560.8
| fo-noteyn_eaghtyr =
| cryss_hraa = UTC-5
| ashchur_utc =
| cryss_hraa_TTSL =
| ashchur_utc_TTSL =
| yrjid_m =
| boayl_s'inshley_m = 0
| boayl_s'yrjey_m = 950
| latd = 08 |latm = 59 |latNS = N
| longd = 79 |longm = 31 |longEW = W
| sorçh_coad_postagh =
| coad_postagh =
| plait_recortyssee =
| coad_ardjynagh = 507
| ynnyd-eggey = [http://www.municipio.gob.pa/ www.municipio.gob.pa]
| coad_iso =
| fo-noteyn =
}}
She [[preeu-valley]] yn [[yn Phanamaa|Phanamaa]] eh '''Ard-valley yn Phanamaa''' ({{langx|es|Ciudad de Panamá}}). 'Sy vlein 2000 va 708,738 cummaltee 'sy valley agh va ny smoo na 1 villioon cummaltee 'sy valjaght.
==Kianglaghyn magh==
{{commonscat}}
* {{Official website}}
{{Preeu-valjyn ayns America Hwoaie}}
{{gurneil eaghtyrys}}
{{DEFAULTSORT:Phanamaa, Ard-valley yn}}
[[Ronney:Ard-valley yn Phanamaa| ]]
[[Ronney:Buill chummaltit ayns Queiggey yn Phanamaa]]
[[Ronney:Coose Sheealtagh y Phanamaa]]
[[Ronney:Preeu-valjyn ayns America Veanagh]]
[[Ronney:Preeu-valjyn ayns America Hwoaie]]
[[Ronney:Lhoob y Phanamaa|Ard-valley]]
[[Ronney:Buill chummaltit bunnit 'sy vlein 1519]]
[[Ronney:Bunneeaghtyn ayns America Hwoaie 'sy vlein 1519]]
[[Ronney:Impiraght y Spaainey ayns ny 1510yn]]
[[Ronney:Laaraghyn Eiraght Dowanagh 'sy Phanamaa]]
[[Ronney:Ard-valjyn tessen-vooarheeragh]]
5xkser01o14rxr681anm6ecn25qldbv
Clowan:RCAH
10
8042
393187
345345
2026-09-14T02:13:43Z
MacTire02
219
++
393187
wikitext
text/x-wiki
{{Navbox
|name = RCAH
|title = [[Reagheydys Chonaant yn Atlantagh Hwoaie|Reagheydys Chonaant yn Atlantagh Hwoaie (RCAH)]]
|state = {{{state|autocollapse}}}
|bodyclass = hlist
| group1 =
| list1 = [[Yn Albaan|Albaan, yn]]{{·}} [[Yn Chanadey|Chanadey, y]]{{·}} [[Yn Çheck|Çheck, y]]{{·}} [[Yn Çheer Injil|Çheer Injil, y]]{{·}} [[Yn Chroit|Chroit, y]]{{·}} [[Yn Clovack|Clovack, y]]{{·}} [[Yn Clovean|Clovean, y]]{{·}} [[Yn Danvarg|Danvarg, y]]{{·}} [[Yn Eeslynn|Eeslynn, yn]]{{·}} [[Yn Estaan|Estaan, yn]]{{·}} [[Finnlynn]]{{·}} [[Yn Ghermaan|Ghermaan, y]]{{·}} [[Yn Ghreag|Ghreag, y]]{{·}} [[Yn Iddaal|Iddaal, yn]]{{·}} [[Yn Latvey|Latvey, y]]{{·}} [[Yn Litaan|Litaan, y]]{{·}} [[Montenegro]]{{·}} [[Lucsemburg]]{{·}} [[Norlynn]]{{·}} [[Yn Pholynn|Pholynn, y]]{{·}} [[Yn Phortiugal|Phortiugal, y]]{{·}} [[Yn Rank|Rank, y]]{{·}} [[Reeriaght Unnaneysit]]{{·}} [[Yn Romaan|Romaan, y]]{{·}} [[Yn Spaainey|Spaainey, y]]{{·}} [[Steatyn Unnaneysit America|Steatyn Unnaneysit, ny]]{{·}} [[Yn Toolynn|Toolynn, y]]{{·}} [[Yn Turkee|Turkee, y]]{{·}} [[Yn Ungaar|Ungaar, yn]]{{·}} [[Yn Vassadoan Hwoaie|Vassadoan Hwoaie, y]]{{·}} [[Yn Velg|Velg, y]]{{·}} [[Yn Vulgeyr|Vulgeyr, y]]
}}<noinclude>
[[Ronney:Clowanyn stiurey|RCAH]]
</noinclude>
opwb0bk2tk71j826ycxt3hoivto1cs4
Clowan:Kishtey fys arrane ashoonagh
10
9483
393188
328030
2026-09-14T02:15:41Z
MacTire02
219
++
393188
wikitext
text/x-wiki
{| border="0" width="240" class="infobox" style="font-size:95%; float:right;"
!align="center" style="font-size:110%;" colspan="2"|"{{{ennym|{{PAGENAME}}}}}"{{#if:{{{çhengey_ennym|}}}|<span style="font-size:0.95em; color:#555;"><small> ({{{çhengey_ennym}}})</small></span>}}{{#if:{{{ennym2|}}}|<br/>"{{{ennym2}}}"}}{{#if:{{{çhengey_ennym2|}}}|<span style="font-size:0.95em; color:#555;"><small> ({{{çhengey_ennym2}}})</small></span>}}<hr /><small>[[Gaelg]]: ''{{{ennym_gaelg}}}''</small><hr />
|-
{{#if:{{{jalloo|}}}|
{{!}} style="text-align: center;" colspan="2" {{!}} [[Coadan:{{{jalloo}}}|{{#if:{{{mooadys_jalloo|}}}|<!--then:-->{{{mooadys_jalloo}}}|<!--else:-->200px}}|]] {{#if:{{{fo-heidyl|}}}|<br />{{{fo-heidyl}}}}}<hr />
}}
|- style="font-size:90%;"
|'''Çheer'''
|{{{çheer}}}
|- style="font-size:90%;"
|'''Focklyn'''
|{{{focklyn}}}
|- style="font-size:90%;"
|'''Kiaull'''
|{{{kiaull}}}
|- style="font-size:90%;"
|'''Doltit'''
|{{{doltit}}}
|}
<noinclude>
{{docamadys}}
</noinclude>
efhynpjkgvsnfvnf8rhzl94mdmb5w7x
Rolley Manninee
0
9849
393189
391315
2026-09-14T06:40:47Z
ListeriaBot
10339
Wikidata list updated [V2]
393189
wikitext
text/x-wiki
She possan kynneeagh ass [[Mannin]] ad ny Manninee. Dy mennick, t'ad coontit mastey ny [[Gaeil|Celtiee]] noa-emshiragh kyndagh rish y [[Gaelg|çhengey Cheltiagh]] yeianagh t'oc, agh ta bun mestit oc ta goaill stiagh sleih [[Mooinjeryn Germaanagh|Germaanagh]] ([[Loghlynee|Loghlynagh]] as [[Sostynee|Sostynagh]]) as linnaghyn [[Goal-Gaeil|Goal-Gaelgagh]].
==Rolley==
{{Wikidata list
|sparql=SELECT ?item ?yob ?yod WHERE
{ ?item wdt:P27|wdt:P17|wdt:P495|wdt:P1532 ?country . # country:
VALUES ?country {
wd:Q9676 # Isle of Man
}
?item wdt:P31 wd:Q5 . # instance of: human
OPTIONAL { ?item wdt:P569 ?dob . BIND(YEAR(?dob) as ?yob) }
OPTIONAL { ?item wdt:P570 ?dod . BIND(YEAR(?dod) as ?yod) }
} limit 5000
|sort=P569
|columns=label:Ennym,P18:Jalloo,Tuarastyl,P106:Keird,?yob:Blein ruggyree,?yod:Blein vaaish,P19:Boayl ruggyree,P20:Boayl baaish,item:Red Wikidata
|thumb=100
|autolist=fallback
|links=red
}}
{| class='wikitable sortable'
! Ennym
! Jalloo
! Tuarastyl
! Keird
! Blein ruggyree
! Blein vaaish
! Boayl ruggyree
! Boayl baaish
! Red Wikidata
|-
| [[William Montagu, 1d Eearley Salisbury]]
| [[Coadan:William Montagu.jpg|center|100px]]
|
| [[diploamagh]]
| 1301
| 1344
| [[Cassington]]
| [[Windsor]]
| [[:d:Q2481359|Q2481359]]
|-
| [[John McHutchin]]
| [[Coadan:John McHutchin.jpg|center|100px]]
|
| [[briw]]
| 1788
| 1847
| [[Purt ny h-Inshey]]
| [[Balley Chashtal]]
| [[:d:Q6247893|Q6247893]]
|-
| [[Laura, Lady Buchan]]
|
|
| [[miallagh]]<br/>[[heiress]]
| 1797
| 1888
| [[Doolish]]
|
| [[:d:Q76245966|Q76245966]]
|-
| [[Thomas Shimmin]]
|
|
| [[feelee]]
| 1800
| 1876
|
|
| [[:d:Q7793942|Q7793942]]
|-
| [[Nan Wade]]
|
|
| [[lusseyr]]
| 1800
| 1900
| [[Balley Keeill Vaayl]]
|
| [[:d:Q136438328|Q136438328]]
|-
| [[Emily Maria Gawne]]
| [[Coadan:Emily Maria Gawne.jpg|center|100px]]
|
|
| 1814
| 1889
| [[Doolish]]
|
| [[:d:Q75265312|Q75265312]]
|-
| [[Arthur Caley]]
| [[Coadan:Goshen-Routh 10.jpg|center|100px]]
|
| [[cloieder kiarkys]]
| 1824
| 1889
| [[Skeerey Chreest ny h-Ayrey]]
|
| [[:d:Q2865029|Q2865029]]
|-
| [[Edward Corteen]]
|
|
| [[Surveyor General]]
| 1827
| 1913
|
| [[Doolish]]
| [[:d:Q137190412|Q137190412]]
|-
| [[George Dashwood Taubman Goldie]]
| [[Coadan:Sir George Dashwood Taubman Goldie by Sir Hubert von Herkomer.jpg|center|100px]]
|
| [[politickeyr]]<br/>[[ronseyder]]<br/>[[offishear armee]]<br/>[[çheer-oayllee]]
| 1846
| 1925
| [[The Nunnery, Douglas]]
| [[Lunnin]]
| [[:d:Q5545092|Q5545092]]
|-
| [[Flaxney Stowell]]
|
|
| [[peinteyr]]
| 1846
| 1916
|
|
| [[:d:Q21459464|Q21459464]]
|-
| [[Josephine Kermode]]
| [[Coadan:Josephine Kermode (Cushag).jpg|center|100px]]
|
| [[screeudeyr cloie]]
| 1852
| 1937
| [[Rhumsaa]]
| [[Bournemouth]]
| [[:d:Q15069220|Q15069220]]
|-
| [[P. M. C. Kermode]]
| [[Coadan:Philip Moore Callow Kermode.png|center|100px]]
|
| [[screeudeyr shennaghys]]<br/>[[antiquarian]]<br/>[[runologist]]
| 1855
| 1932
| [[Rhumsaa]]
|
| [[:d:Q15453822|Q15453822]]
|-
| [[John Quine]]
| [[Coadan:Canon John Quine.jpg|center|100px]]
|
| [[screeudeyr shennaghys]]<br/>[[screeudeyr cloie]]<br/>[[screeudeyr]]
| 1857
| 1940
| [[Skeerey Charmane]]
| [[Skeerey Lonan]]
| [[:d:Q15997058|Q15997058]]
|-
| [[Tommy Leece]]
|
|
| [[meaineyder]]<br/>[[eeasteyr]]
| 1859
| 1956
| [[Skeerey Chairbre]]
|
| [[:d:Q87195007|Q87195007]]
|-
| [[John Quayle-Dickson]]
|
|
| [[sidoor]]<br/>[[politickeyr]]
| 1860
| 1945
| [[Balley Chashtal]]
| [[Kent]]
| [[:d:Q101068189|Q101068189]]
|-
| [[Christopher R. Shimmin]]
| [[Coadan:Christopher R. Shimmin.jpg|center|100px]]
|
| [[politickeyr]]
| 1870
| 1933
| [[Purt ny h-Inshey]]
| [[Purt ny h-Inshey]]
| [[:d:Q16029252|Q16029252]]
|-
| [[Edward Christian Quayle]]
|
|
| [[peinteyr]]
| 1872
| 1946
| [[Kione Beih]]
|
| [[:d:Q21455965|Q21455965]]
|-
| [[John Joseph Kneen]]
|
|
| [[çhengoayllee]]
| 1873
| 1938
| [[Doolish]]
|
| [[:d:Q6243305|Q6243305]]
|-
| [[W. Walter Gill]]
| [[Coadan:W. Walter Gill.jpg|center|100px]]
|
| [[screeudeyr cloie]]
| 1876
| 1963
| [[Mannin]]
| [[Skeerey Chreest ny h-Ayrey]]
| [[:d:Q16002989|Q16002989]]
|-
| [[Albert Hugh Teare]]
|
|
| [[politickeyr]]<br/>[[reagheyder]]
| 1877
| 1932
| [[Rhumsaa]]
|
| [[:d:Q136434024|Q136434024]]
|-
| [[Bertram Kelly]]
| [[Coadan:Bertram Kelly, vicar.jpg|center|100px]]
|
| [[master mariner]]
| 1884
| 1976
| [[Doolish]]
| [[Mannin]]
| [[:d:Q4895790|Q4895790]]
|-
| [[Elizabeth Holloway Marston]]
| [[Coadan:William Moulton Marston and Elizabeth Holloway Marston.png|center|100px]]
|
| [[shicklaagagh]]
| 1893
| 1993
| [[Sulby]]
| [[Caayr York Noa]]
| [[:d:Q1331228|Q1331228]]
|-
| [[Edith Sewell]]
| [[Coadan:Edith sewell lwc 1895.jpg|center|100px]]
|
| [[screeudeyr]]
| 1900
|
|
|
| [[:d:Q140971568|Q140971568]]
|-
| [[Sarah Kerruish]]
|
|
| [[stiureyder fillym]]<br/>[[gienteyder fillym]]
| 1901
|
|
|
| [[:d:Q7422484|Q7422484]]
|-
| [[Kathleen Faragher]]
| [[Coadan:Kathleen Faragher.jpg|center|100px]]
|
| [[feelee]]<br/>[[screeudeyr]]
| 1904
| 1974
| [[Rhumsaa]]
| [[Skeerey Maghal]]
| [[:d:Q16749805|Q16749805]]
|-
| [[Clifford Irving]]
|
|
| [[politickeyr]]
| 1914
| 2004
| [[Mannin]]
|
| [[:d:Q2979086|Q2979086]]
|-
| [[Norman Sayle]]
|
|
| [[ellyneyr reayrtagh]]
| 1926
| 2007
| [[Doolish]]
|
| [[:d:Q98763296|Q98763296]]
|-
| [[Edward Ashton Cannell]]
|
|
| [[ellyneyr]]
| 1927
| 1994
| [[Purt Çhiarn]]
|
| [[:d:Q78901420|Q78901420]]
|-
| [[Walter y Chleree]]
|
|
| [[çhengoayllee]]
| 1928
| 2007
| [[Rhumsaa]]
| [[Mannin]]
| [[:d:Q7964563|Q7964563]]
|-
| [[Terry Cringle]]
|
|
| [[earisheyr]]
| 1931
| 2022
|
|
| [[:d:Q140478514|Q140478514]]
|-
| [[Brian Stowell]]
| [[Coadan:Brian Stowell - Gaisgeach na Gaelg.jpg|center|100px]]
|
| [[screeudeyr]]<br/>[[persoonid radio]]<br/>[[docent]]<br/>[[fishigagh]]
| 1936
| 2019
| [[Doolish]]
| [[Doolish]]
| [[:d:Q2739708|Q2739708]]
|-
| [[David W. Lewis]]
|
|
| [[maddaghteyr]]
| 1944
| 2021
| [[Doolish]]
| [[Glenageary]]
| [[:d:Q102175647|Q102175647]]
|-
| [[Ann Corlett]]
|
|
| [[cloieder badmyntyn]]
| 1945
|
|
|
| [[:d:Q26955604|Q26955604]]
|-
| [[Peter Kniveton]]
|
|
| [[cloieder badmyntyn]]
| 1945
|
|
|
| [[:d:Q26955609|Q26955609]]
|-
| [[Peter Clague]]
|
|
| [[cloieder badmyntyn]]
| 1945
|
|
|
| [[:d:Q26955610|Q26955610]]
|-
| [[Angela Little]]
| [[Coadan:Prof Angela Little.jpg|center|100px]]
|
| [[educational specialist]]
| 1949
|
| [[Doolish]]
|
| [[:d:Q4762488|Q4762488]]
|-
| [[Bob Carswell]]
| [[Coadan:Robert Corteen Carswell.jpg|center|100px]]
|
| [[screeudeyr]]<br/>[[persoonid radio]]<br/>[[sheerloayreyder]]
| 1950
|
| [[Mannin]]
|
| [[:d:Q16144859|Q16144859]]
|-
| [[Patricia Anderson]]
|
|
| [[cloieder badmyntyn]]
| 1950
|
|
|
| [[:d:Q63384817|Q63384817]]
|-
| [[Neil Bennett]]
|
|
| [[rugby union player]]
| 1951
|
| [[Rhumsaa]]
|
| [[:d:Q3337801|Q3337801]]
|-
| [[Paul Lebiedzinski]]
| [[Coadan:Paul Lebiedzinski.jpg|center|100px]]
|
| [[feelee]]
| 1951
| 1995
| [[Rhumsaa]]
|
| [[:d:Q28810393|Q28810393]]
|-
| [[Dennis Moore]]
|
|
| [[cloieder badmyntyn]]
| 1953
|
|
|
| [[:d:Q26958604|Q26958604]]
|-
| [[David Kennaugh]]
|
|
| [[cloieder badmyntyn]]
| 1953
|
|
|
| [[:d:Q26958607|Q26958607]]
|-
| [[Muriel Cain]]
|
|
| [[cloieder badmyntyn]]
| 1953
|
|
|
| [[:d:Q26958652|Q26958652]]
|-
| [[Harry Creevy]]
|
|
| [[publican]]<br/>[[gunneyder spoyrt]]
| 1955
|
| [[Dumbarton]]
|
| [[:d:Q35496274|Q35496274]]
|-
| [[Pauline Kennish]]
|
|
| [[cloieder badmyntyn]]
| 1956
|
|
|
| [[:d:Q65689137|Q65689137]]
|-
| [[Roberta Cannell]]
|
|
| [[cloieder badmyntyn]]
| 1957
|
|
|
| [[:d:Q26986917|Q26986917]]
|-
| [[Philip Mead]]
|
|
| [[cloieder badmyntyn]]
| 1957
|
|
|
| [[:d:Q27036256|Q27036256]]
|-
| [[Alan Shea]]
|
|
| [[sheerloayreyder politickagh]]
| 1958
|
|
|
| [[:d:Q135898249|Q135898249]]
|-
| [[Paul Martin]]
|
|
| [[cloieder badmyntyn]]
| 1960
|
|
|
| [[:d:Q27503277|Q27503277]]
|-
| [[Sharon Nicholson]]
|
|
| [[cloieder badmyntyn]]
| 1960
|
|
|
| [[:d:Q74700713|Q74700713]]
|-
| [[Sharon Baird]]
|
|
| [[cloieder badmyntyn]]
| 1961
|
|
|
| [[:d:Q27043992|Q27043992]]
|-
| [[Ian Anderson]]
|
|
| [[cloieder badmyntyn]]
| 1961
|
|
|
| [[:d:Q27503269|Q27503269]]
|-
| [[Rosie Johnson]]
|
|
| [[cloieder badmyntyn]]
| 1961
|
|
|
| [[:d:Q27503271|Q27503271]]
|-
| [[Keith Allen]]
|
|
| [[feealee]]
| 1962
|
|
|
| [[:d:Q131754832|Q131754832]]
|-
| [[Tony Wilson]]
|
|
| [[snooker player]]
| 1964
|
|
|
| [[:d:Q104973430|Q104973430]]
|-
| [[Colin Whiteway]]
|
|
| [[cloieder badmyntyn]]
| 1965
|
|
|
| [[:d:Q74700016|Q74700016]]
|-
| [[Simon Maddrell]]
|
|
| [[feelee]]<br/>[[charity worker]]<br/>[[deincharrey]]
| 1965
|
| [[Doolish]]
|
| [[:d:Q135898269|Q135898269]]
|-
| [[Dietmar Kolbus]]
| [[Coadan:Dietmar Kolbus 2014 Eppingen.png|center|100px]]
|
| [[feealee]]
| 1966
| 2024
| [[Rahden]]
| [[Biel/Bienne]]
| [[:d:Q1124073|Q1124073]]
|-
| [[Alfred Cannan]]
| [[Coadan:Official Portrait of Alfred Cannan, 2023.jpg|center|100px]]
|
| [[politickeyr]]
| 1968
|
| [[Reading]]
|
| [[:d:Q25752002|Q25752002]]
|-
| [[Andrew Fairhurst]]
|
|
| [[cloieder badmyntyn]]
| 1969
|
|
|
| [[:d:Q27031193|Q27031193]]
|-
| [[Nicola Watson]]
|
|
| [[cloieder badmyntyn]]
| 1970
|
|
|
| [[:d:Q74700542|Q74700542]]
|-
| [[Steve Cochrane]]
|
|
| [[cloieder badmyntyn]]
| 1970
|
|
|
| [[:d:Q74700766|Q74700766]]
|-
| [[Fiona Gell]]
|
|
| [[ronseyder]]<br/>[[marine biologist]]<br/>[[feelee]]<br/>[[egg-oayllee]]<br/>[[çhymmyltaghteyr]]<br/>[[coadeyder]]<br/>[[screeudeyr]]
| 1970
|
| [[Ormskirk]]
|
| [[:d:Q125581728|Q125581728]]
|-
| [[Mark Higgins]]
| [[Coadan:Ss7 higgins.jpg|center|100px]]
|
| [[rally driver]]<br/>[[cloieder cluic]]
| 1971
|
| [[Mannin]]
|
| [[:d:Q570357|Q570357]]
|-
| [[Susie Alegre]]
| [[Coadan:Susie alegre 2022 1.jpg|center|100px]]
|
| [[leigh-oayllee]]<br/>[[leighder]]<br/>[[ynseyder ollooscoill]]
| 1971
|
|
|
| [[:d:Q133226543|Q133226543]]
|-
| [[Steve Colley]]
|
|
| [[motorcycle trials rider]]<br/>[[Motorcycle stunt riding]]
| 1972
|
| [[Kione Droghad]]
|
| [[:d:Q3973323|Q3973323]]
|-
| [[Jannik Jonsson]]
|
|
| [[cloieder badmyntyn]]
| 1977
|
|
|
| [[:d:Q27268593|Q27268593]]
|-
| [[Simon Gaines]]
|
|
| [[cloieder badmyntyn]]
| 1977
|
|
|
| [[:d:Q27270081|Q27270081]]
|-
| [[Sarah Webster]]
|
|
| [[ultramarathon runner]]
| 1979
|
|
|
| [[:d:Q122763639|Q122763639]]
|-
| [[Juan Watterson]]
| [[Coadan:2021-Watterson-Juan-portrait.jpg|center|100px]]
|
| [[politickeyr]]<br/>[[coonteysseyr]]
| 1980
|
| [[Mannin]]
|
| [[:d:Q6301157|Q6301157]]
|-
| [[Cara Kerwin]]
|
|
| [[cloieder badmyntyn]]
| 1980
|
|
|
| [[:d:Q74699914|Q74699914]]
|-
| [[Neil Harding]]
|
|
| [[cloieder badmyntyn]]
| 1980
|
|
|
| [[:d:Q74700521|Q74700521]]
|-
| [[Nicola Wilkinson]]
|
|
| [[cloieder badmyntyn]]
| 1980
|
|
|
| [[:d:Q74700555|Q74700555]]
|-
| [[James Franklin]]
| [[Coadan:James franklin iom 2021 1.jpg|center|100px]]
|
| [[beeal-arrisheyr]]<br/>[[literary scholar]]<br/>[[ynseyder]]<br/>[[screeudeyr]]
| 1980
|
| [[Glen Mona]]
|
| [[:d:Q135898155|Q135898155]]
|-
| [[Tim Kneale]]
|
|
| [[gunneyder spoyrt]]
| 1982
|
| [[Doolish]]
|
| [[:d:Q21642675|Q21642675]]
|-
| [[Christian Varley]]
|
|
| [[daawheeylleyder spoyrt]]
| 1984
|
|
|
| [[:d:Q85019421|Q85019421]]
|-
| [[Oliver Webster]]
|
|
| [[criggadagh]]
| 1985
|
| [[Dewsbury]]
|
| [[:d:Q130525601|Q130525601]]
|-
| [[Dan Kneen]]
| [[Coadan:TT Lightweight - Dan Kneen (8985019419).jpg|center|100px]]
|
| [[ratçheyder roar-bree]]
| 1987
| 2018
| [[Doolish]]
| [[Skeerey Chreest ny h-Ayrey]]
| [[:d:Q5213818|Q5213818]]
|-
| [[Matthew John Wilkinson]]
|
|
| [[cloieder badmyntyn]]
| 1987
|
|
|
| [[:d:Q16325356|Q16325356]]
|-
| [[Kimberley Clague]]
|
|
| [[cloieder badmyntyn]]
| 1988
|
| [[Doolish]]
|
| [[:d:Q15971932|Q15971932]]
|-
| [[Cristen Marritt]]
|
|
| [[cloieder badmyntyn]]
| 1989
|
| [[Doolish]]
|
| [[:d:Q15630984|Q15630984]]
|-
| [[Wu Li]]
|
|
| [[feealee]]
| 1989
|
| [[Deynphobblaght y Çheen]]
|
| [[:d:Q121813465|Q121813465]]
|-
| [[Oliver Swales]]
|
|
| [[criggadagh]]
| 1989
|
|
|
| [[:d:Q130525612|Q130525612]]
|-
| [[Bethany Williams]]
|
|
| [[kiaddeyder fassan]]<br/>[[ellyneyr reayrtagh]]
| 1989
|
| [[Kione Beih]]
|
| [[:d:Q136438116|Q136438116]]
|-
| [[Samantha Barks]]
| [[Coadan:Samantha Barks - Fendi.jpg|center|100px]]
|
| [[aghteyr]]<br/>[[aghteyr ardan]]<br/>[[arraneyder]]<br/>[[aghteyr fillym]]<br/>[[aghteyr çhellveeish]]
| 1990
|
| [[Laksaa]]
|
| [[:d:Q440273|Q440273]]
|-
| [[Seamus Sharkey]]
|
|
| [[bluckaneyr soccer]]
| 1990
|
|
|
| [[:d:Q115802398|Q115802398]]
|-
| [[Sarah Mercer]]
|
|
| [[çhymmyltaghteyr]]<br/>[[sheerloayreyder emshyraght]]<br/>[[insheyder sheanse]]
| 1990
|
| [[Lerphoyll]]
|
| [[:d:Q136434078|Q136434078]]
|-
| [[Grainney Sheard]]
|
|
| [[ellyneyr reayrtagh]]
| 1990
|
|
|
| [[:d:Q138719376|Q138719376]]
|-
| [[Aaron Cook]]
| [[Coadan:Taekwondo competition in Baku.jpg|center|100px]]
|
| [[roortagh taekwondo]]
| 1991
|
| [[Dorchester]]
|
| [[:d:Q187488|Q187488]]
|-
| [[Jade Burden]]
|
|
| [[doarneyr]]
| 1991
|
|
|
| [[:d:Q136568172|Q136568172]]
|-
| [[Jade Boylan]]
|
|
| [[tayrneyder caslyssyn]]<br/>[[kiaddeyder graafagh]]
| 1991
|
|
|
| [[:d:Q138719352|Q138719352]]
|-
| [[Liam Doyle]]
| [[Coadan:Liam Doyle.JPG|center|100px]]
|
| [[bluckaneyr soccer]]
| 1992
|
| [[Mannin]]
|
| [[:d:Q24005468|Q24005468]]
|-
| [[Joshua Green]]
|
|
| [[cloieder badmyntyn]]
| 1992
|
|
|
| [[:d:Q27031248|Q27031248]]
|-
| [[Benjamin Li]]
|
|
| [[cloieder badmyntyn]]
| 1993
|
| [[Cheltenham]]
|
| [[:d:Q27031537|Q27031537]]
|-
| [[Grace Harrison]]
|
|
| [[lheiltagh]]
| 1994
|
|
|
| [[:d:Q137789630|Q137789630]]
|-
| [[Lucy Penrose]]
|
|
| [[aghteyr]]
| 1994
|
| [[Stoke-on-Trent]]
|
| [[:d:Q140157875|Q140157875]]
|-
| [[Anna Christian]]
| [[Coadan:Anna Christian - 2019 Women's Tour of Scotland (stage 3).jpg|center|100px]]
|
| [[daawheeylleyder spoyrt]]
| 1995
|
| [[Doolish]]
|
| [[:d:Q18159989|Q18159989]]
|-
| [[Darryl Hill]]
| [[Coadan:Darryl Hill PHC 2015-1.jpg|center|100px]]
|
| [[snooker player]]
| 1996
|
| [[Leeds]]
|
| [[:d:Q19726811|Q19726811]]
|-
| [[Charlotte Atkinson]]
|
|
| [[snaueder]]
| 1996
|
|
|
| [[:d:Q33404688|Q33404688]]
|-
| [[Joe Reid]]
|
|
| [[roortagh]]
| 1996
|
|
|
| [[:d:Q70225604|Q70225604]]
|-
| [[Aalin George]]
|
|
| [[archer]]
| 1996
|
|
|
| [[:d:Q136486551|Q136486551]]
|-
| [[Yasmin Ingham]]
| [[Coadan:Yasmin Ingham at the Badminton Horse Trials 2025 - 20250510 135552(0).jpg|center|100px]]
|
| [[markiagh]]
| 1997
|
| [[Mannin]]
|
| [[:d:Q114039955|Q114039955]]
|-
| [[Elizabeth Davidson-Blythe]]
| [[Coadan:Elizabeth Davidson-Blythe.jpg|center|100px]]
|
| [[biol-chloieder]]<br/>[[cummeyder]]
| 1997
|
| [[Boston]]
|
| [[:d:Q135654313|Q135654313]]
|-
| [[Jessica Li]]
|
|
| [[cloieder badmyntyn]]
| 1998
|
| [[Doolish]]
|
| [[:d:Q47522723|Q47522723]]
|-
| [[Mera Royle]]
|
|
| [[harpist]]<br/>[[biol-chloieder]]<br/>[[cummeyder]]
| 1999
|
| [[Tameside]]<br/>[[Stalybridge]]
|
| [[:d:Q136444845|Q136444845]]
|-
| [[Alexander Foster]]
|
|
| [[greeseyder dellalys]]
| 1999
|
| [[Doolish]]
|
| [[:d:Q138535546|Q138535546]]
|-
| [[Ana Dawson]]
|
|
| [[golfeyr]]
| 2000
|
|
|
| [[:d:Q136658021|Q136658021]]
|-
| [[Angela Aumonier]]
|
|
| [[beauty queen]]<br/>[[craishteyder]]
| 2000
|
| [[Bangor]]
|
| [[:d:Q140680640|Q140680640]]
|-
| [[Joe Locke (aghteyr)|Joe Locke]]
| [[Coadan:Joe Locke en 2022.jpg|center|100px]]
|
| [[aghteyr]]<br/>[[aghteyr çhellveeish]]
| 2003
|
| [[Doolish]]
|
| [[:d:Q106596551|Q106596551]]
|-
| [[Lucy Barnett]]
|
|
| [[criggadagh]]
| 2006
|
| [[Kione Droghad]]
|
| [[:d:Q126365066|Q126365066]]
|-
| [[Isla Callister]]
|
|
| [[kiaulleyder]]
|
|
| [[Mannin]]
|
| [[:d:Q25680715|Q25680715]]
|-
| [[Paayl Rogers]]
|
|
| [[kiaulleyder]]
|
|
| [[Mannin]]
|
| [[:d:Q25680717|Q25680717]]
|-
| [[Daniel Quayle]]
|
|
| [[kiaulleyder]]<br/>[[persoonid radio]]
|
|
| [[Mannin]]
|
| [[:d:Q25680727|Q25680727]]
|-
| [[Jane Poole-Wilson]]
|
|
| [[solicitor]]<br/>[[politickeyr]]
|
|
|
|
| [[:d:Q43549347|Q43549347]]
|-
| [[Clare Faulds]]
|
|
| [[leighder]]<br/>[[legal counselor]]
|
|
| [[Mannin]]
|
| [[:d:Q59242725|Q59242725]]
|-
| [[Jennifer Kewley Draskau]]
| [[Coadan:Margaret Jennifer Kewley Draskau in the video 'Lady Derby – The Great Whore of Babylon'.png|center|100px]]
|
| [[screeudeyr shennaghys]]<br/>[[çhengoayllee]]<br/>[[screeudeyr cloie]]<br/>[[feelee]]<br/>[[çhyndaader]]<br/>[[screeudeyr]]<br/>[[politickeyr]]
|
| 2024
| [[Mannin]]
|
| [[:d:Q130730092|Q130730092]]
|-
| [[Natalie Anne Byron-Teare]]
|
|
| [[politickeyr]]
|
|
|
|
| [[:d:Q134087187|Q134087187]]
|-
| [[Sue King]]
|
|
| [[local historian]]<br/>[[screeudeyr]]<br/>[[ellyneyr reayrtagh]]<br/>[[food historian]]
|
|
|
|
| [[:d:Q135726900|Q135726900]]
|-
| [[Jenny Derbyshire]]
|
|
| [[screeudeyr cloie]]
|
|
|
|
| [[:d:Q135840144|Q135840144]]
|-
| [[Vida LaFierce]]
|
|
| [[drag queen]]
|
|
|
|
| [[:d:Q135898187|Q135898187]]
|-
| [[Julia Ashby Smyth]]
|
|
| [[tayrneyder caslyssyn]]
|
|
|
|
| [[:d:Q135911527|Q135911527]]
|-
| [[Rowan Henthorn]]
|
|
| [[marine scientist]]<br/>[[egg-oayllee]]<br/>[[çhymmyltaghteyr]]
|
|
|
|
| [[:d:Q136434313|Q136434313]]
|-
| [[Lydia Riddell]]
|
|
| [[çhymmyltaghteyr]]
|
|
|
|
| [[:d:Q136434327|Q136434327]]
|-
| [[Felicity Wood]]
|
|
| [[tayrneyder caslyssyn]]<br/>[[screeudeyr]]<br/>[[ynseyder scoill]]
|
|
|
|
| [[:d:Q136850202|Q136850202]]
|-
| [[Andrew Smith]]
|
|
| [[politickeyr]]
|
|
|
|
| [[:d:Q137217005|Q137217005]]
|-
| [[Katie King]]
|
|
| [[curmeyder]]<br/>[[screeudeyr shennaghys yn ellyn]]<br/>[[archivist]]<br/>[[screeudeyr shennaghys]]
|
|
|
|
| [[:d:Q138649949|Q138649949]]
|-
| [[Charles Guard]]
| [[Coadan:Charles guard 2014 1.jpg|center|100px]]
|
| [[local historian]]<br/>[[broadcaster]]<br/>[[kiaulleyder]]<br/>[[cummeyder]]<br/>[[persoonid radio]]
|
|
|
|
| [[:d:Q140478500|Q140478500]]
|-
| [[Dot Tilbury]]
|
|
| [[cycling coach]]<br/>[[cycling activist]]
|
|
|
|
| [[:d:Q140478504|Q140478504]]
|-
| [[Emma Craig]]
|
|
| [[reagheyder]]<br/>[[screeudeyr]]
|
|
|
|
| [[:d:Q140545850|Q140545850]]
|}
{{Wikidata list end}}
==Jeeagh er neesht==
*[[Rolley cummaltee Vannin]]
*[[Rollaghyn sleih rere ashoonaght]]
*[[Manninee]]
==Imraaghyn==
{{commonscat|Manx people|Manninee}}
{{Reflist|30em}}
[[Ronney:Manninee| Rolley]]
[[Ronney:Rollaghyn rere kynneeaght|Manninee]]
[[Ronney:Rollaghyn bentyn rish Mannin|Manninee]]
r4iy9skqb7nes8au16sf52xy6gxy0jm
Module:Kishtey fys çheer
828
55827
393140
393136
2026-09-13T22:08:13Z
MacTire02
219
lheead
393140
Scribunto
text/plain
local p = {}
-- Helper to safely grab template arguments
local function getArgs(frame)
local parent = frame:getParent()
if parent then return parent.args end
return frame.args
end
-- Strips a leading "the "/"The " from an English P1448 name (Wikidata often
-- stores "the United States of America"). Only applied to English text --
-- a country whose name genuinely starts with "The" (e.g. The Bahamas, The
-- Gambia) should use |ennym_foddey_cadjincliaghtagh= to override this.
local function stripLeadingThe(text, langCode)
if langCode == "en" and text:match("^[Tt]he%s+%S") then
return text:gsub("^[Tt]he%s+", "", 1)
end
return text
end
-- 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 value ~= "" then
local trimmed = value:match("^%s*(.-)%s*$")
if trimmed ~= "" then return trimmed end
end
end
return nil
end
function p.main(frame)
local args = getArgs(frame)
local rows = {}
-- The universal border rule separating your modules
local dividerLine = '<tr><td colspan="2" style="border-top:1px solid #a2a9b1; padding:0; height:0px;"></td></tr>'
-- Centralized module injection manager
local function appendModule(content)
if content and content ~= "" then
if #rows > 0 then
table.insert(rows, dividerLine)
end
table.insert(rows, content)
end
end
--------------------------------------------------
-- MODULE 1: HEADER & OFFICIAL NAMES
--------------------------------------------------
local title = args["ennym"] or mw.title.getCurrentTitle().text
local subTitle = getManual(args, {"ennym_foddey_cadjincliaghtagh", "ennym_dooghyssagh"})
if not subTitle or subTitle == "" then
local entity = mw.wikibase.getEntityObject()
if entity then
local successLang, langData = pcall(mw.loadData, "Module:Lang/data")
if successLang and langData and langData.lang_name_table and langData.lang_name_table.lang then
local statements = entity:getBestStatements("P1448")
if statements and #statements > 0 then
for _, statement in ipairs(statements) do
if statement.mainsnak and statement.mainsnak.datavalue then
local value = statement.mainsnak.datavalue.value
if value and value.text then
local langCode = value.language or ""
local langName = langData.lang_name_table.lang[langCode] or langCode
local nameText = stripLeadingThe(value.text, langCode)
subTitle = nameText .. ' <small>([[' .. langName .. '|' .. langName .. ']])</small>'
break
end
end
end
end
end
end
end
local headerHtml = '<tr class="adr"><th colspan="2" class="fn org country-name" style="line-height:1.2em; padding:0.25em 0.4em 0.33em; font-size:1.25em; text-align:center; font-weight:normal;"><span style="font-weight:bold;">' .. title .. '</span>'
if subTitle and subTitle ~= "" then
headerHtml = headerHtml .. '<div style="padding-top:0.25em; font-weight:normal;">' .. subTitle .. '</div>'
end
headerHtml = headerHtml .. '</th></tr>'
table.insert(rows, headerHtml)
--------------------------------------------------
-- MODULE 2: FLAGS & ARMS
--------------------------------------------------
local successFlags, flagsMod = pcall(require, "Module:Kishtey fys çheer/bratteeyn")
if successFlags and flagsMod and flagsMod.main then
appendModule(flagsMod.main(frame, args))
end
--------------------------------------------------
-- MODULE 3: SYMBOLS (MOTTO & ANTHEMS)
--------------------------------------------------
local successSymbols, symbolsMod = pcall(require, "Module:Kishtey fys çheer/cowraghyn")
if successSymbols and symbolsMod and symbolsMod.main then
appendModule(symbolsMod.main(frame, args))
end
--------------------------------------------------
-- MODULE 4: LOCATOR MAPS
--------------------------------------------------
-- FIXED: Tries BOTH paths sequentially to guarantee zero-fail execution regardless of your physical page name setup
local successMaps, mapsMod = pcall(require, "Module:Kishtey fys çheer/caslyssyn-çheerey")
if not successMaps or not mapsMod then
successMaps, mapsMod = pcall(require, "Module:Kishtey fys çheer/caslyssyn")
end
if successMaps and mapsMod and mapsMod.main then
appendModule(mapsMod.main(frame, args))
end
--------------------------------------------------
-- MODULE 5: CITIES & CAPITALS
--------------------------------------------------
local successCities, citiesMod = pcall(require, "Module:Kishtey fys çheer/balley")
if successCities and citiesMod and citiesMod.main then
appendModule(citiesMod.main(frame, args))
end
--------------------------------------------------
-- MODULE 6: LANGUAGES
--------------------------------------------------
local successLanguages, languagesMod = pcall(require, "Module:Kishtey fys çheer/çhengaghyn")
if successLanguages and languagesMod and languagesMod.main then
appendModule(languagesMod.main(frame, args))
end
--------------------------------------------------
-- MODULE 7: ETHNIC GROUPS
--------------------------------------------------
local successEthnic, ethnicMod = pcall(require, "Module:Kishtey fys çheer/possanyn_kynneeagh")
if successEthnic and ethnicMod and ethnicMod.main then
appendModule(ethnicMod.main(frame, args))
end
--------------------------------------------------
-- MODULE 8: RELIGION
--------------------------------------------------
local successReligion, religionMod = pcall(require, "Module:Kishtey fys çheer/craueeaght")
if successReligion and religionMod and religionMod.main then
appendModule(religionMod.main(frame, args))
end
--------------------------------------------------
-- MODULE 9: GOVERNMENT & LEADERS
--------------------------------------------------
local successGov, govMod = pcall(require, "Module:Kishtey fys çheer/reiltys")
if successGov and govMod and govMod.main then
appendModule(govMod.main(frame, args))
end
if #rows <= 1 then
return nil
end
return '<table class="infobox geography vcard" style="float:right; clear:right; margin:0.5em 0 1em 1em; width:24.15em; border:1px solid #a2a9b1; border-collapse:collapse;">' .. table.concat(rows) .. '</table>'
end
return p
ncesit45lnim4yx9ptwywxqvd7ck5uj
393172
393140
2026-09-14T00:57:46Z
MacTire02
219
+Eaghtyr
393172
Scribunto
text/plain
local p = {}
-- Helper to safely grab template arguments
local function getArgs(frame)
local parent = frame:getParent()
if parent then return parent.args end
return frame.args
end
-- Strips a leading "the "/"The " from an English P1448 name (Wikidata often
-- stores "the United States of America"). Only applied to English text --
-- a country whose name genuinely starts with "The" (e.g. The Bahamas, The
-- Gambia) should use |ennym_foddey_cadjincliaghtagh= to override this.
local function stripLeadingThe(text, langCode)
if langCode == "en" and text:match("^[Tt]he%s+%S") then
return text:gsub("^[Tt]he%s+", "", 1)
end
return text
end
-- 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 value ~= "" then
local trimmed = value:match("^%s*(.-)%s*$")
if trimmed ~= "" then return trimmed end
end
end
return nil
end
function p.main(frame)
local args = getArgs(frame)
local rows = {}
-- The universal border rule separating your modules
local dividerLine = '<tr><td colspan="2" style="border-top:1px solid #a2a9b1; padding:0; height:0px;"></td></tr>'
-- Centralized module injection manager
local function appendModule(content)
if content and content ~= "" then
if #rows > 0 then
table.insert(rows, dividerLine)
end
table.insert(rows, content)
end
end
--------------------------------------------------
-- MODULE 1: HEADER & OFFICIAL NAMES
--------------------------------------------------
local title = args["ennym"] or mw.title.getCurrentTitle().text
local subTitle = getManual(args, {"ennym_foddey_cadjincliaghtagh", "ennym_dooghyssagh"})
if not subTitle or subTitle == "" then
local entity = mw.wikibase.getEntityObject()
if entity then
local successLang, langData = pcall(mw.loadData, "Module:Lang/data")
if successLang and langData and langData.lang_name_table and langData.lang_name_table.lang then
local statements = entity:getBestStatements("P1448")
if statements and #statements > 0 then
for _, statement in ipairs(statements) do
if statement.mainsnak and statement.mainsnak.datavalue then
local value = statement.mainsnak.datavalue.value
if value and value.text then
local langCode = value.language or ""
local langName = langData.lang_name_table.lang[langCode] or langCode
local nameText = stripLeadingThe(value.text, langCode)
subTitle = nameText .. ' <small>([[' .. langName .. '|' .. langName .. ']])</small>'
break
end
end
end
end
end
end
end
local headerHtml = '<tr class="adr"><th colspan="2" class="fn org country-name" style="line-height:1.2em; padding:0.25em 0.4em 0.33em; font-size:1.25em; text-align:center; font-weight:normal;"><span style="font-weight:bold;">' .. title .. '</span>'
if subTitle and subTitle ~= "" then
headerHtml = headerHtml .. '<div style="padding-top:0.25em; font-weight:normal;">' .. subTitle .. '</div>'
end
headerHtml = headerHtml .. '</th></tr>'
table.insert(rows, headerHtml)
--------------------------------------------------
-- MODULE 2: FLAGS & ARMS
--------------------------------------------------
local successFlags, flagsMod = pcall(require, "Module:Kishtey fys çheer/bratteeyn")
if successFlags and flagsMod and flagsMod.main then
appendModule(flagsMod.main(frame, args))
end
--------------------------------------------------
-- MODULE 3: SYMBOLS (MOTTO & ANTHEMS)
--------------------------------------------------
local successSymbols, symbolsMod = pcall(require, "Module:Kishtey fys çheer/cowraghyn")
if successSymbols and symbolsMod and symbolsMod.main then
appendModule(symbolsMod.main(frame, args))
end
--------------------------------------------------
-- MODULE 4: LOCATOR MAPS
--------------------------------------------------
-- FIXED: Tries BOTH paths sequentially to guarantee zero-fail execution regardless of your physical page name setup
local successMaps, mapsMod = pcall(require, "Module:Kishtey fys çheer/caslyssyn-çheerey")
if not successMaps or not mapsMod then
successMaps, mapsMod = pcall(require, "Module:Kishtey fys çheer/caslyssyn")
end
if successMaps and mapsMod and mapsMod.main then
appendModule(mapsMod.main(frame, args))
end
--------------------------------------------------
-- MODULE 5: CITIES & CAPITALS
--------------------------------------------------
local successCities, citiesMod = pcall(require, "Module:Kishtey fys çheer/balley")
if successCities and citiesMod and citiesMod.main then
appendModule(citiesMod.main(frame, args))
end
--------------------------------------------------
-- MODULE 6: LANGUAGES
--------------------------------------------------
local successLanguages, languagesMod = pcall(require, "Module:Kishtey fys çheer/çhengaghyn")
if successLanguages and languagesMod and languagesMod.main then
appendModule(languagesMod.main(frame, args))
end
--------------------------------------------------
-- MODULE 7: ETHNIC GROUPS
--------------------------------------------------
local successEthnic, ethnicMod = pcall(require, "Module:Kishtey fys çheer/possanyn_kynneeagh")
if successEthnic and ethnicMod and ethnicMod.main then
appendModule(ethnicMod.main(frame, args))
end
--------------------------------------------------
-- MODULE 8: RELIGION
--------------------------------------------------
local successReligion, religionMod = pcall(require, "Module:Kishtey fys çheer/craueeaght")
if successReligion and religionMod and religionMod.main then
appendModule(religionMod.main(frame, args))
end
--------------------------------------------------
-- MODULE 9: GOVERNMENT & LEADERS
--------------------------------------------------
local successGov, govMod = pcall(require, "Module:Kishtey fys çheer/reiltys")
if successGov and govMod and govMod.main then
appendModule(govMod.main(frame, args))
end
--------------------------------------------------
-- MODULE 10: AREA
--------------------------------------------------
local successArea, areaMod = pcall(require, "Module:Kishtey fys çheer/eaghtyr")
if successArea and areaMod and areaMod.main then
appendModule(areaMod.main(frame, args))
end
if #rows <= 1 then
return nil
end
return '<table class="infobox geography vcard" style="float:right; clear:right; margin:0.5em 0 1em 1em; width:24.15em; border:1px solid #a2a9b1; border-collapse:collapse;">' .. table.concat(rows) .. '</table>'
end
return p
ttpg4oyf4v8f7eakaxw4gf7o2wg250x
393176
393172
2026-09-14T01:28:15Z
MacTire02
219
+Pobble
393176
Scribunto
text/plain
local p = {}
-- Helper to safely grab template arguments
local function getArgs(frame)
local parent = frame:getParent()
if parent then return parent.args end
return frame.args
end
-- Strips a leading "the "/"The " from an English P1448 name (Wikidata often
-- stores "the United States of America"). Only applied to English text --
-- a country whose name genuinely starts with "The" (e.g. The Bahamas, The
-- Gambia) should use |ennym_foddey_cadjincliaghtagh= to override this.
local function stripLeadingThe(text, langCode)
if langCode == "en" and text:match("^[Tt]he%s+%S") then
return text:gsub("^[Tt]he%s+", "", 1)
end
return text
end
-- 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 value ~= "" then
local trimmed = value:match("^%s*(.-)%s*$")
if trimmed ~= "" then return trimmed end
end
end
return nil
end
function p.main(frame)
local args = getArgs(frame)
local rows = {}
-- The universal border rule separating your modules
local dividerLine = '<tr><td colspan="2" style="border-top:1px solid #a2a9b1; padding:0; height:0px;"></td></tr>'
-- Centralized module injection manager
local function appendModule(content)
if content and content ~= "" then
if #rows > 0 then
table.insert(rows, dividerLine)
end
table.insert(rows, content)
end
end
--------------------------------------------------
-- MODULE 1: HEADER & OFFICIAL NAMES
--------------------------------------------------
local title = args["ennym"] or mw.title.getCurrentTitle().text
local subTitle = getManual(args, {"ennym_foddey_cadjincliaghtagh", "ennym_dooghyssagh"})
if not subTitle or subTitle == "" then
local entity = mw.wikibase.getEntityObject()
if entity then
local successLang, langData = pcall(mw.loadData, "Module:Lang/data")
if successLang and langData and langData.lang_name_table and langData.lang_name_table.lang then
local statements = entity:getBestStatements("P1448")
if statements and #statements > 0 then
for _, statement in ipairs(statements) do
if statement.mainsnak and statement.mainsnak.datavalue then
local value = statement.mainsnak.datavalue.value
if value and value.text then
local langCode = value.language or ""
local langName = langData.lang_name_table.lang[langCode] or langCode
local nameText = stripLeadingThe(value.text, langCode)
subTitle = nameText .. ' <small>([[' .. langName .. '|' .. langName .. ']])</small>'
break
end
end
end
end
end
end
end
local headerHtml = '<tr class="adr"><th colspan="2" class="fn org country-name" style="line-height:1.2em; padding:0.25em 0.4em 0.33em; font-size:1.25em; text-align:center; font-weight:normal;"><span style="font-weight:bold;">' .. title .. '</span>'
if subTitle and subTitle ~= "" then
headerHtml = headerHtml .. '<div style="padding-top:0.25em; font-weight:normal;">' .. subTitle .. '</div>'
end
headerHtml = headerHtml .. '</th></tr>'
table.insert(rows, headerHtml)
--------------------------------------------------
-- MODULE 2: FLAGS & ARMS
--------------------------------------------------
local successFlags, flagsMod = pcall(require, "Module:Kishtey fys çheer/bratteeyn")
if successFlags and flagsMod and flagsMod.main then
appendModule(flagsMod.main(frame, args))
end
--------------------------------------------------
-- MODULE 3: SYMBOLS (MOTTO & ANTHEMS)
--------------------------------------------------
local successSymbols, symbolsMod = pcall(require, "Module:Kishtey fys çheer/cowraghyn")
if successSymbols and symbolsMod and symbolsMod.main then
appendModule(symbolsMod.main(frame, args))
end
--------------------------------------------------
-- MODULE 4: LOCATOR MAPS
--------------------------------------------------
-- FIXED: Tries BOTH paths sequentially to guarantee zero-fail execution regardless of your physical page name setup
local successMaps, mapsMod = pcall(require, "Module:Kishtey fys çheer/caslyssyn-çheerey")
if not successMaps or not mapsMod then
successMaps, mapsMod = pcall(require, "Module:Kishtey fys çheer/caslyssyn")
end
if successMaps and mapsMod and mapsMod.main then
appendModule(mapsMod.main(frame, args))
end
--------------------------------------------------
-- MODULE 5: CITIES & CAPITALS
--------------------------------------------------
local successCities, citiesMod = pcall(require, "Module:Kishtey fys çheer/balley")
if successCities and citiesMod and citiesMod.main then
appendModule(citiesMod.main(frame, args))
end
--------------------------------------------------
-- MODULE 6: LANGUAGES
--------------------------------------------------
local successLanguages, languagesMod = pcall(require, "Module:Kishtey fys çheer/çhengaghyn")
if successLanguages and languagesMod and languagesMod.main then
appendModule(languagesMod.main(frame, args))
end
--------------------------------------------------
-- MODULE 7: ETHNIC GROUPS
--------------------------------------------------
local successEthnic, ethnicMod = pcall(require, "Module:Kishtey fys çheer/possanyn_kynneeagh")
if successEthnic and ethnicMod and ethnicMod.main then
appendModule(ethnicMod.main(frame, args))
end
--------------------------------------------------
-- MODULE 8: RELIGION
--------------------------------------------------
local successReligion, religionMod = pcall(require, "Module:Kishtey fys çheer/craueeaght")
if successReligion and religionMod and religionMod.main then
appendModule(religionMod.main(frame, args))
end
--------------------------------------------------
-- MODULE 9: GOVERNMENT & LEADERS
--------------------------------------------------
local successGov, govMod = pcall(require, "Module:Kishtey fys çheer/reiltys")
if successGov and govMod and govMod.main then
appendModule(govMod.main(frame, args))
end
--------------------------------------------------
-- MODULE 10: AREA
--------------------------------------------------
local successArea, areaMod = pcall(require, "Module:Kishtey fys çheer/eaghtyr")
if successArea and areaMod and areaMod.main then
appendModule(areaMod.main(frame, args))
end
--------------------------------------------------
-- MODULE 11: POPULATION
--------------------------------------------------
local successPop, popMod = pcall(require, "Module:Kishtey fys çheer/pobble")
if successPop and popMod and popMod.main then
appendModule(popMod.main(frame, args))
end
if #rows <= 1 then
return nil
end
return '<table class="infobox geography vcard" style="float:right; clear:right; margin:0.5em 0 1em 1em; width:24.15em; border:1px solid #a2a9b1; border-collapse:collapse;">' .. table.concat(rows) .. '</table>'
end
return p
qqyxwy633x3aojbth0kmxjix6xx97bh
Module:Kishtey fys çheer/balley
828
55830
393142
393125
2026-09-13T22:13:22Z
MacTire02
219
+baarnaghyn
393142
Scribunto
text/plain
local p = {}
-- 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
-- Safely clean up link wrappers without risk of regex index errors
local function normaliseCityName(value)
if not value then return "" end
local clean = mw.text.trim(value)
clean = clean:gsub("^%[%[", ""):gsub("%]%]$", "")
local pipe = clean:find("|", 1, true)
if pipe then
clean = clean:sub(1, pipe - 1)
end
return mw.text.trim(clean)
end
-- Pull a city name from Wikidata (property must hold an item value, e.g. P36 = capital)
local function getWikidataCity(property)
local entity = mw.wikibase.getEntityObject()
if not entity then return nil end
local statements = entity:getBestStatements(property)
if not statements or #statements == 0 then return nil end
local mainsnak = statements[1].mainsnak
if not (mainsnak and mainsnak.snaktype == "value" and mainsnak.datavalue
and mainsnak.datavalue.type == "wikibase-entityid") then
return nil
end
local value = mainsnak.datavalue.value
local id = value.id or ("Q" .. tostring(value["numeric-id"]))
-- Prefer the title of the local (gv) sitelink so the link isn't red;
-- fall back to the item's label if there's no gv article yet.
local sitelink = mw.wikibase.sitelink(id)
if sitelink and sitelink ~= "" then return sitelink end
local label = mw.wikibase.getLabelByLang(id, "gv") or mw.wikibase.label(id)
if label and label ~= "" then return label end
return nil
end
-- Given a plain page title (city name), resolve its own Wikidata item and
-- expand {{coord}} with its P625 coordinates (decimal degrees), which
-- handles the globe icon and the GeoHack link itself.
--
-- FIX (DMS vs. decimal inconsistency): {{coord}} was previously called with
-- no `format=` parameter at all, and its own default formatting turned out
-- NOT to be reliably DMS -- some articles rendered DMS, others plain
-- decimal degrees, with nothing in THIS module's own code varying between
-- them (the only difference is whatever {{coord}} itself decides internally,
-- which this project has no visibility into or control over, since
-- gv.wikipedia.org can't be inspected directly from here). This project's
-- own existing `Module:WikidataIB.getCoords` -- a real, previously-working
-- P625-to-{{coord}} bridge already used elsewhere on gv.wiki -- settles the
-- exact same question by ALWAYS explicitly passing `format=dms` (its own
-- `form` variable defaults to "dms" unless the caller explicitly asks for
-- "dec", then hands it to {{coord}} as `lat_long["format"] = form`) --
-- never leaving it for {{coord}} to decide on its own. Matching that same,
-- already-proven convention here makes every article's coordinates
-- deterministically DMS, regardless of precision, magnitude, or whatever
-- else was silently driving the previous inconsistency.
local function getCityCoordinates(frame, pageTitle)
if not pageTitle or pageTitle == "" then return nil end
local id = mw.wikibase.getEntityIdForTitle(pageTitle)
if not id then return nil end
local entity = mw.wikibase.getEntityObject(id)
if not entity then return nil end
local statements = entity:getBestStatements("P625")
if not statements or #statements == 0 then return nil end
local mainsnak = statements[1].mainsnak
if not (mainsnak and mainsnak.snaktype == "value" and mainsnak.datavalue
and mainsnak.datavalue.type == "globecoordinate") then
return nil
end
local coord = mainsnak.datavalue.value
if not (coord.latitude and coord.longitude) then return nil end
return frame:expandTemplate{
title = "coord",
args = { coord.latitude, coord.longitude, "type:city", display = "inline", format = "dms" }
}
end
-- Manual coordinate override, in the exact old-template component shape --
-- separate degrees/minutes/direction params for latitude and longitude --
-- the only input shape the old HTML template's `{{coor cn}}` call ever
-- accepted (see `Clowan:Kishtey fys çheer`'s own wikitext: `{{coor cn
-- |{{{latd}}}|{{{latm}}}|{{{latNS}}}|{{{longd}}}|{{{longm}}}|{{{longEW}}}|
-- ...}}`), so any of the ~200 existing articles that already set these
-- keep working completely unchanged, and any editor who finds Wikidata's
-- P625 wrong for a given settlement has the same kind of manual escape
-- hatch every other Wikidata-sourced field in this project already has.
--
-- Deliberately does NOT try to also carry over the old template's
-- `latNSgael`/`longEWgael` params (Manx-translated direction-letter
-- overrides for the old, different `{{coor cn}}` template) -- `{{coord}}`,
-- the template this module actually calls, has no equivalent parameter to
-- hand them to, and I don't have visibility into whether it needs/supports
-- one at all. Flagging this rather than guessing at it: if any existing
-- article relies on those specifically, let me know and I'll look at it.
--
-- Returns:
-- "suppress" -- the degrees param was explicitly set to
-- |...=none: no coordinates at all for
-- this row, even if Wikidata has one --
-- same `none`-suppression convention
-- every other Wikidata-sourced field in
-- this project uses.
-- a built {{coord}} expansion -- real DMS component values were
-- supplied: builds the same kind of
-- coordinate text {{coord}} would
-- otherwise produce from Wikidata, just
-- sourced from the manual override
-- instead -- always DMS (`format=dms`,
-- matching the fix above), regardless of
-- what values were actually supplied.
-- nil -- no override at all (the degrees param
-- wasn't supplied): the caller should
-- fall through to its own Wikidata
-- fallback (or show nothing, for a row
-- that doesn't have one).
local function getManualCoordinates(frame, args, degParam, minParam, nsParam, lonDegParam, lonMinParam, ewParam)
local latd = getManual(args, {degParam})
if not latd then return nil end
if isNone(latd) then return "suppress" end
local latm = getManual(args, {minParam}) or ""
local latNS = getManual(args, {nsParam}) or ""
local longd = getManual(args, {lonDegParam}) or ""
local longm = getManual(args, {lonMinParam}) or ""
local longEW = getManual(args, {ewParam}) or ""
return frame:expandTemplate{
title = "coord",
args = { latd, latm, latNS, longd, longm, longEW, "type:city", display = "inline", format = "dms" }
}
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 capital = getManual(args, {"preeu-valley"})
if not capital then
capital = getWikidataCity("P36")
end
local administrative = getManual(args, {"ynnyd_reiragh"})
local largest = getManual(args, {"balley_smoo"})
if not largest then
largest = getWikidataCity("P13574")
end
local capNote = getManual(args, {"noteyn_preeu-valley"})
local adminNote = getManual(args, {"noteyn_ynnyd_reiragh"})
local largeNote = getManual(args, {"noteyn_balley_smoo"})
-- Manual coordinate overrides (see getManualCoordinates above). `latd`
-- et al. are the OLD template's params, which always bound to whichever
-- of the capital or the administrative centre was the primary
-- settlement row shown (the old template could only ever show one of
-- the two at once); this module shows both as independent rows, so the
-- same override now binds to the capital row specifically whenever a
-- capital is present, and only falls through to the administrative-
-- centre row when there is no capital -- mirroring the old template's
-- own branching as closely as the new two-row layout allows.
-- `latd_balley_smoo` et al. are new -- the old template never showed
-- coordinates for a genuinely separate largest-city row at all (only
-- ever for whichever settlement was already shown as capital/admin
-- centre), so there's no legacy param name to preserve here.
-- Computed right where each is first used (below) rather than
-- eagerly here -- a manual override's {{coord}} expansion only
-- actually fires once the row that would show it is confirmed to be
-- displayed, so a suppressed/absent row never triggers a pointless
-- template expansion for an override nothing will ever use.
local manualPrimaryCoords = getManualCoordinates(frame, args, "latd", "latm", "latNS", "longd", "longm", "longEW")
local subRows = {}
-- Verify if capital and largest city match
local isSame = false
if largest then
local cleanLargest = mw.text.trim(largest):lower()
if cleanLargest == "preeu-valley" or cleanLargest == "preeu_valley" then
isSame = true
elseif capital and normaliseCityName(capital):lower() == normaliseCityName(largest):lower() then
isSame = true
end
end
-- 1. CAPITAL ROW
if capital and mw.text.trim(capital):lower() ~= "none" then
local label = args["sorçh_preeu-valley"] or "Preeu-valley"
local displayLabel = '[[' .. label .. ']]'
if isSame then
displayLabel = '[[' .. label .. ']]<br/><small style="font-weight:normal;">(as y balley smoo)</small>'
end
local cleanCapName = normaliseCityName(capital)
local text = '[[' .. cleanCapName .. '|' .. cleanCapName .. ']]'
if capNote and capNote ~= "" then
text = text .. frame:expandTemplate{ title = "efn", args = { capNote } }
end
-- Manual override wins outright over Wikidata (and an explicit
-- |latd=none suppresses coordinates entirely for this row, even
-- when Wikidata has one); only falls through to the Wikidata
-- fetch when the manual param wasn't supplied at all.
local capCoords
if manualPrimaryCoords == "suppress" then
capCoords = nil
elseif manualPrimaryCoords then
capCoords = manualPrimaryCoords
else
capCoords = getCityCoordinates(frame, cleanCapName)
end
if capCoords then
text = text .. '<br/><small>' .. capCoords .. '</small>'
end
table.insert(subRows, '<tr><th style="vertical-align:top; white-space:nowrap; text-align:left; font-weight:bold; padding-left:0.4em; padding-right:0.4em;">' .. displayLabel .. '</th><td style="vertical-align:top; padding-left:0.4em; padding-right:0.4em;">' .. text .. '</td></tr>')
end
-- 2. ADMINISTRATIVE CENTER ROW
if administrative and mw.text.trim(administrative):lower() ~= "none" then
local label = args["sorçh_ynnyd_reiragh"] or "Ynnyd reiragh"
local cleanAdminName = normaliseCityName(administrative)
local text = '[[' .. cleanAdminName .. '|' .. cleanAdminName .. ']]'
if adminNote and adminNote ~= "" then
text = text .. frame:expandTemplate{ title = "efn", args = { adminNote } }
end
-- The shared |latd=/etc. override only ever falls through to this
-- row when there's no capital row already claiming it (see the
-- comment on manualPrimaryCoords above) -- this module has no
-- Wikidata-sourced coordinate fetch of its own for an
-- administrative centre (the old template never had one either),
-- so this is manual-override-only.
if not (capital and mw.text.trim(capital):lower() ~= "none") then
local adminCoords
if manualPrimaryCoords == "suppress" then
adminCoords = nil
elseif manualPrimaryCoords then
adminCoords = manualPrimaryCoords
end
if adminCoords then
text = text .. '<br/><small>' .. adminCoords .. '</small>'
end
end
table.insert(subRows, '<tr><th style="vertical-align:top; white-space:nowrap; text-align:left; font-weight:bold; padding-left:0.4em; padding-right:0.4em;">[[' .. label .. ']]</th><td style="vertical-align:top; padding-left:0.4em; padding-right:0.4em;">' .. text .. '</td></tr>')
end
-- 3. LARGEST CITY ROW
if largest and mw.text.trim(largest):lower() ~= "none" and not isSame then
local cleanLargeName = normaliseCityName(largest)
local text = '[[' .. cleanLargeName .. '|' .. cleanLargeName .. ']]'
if largeNote and largeNote ~= "" then
text = text .. frame:expandTemplate{ title = "efn", args = { largeNote } }
end
-- Computed here, right at its point of use, same reasoning as
-- manualPrimaryCoords above -- new params (see getManualCoordinates'
-- own header comment for why there's no old-template name to
-- preserve for this row).
local manualLargeCoords = getManualCoordinates(frame, args, "latd_balley_smoo", "latm_balley_smoo", "latNS_balley_smoo", "longd_balley_smoo", "longm_balley_smoo", "longEW_balley_smoo")
local largeCoords
if manualLargeCoords == "suppress" then
largeCoords = nil
elseif manualLargeCoords then
largeCoords = manualLargeCoords
else
largeCoords = getCityCoordinates(frame, cleanLargeName)
end
if largeCoords then
text = text .. '<br/><small>' .. largeCoords .. '</small>'
end
table.insert(subRows, '<tr><th style="vertical-align:top; white-space:nowrap; text-align:left; font-weight:bold; padding-left:0.4em; padding-right:0.4em;">Balley smoo</th><td style="vertical-align:top; padding-left:0.4em; padding-right:0.4em;">' .. text .. '</td></tr>')
end
if #subRows == 0 then return nil end
return table.concat(subRows)
end
return p
tqnczc34hsajnw6axkn3vb1dte35v14
393162
393142
2026-09-13T23:47:13Z
MacTire02
219
++
393162
Scribunto
text/plain
local p = {}
-- 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
-- Safely clean up link wrappers without risk of regex index errors
local function normaliseCityName(value)
if not value then return "" end
local clean = mw.text.trim(value)
clean = clean:gsub("^%[%[", ""):gsub("%]%]$", "")
local pipe = clean:find("|", 1, true)
if pipe then
clean = clean:sub(1, pipe - 1)
end
return mw.text.trim(clean)
end
-- Pull a city name from Wikidata (property must hold an item value, e.g. P36 = capital)
local function getWikidataCity(property)
local entity = mw.wikibase.getEntityObject()
if not entity then return nil end
local statements = entity:getBestStatements(property)
if not statements or #statements == 0 then return nil end
local mainsnak = statements[1].mainsnak
if not (mainsnak and mainsnak.snaktype == "value" and mainsnak.datavalue
and mainsnak.datavalue.type == "wikibase-entityid") then
return nil
end
local value = mainsnak.datavalue.value
local id = value.id or ("Q" .. tostring(value["numeric-id"]))
-- Prefer the title of the local (gv) sitelink so the link isn't red;
-- fall back to the item's label if there's no gv article yet.
local sitelink = mw.wikibase.sitelink(id)
if sitelink and sitelink ~= "" then return sitelink end
local label = mw.wikibase.getLabelByLang(id, "gv") or mw.wikibase.label(id)
if label and label ~= "" then return label end
return nil
end
-- Given a plain page title (city name), resolve its own Wikidata item and
-- expand {{coord}} with its P625 coordinates (decimal degrees), which
-- handles the globe icon and the GeoHack link itself.
--
-- FIX (DMS vs. decimal inconsistency): {{coord}} was previously called with
-- no `format=` parameter at all, and its own default formatting turned out
-- NOT to be reliably DMS -- some articles rendered DMS, others plain
-- decimal degrees, with nothing in THIS module's own code varying between
-- them (the only difference is whatever {{coord}} itself decides internally,
-- which this project has no visibility into or control over, since
-- gv.wikipedia.org can't be inspected directly from here). This project's
-- own existing `Module:WikidataIB.getCoords` -- a real, previously-working
-- P625-to-{{coord}} bridge already used elsewhere on gv.wiki -- settles the
-- exact same question by ALWAYS explicitly passing `format=dms` (its own
-- `form` variable defaults to "dms" unless the caller explicitly asks for
-- "dec", then hands it to {{coord}} as `lat_long["format"] = form`) --
-- never leaving it for {{coord}} to decide on its own. Matching that same,
-- already-proven convention here makes every article's coordinates
-- deterministically DMS, regardless of precision, magnitude, or whatever
-- else was silently driving the previous inconsistency.
local function getCityCoordinates(frame, pageTitle)
if not pageTitle or pageTitle == "" then return nil end
local id = mw.wikibase.getEntityIdForTitle(pageTitle)
if not id then return nil end
local entity = mw.wikibase.getEntityObject(id)
if not entity then return nil end
local statements = entity:getBestStatements("P625")
if not statements or #statements == 0 then return nil end
local mainsnak = statements[1].mainsnak
if not (mainsnak and mainsnak.snaktype == "value" and mainsnak.datavalue
and mainsnak.datavalue.type == "globecoordinate") then
return nil
end
local coord = mainsnak.datavalue.value
if not (coord.latitude and coord.longitude) then return nil end
return frame:expandTemplate{
title = "coord",
args = { coord.latitude, coord.longitude, "type:city", display = "inline", format = "dms" }
}
end
-- Manual coordinate override, in the exact old-template component shape --
-- separate degrees/minutes/direction params for latitude and longitude --
-- the only input shape the old HTML template's `{{coor cn}}` call ever
-- accepted (see `Clowan:Kishtey fys çheer`'s own wikitext: `{{coor cn
-- |{{{latd}}}|{{{latm}}}|{{{latNS}}}|{{{longd}}}|{{{longm}}}|{{{longEW}}}|
-- ...}}`), so any of the ~200 existing articles that already set these
-- keep working completely unchanged, and any editor who finds Wikidata's
-- P625 wrong for a given settlement has the same kind of manual escape
-- hatch every other Wikidata-sourced field in this project already has.
--
-- Deliberately does NOT try to also carry over the old template's
-- `latNSgael`/`longEWgael` params (Manx-translated direction-letter
-- overrides for the old, different `{{coor cn}}` template) -- `{{coord}}`,
-- the template this module actually calls, has no equivalent parameter to
-- hand them to, and I don't have visibility into whether it needs/supports
-- one at all. Flagging this rather than guessing at it: if any existing
-- article relies on those specifically, let me know and I'll look at it.
--
-- Returns:
-- "suppress" -- the degrees param was explicitly set to
-- |...=none: no coordinates at all for
-- this row, even if Wikidata has one --
-- same `none`-suppression convention
-- every other Wikidata-sourced field in
-- this project uses.
-- a built {{coord}} expansion -- real DMS component values were
-- supplied: builds the same kind of
-- coordinate text {{coord}} would
-- otherwise produce from Wikidata, just
-- sourced from the manual override
-- instead -- always DMS (`format=dms`,
-- matching the fix above), regardless of
-- what values were actually supplied.
-- nil -- no override at all (the degrees param
-- wasn't supplied): the caller should
-- fall through to its own Wikidata
-- fallback (or show nothing, for a row
-- that doesn't have one).
local function getManualCoordinates(frame, args, degParam, minParam, nsParam, lonDegParam, lonMinParam, ewParam)
local latd = getManual(args, {degParam})
if not latd then return nil end
if isNone(latd) then return "suppress" end
local latm = getManual(args, {minParam}) or ""
local latNS = getManual(args, {nsParam}) or ""
local longd = getManual(args, {lonDegParam}) or ""
local longm = getManual(args, {lonMinParam}) or ""
local longEW = getManual(args, {ewParam}) or ""
return frame:expandTemplate{
title = "coord",
args = { latd, latm, latNS, longd, longm, longEW, "type:city", display = "inline", format = "dms" }
}
end
-- Coordinates must never line-wrap inside the infobox's narrow value
-- column: {{coord}}'s own output uses ordinary spaces between the lat and
-- long halves (e.g. "38°53'42"N 77°02'12"W"), which the browser is free to
-- break on when the column is too narrow for both halves on one line --
-- this is purely a display wrapper around whatever {{coord}} returns, so
-- every caller below (capital/admin/largest-city rows) should route
-- through this rather than inlining the <small> tag itself.
local function coordSpan(coordText)
if not coordText or coordText == "" then return "" end
return '<br/><small style="white-space:nowrap;">' .. coordText .. '</small>'
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 capital = getManual(args, {"preeu-valley"})
if not capital then
capital = getWikidataCity("P36")
end
local administrative = getManual(args, {"ynnyd_reiragh"})
local largest = getManual(args, {"balley_smoo"})
if not largest then
largest = getWikidataCity("P13574")
end
local capNote = getManual(args, {"noteyn_preeu-valley"})
local adminNote = getManual(args, {"noteyn_ynnyd_reiragh"})
local largeNote = getManual(args, {"noteyn_balley_smoo"})
-- Manual coordinate overrides (see getManualCoordinates above). `latd`
-- et al. are the OLD template's params, which always bound to whichever
-- of the capital or the administrative centre was the primary
-- settlement row shown (the old template could only ever show one of
-- the two at once); this module shows both as independent rows, so the
-- same override now binds to the capital row specifically whenever a
-- capital is present, and only falls through to the administrative-
-- centre row when there is no capital -- mirroring the old template's
-- own branching as closely as the new two-row layout allows.
-- `latd_balley_smoo` et al. are new -- the old template never showed
-- coordinates for a genuinely separate largest-city row at all (only
-- ever for whichever settlement was already shown as capital/admin
-- centre), so there's no legacy param name to preserve here.
-- Computed right where each is first used (below) rather than
-- eagerly here -- a manual override's {{coord}} expansion only
-- actually fires once the row that would show it is confirmed to be
-- displayed, so a suppressed/absent row never triggers a pointless
-- template expansion for an override nothing will ever use.
local manualPrimaryCoords = getManualCoordinates(frame, args, "latd", "latm", "latNS", "longd", "longm", "longEW")
local subRows = {}
-- Verify if capital and largest city match
local isSame = false
if largest then
local cleanLargest = mw.text.trim(largest):lower()
if cleanLargest == "preeu-valley" or cleanLargest == "preeu_valley" then
isSame = true
elseif capital and normaliseCityName(capital):lower() == normaliseCityName(largest):lower() then
isSame = true
end
end
-- 1. CAPITAL ROW
if capital and mw.text.trim(capital):lower() ~= "none" then
local label = args["sorçh_preeu-valley"] or "Preeu-valley"
local displayLabel = '[[' .. label .. ']]'
if isSame then
displayLabel = '[[' .. label .. ']]<br/><small style="font-weight:normal;">(as y balley smoo)</small>'
end
local cleanCapName = normaliseCityName(capital)
local text = '[[' .. cleanCapName .. '|' .. cleanCapName .. ']]'
if capNote and capNote ~= "" then
text = text .. frame:expandTemplate{ title = "efn", args = { capNote } }
end
-- Manual override wins outright over Wikidata (and an explicit
-- |latd=none suppresses coordinates entirely for this row, even
-- when Wikidata has one); only falls through to the Wikidata
-- fetch when the manual param wasn't supplied at all.
local capCoords
if manualPrimaryCoords == "suppress" then
capCoords = nil
elseif manualPrimaryCoords then
capCoords = manualPrimaryCoords
else
capCoords = getCityCoordinates(frame, cleanCapName)
end
text = text .. coordSpan(capCoords)
table.insert(subRows, '<tr><th style="vertical-align:top; white-space:nowrap; text-align:left; font-weight:bold; padding-left:0.4em; padding-right:0.4em;">' .. displayLabel .. '</th><td style="vertical-align:top; padding-left:0.4em; padding-right:0.4em;">' .. text .. '</td></tr>')
end
-- 2. ADMINISTRATIVE CENTER ROW
if administrative and mw.text.trim(administrative):lower() ~= "none" then
local label = args["sorçh_ynnyd_reiragh"] or "Ynnyd reiragh"
local cleanAdminName = normaliseCityName(administrative)
local text = '[[' .. cleanAdminName .. '|' .. cleanAdminName .. ']]'
if adminNote and adminNote ~= "" then
text = text .. frame:expandTemplate{ title = "efn", args = { adminNote } }
end
-- The shared |latd=/etc. override only ever falls through to this
-- row when there's no capital row already claiming it (see the
-- comment on manualPrimaryCoords above) -- this module has no
-- Wikidata-sourced coordinate fetch of its own for an
-- administrative centre (the old template never had one either),
-- so this is manual-override-only.
if not (capital and mw.text.trim(capital):lower() ~= "none") then
local adminCoords
if manualPrimaryCoords == "suppress" then
adminCoords = nil
elseif manualPrimaryCoords then
adminCoords = manualPrimaryCoords
end
text = text .. coordSpan(adminCoords)
end
table.insert(subRows, '<tr><th style="vertical-align:top; white-space:nowrap; text-align:left; font-weight:bold; padding-left:0.4em; padding-right:0.4em;">[[' .. label .. ']]</th><td style="vertical-align:top; padding-left:0.4em; padding-right:0.4em;">' .. text .. '</td></tr>')
end
-- 3. LARGEST CITY ROW
if largest and mw.text.trim(largest):lower() ~= "none" and not isSame then
local cleanLargeName = normaliseCityName(largest)
local text = '[[' .. cleanLargeName .. '|' .. cleanLargeName .. ']]'
if largeNote and largeNote ~= "" then
text = text .. frame:expandTemplate{ title = "efn", args = { largeNote } }
end
-- Computed here, right at its point of use, same reasoning as
-- manualPrimaryCoords above -- new params (see getManualCoordinates'
-- own header comment for why there's no old-template name to
-- preserve for this row).
local manualLargeCoords = getManualCoordinates(frame, args, "latd_balley_smoo", "latm_balley_smoo", "latNS_balley_smoo", "longd_balley_smoo", "longm_balley_smoo", "longEW_balley_smoo")
local largeCoords
if manualLargeCoords == "suppress" then
largeCoords = nil
elseif manualLargeCoords then
largeCoords = manualLargeCoords
else
largeCoords = getCityCoordinates(frame, cleanLargeName)
end
text = text .. coordSpan(largeCoords)
table.insert(subRows, '<tr><th style="vertical-align:top; white-space:nowrap; text-align:left; font-weight:bold; padding-left:0.4em; padding-right:0.4em;">Balley smoo</th><td style="vertical-align:top; padding-left:0.4em; padding-right:0.4em;">' .. text .. '</td></tr>')
end
if #subRows == 0 then return nil end
return table.concat(subRows)
end
return p
1tn4ic3qfhty3fnb6vxkx7993wjs95i
393169
393162
2026-09-14T00:06:43Z
MacTire02
219
++
393169
Scribunto
text/plain
local p = {}
-- 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
-- Safely clean up link wrappers without risk of regex index errors
local function normaliseCityName(value)
if not value then return "" end
local clean = mw.text.trim(value)
clean = clean:gsub("^%[%[", ""):gsub("%]%]$", "")
local pipe = clean:find("|", 1, true)
if pipe then
clean = clean:sub(1, pipe - 1)
end
return mw.text.trim(clean)
end
-- Pull a city name from Wikidata (property must hold an item value, e.g. P36 = capital)
local function getWikidataCity(property)
local entity = mw.wikibase.getEntityObject()
if not entity then return nil end
local statements = entity:getBestStatements(property)
if not statements or #statements == 0 then return nil end
local mainsnak = statements[1].mainsnak
if not (mainsnak and mainsnak.snaktype == "value" and mainsnak.datavalue
and mainsnak.datavalue.type == "wikibase-entityid") then
return nil
end
local value = mainsnak.datavalue.value
local id = value.id or ("Q" .. tostring(value["numeric-id"]))
-- Prefer the title of the local (gv) sitelink so the link isn't red;
-- fall back to the item's label if there's no gv article yet.
local sitelink = mw.wikibase.sitelink(id)
if sitelink and sitelink ~= "" then return sitelink end
local label = mw.wikibase.getLabelByLang(id, "gv") or mw.wikibase.label(id)
if label and label ~= "" then return label end
return nil
end
-- Given a plain page title (city name), resolve its own Wikidata item and
-- expand {{coord}} with its P625 coordinates -- always with format="dms"
-- (matching Module:WikidataIB.getCoords' own convention), since {{coord}}'s
-- own default formatting isn't reliably DMS on its own.
local function getCityCoordinates(frame, pageTitle)
if not pageTitle or pageTitle == "" then return nil end
local id = mw.wikibase.getEntityIdForTitle(pageTitle)
if not id then return nil end
local entity = mw.wikibase.getEntityObject(id)
if not entity then return nil end
local statements = entity:getBestStatements("P625")
if not statements or #statements == 0 then return nil end
local mainsnak = statements[1].mainsnak
if not (mainsnak and mainsnak.snaktype == "value" and mainsnak.datavalue
and mainsnak.datavalue.type == "globecoordinate") then
return nil
end
local coord = mainsnak.datavalue.value
if not (coord.latitude and coord.longitude) then return nil end
return frame:expandTemplate{
title = "coord",
args = { coord.latitude, coord.longitude, "type:city", display = "inline", format = "dms" }
}
end
-- Manual coordinate override, in the old template's own component shape
-- (separate deg/min/direction params for lat and long -- the old {{coor
-- cn}} call's input shape). Doesn't carry over the old `latNSgael`/
-- `longEWgael` Manx-direction params -- {{coord}} has no equivalent slot.
-- Returns "suppress" (|...=none), a built {{coord}} expansion (format=dms),
-- or nil (no override -- caller falls through to Wikidata).
local function getManualCoordinates(frame, args, degParam, minParam, nsParam, lonDegParam, lonMinParam, ewParam)
local latd = getManual(args, {degParam})
if not latd then return nil end
if isNone(latd) then return "suppress" end
local latm = getManual(args, {minParam}) or ""
local latNS = getManual(args, {nsParam}) or ""
local longd = getManual(args, {lonDegParam}) or ""
local longm = getManual(args, {lonMinParam}) or ""
local longEW = getManual(args, {ewParam}) or ""
return frame:expandTemplate{
title = "coord",
args = { latd, latm, latNS, longd, longm, longEW, "type:city", display = "inline", format = "dms" }
}
end
-- Prevents coordinates from line-wrapping in the infobox's narrow column
-- ({{coord}}'s output has plain spaces the browser is free to break on).
local function coordSpan(coordText)
if not coordText or coordText == "" then return "" end
return '<br/><small style="white-space:nowrap;">' .. coordText .. '</small>'
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 capital = getManual(args, {"preeu-valley"})
if not capital then
capital = getWikidataCity("P36")
end
local administrative = getManual(args, {"ynnyd_reiragh"})
local largest = getManual(args, {"balley_smoo"})
if not largest then
largest = getWikidataCity("P13574")
end
local capNote = getManual(args, {"noteyn_preeu-valley"})
local adminNote = getManual(args, {"noteyn_ynnyd_reiragh"})
local largeNote = getManual(args, {"noteyn_balley_smoo"})
-- `latd` et al. (old template's params) bind to the capital row when one
-- is present, else fall through to the administrative-centre row --
-- mirroring the old template's single combined row as closely as this
-- module's two-row layout allows. `latd_balley_smoo` et al. (new) cover
-- the largest-city row, which the old template never had coordinates for.
local manualPrimaryCoords = getManualCoordinates(frame, args, "latd", "latm", "latNS", "longd", "longm", "longEW")
local subRows = {}
-- Verify if capital and largest city match
local isSame = false
if largest then
local cleanLargest = mw.text.trim(largest):lower()
if cleanLargest == "preeu-valley" or cleanLargest == "preeu_valley" then
isSame = true
elseif capital and normaliseCityName(capital):lower() == normaliseCityName(largest):lower() then
isSame = true
end
end
-- 1. CAPITAL ROW
if capital and mw.text.trim(capital):lower() ~= "none" then
local label = args["sorçh_preeu-valley"] or "Preeu-valley"
local displayLabel = '[[' .. label .. ']]'
if isSame then
displayLabel = '[[' .. label .. ']]<br/><small style="font-weight:normal;">(as y balley smoo)</small>'
end
local cleanCapName = normaliseCityName(capital)
local text = '[[' .. cleanCapName .. '|' .. cleanCapName .. ']]'
if capNote and capNote ~= "" then
text = text .. frame:expandTemplate{ title = "efn", args = { capNote } }
end
-- Manual override wins outright over Wikidata (and an explicit
-- |latd=none suppresses coordinates entirely for this row, even
-- when Wikidata has one); only falls through to the Wikidata
-- fetch when the manual param wasn't supplied at all.
local capCoords
if manualPrimaryCoords == "suppress" then
capCoords = nil
elseif manualPrimaryCoords then
capCoords = manualPrimaryCoords
else
capCoords = getCityCoordinates(frame, cleanCapName)
end
text = text .. coordSpan(capCoords)
table.insert(subRows, '<tr><th style="vertical-align:top; white-space:nowrap; text-align:left; font-weight:bold; padding-left:0.4em; padding-right:0.4em;">' .. displayLabel .. '</th><td style="vertical-align:top; padding-left:0.4em; padding-right:0.4em;">' .. text .. '</td></tr>')
end
-- 2. ADMINISTRATIVE CENTER ROW
if administrative and mw.text.trim(administrative):lower() ~= "none" then
local label = args["sorçh_ynnyd_reiragh"] or "Ynnyd reiragh"
local cleanAdminName = normaliseCityName(administrative)
local text = '[[' .. cleanAdminName .. '|' .. cleanAdminName .. ']]'
if adminNote and adminNote ~= "" then
text = text .. frame:expandTemplate{ title = "efn", args = { adminNote } }
end
-- Manual-override-only -- no Wikidata coordinate fetch for an
-- administrative centre (the old template never had one either).
if not (capital and mw.text.trim(capital):lower() ~= "none") then
local adminCoords
if manualPrimaryCoords == "suppress" then
adminCoords = nil
elseif manualPrimaryCoords then
adminCoords = manualPrimaryCoords
end
text = text .. coordSpan(adminCoords)
end
table.insert(subRows, '<tr><th style="vertical-align:top; white-space:nowrap; text-align:left; font-weight:bold; padding-left:0.4em; padding-right:0.4em;">[[' .. label .. ']]</th><td style="vertical-align:top; padding-left:0.4em; padding-right:0.4em;">' .. text .. '</td></tr>')
end
-- 3. LARGEST CITY ROW
if largest and mw.text.trim(largest):lower() ~= "none" and not isSame then
local cleanLargeName = normaliseCityName(largest)
local text = '[[' .. cleanLargeName .. '|' .. cleanLargeName .. ']]'
if largeNote and largeNote ~= "" then
text = text .. frame:expandTemplate{ title = "efn", args = { largeNote } }
end
local manualLargeCoords = getManualCoordinates(frame, args, "latd_balley_smoo", "latm_balley_smoo", "latNS_balley_smoo", "longd_balley_smoo", "longm_balley_smoo", "longEW_balley_smoo")
local largeCoords
if manualLargeCoords == "suppress" then
largeCoords = nil
elseif manualLargeCoords then
largeCoords = manualLargeCoords
else
largeCoords = getCityCoordinates(frame, cleanLargeName)
end
text = text .. coordSpan(largeCoords)
table.insert(subRows, '<tr><th style="vertical-align:top; white-space:nowrap; text-align:left; font-weight:bold; padding-left:0.4em; padding-right:0.4em;">Balley smoo</th><td style="vertical-align:top; padding-left:0.4em; padding-right:0.4em;">' .. text .. '</td></tr>')
end
if #subRows == 0 then return nil end
return table.concat(subRows)
end
return p
6700pwqhinb8ahp03teot3ybd4tn1y2
Module:Kishtey fys çheer/bratteeyn
828
55831
393147
392907
2026-09-13T22:16:39Z
MacTire02
219
baarney
393147
Scribunto
text/plain
local p = {}
local enmynCheerey = require("Module:Enmyn çheerey")
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 getWikidataImage(property)
local entity = mw.wikibase.getEntityObject()
if not entity then return nil end
local statements = entity:getBestStatements(property)
if not statements or #statements == 0 then return nil end
for _, statement in ipairs(statements) do
local mainsnak = statement.mainsnak
if mainsnak and mainsnak.snaktype == "value" and mainsnak.datavalue and mainsnak.datavalue.type == "string" then
local file = mainsnak.datavalue.value
if file and file ~= "" then return file end
end
end
return nil
end
local NON_RECTANGULAR_FLAGS = {
["Flag of Nepal.svg"] = true,
["Flag of Ohio.svg"] = true,
["Flag of Switzerland.svg"] = true,
}
local function needsFlagBorder(flagFile)
if not flagFile then return true end
if NON_RECTANGULAR_FLAGS[flagFile] then return false end
if mw.ustring.find(mw.ustring.lower(flagFile), "nepal") then return false end
return true
end
function p.main(frame, args)
local flag = getManual(args, {"jalloo_brattagh"})
if flag and mw.ustring.lower(flag) == "none" then flag = nil elseif not flag then flag = getWikidataImage("P41") end
local flag2 = getManual(args, {"jalloo_brattagh_2", "jalloo_brattagh_elley"})
if flag2 and mw.ustring.lower(flag2) == "none" then flag2 = nil elseif not flag2 then flag2 = getWikidataImage("P163") end
local arms = getManual(args, {"jalloo_armys", "jalloo_cleinney", "jalloo_cowrey"})
if arms and mw.ustring.lower(arms) == "none" then arms = nil elseif not arms then arms = getWikidataImage("P94") end
local arms2 = getManual(args, {"jalloo_armys_2", "jalloo_cleinney_2"})
if arms2 and mw.ustring.lower(arms2) == "none" then arms2 = nil elseif not arms2 then arms2 = getWikidataImage("P237") end
if not flag and not flag2 and not arms and not arms2 then return nil end
local nameRaw = getManual(args, {"ennym_gienneydagh", "ennym", "ennym_çheerey", "ennym_çheer"}) or (mw.title.getCurrentTitle() and mw.title.getCurrentTitle().text) or ""
local name = enmynCheerey.genitive(nameRaw)
local data = { flags = {}, armses = {} }
if flag then
table.insert(data.flags, { image = flag, width = getManual(args, {"lheead_brattagh"}) or "125px", hasBorder = needsFlagBorder(flag), link = "Brattagh " .. name, label = getManual(args, {"fo-heidyl_brattagh"}) or "Brattagh" })
end
if flag2 then
table.insert(data.flags, { image = flag2, width = getManual(args, {"lheead_brattagh_2", "lheead_brattagh"}) or "100px", hasBorder = needsFlagBorder(flag2), link = "Brattagh " .. name, label = getManual(args, {"fo-heidyl_brattagh_2"}) or "Brattagh elley" })
end
if arms then
local kind = getManual(args, {"art_sorçh_cowrey", "sorçh_cowrey"}) or "Armys"
table.insert(data.armses, { image = arms, width = getManual(args, {"lheead_armys", "lheead_cleinney", "lheead_cowrey"}) or "85px", link = kind .. " " .. name, label = getManual(args, {"sorçh_cowrey"}) or "Armys" })
end
if arms2 then
table.insert(data.armses, { image = arms2, width = getManual(args, {"lheead_armys_2", "lheead_cleinney_2"}) or "85px", link = "Armys " .. name, label = getManual(args, {"sorçh_cowrey_2"}) or "Armys" })
end
local imageCells = {}
local captionCells = {}
local hasFlags = #data.flags > 0
local hasArms = #data.armses > 0
if hasFlags then
local flagContent = {}
for _, f in ipairs(data.flags) do
local border = f.hasBorder and '|style="border:1px solid #a2a9b1;"' or ""
table.insert(flagContent, '[[Coadan:' .. f.image .. '|' .. f.width .. border .. ']]')
end
table.insert(imageCells, '<td align="center" style="' .. (hasArms and "width:58%; " or "width:100%; ") .. 'vertical-align:middle;">' .. table.concat(flagContent, '<br/>') .. '</td>')
local flagCaptions = {}
for _, f in ipairs(data.flags) do table.insert(flagCaptions, '<small>[[' .. f.link .. '|' .. f.label .. ']]</small>') end
table.insert(captionCells, '<td align="center">' .. table.concat(flagCaptions, '<br/>') .. '</td>')
end
if hasArms then
local armsContent = {}
for _, a in ipairs(data.armses) do table.insert(armsContent, '[[Coadan:' .. a.image .. '|' .. a.width .. ']]') end
table.insert(imageCells, '<td align="center" style="width:auto; vertical-align:middle;">' .. table.concat(armsContent, '<br/>') .. '</td>')
local armsCaptions = {}
for _, a in ipairs(data.armses) do table.insert(armsCaptions, '<small>[[' .. a.link .. '|' .. a.label .. ']]</small>') end
table.insert(captionCells, '<td align="center">' .. table.concat(armsCaptions, '<br/>') .. '</td>')
end
return '<tr><td colspan="2" align="center" style="padding:0.5em 0.4em;"><table align="center" style="width:100%; background:none;"><tr>' .. table.concat(imageCells) .. '</tr><tr>' .. table.concat(captionCells) .. '</tr></table></td></tr>'
end
return p
8oo6ucrmo1uujkjj6lyvmrarki22c2j
Module:Kishtey fys çheer/cowraghyn
828
55832
393146
393137
2026-09-13T22:16:04Z
MacTire02
219
baarney
393146
Scribunto
text/plain
local p = {}
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 getMottoData(args)
local motto = getManual(args, {"jarroo-raa_ashoonagh", "jarroo_raa", "jarroo-raa"})
local reference = getManual(args, {"imraa_jarroo_raa", "imraa_jarroo-raa"})
local chyndaa = getManual(args, {"çhyndaa_jarroo-raa", "chyndaa_jarroo-raa", "çhyndaa_jarroo_raa", "chyndaa_jarroo_raa"})
local tessen = getManual(args, {"tessen-lettyraghey_jarroo-raa", "tessen-lettyraghey_jarroo_raa"})
local finalText = nil
if motto and mw.ustring.lower(motto) ~= "none" then
finalText = motto
else
local entity = mw.wikibase.getEntityObject()
if entity then
local statements = entity:getBestStatements("P1451")
if statements and #statements > 0 then
-- FIXED: Safely loops through statements array elements instead of tracking a nil mainsnak index
for _, statement in ipairs(statements) do
if statement.mainsnak and statement.mainsnak.datavalue then
local value = statement.mainsnak.datavalue.value
if value and value.text then
finalText = value.text
break
end
end
end
end
end
end
local finalRef = nil
if reference then finalRef = "<ref>" .. reference .. "</ref>" end
if finalText then return { text = finalText, reference = finalRef, chyndaa = chyndaa, tessenLettyraghey = tessen } end
return nil
end
-- Given a property holding an item value (e.g. P85 = anthem), resolve the
-- linked item to a page title: prefer the local (gv) sitelink so the link
-- isn't red, falling back to the item's label if no gv article exists yet.
-- Returns both the title and the item's own ID (needed to query further
-- properties, e.g. an audio file, on that item rather than the country's).
local function getWikidataItemInfo(property)
local entity = mw.wikibase.getEntityObject()
if not entity then return nil end
local statements = entity:getBestStatements(property)
if not statements or #statements == 0 then return nil end
local mainsnak = statements[1].mainsnak
if not (mainsnak and mainsnak.snaktype == "value" and mainsnak.datavalue
and mainsnak.datavalue.type == "wikibase-entityid") then
return nil
end
local value = mainsnak.datavalue.value
local id = value.id or ("Q" .. tostring(value["numeric-id"]))
local title = mw.wikibase.sitelink(id)
if not title or title == "" then
title = mw.wikibase.getLabelByLang(id, "gv") or mw.wikibase.label(id)
end
if not title or title == "" then return nil end
return { id = id, title = title }
end
-- Given a Wikidata item ID, return its P51 (audio) file name, if any.
local function getWikidataAudioFile(id)
if not id then return nil end
local entity = mw.wikibase.getEntityObject(id)
if not entity then return nil end
local statements = entity:getBestStatements("P51")
if not statements or #statements == 0 then return nil end
local mainsnak = statements[1].mainsnak
if not (mainsnak and mainsnak.snaktype == "value" and mainsnak.datavalue
and mainsnak.datavalue.type == "string") then
return nil
end
local file = mainsnak.datavalue.value
if file and file ~= "" then return file end
return nil
end
-- Codepoint ranges treated as "Latin or script-neutral" for italicisation
-- purposes: Basic Latin, Latin-1 Supplement, Latin Extended-A/B, IPA
-- Extensions, combining diacritics, Latin Extended Additional, and general
-- punctuation (smart quotes, dashes, etc., which carry no script of their
-- own). Anything outside these ranges (Cyrillic, Greek, Arabic, Hebrew,
-- CJK, Devanagari, ...) is a non-Latin script and must not be italicised
-- per MOS:FOREIGNITALIC - italic forms don't meaningfully exist for most
-- non-Latin scripts.
local function isLatinOrNeutral(cp)
if cp < 0x80 then return true end
if cp <= 0x02AF then return true end
if cp >= 0x0300 and cp <= 0x036F then return true end
if cp >= 0x1E00 and cp <= 0x1EFF then return true end
if cp >= 0x2000 and cp <= 0x206F then return true end
return false
end
local function isNonLatinScript(text)
if not text or text == "" then return false end
local length = mw.ustring.len(text)
if not length or length == 0 then return false end
local codepoints = { mw.ustring.codepoint(text, 1, length) }
for _, cp in ipairs(codepoints) do
if not isLatinOrNeutral(cp) then return true end
end
return false
end
function p.main(frame, args)
local motto = getMottoData(args)
local rows = {}
if motto then
local baseText = mw.text.trim(motto.text):gsub('^["“]', ''):gsub('["”]$', '')
-- Italicised purely by script (MOS:FOREIGNITALIC) -- whether the
-- text happens to also be a wikilink is irrelevant; ''[[x|y]]''
-- renders as an italicised link exactly as intended.
if not isNonLatinScript(baseText) then
baseText = "''" .. baseText .. "''"
end
local mottoNote = getManual(args, {"noteyn_jarroo-raa", "noteyn_jarroo_raa"})
if mottoNote and mottoNote ~= "" then
baseText = baseText .. frame:expandTemplate{ title = "efn", args = { mottoNote } }
end
if motto.reference then baseText = baseText .. motto.reference end
if motto.tessenLettyraghey and motto.tessenLettyraghey ~= "" then baseText = baseText .. " (''" .. motto.tessenLettyraghey .. "'')" end
if motto.chyndaa and motto.chyndaa ~= "" then baseText = baseText .. " <br/><small>“" .. motto.chyndaa .. "”</small>" end
table.insert(rows, "'''[[Jarroo-raa]]: '''" .. baseText)
end
-- wikidataProperty is optional: pass a property (e.g. "P85") to fall
-- back to Wikidata when no manual parameter is set for this anthem slot.
local function formatAnthem(label, key, wikidataProperty)
local title = getManual(args, {key})
local wikidataInfo = nil
if (not title or mw.ustring.lower(title) == "none") and wikidataProperty then
wikidataInfo = getWikidataItemInfo(wikidataProperty)
if wikidataInfo then title = wikidataInfo.title end
end
if not title or mw.ustring.lower(title) == "none" then return end
local clean = mw.text.trim(title):gsub('^["“]', ''):gsub('["”]$', '')
if not mw.ustring.find(clean, "%[%[") then clean = '[[' .. clean .. '|' .. clean .. ']]' end
local display = '“' .. clean .. '”'
local note = getManual(args, {"noteyn_" .. key})
if note and note ~= "" then display = display .. frame:expandTemplate{ title = "efn", args = { note } } end
local ref = getManual(args, {"imraa_" .. key})
if ref then display = display .. "<ref>" .. ref .. "</ref>" end
local tessen = getManual(args, {"tessen-lettyraghey_" .. key})
if tessen and tessen ~= "" then display = display .. " (''" .. tessen .. "'')" end
local chyndaa = getManual(args, {"çhyndaa_" .. key, "chyndaa_" .. key})
if chyndaa and chyndaa ~= "" then display = display .. " <br/><small>“" .. chyndaa .. "”</small>" end
local audio = getManual(args, {"coadan_" .. key})
if (not audio or audio == "") and wikidataInfo then
audio = getWikidataAudioFile(wikidataInfo.id)
end
if audio and audio ~= "" then display = display .. '<br/><div style="text-align:center; margin-top:0.3em;">[[Coadan:' .. audio .. '|center]]</div>' end
table.insert(rows, "'''" .. label .. ": '''" .. display)
end
formatAnthem("[[Arrane ashoonagh]]", "arrane_ashoonagh", "P85")
formatAnthem("Anthym", "arrane")
formatAnthem("[[Arrane reeoil]]", "arrane_reeoil")
if #rows == 0 then return nil end
return '<tr><td colspan="2" style="padding:0.4em; line-height:1.2em; text-align:center;">' .. table.concat(rows, "<br/>") .. '</td></tr>'
end
return p
h95lbs0ah4mgfpouyuc2x8dyq4760r1
393155
393146
2026-09-13T22:30:36Z
MacTire02
219
++
393155
Scribunto
text/plain
local p = {}
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 wrapReference(ref)
if not ref or ref == "" then return nil end
if mw.ustring.find(mw.ustring.lower(ref), "<ref", 1, true) then
return ref
end
return "<ref>" .. ref .. "</ref>"
end
local function getMottoData(args)
local motto = getManual(args, {"jarroo-raa_ashoonagh", "jarroo_raa", "jarroo-raa"})
local reference = getManual(args, {"imraa_jarroo_raa", "imraa_jarroo-raa"})
local chyndaa = getManual(args, {"çhyndaa_jarroo-raa", "chyndaa_jarroo-raa", "çhyndaa_jarroo_raa", "chyndaa_jarroo_raa"})
local tessen = getManual(args, {"tessen-lettyraghey_jarroo-raa", "tessen-lettyraghey_jarroo_raa"})
local finalText = nil
if motto and mw.ustring.lower(motto) ~= "none" then
finalText = motto
else
local entity = mw.wikibase.getEntityObject()
if entity then
local statements = entity:getBestStatements("P1451")
if statements and #statements > 0 then
-- FIXED: Safely loops through statements array elements instead of tracking a nil mainsnak index
for _, statement in ipairs(statements) do
if statement.mainsnak and statement.mainsnak.datavalue then
local value = statement.mainsnak.datavalue.value
if value and value.text then
finalText = value.text
break
end
end
end
end
end
end
local finalRef = wrapReference(reference)
if finalText then return { text = finalText, reference = finalRef, chyndaa = chyndaa, tessenLettyraghey = tessen } end
return nil
end
-- Given a property holding an item value (e.g. P85 = anthem), resolve the
-- linked item to a page title: prefer the local (gv) sitelink so the link
-- isn't red, falling back to the item's label if no gv article exists yet.
-- Returns both the title and the item's own ID (needed to query further
-- properties, e.g. an audio file, on that item rather than the country's).
local function getWikidataItemInfo(property)
local entity = mw.wikibase.getEntityObject()
if not entity then return nil end
local statements = entity:getBestStatements(property)
if not statements or #statements == 0 then return nil end
local mainsnak = statements[1].mainsnak
if not (mainsnak and mainsnak.snaktype == "value" and mainsnak.datavalue
and mainsnak.datavalue.type == "wikibase-entityid") then
return nil
end
local value = mainsnak.datavalue.value
local id = value.id or ("Q" .. tostring(value["numeric-id"]))
local title = mw.wikibase.sitelink(id)
if not title or title == "" then
title = mw.wikibase.getLabelByLang(id, "gv") or mw.wikibase.label(id)
end
if not title or title == "" then return nil end
return { id = id, title = title }
end
-- Given a Wikidata item ID, return its P51 (audio) file name, if any.
local function getWikidataAudioFile(id)
if not id then return nil end
local entity = mw.wikibase.getEntityObject(id)
if not entity then return nil end
local statements = entity:getBestStatements("P51")
if not statements or #statements == 0 then return nil end
local mainsnak = statements[1].mainsnak
if not (mainsnak and mainsnak.snaktype == "value" and mainsnak.datavalue
and mainsnak.datavalue.type == "string") then
return nil
end
local file = mainsnak.datavalue.value
if file and file ~= "" then return file end
return nil
end
-- Codepoint ranges treated as "Latin or script-neutral" for italicisation
-- purposes: Basic Latin, Latin-1 Supplement, Latin Extended-A/B, IPA
-- Extensions, combining diacritics, Latin Extended Additional, and general
-- punctuation (smart quotes, dashes, etc., which carry no script of their
-- own). Anything outside these ranges (Cyrillic, Greek, Arabic, Hebrew,
-- CJK, Devanagari, ...) is a non-Latin script and must not be italicised
-- per MOS:FOREIGNITALIC - italic forms don't meaningfully exist for most
-- non-Latin scripts.
local function isLatinOrNeutral(cp)
if cp < 0x80 then return true end
if cp <= 0x02AF then return true end
if cp >= 0x0300 and cp <= 0x036F then return true end
if cp >= 0x1E00 and cp <= 0x1EFF then return true end
if cp >= 0x2000 and cp <= 0x206F then return true end
return false
end
local function isNonLatinScript(text)
if not text or text == "" then return false end
local length = mw.ustring.len(text)
if not length or length == 0 then return false end
local codepoints = { mw.ustring.codepoint(text, 1, length) }
for _, cp in ipairs(codepoints) do
if not isLatinOrNeutral(cp) then return true end
end
return false
end
function p.main(frame, args)
local motto = getMottoData(args)
local rows = {}
if motto then
local baseText = mw.text.trim(motto.text):gsub('^["“]', ''):gsub('["”]$', '')
-- Italicised purely by script (MOS:FOREIGNITALIC) -- whether the
-- text happens to also be a wikilink is irrelevant; ''[[x|y]]''
-- renders as an italicised link exactly as intended.
if not isNonLatinScript(baseText) then
baseText = "''" .. baseText .. "''"
end
local mottoNote = getManual(args, {"noteyn_jarroo-raa", "noteyn_jarroo_raa"})
if mottoNote and mottoNote ~= "" then
baseText = baseText .. frame:expandTemplate{ title = "efn", args = { mottoNote } }
end
if motto.reference then baseText = baseText .. motto.reference end
if motto.tessenLettyraghey and motto.tessenLettyraghey ~= "" then baseText = baseText .. " (''" .. motto.tessenLettyraghey .. "'')" end
if motto.chyndaa and motto.chyndaa ~= "" then baseText = baseText .. " <br/><small>“" .. motto.chyndaa .. "”</small>" end
table.insert(rows, "'''[[Jarroo-raa]]: '''" .. baseText)
end
-- wikidataProperty is optional: pass a property (e.g. "P85") to fall
-- back to Wikidata when no manual parameter is set for this anthem slot.
local function formatAnthem(label, key, wikidataProperty)
local title = getManual(args, {key})
local wikidataInfo = nil
if (not title or mw.ustring.lower(title) == "none") and wikidataProperty then
wikidataInfo = getWikidataItemInfo(wikidataProperty)
if wikidataInfo then title = wikidataInfo.title end
end
if not title or mw.ustring.lower(title) == "none" then return end
local clean = mw.text.trim(title):gsub('^["“]', ''):gsub('["”]$', '')
if not mw.ustring.find(clean, "%[%[") then clean = '[[' .. clean .. '|' .. clean .. ']]' end
local display = '“' .. clean .. '”'
local note = getManual(args, {"noteyn_" .. key})
if note and note ~= "" then display = display .. frame:expandTemplate{ title = "efn", args = { note } } end
local ref = getManual(args, {"imraa_" .. key})
if ref then display = display .. wrapReference(ref) end
local tessen = getManual(args, {"tessen-lettyraghey_" .. key})
if tessen and tessen ~= "" then display = display .. " (''" .. tessen .. "'')" end
local chyndaa = getManual(args, {"çhyndaa_" .. key, "chyndaa_" .. key})
if chyndaa and chyndaa ~= "" then display = display .. " <br/><small>“" .. chyndaa .. "”</small>" end
local audio = getManual(args, {"coadan_" .. key})
if (not audio or audio == "") and wikidataInfo then
audio = getWikidataAudioFile(wikidataInfo.id)
end
if audio and audio ~= "" then display = display .. '<br/><div style="text-align:center; margin-top:0.3em;">[[Coadan:' .. audio .. '|center]]</div>' end
table.insert(rows, "'''" .. label .. ": '''" .. display)
end
formatAnthem("[[Arrane ashoonagh]]", "arrane_ashoonagh", "P85")
formatAnthem("Anthym", "arrane")
formatAnthem("[[Arrane reeoil]]", "arrane_reeoil")
if #rows == 0 then return nil end
return '<tr><td colspan="2" style="padding:0.4em; line-height:1.2em; text-align:center;">' .. table.concat(rows, "<br/>") .. '</td></tr>'
end
return p
jux5vqy8hsjpjhprksjufwp24dnroan
393161
393155
2026-09-13T23:35:42Z
MacTire02
219
++
393161
Scribunto
text/plain
local p = {}
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
-- Wraps a manual citation in <ref>...</ref>, unless it's already been
-- processed: a literal <ref> typed in a template parameter is expanded by
-- Scribunto into an opaque strip marker (\127UNIQ...QINU\127) the moment
-- frame.args is read, not literal "<ref" text -- re-wrapping that marker
-- creates a bogus extra reference. Pass strip markers and literal <ref>
-- text through unchanged; wrap anything else.
local function wrapReference(ref)
if not ref or ref == "" then return nil end
if mw.ustring.find(ref, "\127", 1, true) then
return ref
end
if mw.ustring.find(mw.ustring.lower(ref), "<ref", 1, true) then
return ref
end
return "<ref>" .. ref .. "</ref>"
end
local function getMottoData(args)
local motto = getManual(args, {"jarroo-raa_ashoonagh", "jarroo_raa", "jarroo-raa"})
local reference = getManual(args, {"imraa_jarroo_raa", "imraa_jarroo-raa"})
local chyndaa = getManual(args, {"çhyndaa_jarroo-raa", "chyndaa_jarroo-raa", "çhyndaa_jarroo_raa", "chyndaa_jarroo_raa"})
local tessen = getManual(args, {"tessen-lettyraghey_jarroo-raa", "tessen-lettyraghey_jarroo_raa"})
local finalText = nil
if motto and mw.ustring.lower(motto) ~= "none" then
finalText = motto
else
local entity = mw.wikibase.getEntityObject()
if entity then
local statements = entity:getBestStatements("P1451")
if statements and #statements > 0 then
-- FIXED: Safely loops through statements array elements instead of tracking a nil mainsnak index
for _, statement in ipairs(statements) do
if statement.mainsnak and statement.mainsnak.datavalue then
local value = statement.mainsnak.datavalue.value
if value and value.text then
finalText = value.text
break
end
end
end
end
end
end
local finalRef = wrapReference(reference)
if finalText then return { text = finalText, reference = finalRef, chyndaa = chyndaa, tessenLettyraghey = tessen } end
return nil
end
-- Given a property holding an item value (e.g. P85 = anthem), resolve the
-- linked item to a page title: prefer the local (gv) sitelink so the link
-- isn't red, falling back to the item's label if no gv article exists yet.
-- Returns both the title and the item's own ID (needed to query further
-- properties, e.g. an audio file, on that item rather than the country's).
local function getWikidataItemInfo(property)
local entity = mw.wikibase.getEntityObject()
if not entity then return nil end
local statements = entity:getBestStatements(property)
if not statements or #statements == 0 then return nil end
local mainsnak = statements[1].mainsnak
if not (mainsnak and mainsnak.snaktype == "value" and mainsnak.datavalue
and mainsnak.datavalue.type == "wikibase-entityid") then
return nil
end
local value = mainsnak.datavalue.value
local id = value.id or ("Q" .. tostring(value["numeric-id"]))
local title = mw.wikibase.sitelink(id)
if not title or title == "" then
title = mw.wikibase.getLabelByLang(id, "gv") or mw.wikibase.label(id)
end
if not title or title == "" then return nil end
return { id = id, title = title }
end
-- Given a Wikidata item ID, return its P51 (audio) file name, if any.
local function getWikidataAudioFile(id)
if not id then return nil end
local entity = mw.wikibase.getEntityObject(id)
if not entity then return nil end
local statements = entity:getBestStatements("P51")
if not statements or #statements == 0 then return nil end
local mainsnak = statements[1].mainsnak
if not (mainsnak and mainsnak.snaktype == "value" and mainsnak.datavalue
and mainsnak.datavalue.type == "string") then
return nil
end
local file = mainsnak.datavalue.value
if file and file ~= "" then return file end
return nil
end
-- Codepoint ranges treated as "Latin or script-neutral" for italicisation
-- purposes: Basic Latin, Latin-1 Supplement, Latin Extended-A/B, IPA
-- Extensions, combining diacritics, Latin Extended Additional, and general
-- punctuation (smart quotes, dashes, etc., which carry no script of their
-- own). Anything outside these ranges (Cyrillic, Greek, Arabic, Hebrew,
-- CJK, Devanagari, ...) is a non-Latin script and must not be italicised
-- per MOS:FOREIGNITALIC - italic forms don't meaningfully exist for most
-- non-Latin scripts.
local function isLatinOrNeutral(cp)
if cp < 0x80 then return true end
if cp <= 0x02AF then return true end
if cp >= 0x0300 and cp <= 0x036F then return true end
if cp >= 0x1E00 and cp <= 0x1EFF then return true end
if cp >= 0x2000 and cp <= 0x206F then return true end
return false
end
local function isNonLatinScript(text)
if not text or text == "" then return false end
local length = mw.ustring.len(text)
if not length or length == 0 then return false end
local codepoints = { mw.ustring.codepoint(text, 1, length) }
for _, cp in ipairs(codepoints) do
if not isLatinOrNeutral(cp) then return true end
end
return false
end
function p.main(frame, args)
local motto = getMottoData(args)
local rows = {}
if motto then
local baseText = mw.text.trim(motto.text):gsub('^["“]', ''):gsub('["”]$', '')
-- Italicised purely by script (MOS:FOREIGNITALIC) -- whether the
-- text happens to also be a wikilink is irrelevant; ''[[x|y]]''
-- renders as an italicised link exactly as intended.
if not isNonLatinScript(baseText) then
baseText = "''" .. baseText .. "''"
end
local mottoNote = getManual(args, {"noteyn_jarroo-raa", "noteyn_jarroo_raa"})
if mottoNote and mottoNote ~= "" then
baseText = baseText .. frame:expandTemplate{ title = "efn", args = { mottoNote } }
end
if motto.reference then baseText = baseText .. motto.reference end
if motto.tessenLettyraghey and motto.tessenLettyraghey ~= "" then baseText = baseText .. " (''" .. motto.tessenLettyraghey .. "'')" end
if motto.chyndaa and motto.chyndaa ~= "" then baseText = baseText .. " <br/><small>“" .. motto.chyndaa .. "”</small>" end
table.insert(rows, "'''[[Jarroo-raa]]: '''" .. baseText)
end
-- wikidataProperty is optional: pass a property (e.g. "P85") to fall
-- back to Wikidata when no manual parameter is set for this anthem slot.
local function formatAnthem(label, key, wikidataProperty)
local title = getManual(args, {key})
local wikidataInfo = nil
if (not title or mw.ustring.lower(title) == "none") and wikidataProperty then
wikidataInfo = getWikidataItemInfo(wikidataProperty)
if wikidataInfo then title = wikidataInfo.title end
end
if not title or mw.ustring.lower(title) == "none" then return end
local clean = mw.text.trim(title):gsub('^["“]', ''):gsub('["”]$', '')
if not mw.ustring.find(clean, "%[%[") then clean = '[[' .. clean .. '|' .. clean .. ']]' end
local display = '“' .. clean .. '”'
local note = getManual(args, {"noteyn_" .. key})
if note and note ~= "" then display = display .. frame:expandTemplate{ title = "efn", args = { note } } end
local ref = getManual(args, {"imraa_" .. key})
if ref then display = display .. wrapReference(ref) end
local tessen = getManual(args, {"tessen-lettyraghey_" .. key})
if tessen and tessen ~= "" then display = display .. " (''" .. tessen .. "'')" end
local chyndaa = getManual(args, {"çhyndaa_" .. key, "chyndaa_" .. key})
if chyndaa and chyndaa ~= "" then display = display .. " <br/><small>“" .. chyndaa .. "”</small>" end
local audio = getManual(args, {"coadan_" .. key})
if (not audio or audio == "") and wikidataInfo then
audio = getWikidataAudioFile(wikidataInfo.id)
end
if audio and audio ~= "" then display = display .. '<br/><div style="text-align:center; margin-top:0.3em;">[[Coadan:' .. audio .. '|center]]</div>' end
table.insert(rows, "'''" .. label .. ": '''" .. display)
end
formatAnthem("[[Arrane ashoonagh]]", "arrane_ashoonagh", "P85")
formatAnthem("Anthym", "arrane")
formatAnthem("[[Arrane reeoil]]", "arrane_reeoil")
if #rows == 0 then return nil end
return '<tr><td colspan="2" style="padding:0.4em; line-height:1.2em; text-align:center;">' .. table.concat(rows, "<br/>") .. '</td></tr>'
end
return p
73fl3tgu7p8rgt79rl4jcputtm42ox4
393168
393161
2026-09-14T00:06:24Z
MacTire02
219
++
393168
Scribunto
text/plain
local p = {}
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
-- Wraps a manual citation in <ref>...</ref>, unless it's already fully
-- <ref>-tagged (Scribunto expands a literal <ref> in a parameter into an
-- opaque \127UNIQ...QINU\127 strip marker before this module sees it, so we
-- strip those out and check what's left -- nothing left means it was
-- already tag(s), pass through unchanged; real text left over -- e.g. a
-- bare {{cite web}} call whose own <templatestyles/> leaves an incidental
-- marker -- means it still needs wrapping).
local function wrapReference(ref)
if not ref or ref == "" then return nil end
local withoutMarkers = mw.ustring.gsub(ref, "\127UNIQ.-QINU\127", "")
if mw.ustring.gsub(withoutMarkers, "%s+", "") == "" then
return ref
end
if mw.ustring.find(mw.ustring.lower(ref), "<ref", 1, true) then
return ref
end
return "<ref>" .. ref .. "</ref>"
end
local function getMottoData(args)
local motto = getManual(args, {"jarroo-raa_ashoonagh", "jarroo_raa", "jarroo-raa"})
local reference = getManual(args, {"imraa_jarroo_raa", "imraa_jarroo-raa"})
local chyndaa = getManual(args, {"çhyndaa_jarroo-raa", "chyndaa_jarroo-raa", "çhyndaa_jarroo_raa", "chyndaa_jarroo_raa"})
local tessen = getManual(args, {"tessen-lettyraghey_jarroo-raa", "tessen-lettyraghey_jarroo_raa"})
local finalText = nil
if motto and mw.ustring.lower(motto) ~= "none" then
finalText = motto
else
local entity = mw.wikibase.getEntityObject()
if entity then
local statements = entity:getBestStatements("P1451")
if statements and #statements > 0 then
-- FIXED: Safely loops through statements array elements instead of tracking a nil mainsnak index
for _, statement in ipairs(statements) do
if statement.mainsnak and statement.mainsnak.datavalue then
local value = statement.mainsnak.datavalue.value
if value and value.text then
finalText = value.text
break
end
end
end
end
end
end
local finalRef = wrapReference(reference)
if finalText then return { text = finalText, reference = finalRef, chyndaa = chyndaa, tessenLettyraghey = tessen } end
return nil
end
-- Given a property holding an item value (e.g. P85 = anthem), resolve the
-- linked item to a page title: prefer the local (gv) sitelink so the link
-- isn't red, falling back to the item's label if no gv article exists yet.
-- Returns both the title and the item's own ID (needed to query further
-- properties, e.g. an audio file, on that item rather than the country's).
local function getWikidataItemInfo(property)
local entity = mw.wikibase.getEntityObject()
if not entity then return nil end
local statements = entity:getBestStatements(property)
if not statements or #statements == 0 then return nil end
local mainsnak = statements[1].mainsnak
if not (mainsnak and mainsnak.snaktype == "value" and mainsnak.datavalue
and mainsnak.datavalue.type == "wikibase-entityid") then
return nil
end
local value = mainsnak.datavalue.value
local id = value.id or ("Q" .. tostring(value["numeric-id"]))
local title = mw.wikibase.sitelink(id)
if not title or title == "" then
title = mw.wikibase.getLabelByLang(id, "gv") or mw.wikibase.label(id)
end
if not title or title == "" then return nil end
return { id = id, title = title }
end
-- Given a Wikidata item ID, return its P51 (audio) file name, if any.
local function getWikidataAudioFile(id)
if not id then return nil end
local entity = mw.wikibase.getEntityObject(id)
if not entity then return nil end
local statements = entity:getBestStatements("P51")
if not statements or #statements == 0 then return nil end
local mainsnak = statements[1].mainsnak
if not (mainsnak and mainsnak.snaktype == "value" and mainsnak.datavalue
and mainsnak.datavalue.type == "string") then
return nil
end
local file = mainsnak.datavalue.value
if file and file ~= "" then return file end
return nil
end
-- Codepoint ranges treated as "Latin or script-neutral" for italicisation
-- purposes: Basic Latin, Latin-1 Supplement, Latin Extended-A/B, IPA
-- Extensions, combining diacritics, Latin Extended Additional, and general
-- punctuation (smart quotes, dashes, etc., which carry no script of their
-- own). Anything outside these ranges (Cyrillic, Greek, Arabic, Hebrew,
-- CJK, Devanagari, ...) is a non-Latin script and must not be italicised
-- per MOS:FOREIGNITALIC - italic forms don't meaningfully exist for most
-- non-Latin scripts.
local function isLatinOrNeutral(cp)
if cp < 0x80 then return true end
if cp <= 0x02AF then return true end
if cp >= 0x0300 and cp <= 0x036F then return true end
if cp >= 0x1E00 and cp <= 0x1EFF then return true end
if cp >= 0x2000 and cp <= 0x206F then return true end
return false
end
local function isNonLatinScript(text)
if not text or text == "" then return false end
local length = mw.ustring.len(text)
if not length or length == 0 then return false end
local codepoints = { mw.ustring.codepoint(text, 1, length) }
for _, cp in ipairs(codepoints) do
if not isLatinOrNeutral(cp) then return true end
end
return false
end
function p.main(frame, args)
local motto = getMottoData(args)
local rows = {}
if motto then
local baseText = mw.text.trim(motto.text):gsub('^["“]', ''):gsub('["”]$', '')
-- Italicised purely by script (MOS:FOREIGNITALIC) -- whether the
-- text happens to also be a wikilink is irrelevant; ''[[x|y]]''
-- renders as an italicised link exactly as intended.
if not isNonLatinScript(baseText) then
baseText = "''" .. baseText .. "''"
end
local mottoNote = getManual(args, {"noteyn_jarroo-raa", "noteyn_jarroo_raa"})
if mottoNote and mottoNote ~= "" then
baseText = baseText .. frame:expandTemplate{ title = "efn", args = { mottoNote } }
end
if motto.reference then baseText = baseText .. motto.reference end
if motto.tessenLettyraghey and motto.tessenLettyraghey ~= "" then baseText = baseText .. " (''" .. motto.tessenLettyraghey .. "'')" end
if motto.chyndaa and motto.chyndaa ~= "" then baseText = baseText .. " <br/><small>“" .. motto.chyndaa .. "”</small>" end
table.insert(rows, "'''[[Jarroo-raa]]: '''" .. baseText)
end
-- wikidataProperty is optional: pass a property (e.g. "P85") to fall
-- back to Wikidata when no manual parameter is set for this anthem slot.
local function formatAnthem(label, key, wikidataProperty)
local title = getManual(args, {key})
local wikidataInfo = nil
if (not title or mw.ustring.lower(title) == "none") and wikidataProperty then
wikidataInfo = getWikidataItemInfo(wikidataProperty)
if wikidataInfo then title = wikidataInfo.title end
end
if not title or mw.ustring.lower(title) == "none" then return end
local clean = mw.text.trim(title):gsub('^["“]', ''):gsub('["”]$', '')
if not mw.ustring.find(clean, "%[%[") then clean = '[[' .. clean .. '|' .. clean .. ']]' end
local display = '“' .. clean .. '”'
local note = getManual(args, {"noteyn_" .. key})
if note and note ~= "" then display = display .. frame:expandTemplate{ title = "efn", args = { note } } end
local ref = getManual(args, {"imraa_" .. key})
if ref then display = display .. wrapReference(ref) end
local tessen = getManual(args, {"tessen-lettyraghey_" .. key})
if tessen and tessen ~= "" then display = display .. " (''" .. tessen .. "'')" end
local chyndaa = getManual(args, {"çhyndaa_" .. key, "chyndaa_" .. key})
if chyndaa and chyndaa ~= "" then display = display .. " <br/><small>“" .. chyndaa .. "”</small>" end
local audio = getManual(args, {"coadan_" .. key})
if (not audio or audio == "") and wikidataInfo then
audio = getWikidataAudioFile(wikidataInfo.id)
end
if audio and audio ~= "" then display = display .. '<br/><div style="text-align:center; margin-top:0.3em;">[[Coadan:' .. audio .. '|center]]</div>' end
table.insert(rows, "'''" .. label .. ": '''" .. display)
end
formatAnthem("[[Arrane ashoonagh]]", "arrane_ashoonagh", "P85")
formatAnthem("Anthym", "arrane")
formatAnthem("[[Arrane reeoil]]", "arrane_reeoil")
if #rows == 0 then return nil end
return '<tr><td colspan="2" style="padding:0.4em; line-height:1.2em; text-align:center;">' .. table.concat(rows, "<br/>") .. '</td></tr>'
end
return p
b0lrqkbl39da1pfc0p2eb2k5qyfqfwu
Module:Kishtey fys çheer/çhengaghyn
828
55833
393143
393126
2026-09-13T22:13:56Z
MacTire02
219
baarney
393143
Scribunto
text/plain
local p = {}
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 manxSort(a, b)
local function norm(text) return text:lower():gsub("çh", "ch") end
return norm(a) < norm(b)
end
local function getWikidataLanguageItems(property)
local entity = mw.wikibase.getEntityObject()
if not entity then return nil end
local statements = entity:getBestStatements(property)
if not statements or #statements == 0 then return nil end
local items = {}
for _, statement in ipairs(statements) do
local mainsnak = statement.mainsnak
if mainsnak and mainsnak.snaktype == "value" and mainsnak.datavalue
and mainsnak.datavalue.type == "wikibase-entityid" then
local value = mainsnak.datavalue.value
local id = value.id or ("Q" .. tostring(value["numeric-id"]))
local label = mw.wikibase.getLabelByLang(id, "gv") or mw.wikibase.label(id)
if label and label ~= "" then
table.insert(items, { id = id, name = label })
end
end
end
if #items == 0 then return nil end
return items
end
local function itemsToRaw(items, excludeIds)
local names = {}
for _, item in ipairs(items) do
if not (excludeIds and excludeIds[item.id]) then
table.insert(names, item.name)
end
end
if #names == 0 then return nil end
return table.concat(names, ",")
end
-- FIX (double-bracket / duplicated-language bug): the old HTML template
-- dropped a language parameter's value straight into its cell with NO
-- processing at all (a plain `{{{çhengaghyn_oikoil|}}}` substitution), so
-- editors on many of the ~200 existing articles typed the ENTIRE display
-- string themselves, already wikilinked and separated with " ·" or
-- "·" -- e.g. "[[Baarle]] · [[Baarle Albinagh]] · [[Gaelg ny h-Albey]]".
-- Feeding a value like that through the comma-split-then-self-link logic
-- below (which assumes a plain, comma-separated list of BARE language
-- names -- the shape Wikidata's own P37 fetch produces via itemsToRaw
-- above) treats the WHOLE pre-linked string as a single "name" (there's no
-- comma in it, only middle dots) and wraps it AGAIN in a self-linking
-- `[[...|...]]` pair -- producing literal, unparsed `[[`/`]]`/`|`
-- characters around a doubled-up copy of the already-linked list (the
-- inner `[[Baarle]]`-style links still render normally, which is exactly
-- why the reported screenshot showed the language names rendering
-- correctly TWICE with stray bracket/pipe characters around them).
--
-- So: whenever the raw manual value already contains a wikilink, it's
-- used completely unchanged -- exactly like the old template did -- with
-- no splitting, no re-linking, and no sorting. Only a plain, bracket-free
-- value (a fresh manual entry, or anything coming through Wikidata) gets
-- the new auto-link/sort treatment.
local function buildLanguageValue(raw, ref, note, frame)
if not raw or mw.text.trim(raw):lower() == "none" then return nil, 0 end
if raw:find("%[%[", 1, false) then
local display = raw
if note and note ~= "" and frame then
display = display .. frame:expandTemplate{ title = "efn", args = { note } }
end
if ref then
display = display .. "<ref>" .. ref .. "</ref>"
end
-- Only used for the singular/plural label choice below -- counts
-- wikilinks as a rough stand-in for "how many languages are
-- listed" since there's no reliable delimiter to split on in an
-- already-formatted value.
local linkCount = 0
for _ in raw:gmatch("%[%[") do linkCount = linkCount + 1 end
return display, linkCount
end
-- Safe tokenization using native text utilities instead of fragile match strings
local cleaned = raw:gsub("<ref[^>]*>.-</ref>", ""):gsub("<ref[^>]*/>", "")
local names = mw.text.split(cleaned, ",", true)
local filteredNames = {}
for _, part in ipairs(names) do
local trimmed = mw.text.trim(part)
if trimmed ~= "" then
table.insert(filteredNames, trimmed)
end
end
if #filteredNames == 0 then return nil, 0 end
table.sort(filteredNames, manxSort)
local parts = {}
for _, name in ipairs(filteredNames) do
table.insert(parts, '[[' .. name .. '|' .. name .. ']]')
end
local display = '<div class="hlist">' .. table.concat(parts, ' · ') .. '</div>'
if note and note ~= "" and frame then
display = display .. frame:expandTemplate{ title = "efn", args = { note } }
end
if ref then
display = display .. "<ref>" .. ref .. "</ref>"
end
return display, #filteredNames
end
function p.main(frame, args)
if not args then
args = frame
frame = mw.getCurrentFrame()
end
local officialItems = nil
local officialRaw = getManual(args, {"çhengaghyn_oikoil", "çhengey_oikoil"})
if not officialRaw then
officialItems = getWikidataLanguageItems("P37")
officialRaw = itemsToRaw(officialItems)
end
local regionalRaw = getManual(args, {"çhengaghyn_ardjynagh", "çhengey_ardjynagh"})
local minorityRaw = getManual(args, {"mynçhengaghyn", "mynçhengey"})
local otherRaw = getManual(args, {"çhengaghyn", "çhengey"})
local official, offCount = buildLanguageValue(officialRaw, getManual(args, {"imraa_çhengaghyn_oikoil", "imraa_çhengey_oikoil"}), getManual(args, {"noteyn_çhengaghyn_oikoil", "noteyn_çhengey_oikoil"}), frame)
local regional, regCount = buildLanguageValue(regionalRaw, getManual(args, {"imraa_çhengaghyn_ardjynagh", "imraa_çhengey_ardjynagh"}), getManual(args, {"noteyn_çhengaghyn_ardjynagh", "noteyn_çhengey_ardjynagh"}), frame)
local minority, minCount = buildLanguageValue(minorityRaw, getManual(args, {"imraa_mynçhengaghyn", "imraa_mynçhengey"}), getManual(args, {"noteyn_mynçhengaghyn", "noteyn_mynçhengey"}), frame)
local other, othCount = buildLanguageValue(otherRaw, getManual(args, {"imraa_çhengaghyn", "imraa_çhengey"}), getManual(args, {"noteyn_çhengaghyn", "noteyn_çhengey"}), frame)
local subRows = {}
if official then
local label = offCount > 1 and "[[Çhengey oikoil|Çhengaghyn oikoil]]" or "[[Çhengey oikoil]]"
table.insert(subRows, '<tr><th style="vertical-align:top; white-space:nowrap; text-align:left; font-weight:bold; padding-left:0.4em; padding-right:0.4em;">' .. label .. '</th><td style="vertical-align:top; padding-left:0.4em; padding-right:0.4em;">' .. official .. '</td></tr>')
if regional then
local rLabel = regCount > 1 and "Çhengaghyn ardjynagh er enney" or "Çhengey ardjynagh er enney"
table.insert(subRows, '<tr><th style="vertical-align:top; white-space:nowrap; text-align:left; font-weight:normal; padding-left:0.4em; padding-right:0.4em;">[[Çhengey ardjynagh|' .. rLabel .. ']]</th><td style="vertical-align:top; padding-left:0.4em; padding-right:0.4em;">' .. regional .. '</td></tr>')
end
elseif regional then
local rLabel = regCount > 1 and "Çhengaghyn ardjynagh er enney" or "Çhengey ardjynagh er enney"
table.insert(subRows, '<tr><th style="vertical-align:top; white-space:nowrap; text-align:left; font-weight:bold; padding-left:0.4em; padding-right:0.4em;">[[Çhengey ardjynagh|' .. rLabel .. ']]</th><td style="vertical-align:top; padding-left:0.4em; padding-right:0.4em;">' .. regional .. '</td></tr>')
end
if minority then
local mLabel = minCount > 1 and "[[Mynçhengey|Mynçhengaghyn]]" or "[[Mynçhengey]]"
table.insert(subRows, '<tr><th style="vertical-align:top; white-space:nowrap; text-align:left; font-weight:bold; padding-left:0.4em; padding-right:0.4em;">' .. mLabel .. '</th><td style="vertical-align:top; padding-left:0.4em; padding-right:0.4em;">' .. minority .. '</td></tr>')
end
if other then
local oLabel = args["sorçh_çhengaghyn"] or (othCount > 1 and "Çhengaghyn" or "Çhengey")
table.insert(subRows, '<tr><th style="vertical-align:top; white-space:nowrap; text-align:left; font-weight:bold; padding-left:0.4em; padding-right:0.4em;">' .. oLabel .. '</th><td style="vertical-align:top; padding-left:0.4em; padding-right:0.4em;">' .. other .. '</td></tr>')
end
if #subRows == 0 then return nil end
return table.concat(subRows)
end
return p
hr89mrz6b4rjl5lhdth8oas89q9u7x3
393154
393143
2026-09-13T22:29:58Z
MacTire02
219
++
393154
Scribunto
text/plain
local p = {}
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 manxSort(a, b)
local function norm(text) return text:lower():gsub("çh", "ch") end
return norm(a) < norm(b)
end
local function wrapReference(ref)
if not ref or ref == "" then return nil end
if mw.ustring.find(mw.ustring.lower(ref), "<ref", 1, true) then
return ref
end
return "<ref>" .. ref .. "</ref>"
end
local function getWikidataLanguageItems(property)
local entity = mw.wikibase.getEntityObject()
if not entity then return nil end
local statements = entity:getBestStatements(property)
if not statements or #statements == 0 then return nil end
local items = {}
for _, statement in ipairs(statements) do
local mainsnak = statement.mainsnak
if mainsnak and mainsnak.snaktype == "value" and mainsnak.datavalue
and mainsnak.datavalue.type == "wikibase-entityid" then
local value = mainsnak.datavalue.value
local id = value.id or ("Q" .. tostring(value["numeric-id"]))
local label = mw.wikibase.getLabelByLang(id, "gv") or mw.wikibase.label(id)
if label and label ~= "" then
table.insert(items, { id = id, name = label })
end
end
end
if #items == 0 then return nil end
return items
end
local function itemsToRaw(items, excludeIds)
local names = {}
for _, item in ipairs(items) do
if not (excludeIds and excludeIds[item.id]) then
table.insert(names, item.name)
end
end
if #names == 0 then return nil end
return table.concat(names, ",")
end
local function buildLanguageValue(raw, ref, note, frame)
if not raw or mw.text.trim(raw):lower() == "none" then return nil, 0 end
if raw:find("%[%[", 1, false) then
local display = raw
if note and note ~= "" and frame then
display = display .. frame:expandTemplate{ title = "efn", args = { note } }
end
if ref then
display = display .. wrapReference(ref)
end
local linkCount = 0
for _ in raw:gmatch("%[%[") do linkCount = linkCount + 1 end
return display, linkCount
end
-- Safe tokenization using native text utilities instead of fragile match strings
local cleaned = raw:gsub("<ref[^>]*>.-</ref>", ""):gsub("<ref[^>]*/>", "")
local names = mw.text.split(cleaned, ",", true)
local filteredNames = {}
for _, part in ipairs(names) do
local trimmed = mw.text.trim(part)
if trimmed ~= "" then
table.insert(filteredNames, trimmed)
end
end
if #filteredNames == 0 then return nil, 0 end
table.sort(filteredNames, manxSort)
local parts = {}
for _, name in ipairs(filteredNames) do
table.insert(parts, '[[' .. name .. '|' .. name .. ']]')
end
local display = '<div class="hlist">' .. table.concat(parts, ' · ') .. '</div>'
if note and note ~= "" and frame then
display = display .. frame:expandTemplate{ title = "efn", args = { note } }
end
if ref then
display = display .. wrapReference(ref)
end
return display, #filteredNames
end
function p.main(frame, args)
if not args then
args = frame
frame = mw.getCurrentFrame()
end
local officialItems = nil
local officialRaw = getManual(args, {"çhengaghyn_oikoil", "çhengey_oikoil"})
if not officialRaw then
officialItems = getWikidataLanguageItems("P37")
officialRaw = itemsToRaw(officialItems)
end
local regionalRaw = getManual(args, {"çhengaghyn_ardjynagh", "çhengey_ardjynagh"})
local minorityRaw = getManual(args, {"mynçhengaghyn", "mynçhengey"})
local otherRaw = getManual(args, {"çhengaghyn", "çhengey"})
local official, offCount = buildLanguageValue(officialRaw, getManual(args, {"imraa_çhengaghyn_oikoil", "imraa_çhengey_oikoil"}), getManual(args, {"noteyn_çhengaghyn_oikoil", "noteyn_çhengey_oikoil"}), frame)
local regional, regCount = buildLanguageValue(regionalRaw, getManual(args, {"imraa_çhengaghyn_ardjynagh", "imraa_çhengey_ardjynagh"}), getManual(args, {"noteyn_çhengaghyn_ardjynagh", "noteyn_çhengey_ardjynagh"}), frame)
local minority, minCount = buildLanguageValue(minorityRaw, getManual(args, {"imraa_mynçhengaghyn", "imraa_mynçhengey"}), getManual(args, {"noteyn_mynçhengaghyn", "noteyn_mynçhengey"}), frame)
local other, othCount = buildLanguageValue(otherRaw, getManual(args, {"imraa_çhengaghyn", "imraa_çhengey"}), getManual(args, {"noteyn_çhengaghyn", "noteyn_çhengey"}), frame)
local subRows = {}
if official then
local label = offCount > 1 and "[[Çhengey oikoil|Çhengaghyn oikoil]]" or "[[Çhengey oikoil]]"
table.insert(subRows, '<tr><th style="vertical-align:top; white-space:nowrap; text-align:left; font-weight:bold; padding-left:0.4em; padding-right:0.4em;">' .. label .. '</th><td style="vertical-align:top; padding-left:0.4em; padding-right:0.4em;">' .. official .. '</td></tr>')
if regional then
local rLabel = regCount > 1 and "Çhengaghyn ardjynagh er enney" or "Çhengey ardjynagh er enney"
table.insert(subRows, '<tr><th style="vertical-align:top; white-space:nowrap; text-align:left; font-weight:normal; padding-left:0.4em; padding-right:0.4em;">[[Çhengey ardjynagh|' .. rLabel .. ']]</th><td style="vertical-align:top; padding-left:0.4em; padding-right:0.4em;">' .. regional .. '</td></tr>')
end
elseif regional then
local rLabel = regCount > 1 and "Çhengaghyn ardjynagh er enney" or "Çhengey ardjynagh er enney"
table.insert(subRows, '<tr><th style="vertical-align:top; white-space:nowrap; text-align:left; font-weight:bold; padding-left:0.4em; padding-right:0.4em;">[[Çhengey ardjynagh|' .. rLabel .. ']]</th><td style="vertical-align:top; padding-left:0.4em; padding-right:0.4em;">' .. regional .. '</td></tr>')
end
if minority then
local mLabel = minCount > 1 and "[[Mynçhengey|Mynçhengaghyn]]" or "[[Mynçhengey]]"
table.insert(subRows, '<tr><th style="vertical-align:top; white-space:nowrap; text-align:left; font-weight:bold; padding-left:0.4em; padding-right:0.4em;">' .. mLabel .. '</th><td style="vertical-align:top; padding-left:0.4em; padding-right:0.4em;">' .. minority .. '</td></tr>')
end
if other then
local oLabel = args["sorçh_çhengaghyn"] or (othCount > 1 and "Çhengaghyn" or "Çhengey")
table.insert(subRows, '<tr><th style="vertical-align:top; white-space:nowrap; text-align:left; font-weight:bold; padding-left:0.4em; padding-right:0.4em;">' .. oLabel .. '</th><td style="vertical-align:top; padding-left:0.4em; padding-right:0.4em;">' .. other .. '</td></tr>')
end
if #subRows == 0 then return nil end
return table.concat(subRows)
end
return p
eghja6pqf4bn8w1lhnl3nqcqm5ijc1t
393160
393154
2026-09-13T23:34:53Z
MacTire02
219
++
393160
Scribunto
text/plain
local p = {}
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 manxSort(a, b)
local function norm(text) return text:lower():gsub("çh", "ch") end
return norm(a) < norm(b)
end
-- Wraps a manual citation in <ref>...</ref>, unless it's already been
-- processed: a literal <ref> typed in a template parameter is expanded by
-- Scribunto into an opaque strip marker (\127UNIQ...QINU\127) the moment
-- frame.args is read, not literal "<ref" text -- re-wrapping that marker
-- creates a bogus extra reference. Pass strip markers and literal <ref>
-- text through unchanged; wrap anything else.
local function wrapReference(ref)
if not ref or ref == "" then return nil end
if mw.ustring.find(ref, "\127", 1, true) then
return ref
end
if mw.ustring.find(mw.ustring.lower(ref), "<ref", 1, true) then
return ref
end
return "<ref>" .. ref .. "</ref>"
end
local function getWikidataLanguageItems(property)
local entity = mw.wikibase.getEntityObject()
if not entity then return nil end
local statements = entity:getBestStatements(property)
if not statements or #statements == 0 then return nil end
local items = {}
for _, statement in ipairs(statements) do
local mainsnak = statement.mainsnak
if mainsnak and mainsnak.snaktype == "value" and mainsnak.datavalue
and mainsnak.datavalue.type == "wikibase-entityid" then
local value = mainsnak.datavalue.value
local id = value.id or ("Q" .. tostring(value["numeric-id"]))
local label = mw.wikibase.getLabelByLang(id, "gv") or mw.wikibase.label(id)
if label and label ~= "" then
table.insert(items, { id = id, name = label })
end
end
end
if #items == 0 then return nil end
return items
end
local function itemsToRaw(items, excludeIds)
local names = {}
for _, item in ipairs(items) do
if not (excludeIds and excludeIds[item.id]) then
table.insert(names, item.name)
end
end
if #names == 0 then return nil end
return table.concat(names, ",")
end
local function buildLanguageValue(raw, ref, note, frame)
if not raw or mw.text.trim(raw):lower() == "none" then return nil, 0 end
if raw:find("%[%[", 1, false) then
local display = raw
if note and note ~= "" and frame then
display = display .. frame:expandTemplate{ title = "efn", args = { note } }
end
if ref then
display = display .. wrapReference(ref)
end
local linkCount = 0
for _ in raw:gmatch("%[%[") do linkCount = linkCount + 1 end
return display, linkCount
end
-- Safe tokenization using native text utilities instead of fragile match strings.
-- A literal <ref> typed directly in this comma-separated field (rather than via
-- the separate imraa_* parameter) is expanded by Scribunto into an opaque strip
-- marker (\127UNIQ...QINU\127) the moment frame.args is read, not literal "<ref"
-- text -- see wrapReference above -- so both forms are stripped here.
local cleaned = raw:gsub("<ref[^>]*>.-</ref>", ""):gsub("<ref[^>]*/>", ""):gsub("\127UNIQ.-QINU\127", "")
local names = mw.text.split(cleaned, ",", true)
local filteredNames = {}
for _, part in ipairs(names) do
local trimmed = mw.text.trim(part)
if trimmed ~= "" then
table.insert(filteredNames, trimmed)
end
end
if #filteredNames == 0 then return nil, 0 end
table.sort(filteredNames, manxSort)
local parts = {}
for _, name in ipairs(filteredNames) do
table.insert(parts, '[[' .. name .. '|' .. name .. ']]')
end
local display = '<div class="hlist">' .. table.concat(parts, ' · ') .. '</div>'
if note and note ~= "" and frame then
display = display .. frame:expandTemplate{ title = "efn", args = { note } }
end
if ref then
display = display .. wrapReference(ref)
end
return display, #filteredNames
end
function p.main(frame, args)
if not args then
args = frame
frame = mw.getCurrentFrame()
end
local officialItems = nil
local officialRaw = getManual(args, {"çhengaghyn_oikoil", "çhengey_oikoil"})
if not officialRaw then
officialItems = getWikidataLanguageItems("P37")
officialRaw = itemsToRaw(officialItems)
end
local regionalRaw = getManual(args, {"çhengaghyn_ardjynagh", "çhengey_ardjynagh"})
local minorityRaw = getManual(args, {"mynçhengaghyn", "mynçhengey"})
local otherRaw = getManual(args, {"çhengaghyn", "çhengey"})
local official, offCount = buildLanguageValue(officialRaw, getManual(args, {"imraa_çhengaghyn_oikoil", "imraa_çhengey_oikoil"}), getManual(args, {"noteyn_çhengaghyn_oikoil", "noteyn_çhengey_oikoil"}), frame)
local regional, regCount = buildLanguageValue(regionalRaw, getManual(args, {"imraa_çhengaghyn_ardjynagh", "imraa_çhengey_ardjynagh"}), getManual(args, {"noteyn_çhengaghyn_ardjynagh", "noteyn_çhengey_ardjynagh"}), frame)
local minority, minCount = buildLanguageValue(minorityRaw, getManual(args, {"imraa_mynçhengaghyn", "imraa_mynçhengey"}), getManual(args, {"noteyn_mynçhengaghyn", "noteyn_mynçhengey"}), frame)
local other, othCount = buildLanguageValue(otherRaw, getManual(args, {"imraa_çhengaghyn", "imraa_çhengey"}), getManual(args, {"noteyn_çhengaghyn", "noteyn_çhengey"}), frame)
local subRows = {}
if official then
local label = offCount > 1 and "[[Çhengey oikoil|Çhengaghyn oikoil]]" or "[[Çhengey oikoil]]"
table.insert(subRows, '<tr><th style="vertical-align:top; white-space:nowrap; text-align:left; font-weight:bold; padding-left:0.4em; padding-right:0.4em;">' .. label .. '</th><td style="vertical-align:top; padding-left:0.4em; padding-right:0.4em;">' .. official .. '</td></tr>')
if regional then
local rLabel = regCount > 1 and "Çhengaghyn ardjynagh er enney" or "Çhengey ardjynagh er enney"
table.insert(subRows, '<tr><th style="vertical-align:top; white-space:nowrap; text-align:left; font-weight:normal; padding-left:0.4em; padding-right:0.4em;">[[Çhengey ardjynagh|' .. rLabel .. ']]</th><td style="vertical-align:top; padding-left:0.4em; padding-right:0.4em;">' .. regional .. '</td></tr>')
end
elseif regional then
local rLabel = regCount > 1 and "Çhengaghyn ardjynagh er enney" or "Çhengey ardjynagh er enney"
table.insert(subRows, '<tr><th style="vertical-align:top; white-space:nowrap; text-align:left; font-weight:bold; padding-left:0.4em; padding-right:0.4em;">[[Çhengey ardjynagh|' .. rLabel .. ']]</th><td style="vertical-align:top; padding-left:0.4em; padding-right:0.4em;">' .. regional .. '</td></tr>')
end
if minority then
local mLabel = minCount > 1 and "[[Mynçhengey|Mynçhengaghyn]]" or "[[Mynçhengey]]"
table.insert(subRows, '<tr><th style="vertical-align:top; white-space:nowrap; text-align:left; font-weight:bold; padding-left:0.4em; padding-right:0.4em;">' .. mLabel .. '</th><td style="vertical-align:top; padding-left:0.4em; padding-right:0.4em;">' .. minority .. '</td></tr>')
end
if other then
local oLabel = args["sorçh_çhengaghyn"] or (othCount > 1 and "Çhengaghyn" or "Çhengey")
table.insert(subRows, '<tr><th style="vertical-align:top; white-space:nowrap; text-align:left; font-weight:bold; padding-left:0.4em; padding-right:0.4em;">' .. oLabel .. '</th><td style="vertical-align:top; padding-left:0.4em; padding-right:0.4em;">' .. other .. '</td></tr>')
end
if #subRows == 0 then return nil end
return table.concat(subRows)
end
return p
qcqgica2rqc91prsdnh03earst0dp8h
393167
393160
2026-09-14T00:06:01Z
MacTire02
219
++
393167
Scribunto
text/plain
local p = {}
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 manxSort(a, b)
local function norm(text) return text:lower():gsub("çh", "ch") end
return norm(a) < norm(b)
end
-- Wraps a manual citation in <ref>...</ref>, unless it's already fully
-- <ref>-tagged (Scribunto expands a literal <ref> in a parameter into an
-- opaque \127UNIQ...QINU\127 strip marker before this module sees it, so we
-- strip those out and check what's left -- nothing left means it was
-- already tag(s), pass through unchanged; real text left over -- e.g. a
-- bare {{cite web}} call whose own <templatestyles/> leaves an incidental
-- marker -- means it still needs wrapping).
local function wrapReference(ref)
if not ref or ref == "" then return nil end
local withoutMarkers = mw.ustring.gsub(ref, "\127UNIQ.-QINU\127", "")
if mw.ustring.gsub(withoutMarkers, "%s+", "") == "" then
return ref
end
if mw.ustring.find(mw.ustring.lower(ref), "<ref", 1, true) then
return ref
end
return "<ref>" .. ref .. "</ref>"
end
local function getWikidataLanguageItems(property)
local entity = mw.wikibase.getEntityObject()
if not entity then return nil end
local statements = entity:getBestStatements(property)
if not statements or #statements == 0 then return nil end
local items = {}
for _, statement in ipairs(statements) do
local mainsnak = statement.mainsnak
if mainsnak and mainsnak.snaktype == "value" and mainsnak.datavalue
and mainsnak.datavalue.type == "wikibase-entityid" then
local value = mainsnak.datavalue.value
local id = value.id or ("Q" .. tostring(value["numeric-id"]))
local label = mw.wikibase.getLabelByLang(id, "gv") or mw.wikibase.label(id)
if label and label ~= "" then
table.insert(items, { id = id, name = label })
end
end
end
if #items == 0 then return nil end
return items
end
local function itemsToRaw(items, excludeIds)
local names = {}
for _, item in ipairs(items) do
if not (excludeIds and excludeIds[item.id]) then
table.insert(names, item.name)
end
end
if #names == 0 then return nil end
return table.concat(names, ",")
end
local function buildLanguageValue(raw, ref, note, frame)
if not raw or mw.text.trim(raw):lower() == "none" then return nil, 0 end
if raw:find("%[%[", 1, false) then
local display = raw
if note and note ~= "" and frame then
display = display .. frame:expandTemplate{ title = "efn", args = { note } }
end
if ref then
display = display .. wrapReference(ref)
end
local linkCount = 0
for _ in raw:gmatch("%[%[") do linkCount = linkCount + 1 end
return display, linkCount
end
-- Strip any ref out of this comma-separated field before splitting -- a
-- literal <ref> typed here (rather than via imraa_*) arrives as a strip
-- marker (see wrapReference above), so both shapes are stripped.
local cleaned = raw:gsub("<ref[^>]*>.-</ref>", ""):gsub("<ref[^>]*/>", ""):gsub("\127UNIQ.-QINU\127", "")
local names = mw.text.split(cleaned, ",", true)
local filteredNames = {}
for _, part in ipairs(names) do
local trimmed = mw.text.trim(part)
if trimmed ~= "" then
table.insert(filteredNames, trimmed)
end
end
if #filteredNames == 0 then return nil, 0 end
table.sort(filteredNames, manxSort)
local parts = {}
for _, name in ipairs(filteredNames) do
table.insert(parts, '[[' .. name .. '|' .. name .. ']]')
end
local display = '<div class="hlist">' .. table.concat(parts, ' · ') .. '</div>'
if note and note ~= "" and frame then
display = display .. frame:expandTemplate{ title = "efn", args = { note } }
end
if ref then
display = display .. wrapReference(ref)
end
return display, #filteredNames
end
function p.main(frame, args)
if not args then
args = frame
frame = mw.getCurrentFrame()
end
local officialItems = nil
local officialRaw = getManual(args, {"çhengaghyn_oikoil", "çhengey_oikoil"})
if not officialRaw then
officialItems = getWikidataLanguageItems("P37")
officialRaw = itemsToRaw(officialItems)
end
local regionalRaw = getManual(args, {"çhengaghyn_ardjynagh", "çhengey_ardjynagh"})
local minorityRaw = getManual(args, {"mynçhengaghyn", "mynçhengey"})
local otherRaw = getManual(args, {"çhengaghyn", "çhengey"})
local official, offCount = buildLanguageValue(officialRaw, getManual(args, {"imraa_çhengaghyn_oikoil", "imraa_çhengey_oikoil"}), getManual(args, {"noteyn_çhengaghyn_oikoil", "noteyn_çhengey_oikoil"}), frame)
local regional, regCount = buildLanguageValue(regionalRaw, getManual(args, {"imraa_çhengaghyn_ardjynagh", "imraa_çhengey_ardjynagh"}), getManual(args, {"noteyn_çhengaghyn_ardjynagh", "noteyn_çhengey_ardjynagh"}), frame)
local minority, minCount = buildLanguageValue(minorityRaw, getManual(args, {"imraa_mynçhengaghyn", "imraa_mynçhengey"}), getManual(args, {"noteyn_mynçhengaghyn", "noteyn_mynçhengey"}), frame)
local other, othCount = buildLanguageValue(otherRaw, getManual(args, {"imraa_çhengaghyn", "imraa_çhengey"}), getManual(args, {"noteyn_çhengaghyn", "noteyn_çhengey"}), frame)
local subRows = {}
if official then
local label = offCount > 1 and "[[Çhengey oikoil|Çhengaghyn oikoil]]" or "[[Çhengey oikoil]]"
table.insert(subRows, '<tr><th style="vertical-align:top; white-space:nowrap; text-align:left; font-weight:bold; padding-left:0.4em; padding-right:0.4em;">' .. label .. '</th><td style="vertical-align:top; padding-left:0.4em; padding-right:0.4em;">' .. official .. '</td></tr>')
if regional then
local rLabel = regCount > 1 and "Çhengaghyn ardjynagh er enney" or "Çhengey ardjynagh er enney"
table.insert(subRows, '<tr><th style="vertical-align:top; white-space:nowrap; text-align:left; font-weight:normal; padding-left:0.4em; padding-right:0.4em;">[[Çhengey ardjynagh|' .. rLabel .. ']]</th><td style="vertical-align:top; padding-left:0.4em; padding-right:0.4em;">' .. regional .. '</td></tr>')
end
elseif regional then
local rLabel = regCount > 1 and "Çhengaghyn ardjynagh er enney" or "Çhengey ardjynagh er enney"
table.insert(subRows, '<tr><th style="vertical-align:top; white-space:nowrap; text-align:left; font-weight:bold; padding-left:0.4em; padding-right:0.4em;">[[Çhengey ardjynagh|' .. rLabel .. ']]</th><td style="vertical-align:top; padding-left:0.4em; padding-right:0.4em;">' .. regional .. '</td></tr>')
end
if minority then
local mLabel = minCount > 1 and "[[Mynçhengey|Mynçhengaghyn]]" or "[[Mynçhengey]]"
table.insert(subRows, '<tr><th style="vertical-align:top; white-space:nowrap; text-align:left; font-weight:bold; padding-left:0.4em; padding-right:0.4em;">' .. mLabel .. '</th><td style="vertical-align:top; padding-left:0.4em; padding-right:0.4em;">' .. minority .. '</td></tr>')
end
if other then
local oLabel = args["sorçh_çhengaghyn"] or (othCount > 1 and "Çhengaghyn" or "Çhengey")
table.insert(subRows, '<tr><th style="vertical-align:top; white-space:nowrap; text-align:left; font-weight:bold; padding-left:0.4em; padding-right:0.4em;">' .. oLabel .. '</th><td style="vertical-align:top; padding-left:0.4em; padding-right:0.4em;">' .. other .. '</td></tr>')
end
if #subRows == 0 then return nil end
return table.concat(subRows)
end
return p
0aavjpw6e5dbe06bq5ejgn0cobqcnx0
Module:Kishtey fys çheer/caslyssyn-çheerey
828
55834
393148
392911
2026-09-13T22:17:05Z
MacTire02
219
baarney
393148
Scribunto
text/plain
local p = {}
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 getWikidataLocatorMap()
local entity = mw.wikibase.getEntityObject()
if not entity then return nil end
local statements = entity:getBestStatements("P242")
if not statements or #statements == 0 then return nil end
for _, statement in ipairs(statements) do
local mainsnak = statement.mainsnak
if mainsnak and mainsnak.snaktype == "value" and mainsnak.datavalue and mainsnak.datavalue.type == "string" then
local file = mainsnak.datavalue.value
if file and file ~= "" then return file end
end
end
return nil
end
function p.main(frame, args)
local map = getManual(args, {"jalloo_caslys-çheerey", "jalloo_caslys"})
if map and mw.ustring.lower(map) == "none" then
return nil
end
if not map then
map = getWikidataLocatorMap()
end
if not map then
return nil
end
local width = getManual(args, {"lheead_caslys-çheerey", "lheead_caslys"}) or "250px"
local caption = getManual(args, {"fo-heidyl_caslys-çheerey", "fo-heidyl_caslys"})
local mapHtml = '[[Coadan:' .. map .. '|' .. width .. '|center]]'
if caption then
mapHtml = mapHtml .. '<div style="position:relative; top:0.3em;"><small>' .. caption .. '</small></div>'
end
return '<tr><td colspan="2" style="text-align:center; padding:0.2em 0.4em;">' .. mapHtml .. '</td></tr>'
end
return p
424oadjg1za8uardl6zszno9slatlr2
Module:Kishtey fys çheer/reiltys
828
55837
393139
393134
2026-09-13T16:37:07Z
MacTire02
219
++
393139
Scribunto
text/plain
local p = {}
-- Wikidata fetch/citation module. Used instead of Module:WikidataIB, which
-- has no working citation-building of its own.
local wdOK, Wd = pcall(require, "Module:Wd")
-- Country genitive/mutated name forms (e.g. "Mannin" -> "Vannin", "Nalbin"
-- -> "ny h-Albey"). See getCurrentCountryGenitive/shortManxForm below.
local enmynOK, EnmynCheerey = pcall(require, "Module:Enmyn çheerey")
-- Shared "Manx label, else linked Wikidata fallback" helper -- see its own
-- header comment. Used as the last rung in getWdItemManxLink below.
local ennymWdOK, EnnymWd = pcall(require, "Module:Kishtey fys çheer/ennym-wd")
-- Returns the first non-empty manual parameter from a list of names.
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
-- Appends a manual <ref> and/or {{efn}} note (the imraa_*/noteyn_* params)
-- to a value, on top of any Wikidata-sourced citation it already has.
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
-- Shared innards of getWdProperty/getWdPropertyWithCitation.
-- includeReference controls whether Wd's "reference" flag is passed.
local function getWdPropertyRaw(property, flags, includeReference)
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
if includeReference then table.insert(callArgs, "reference") end
table.insert(callArgs, "best") -- single best-ranked value
table.insert(callArgs, property)
local ok, result = pcall(Wd._property, callArgs)
if ok and result and result ~= "" then return result end
return nil
end
-- Fetches a Wikidata property value with its auto-built citation already
-- appended. `flags` is an optional array of extra Wd flags (e.g.
-- {"linked"}). Safe only when the result isn't going to be re-wrapped in a
-- fresh "[[...]]" by the caller -- use getWdPropertyWithCitation for that.
local function getWdProperty(property, flags)
return getWdPropertyRaw(property, flags, true)
end
-- Fetches a property's value and its citation as two separate strings.
--
-- Wd's "reference" flag builds the citation via
-- frame:extensionTag("ref", ...), which runs the <ref> tag hook
-- immediately and returns the ALREADY-RENDERED footnote marker (e.g. "[1]",
-- with real "[" "]" characters) -- not literal <ref> wikitext. If a caller
-- then wraps a sitelink-less value in its own "[[...]]" (see ensureLinked),
-- that marker's own "[" breaks the link.
--
-- Fixed by fetching the same property+flags twice (with and without
-- "reference") and diffing the two to isolate the citation, instead of
-- pattern-matching its shape. Returns `value, citation` -- citation is nil
-- when there is none, or when the two calls didn't line up as a clean
-- prefix match (falls back to the combined string in that case).
local function getWdPropertyWithCitation(property, flags)
local base = getWdPropertyRaw(property, flags, false)
if not base then return nil, nil end
local withRef = getWdPropertyRaw(property, flags, true)
if not withRef or withRef == base then return base, nil end
if withRef:sub(1, #base) == base then
local citation = withRef:sub(#base + 1)
if citation ~= "" then return base, citation end
return base, nil
end
return withRef, nil
end
-- Forces a value into a wikilink when Wd's "linked" flag didn't already
-- produce one (no gv sitelink yet), without touching a trailing citation.
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
-- Manx label of a Wikidata PROPERTY itself (e.g. P35 -> "head of state"),
-- used as a title fallback. Uses getLabelByLang(property, "gv")
-- specifically -- plain label()/mw.wikibase.label follows Wikidata's
-- fallback chain and would leak English when no Manx label exists.
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 link/label formatting) of an entity-valued property on the
-- current page's own item -- e.g. P35's value, for chaining into a lookup
-- on that person's own item (see getWdPositionTitle below).
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 the current
-- page's own item (plural version of getWdRawPropertyId above) -- e.g.
-- every P122 ("basic form of government") statement.
local function getWdRawPropertyIds(property)
if not wdOK or not Wd or not Wd._properties then return {} end
local ok, result = pcall(Wd._properties, {"raw", property})
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
-- Raw QID of a QUALIFIER on the current page's own "best" statement of
-- `property` -- e.g. the P1393 ("proxy") qualifier on a P35 statement. Call
-- shape is {"raw", "best", mainProperty, qualifierProperty}; no `eid`, so it
-- defaults to the current page's own entity.
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`) -- e.g. a leader's own P39 ("position held")
-- statements. Uses Wd's plural "properties" command so every matching
-- claim is returned, not just one. `qualifiers` is an optional
-- {qualifierProperty = requiredValue} table to filter by (e.g. P1001
-- "applies to jurisdiction" -- see getWdPositionTitle below).
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
-- QID of the Wikidata item connected to the current page.
local function getCurrentCountryQid()
local ok, id = pcall(mw.wikibase.getEntityIdForCurrentPage)
if ok and id and id ~= "" then return id end
return nil
end
-- Manx genitive form of the current page's own country/territory (e.g.
-- "Vannin" for the Isle of Man, "y Reeriaght Unnaneysit" for the UK), from
-- Module:Enmyn çheerey's table, keyed on the page's own title.
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
-- Section label linked to the country-specific article/redirect when one
-- exists (e.g. "[[Reiltys y Reeriaght Unnaneysit|Reiltys]]" for the UK,
-- "[[Reiltys Vannin|Reiltys]]" for the Isle of Man), else a plain
-- "[[Reiltys]]" when the current page's genitive can't be resolved.
local function getGenitiveLinkedLabel(baseWord)
local genitive = getCurrentCountryGenitive()
if genitive and genitive ~= "" then
return "[[" .. baseWord .. " " .. genitive .. "|" .. baseWord .. "]]"
end
return "[[" .. baseWord .. "]]"
end
-- Titles to leave unshortened even though they'd otherwise match a rung
-- below (e.g. "Çhiarn Vannin" should stay whole, not lose " Vannin").
local shortFormExceptions = {
["Çhiarn Vannin"] = true,
}
-- Strips the country name from an office title for display, e.g. "Monark y
-- Reeriaght Unnaneysit" -> "Monark". Tries, in order: Module:Enmyn
-- çheerey's exact genitive suffix, an explicit " y " split, then a blind
-- last-space split. A title with no space at all is returned unchanged.
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
-- Same idea as shortManxForm, but for a PERSON's name (a shared monarch's
-- own per-realm article, e.g. "Çhalse III y Reeriaght Unnaneysit"). Skips
-- the blind last-space rung, which would wrongly truncate an ordinary name
-- with no country suffix (e.g. "Charse III" -> "Charse").
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 a head-of-state link when it's a per-realm-
-- disambiguated article (see shortenCountrySuffixedName above), leaving the
-- link target and any citation untouched. Handles both a bare "[[target]]"
-- and an already-piped "[[target|display]]" link. Scoped to the head-of-
-- state slot only -- an ordinary head of government is never shared across
-- countries, so this shape of data doesn't arise there.
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 via the content language's own ucfirst
-- (UTF-8/digraph-safe, e.g. "çh") -- not a plain Lua upper() on byte 1.
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
-- Capitalizes the first letter a reader actually sees, even when the value
-- starts with wikilink or ennym-wd external-link markup. Only the very
-- first letter of the whole string is touched -- for a multi-value line
-- joined with commas, only the first item gets capitalized, matching
-- ordinary sentence capitalization. Manual (editor-typed) values are never
-- passed through this.
local function capitalizeFirstLetter(text)
if not text or text == "" then return text end
if text:match("^%[%[") then
local closePos = text:find("%]%]", 3, true)
local pipePos = text:find("|", 1, true)
local splitPos
if pipePos and (not closePos or pipePos < closePos) then
splitPos = pipePos -- piped: capitalize the display half only
else
splitPos = 2 -- unpiped: capitalize just past the leading "[["
end
return text:sub(1, splitPos) .. wikiUcfirst(text:sub(splitPos + 1))
elseif text:match("^%[https?://") then
-- ennym-wd external link: "[url label] <sup>(lang)</sup>" --
-- capitalize the label, right after the URL's own space.
local spacePos = text:find(" ", 2, true)
if spacePos then
return text:sub(1, spacePos) .. wikiUcfirst(text:sub(spacePos + 1))
end
return text
end
return wikiUcfirst(text)
end
-- Builds a wikilink for a Wikidata item: a gv sitelink when one exists,
-- else a gv label (as a redlink), else an ennym-wd external link to
-- Wikidata tagged with its language. Target and display are resolved
-- separately -- the gv label is always preferred for display, even when a
-- sitelink with a different title exists.
--
-- shorten (default true): strip the "role + country" suffix from the
-- display text (see shortManxForm). Pass false for an ordinary proper name
-- with no such structure (a chamber, a calendar concept).
-- capitalize (default true): capitalize a gv label's first letter. Pass
-- false when building one item out of a multi-value list, where only the
-- first item in the finished line should be capitalized by the caller
-- (see capitalizeFirstLetter).
--
-- Returns nil only when neither a sitelink nor a gv label nor an ennym-wd
-- fallback resolves to anything.
local function getWdItemManxLink(qid, shorten, capitalize)
if not qid then return nil end
if capitalize == nil then capitalize = true 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
if capitalize then
gvLabel = wikiUcfirst(gvLabel)
end
else
gvLabel = nil
end
if not sitelinkTitle and not gvLabel then
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
-- Office title from a property set directly on the country (P1906 "office
-- held by head of state" / P1313 "office held by head of government"),
-- when Wikidata records it -- avoids the multi-role ambiguity in
-- getWdPositionTitle below. Tried first.
local function getWdOfficeItemTitle(officeProperty)
local officeQid = getWdRawPropertyId(officeProperty)
if not officeQid then return nil end
return getWdItemManxLink(officeQid)
end
-- Fallback (see getWdOfficeItemTitle above, tried first): the office-
-- holder's own specific title, via their "position held" (P39) statement,
-- for a country with no P1906/P1313 set.
--
-- A head of state/government can hold several simultaneous P39 positions
-- (a shared monarch's several realms, or an MP/party-leader/PM combination),
-- with no reliable qualifier on a fresh statement to say which one is "the"
-- state office. So this collects every current P39 candidate (P1001-
-- jurisdiction-filtered ones first, when present) and uses the first that
-- resolves to a real gv sitelink or label -- in practice the actual office
-- is the one likely to have a gv article, while an ancillary role usually
-- doesn't.
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 "upper house" / "lower house" class items.
local UPPER_HOUSE_QID = "Q637846"
local LOWER_HOUSE_QID = "Q375928"
-- Resolves a bicameral legislature's two chambers via "has part(s)" (P527)
-- + "instance of" (P31) on each part. Only acts when exactly one part is
-- classified as upper and exactly one as lower; a unicameral legislature
-- (no P527 at all) or ambiguous data yields nothing for that side -- the
-- manual |thie_heose=/|thie_heese= override covers the rest. No auto-built
-- citation is attached (only a direct property fetch off the current
-- page's own item can produce one).
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
-- Wikidata's "proleptic Julian calendar" item -- not plain "Julian
-- calendar" (Q11184); a time value's calendar model always points to the
-- proleptic variant.
local JULIAN_CALENDAR_QID = "Q1985786"
-- Wd's own time-value formatting appends " (Joolagh)" to a date recorded on
-- the Julian calendar, but links it (or not) with a blind, unverified
-- wikilink to the hardcoded word "feaillere Yool". This rebuilds that
-- suffix as a real three-tier link (sitelink/label/ennym-wd), keeping Wd's
-- own "Joolagh" wording as the display text. Falls back to plain unlinked
-- "Joolagh" if nothing resolves at all.
local function getJulianCalendarSuffixLink()
local link = getWdItemManxLink(JULIAN_CALENDAR_QID, false)
if link then
local target = link:match("^%[%[([^%[%]|]+)") or link:match("^%[%[([^%[%]|]+)%]%]$")
if target then
return "[[" .. target .. "|Joolagh]]"
end
return link
end
return "Joolagh"
end
-- Row templates: plain 2-cell rows, matching every other submodule
-- (çhengaghyn, balley, bratteeyn). The old template's 3-column grid caused
-- a layout bug when mixed with 2-column rows. Sub-items get a "•" bullet +
-- lighter weight instead of a spacer column.
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;">• %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.
local function trClass(name)
if name and name ~= "" then return ' class="' .. name .. '"' end
return ""
end
-- Wraps a section label in [[...]], unless it's already a full wikilink
-- (a manual |sorçh_kionedeeaght=[[target|display]] override) -- otherwise
-- that would double-bracket into a broken [[[[target|display]]]].
local function wikilinkLabel(label)
if not label or label == "" then return label end
if label:find("%[%[") then return label end
return "[[" .. label .. "]]"
end
-- Formats a run of bullet sub-rows with the merged-border classes: every
-- row but the last gets mergedrow, the last gets mergedbottomrow.
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 Module:Kishtey fys çheer uses between submodules, reused
-- here between this module's own sections -- only inserted between two
-- sections that both produced rows.
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)
-- Allow being called as p.main(args) with no frame (used by tests).
if not args then
args = frame
frame = mw.getCurrentFrame()
end
local rows = {}
local govRows = {}
local quaiylRows = {}
local foundingRows = {}
----------------------------------------------------------------
-- 1-2. REILTYS (government type) + leaders (head of state/government,
-- etc.). enmysN_fer-toshee/ennymN_fer-toshee are the old gendered
-- param names; enmys_toshiaghN/ennym_toshiaghN are the gender-neutral
-- synonyms and take priority when both are given.
----------------------------------------------------------------
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: basic form of government (P122), joining every
-- value Wikidata records. Routed through getWdItemManxLink rather
-- than Wd's own "linked" property call -- a P122 value rarely has a
-- gv sitelink, and Wd's own formatting would leak plain, unlinked
-- English otherwise. shorten=false: not a "role + country" phrase.
-- capitalize=false: only the joined line's first letter should be
-- capitalized (below), not every value.
local govTypeQids = getWdRawPropertyIds("P122")
local govTypeParts = {}
for _, qid in ipairs(govTypeQids) do
local link = getWdItemManxLink(qid, false, false)
if link then table.insert(govTypeParts, link) end
end
if #govTypeParts > 0 then
govTypeRaw = capitalizeFirstLetter(table.concat(govTypeParts, ", "))
end
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: head of state (P35) / head of government (P6).
-- Names are always forced into a link via ensureLinked. Value and
-- citation are fetched separately and the citation appended only
-- after the link is built -- see getWdPropertyWithCitation.
local hosBase, hosCitation = getWdPropertyWithCitation("P35", {"linked"})
local hos = shortenLinkedCountryName(ensureLinked(hosBase))
if hos and hosCitation then hos = hos .. hosCitation end
local hogBase, hogCitation = getWdPropertyWithCitation("P6", {"linked"})
local hog = ensureLinked(hogBase)
if hog and hogCitation then hog = hog .. hogCitation end
-- Some countries (US, France, Russia, ...) record the same person
-- as both P35 and P6 -- one office, not two. Skip the head-of-
-- government row when the raw QIDs match, rather than showing it
-- twice.
local hosQid = getWdRawPropertyId("P35")
local hogQid = getWdRawPropertyId("P6")
local sameHeadOfStateAndGovernment = hos and hog and hosQid and hogQid and hosQid == hogQid
if hos then
local hosTitle = getManual(args, {"sorçh_kione_steat"})
or getWdOfficeItemTitle("P1906") -- office held by head of state
or getWdPositionTitle("P35")
or getWikidataPropertyLabel("P35")
or "Kione steat"
table.insert(leaderPairs, {title = hosTitle, name = hos})
-- Head of state's "proxy" (e.g. the Isle of Man's Lieutenant
-- Governor) -- a representative, distinct from a deputy. Shown
-- between the head of state and head of government when
-- Wikidata records one via P1393 (a qualifier on the P35
-- statement, whose value is the office; the current holder is
-- a separate P1308 lookup on that office).
if not isNone(getManual(args, {"ynnydee_kione_steat"})) then
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
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 and not sameHeadOfStateAndGovernment then
local hogTitle = getManual(args, {"sorçh_kione_reiltys"})
or getWdOfficeItemTitle("P1313") -- office held by head of government
or getWdPositionTitle("P6")
or getWikidataPropertyLabel("P6")
or "Kione reiltys"
table.insert(leaderPairs, {title = hogTitle, name = hog})
end
end
local reiltysLabel = getGenitiveLinkedLabel("Reiltys")
if govShown then
local govClass = (#leaderPairs > 0) and "mergedtoprow" or ""
table.insert(govRows, string.format(ROW, trClass(govClass), reiltysLabel, applyRefNote(govTypeRaw, govRef, govNote, frame)))
elseif #leaderPairs > 0 then
table.insert(govRows, string.format(HEADER, reiltysLabel))
end
if #leaderPairs > 0 then
-- Manual ref/note for the whole leaders block is attached to the
-- last row (a Wikidata-sourced name already carries its own).
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.
----------------------------------------------------------------
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"})
local quaiylQid = nil
if not quaiyl then
-- Wd's own "linked" flag leaks a plain, unlinked English label when
-- there's no gv sitelink (e.g. Scotland's P194 leaking "Scottish
-- Parliament"). Chains through the raw QID and getWdItemManxLink
-- instead. QID is kept for getWdChambers below.
quaiylQid = getWdRawPropertyId("P194")
if quaiylQid then
quaiyl = getWdItemManxLink(quaiylQid, false)
end
end
if not quaiylSyrjey or not quaiylInshley then
-- Chamber names, applied independently to whichever side is still
-- unset (an explicit "none" always wins). Chained off the same
-- legislative body as `quaiyl` above.
local legislatureQid = quaiylQid or 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) + establishment
-- events -- manual-only, ported from the old template's numbered
-- slots (1-9). kionedeeaght is a synonym for kiondeeaght.
----------------------------------------------------------------
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
-- taghyrt_bunneeaghtN/date_bunneeaghtN are the new, preferred
-- spellings; taghyrtN_bunnit/dateN_bunnit (old) still work.
local event = getManual(args, {"taghyrt_bunneeaght" .. i, "taghyrt" .. i .. "_bunnit"})
local date = getManual(args, {"date_bunneeaght" .. i, "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), wikilinkLabel(foundingLabel), applyRefNote(foundingValue, foundingRef, foundingNote, frame)))
elseif #establishmentRows > 0 then
local headerLabel = applyRefNote(wikilinkLabel(foundingLabel), foundingRef, foundingNote, frame)
table.insert(foundingRows, string.format(HEADER, headerLabel))
end
appendIndentRun(foundingRows, establishmentRows)
elseif not isNone(getManual(args, {"bunnit"})) then
-- Wikidata fallback: inception (P571), only when the whole
-- establishment block was left unset (not |bunnit=none). Wd already
-- renders a full date when the statement has day precision; a
-- year-only result means Wikidata itself only has year precision.
--
-- A Julian-calendar date gets a literal " (Joolagh)" from Wd,
-- linked (or not) unreliably -- upgraded here to a real three-tier
-- link; everything else about the date is left untouched.
local inception = getWdProperty("P571")
if inception and inception:find(" (Joolagh)", 1, true) then
inception = inception:gsub(" %(Joolagh%)", " (" .. getJulianCalendarSuffixLink() .. ")", 1)
end
if inception then
table.insert(foundingRows, string.format(ROW, "", wikilinkLabel(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
0ta7c29n6uhn5wyolief9oy2axi5nav
393141
393139
2026-09-13T22:12:02Z
MacTire02
219
++
393141
Scribunto
text/plain
local p = {}
-- Wikidata fetch/citation module. Used instead of Module:WikidataIB, which
-- has no working citation-building of its own.
local wdOK, Wd = pcall(require, "Module:Wd")
-- Country genitive/mutated name forms (e.g. "Mannin" -> "Vannin", "Nalbin"
-- -> "ny h-Albey"). See getCurrentCountryGenitive/shortManxForm below.
local enmynOK, EnmynCheerey = pcall(require, "Module:Enmyn çheerey")
-- Shared "Manx label, else linked Wikidata fallback" helper -- see its own
-- header comment. Used as the last rung in getWdItemManxLink below.
local ennymWdOK, EnnymWd = pcall(require, "Module:Kishtey fys çheer/ennym-wd")
-- Returns the first non-empty manual parameter from a list of names.
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
-- Appends a manual <ref> and/or {{efn}} note (the imraa_*/noteyn_* params)
-- to a value, on top of any Wikidata-sourced citation it already has.
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
-- Shared innards of getWdProperty/getWdPropertyWithCitation.
-- includeReference controls whether Wd's "reference" flag is passed.
local function getWdPropertyRaw(property, flags, includeReference)
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
if includeReference then table.insert(callArgs, "reference") end
table.insert(callArgs, "best") -- single best-ranked value
table.insert(callArgs, property)
local ok, result = pcall(Wd._property, callArgs)
if ok and result and result ~= "" then return result end
return nil
end
-- Fetches a Wikidata property value with its auto-built citation already
-- appended. `flags` is an optional array of extra Wd flags (e.g.
-- {"linked"}). Safe only when the result isn't going to be re-wrapped in a
-- fresh "[[...]]" by the caller -- use getWdPropertyWithCitation for that.
local function getWdProperty(property, flags)
return getWdPropertyRaw(property, flags, true)
end
-- Fetches a property's value and its citation as two separate strings.
--
-- Wd's "reference" flag builds the citation via
-- frame:extensionTag("ref", ...), which runs the <ref> tag hook
-- immediately and returns the ALREADY-RENDERED footnote marker (e.g. "[1]",
-- with real "[" "]" characters) -- not literal <ref> wikitext. If a caller
-- then wraps a sitelink-less value in its own "[[...]]" (see ensureLinked),
-- that marker's own "[" breaks the link.
--
-- Fixed by fetching the same property+flags twice (with and without
-- "reference") and diffing the two to isolate the citation, instead of
-- pattern-matching its shape. Returns `value, citation` -- citation is nil
-- when there is none, or when the two calls didn't line up as a clean
-- prefix match (falls back to the combined string in that case).
local function getWdPropertyWithCitation(property, flags)
local base = getWdPropertyRaw(property, flags, false)
if not base then return nil, nil end
local withRef = getWdPropertyRaw(property, flags, true)
if not withRef or withRef == base then return base, nil end
if withRef:sub(1, #base) == base then
local citation = withRef:sub(#base + 1)
if citation ~= "" then return base, citation end
return base, nil
end
return withRef, nil
end
-- Forces a value into a wikilink when Wd's "linked" flag didn't already
-- produce one (no gv sitelink yet), without touching a trailing citation.
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
-- Manx label of a Wikidata PROPERTY itself (e.g. P35 -> "head of state"),
-- used as a title fallback. Uses getLabelByLang(property, "gv")
-- specifically -- plain label()/mw.wikibase.label follows Wikidata's
-- fallback chain and would leak English when no Manx label exists.
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 link/label formatting) of an entity-valued property on the
-- current page's own item -- e.g. P35's value, for chaining into a lookup
-- on that person's own item (see getWdPositionTitle below).
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 the current
-- page's own item (plural version of getWdRawPropertyId above) -- e.g.
-- every P122 ("basic form of government") statement.
local function getWdRawPropertyIds(property)
if not wdOK or not Wd or not Wd._properties then return {} end
local ok, result = pcall(Wd._properties, {"raw", property})
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
-- Raw QID of a QUALIFIER on the current page's own "best" statement of
-- `property` -- e.g. the P1393 ("proxy") qualifier on a P35 statement. Call
-- shape is {"raw", "best", mainProperty, qualifierProperty}; no `eid`, so it
-- defaults to the current page's own entity.
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`) -- e.g. a leader's own P39 ("position held")
-- statements. Uses Wd's plural "properties" command so every matching
-- claim is returned, not just one. `qualifiers` is an optional
-- {qualifierProperty = requiredValue} table to filter by (e.g. P1001
-- "applies to jurisdiction" -- see getWdPositionTitle below).
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
-- QID of the Wikidata item connected to the current page.
local function getCurrentCountryQid()
local ok, id = pcall(mw.wikibase.getEntityIdForCurrentPage)
if ok and id and id ~= "" then return id end
return nil
end
-- Manx genitive form of the current page's own country/territory (e.g.
-- "Vannin" for the Isle of Man, "y Reeriaght Unnaneysit" for the UK), from
-- Module:Enmyn çheerey's table, keyed on the page's own title.
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
-- Section label linked to the country-specific article/redirect when one
-- exists (e.g. "[[Reiltys y Reeriaght Unnaneysit|Reiltys]]" for the UK,
-- "[[Reiltys Vannin|Reiltys]]" for the Isle of Man), else a plain
-- "[[Reiltys]]" when the current page's genitive can't be resolved.
local function getGenitiveLinkedLabel(baseWord)
local genitive = getCurrentCountryGenitive()
if genitive and genitive ~= "" then
return "[[" .. baseWord .. " " .. genitive .. "|" .. baseWord .. "]]"
end
return "[[" .. baseWord .. "]]"
end
-- Titles to leave unshortened even though they'd otherwise match a rung
-- below (e.g. "Çhiarn Vannin" should stay whole, not lose " Vannin").
local shortFormExceptions = {
["Çhiarn Vannin"] = true,
}
-- Strips the country name from an office title for display, e.g. "Monark y
-- Reeriaght Unnaneysit" -> "Monark". Tries, in order: Module:Enmyn
-- çheerey's exact genitive suffix, an explicit " y " split, then a blind
-- last-space split. A title with no space at all is returned unchanged.
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
-- Same idea as shortManxForm, but for a PERSON's name (a shared monarch's
-- own per-realm article, e.g. "Çhalse III y Reeriaght Unnaneysit"). Skips
-- the blind last-space rung, which would wrongly truncate an ordinary name
-- with no country suffix (e.g. "Charse III" -> "Charse").
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 a head-of-state link when it's a per-realm-
-- disambiguated article (see shortenCountrySuffixedName above), leaving the
-- link target and any citation untouched. Handles both a bare "[[target]]"
-- and an already-piped "[[target|display]]" link. Scoped to the head-of-
-- state slot only -- an ordinary head of government is never shared across
-- countries, so this shape of data doesn't arise there.
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 via the content language's own ucfirst
-- (UTF-8/digraph-safe, e.g. "çh") -- not a plain Lua upper() on byte 1.
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
-- Capitalizes the first letter a reader actually sees, even when the value
-- starts with wikilink or ennym-wd external-link markup. Only the very
-- first letter of the whole string is touched -- for a multi-value line
-- joined with commas, only the first item gets capitalized, matching
-- ordinary sentence capitalization. Manual (editor-typed) values are never
-- passed through this.
local function capitalizeFirstLetter(text)
if not text or text == "" then return text end
if text:match("^%[%[") then
local closePos = text:find("%]%]", 3, true)
local pipePos = text:find("|", 1, true)
local splitPos
if pipePos and (not closePos or pipePos < closePos) then
splitPos = pipePos -- piped: capitalize the display half only
else
splitPos = 2 -- unpiped: capitalize just past the leading "[["
end
return text:sub(1, splitPos) .. wikiUcfirst(text:sub(splitPos + 1))
elseif text:match("^%[https?://") then
-- ennym-wd external link: "[url label] <sup>(lang)</sup>" --
-- capitalize the label, right after the URL's own space.
local spacePos = text:find(" ", 2, true)
if spacePos then
return text:sub(1, spacePos) .. wikiUcfirst(text:sub(spacePos + 1))
end
return text
end
return wikiUcfirst(text)
end
-- Builds a wikilink for a Wikidata item: a gv sitelink when one exists,
-- else a gv label (as a redlink), else an ennym-wd external link to
-- Wikidata tagged with its language. Target and display are resolved
-- separately -- the gv label is always preferred for display, even when a
-- sitelink with a different title exists.
--
-- shorten (default true): strip the "role + country" suffix from the
-- display text (see shortManxForm). Pass false for an ordinary proper name
-- with no such structure (a chamber, a calendar concept).
-- capitalize (default true): capitalize a gv label's first letter. Pass
-- false when building one item out of a multi-value list, where only the
-- first item in the finished line should be capitalized by the caller
-- (see capitalizeFirstLetter).
--
-- Returns nil only when neither a sitelink nor a gv label nor an ennym-wd
-- fallback resolves to anything.
local function getWdItemManxLink(qid, shorten, capitalize)
if not qid then return nil end
if capitalize == nil then capitalize = true 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
if capitalize then
gvLabel = wikiUcfirst(gvLabel)
end
else
gvLabel = nil
end
if not sitelinkTitle and not gvLabel then
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
-- Office title from a property set directly on the country (P1906 "office
-- held by head of state" / P1313 "office held by head of government"),
-- when Wikidata records it -- avoids the multi-role ambiguity in
-- getWdPositionTitle below. Tried first.
local function getWdOfficeItemTitle(officeProperty)
local officeQid = getWdRawPropertyId(officeProperty)
if not officeQid then return nil end
return getWdItemManxLink(officeQid)
end
-- Fallback (see getWdOfficeItemTitle above, tried first): the office-
-- holder's own specific title, via their "position held" (P39) statement,
-- for a country with no P1906/P1313 set.
--
-- A head of state/government can hold several simultaneous P39 positions
-- (a shared monarch's several realms, or an MP/party-leader/PM combination),
-- with no reliable qualifier on a fresh statement to say which one is "the"
-- state office. So this collects every current P39 candidate (P1001-
-- jurisdiction-filtered ones first, when present) and uses the first that
-- resolves to a real gv sitelink or label -- in practice the actual office
-- is the one likely to have a gv article, while an ancillary role usually
-- doesn't.
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 "upper house" / "lower house" class items.
local UPPER_HOUSE_QID = "Q637846"
local LOWER_HOUSE_QID = "Q375928"
-- Resolves a bicameral legislature's two chambers via "has part(s)" (P527)
-- + "instance of" (P31) on each part. Only acts when exactly one part is
-- classified as upper and exactly one as lower; a unicameral legislature
-- (no P527 at all) or ambiguous data yields nothing for that side -- the
-- manual |thie_heose=/|thie_heese= override covers the rest. No auto-built
-- citation is attached (only a direct property fetch off the current
-- page's own item can produce one).
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
-- Wikidata's "proleptic Julian calendar" item -- not plain "Julian
-- calendar" (Q11184); a time value's calendar model always points to the
-- proleptic variant.
local JULIAN_CALENDAR_QID = "Q1985786"
-- Wd's own time-value formatting appends " (Joolagh)" to a date recorded on
-- the Julian calendar, but links it (or not) with a blind, unverified
-- wikilink to the hardcoded word "feaillere Yool". This rebuilds that
-- suffix as a real three-tier link (sitelink/label/ennym-wd), keeping Wd's
-- own "Joolagh" wording as the display text. Falls back to plain unlinked
-- "Joolagh" if nothing resolves at all.
local function getJulianCalendarSuffixLink()
local link = getWdItemManxLink(JULIAN_CALENDAR_QID, false)
if link then
local target = link:match("^%[%[([^%[%]|]+)") or link:match("^%[%[([^%[%]|]+)%]%]$")
if target then
return "[[" .. target .. "|Joolagh]]"
end
return link
end
return "Joolagh"
end
-- Row templates: plain 2-cell rows, matching every other submodule
-- (çhengaghyn, balley, bratteeyn). The old template's 3-column grid caused
-- a layout bug when mixed with 2-column rows. Sub-items get a "•" bullet +
-- lighter weight instead of a spacer column.
local ROW = '<tr%s><th style="vertical-align:top; white-space:nowrap; text-align:left; font-weight:bold; padding-left:0.4em; padding-right:0.4em;">%s</th><td style="vertical-align:top; padding-left:0.4em; padding-right:0.4em;">%s</td></tr>'
local SUBROW = '<tr%s><th style="vertical-align:top; white-space:nowrap; text-align:left; font-weight:normal; padding-left:0.9em; padding-right:0.4em;">• %s</th><td style="vertical-align:top; padding-left:0.4em; padding-right:0.4em;">%s</td></tr>'
local HEADER = '<tr class="mergedtoprow"><th colspan="2" style="text-align:left; padding-left:0.4em; padding-right:0.4em;">%s</th></tr>'
-- Builds a class="..." attribute, or an empty string.
local function trClass(name)
if name and name ~= "" then return ' class="' .. name .. '"' end
return ""
end
-- Wraps a section label in [[...]], unless it's already a full wikilink
-- (a manual |sorçh_kionedeeaght=[[target|display]] override) -- otherwise
-- that would double-bracket into a broken [[[[target|display]]]].
local function wikilinkLabel(label)
if not label or label == "" then return label end
if label:find("%[%[") then return label end
return "[[" .. label .. "]]"
end
-- Formats a run of bullet sub-rows with the merged-border classes: every
-- row but the last gets mergedrow, the last gets mergedbottomrow.
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 Module:Kishtey fys çheer uses between submodules, reused
-- here between this module's own sections -- only inserted between two
-- sections that both produced rows.
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)
-- Allow being called as p.main(args) with no frame (used by tests).
if not args then
args = frame
frame = mw.getCurrentFrame()
end
local rows = {}
local govRows = {}
local quaiylRows = {}
local foundingRows = {}
----------------------------------------------------------------
-- 1-2. REILTYS (government type) + leaders (head of state/government,
-- etc.). enmysN_fer-toshee/ennymN_fer-toshee are the old gendered
-- param names; enmys_toshiaghN/ennym_toshiaghN are the gender-neutral
-- synonyms and take priority when both are given.
----------------------------------------------------------------
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: basic form of government (P122), joining every
-- value Wikidata records. Routed through getWdItemManxLink rather
-- than Wd's own "linked" property call -- a P122 value rarely has a
-- gv sitelink, and Wd's own formatting would leak plain, unlinked
-- English otherwise. shorten=false: not a "role + country" phrase.
-- capitalize=false: only the joined line's first letter should be
-- capitalized (below), not every value.
local govTypeQids = getWdRawPropertyIds("P122")
local govTypeParts = {}
for _, qid in ipairs(govTypeQids) do
local link = getWdItemManxLink(qid, false, false)
if link then table.insert(govTypeParts, link) end
end
if #govTypeParts > 0 then
govTypeRaw = capitalizeFirstLetter(table.concat(govTypeParts, ", "))
end
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: head of state (P35) / head of government (P6).
-- Names are always forced into a link via ensureLinked. Value and
-- citation are fetched separately and the citation appended only
-- after the link is built -- see getWdPropertyWithCitation.
local hosBase, hosCitation = getWdPropertyWithCitation("P35", {"linked"})
local hos = shortenLinkedCountryName(ensureLinked(hosBase))
if hos and hosCitation then hos = hos .. hosCitation end
local hogBase, hogCitation = getWdPropertyWithCitation("P6", {"linked"})
local hog = ensureLinked(hogBase)
if hog and hogCitation then hog = hog .. hogCitation end
-- Some countries (US, France, Russia, ...) record the same person
-- as both P35 and P6 -- one office, not two. Skip the head-of-
-- government row when the raw QIDs match, rather than showing it
-- twice.
local hosQid = getWdRawPropertyId("P35")
local hogQid = getWdRawPropertyId("P6")
local sameHeadOfStateAndGovernment = hos and hog and hosQid and hogQid and hosQid == hogQid
if hos then
local hosTitle = getManual(args, {"sorçh_kione_steat"})
or getWdOfficeItemTitle("P1906") -- office held by head of state
or getWdPositionTitle("P35")
or getWikidataPropertyLabel("P35")
or "Kione steat"
table.insert(leaderPairs, {title = hosTitle, name = hos})
-- Head of state's "proxy" (e.g. the Isle of Man's Lieutenant
-- Governor) -- a representative, distinct from a deputy. Shown
-- between the head of state and head of government when
-- Wikidata records one via P1393 (a qualifier on the P35
-- statement, whose value is the office; the current holder is
-- a separate P1308 lookup on that office).
if not isNone(getManual(args, {"ynnydee_kione_steat"})) then
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
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 and not sameHeadOfStateAndGovernment then
local hogTitle = getManual(args, {"sorçh_kione_reiltys"})
or getWdOfficeItemTitle("P1313") -- office held by head of government
or getWdPositionTitle("P6")
or getWikidataPropertyLabel("P6")
or "Kione reiltys"
table.insert(leaderPairs, {title = hogTitle, name = hog})
end
end
local reiltysLabel = getGenitiveLinkedLabel("Reiltys")
if govShown then
local govClass = (#leaderPairs > 0) and "mergedtoprow" or ""
table.insert(govRows, string.format(ROW, trClass(govClass), reiltysLabel, applyRefNote(govTypeRaw, govRef, govNote, frame)))
elseif #leaderPairs > 0 then
table.insert(govRows, string.format(HEADER, reiltysLabel))
end
if #leaderPairs > 0 then
-- Manual ref/note for the whole leaders block is attached to the
-- last row (a Wikidata-sourced name already carries its own).
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.
----------------------------------------------------------------
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"})
local quaiylQid = nil
if not quaiyl then
-- Wd's own "linked" flag leaks a plain, unlinked English label when
-- there's no gv sitelink (e.g. Scotland's P194 leaking "Scottish
-- Parliament"). Chains through the raw QID and getWdItemManxLink
-- instead. QID is kept for getWdChambers below.
quaiylQid = getWdRawPropertyId("P194")
if quaiylQid then
quaiyl = getWdItemManxLink(quaiylQid, false)
end
end
if not quaiylSyrjey or not quaiylInshley then
-- Chamber names, applied independently to whichever side is still
-- unset (an explicit "none" always wins). Chained off the same
-- legislative body as `quaiyl` above.
local legislatureQid = quaiylQid or 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) + establishment
-- events -- manual-only, ported from the old template's numbered
-- slots (1-9). kionedeeaght is a synonym for kiondeeaght.
----------------------------------------------------------------
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
-- taghyrt_bunneeaghtN/date_bunneeaghtN are the new, preferred
-- spellings; taghyrtN_bunnit/dateN_bunnit (old) still work.
local event = getManual(args, {"taghyrt_bunneeaght" .. i, "taghyrt" .. i .. "_bunnit"})
local date = getManual(args, {"date_bunneeaght" .. i, "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), wikilinkLabel(foundingLabel), applyRefNote(foundingValue, foundingRef, foundingNote, frame)))
elseif #establishmentRows > 0 then
local headerLabel = applyRefNote(wikilinkLabel(foundingLabel), foundingRef, foundingNote, frame)
table.insert(foundingRows, string.format(HEADER, headerLabel))
end
appendIndentRun(foundingRows, establishmentRows)
elseif not isNone(getManual(args, {"bunnit"})) then
-- Wikidata fallback: inception (P571), only when the whole
-- establishment block was left unset (not |bunnit=none). Wd already
-- renders a full date when the statement has day precision; a
-- year-only result means Wikidata itself only has year precision.
--
-- A Julian-calendar date gets a literal " (Joolagh)" from Wd,
-- linked (or not) unreliably -- upgraded here to a real three-tier
-- link; everything else about the date is left untouched.
local inception = getWdProperty("P571")
if inception and inception:find(" (Joolagh)", 1, true) then
inception = inception:gsub(" %(Joolagh%)", " (" .. getJulianCalendarSuffixLink() .. ")", 1)
end
if inception then
table.insert(foundingRows, string.format(ROW, "", wikilinkLabel(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
de81uubag4jx7sr1np2oi9ggmv3kb0j
393149
393141
2026-09-13T22:26:24Z
MacTire02
219
+coodagh imraaghyn
393149
Scribunto
text/plain
local p = {}
-- Wikidata fetch/citation module. Used instead of Module:WikidataIB, which
-- has no working citation-building of its own.
local wdOK, Wd = pcall(require, "Module:Wd")
-- Country genitive/mutated name forms (e.g. "Mannin" -> "Vannin", "Nalbin"
-- -> "ny h-Albey"). See getCurrentCountryGenitive/shortManxForm below.
local enmynOK, EnmynCheerey = pcall(require, "Module:Enmyn çheerey")
-- Shared "Manx label, else linked Wikidata fallback" helper -- see its own
-- header comment. Used as the last rung in getWdItemManxLink below.
local ennymWdOK, EnnymWd = pcall(require, "Module:Kishtey fys çheer/ennym-wd")
-- Returns the first non-empty manual parameter from a list of names.
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
-- Wraps a manual |imraa_*= citation in <ref>...</ref>, unless it already
-- contains one or more complete <ref>...</ref> tags of its own -- an editor
-- citing SEVERAL sources for one field has to type them as separate
-- <ref>...</ref> blocks for MediaWiki to number them as separate
-- references (e.g. |imraa_reiltys=<ref>{{cite web|...}}</ref><ref>{{cite
-- web|...}}</ref><ref>{{cite web|...}}</ref>). Blindly wrapping that whole
-- string in ANOTHER outer <ref>...</ref> nests all of them inside one
-- reference tag, so MediaWiki renders just a single bundled numbered note
-- (e.g. "[9]") instead of the several distinct ones the editor wrote --
-- passing an already-<ref>-tagged value through unchanged is what lets each
-- one surface as its own numbered reference.
local function wrapReference(ref)
if not ref or ref == "" then return nil end
if mw.ustring.find(mw.ustring.lower(ref), "<ref", 1, true) then
return ref
end
return "<ref>" .. ref .. "</ref>"
end
-- Appends a manual <ref> and/or {{efn}} note (the imraa_*/noteyn_* params)
-- to a value, on top of any Wikidata-sourced citation it already has.
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 .. wrapReference(ref)
end
return value
end
-- Shared innards of getWdProperty/getWdPropertyWithCitation.
-- includeReference controls whether Wd's "reference" flag is passed.
local function getWdPropertyRaw(property, flags, includeReference)
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
if includeReference then table.insert(callArgs, "reference") end
table.insert(callArgs, "best") -- single best-ranked value
table.insert(callArgs, property)
local ok, result = pcall(Wd._property, callArgs)
if ok and result and result ~= "" then return result end
return nil
end
-- Fetches a Wikidata property value with its auto-built citation already
-- appended. `flags` is an optional array of extra Wd flags (e.g.
-- {"linked"}). Safe only when the result isn't going to be re-wrapped in a
-- fresh "[[...]]" by the caller -- use getWdPropertyWithCitation for that.
local function getWdProperty(property, flags)
return getWdPropertyRaw(property, flags, true)
end
-- Fetches a property's value and its citation as two separate strings.
--
-- Wd's "reference" flag builds the citation via
-- frame:extensionTag("ref", ...), which runs the <ref> tag hook
-- immediately and returns the ALREADY-RENDERED footnote marker (e.g. "[1]",
-- with real "[" "]" characters) -- not literal <ref> wikitext. If a caller
-- then wraps a sitelink-less value in its own "[[...]]" (see ensureLinked),
-- that marker's own "[" breaks the link.
--
-- Fixed by fetching the same property+flags twice (with and without
-- "reference") and diffing the two to isolate the citation, instead of
-- pattern-matching its shape. Returns `value, citation` -- citation is nil
-- when there is none, or when the two calls didn't line up as a clean
-- prefix match (falls back to the combined string in that case).
local function getWdPropertyWithCitation(property, flags)
local base = getWdPropertyRaw(property, flags, false)
if not base then return nil, nil end
local withRef = getWdPropertyRaw(property, flags, true)
if not withRef or withRef == base then return base, nil end
if withRef:sub(1, #base) == base then
local citation = withRef:sub(#base + 1)
if citation ~= "" then return base, citation end
return base, nil
end
return withRef, nil
end
-- Forces a value into a wikilink when Wd's "linked" flag didn't already
-- produce one (no gv sitelink yet), without touching a trailing citation.
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
-- Manx label of a Wikidata PROPERTY itself (e.g. P35 -> "head of state"),
-- used as a title fallback. Uses getLabelByLang(property, "gv")
-- specifically -- plain label()/mw.wikibase.label follows Wikidata's
-- fallback chain and would leak English when no Manx label exists.
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 link/label formatting) of an entity-valued property on the
-- current page's own item -- e.g. P35's value, for chaining into a lookup
-- on that person's own item (see getWdPositionTitle below).
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 the current
-- page's own item (plural version of getWdRawPropertyId above) -- e.g.
-- every P122 ("basic form of government") statement.
local function getWdRawPropertyIds(property)
if not wdOK or not Wd or not Wd._properties then return {} end
local ok, result = pcall(Wd._properties, {"raw", property})
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
-- Raw QID of a QUALIFIER on the current page's own "best" statement of
-- `property` -- e.g. the P1393 ("proxy") qualifier on a P35 statement. Call
-- shape is {"raw", "best", mainProperty, qualifierProperty}; no `eid`, so it
-- defaults to the current page's own entity.
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`) -- e.g. a leader's own P39 ("position held")
-- statements. Uses Wd's plural "properties" command so every matching
-- claim is returned, not just one. `qualifiers` is an optional
-- {qualifierProperty = requiredValue} table to filter by (e.g. P1001
-- "applies to jurisdiction" -- see getWdPositionTitle below).
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
-- QID of the Wikidata item connected to the current page.
local function getCurrentCountryQid()
local ok, id = pcall(mw.wikibase.getEntityIdForCurrentPage)
if ok and id and id ~= "" then return id end
return nil
end
-- Manx genitive form of the current page's own country/territory (e.g.
-- "Vannin" for the Isle of Man, "y Reeriaght Unnaneysit" for the UK), from
-- Module:Enmyn çheerey's table, keyed on the page's own title.
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
-- Section label linked to the country-specific article/redirect when one
-- exists (e.g. "[[Reiltys y Reeriaght Unnaneysit|Reiltys]]" for the UK,
-- "[[Reiltys Vannin|Reiltys]]" for the Isle of Man), else a plain
-- "[[Reiltys]]" when the current page's genitive can't be resolved.
local function getGenitiveLinkedLabel(baseWord)
local genitive = getCurrentCountryGenitive()
if genitive and genitive ~= "" then
return "[[" .. baseWord .. " " .. genitive .. "|" .. baseWord .. "]]"
end
return "[[" .. baseWord .. "]]"
end
-- Titles to leave unshortened even though they'd otherwise match a rung
-- below (e.g. "Çhiarn Vannin" should stay whole, not lose " Vannin").
local shortFormExceptions = {
["Çhiarn Vannin"] = true,
}
-- Strips the country name from an office title for display, e.g. "Monark y
-- Reeriaght Unnaneysit" -> "Monark". Tries, in order: Module:Enmyn
-- çheerey's exact genitive suffix, an explicit " y " split, then a blind
-- last-space split. A title with no space at all is returned unchanged.
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
-- Same idea as shortManxForm, but for a PERSON's name (a shared monarch's
-- own per-realm article, e.g. "Çhalse III y Reeriaght Unnaneysit"). Skips
-- the blind last-space rung, which would wrongly truncate an ordinary name
-- with no country suffix (e.g. "Charse III" -> "Charse").
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 a head-of-state link when it's a per-realm-
-- disambiguated article (see shortenCountrySuffixedName above), leaving the
-- link target and any citation untouched. Handles both a bare "[[target]]"
-- and an already-piped "[[target|display]]" link. Scoped to the head-of-
-- state slot only -- an ordinary head of government is never shared across
-- countries, so this shape of data doesn't arise there.
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 via the content language's own ucfirst
-- (UTF-8/digraph-safe, e.g. "çh") -- not a plain Lua upper() on byte 1.
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
-- Capitalizes the first letter a reader actually sees, even when the value
-- starts with wikilink or ennym-wd external-link markup. Only the very
-- first letter of the whole string is touched -- for a multi-value line
-- joined with commas, only the first item gets capitalized, matching
-- ordinary sentence capitalization. Manual (editor-typed) values are never
-- passed through this.
local function capitalizeFirstLetter(text)
if not text or text == "" then return text end
if text:match("^%[%[") then
local closePos = text:find("%]%]", 3, true)
local pipePos = text:find("|", 1, true)
local splitPos
if pipePos and (not closePos or pipePos < closePos) then
splitPos = pipePos -- piped: capitalize the display half only
else
splitPos = 2 -- unpiped: capitalize just past the leading "[["
end
return text:sub(1, splitPos) .. wikiUcfirst(text:sub(splitPos + 1))
elseif text:match("^%[https?://") then
-- ennym-wd external link: "[url label] <sup>(lang)</sup>" --
-- capitalize the label, right after the URL's own space.
local spacePos = text:find(" ", 2, true)
if spacePos then
return text:sub(1, spacePos) .. wikiUcfirst(text:sub(spacePos + 1))
end
return text
end
return wikiUcfirst(text)
end
-- Builds a wikilink for a Wikidata item: a gv sitelink when one exists,
-- else a gv label (as a redlink), else an ennym-wd external link to
-- Wikidata tagged with its language. Target and display are resolved
-- separately -- the gv label is always preferred for display, even when a
-- sitelink with a different title exists.
--
-- shorten (default true): strip the "role + country" suffix from the
-- display text (see shortManxForm). Pass false for an ordinary proper name
-- with no such structure (a chamber, a calendar concept).
-- capitalize (default true): capitalize a gv label's first letter. Pass
-- false when building one item out of a multi-value list, where only the
-- first item in the finished line should be capitalized by the caller
-- (see capitalizeFirstLetter).
--
-- Returns nil only when neither a sitelink nor a gv label nor an ennym-wd
-- fallback resolves to anything.
local function getWdItemManxLink(qid, shorten, capitalize)
if not qid then return nil end
if capitalize == nil then capitalize = true 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
if capitalize then
gvLabel = wikiUcfirst(gvLabel)
end
else
gvLabel = nil
end
if not sitelinkTitle and not gvLabel then
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
-- Office title from a property set directly on the country (P1906 "office
-- held by head of state" / P1313 "office held by head of government"),
-- when Wikidata records it -- avoids the multi-role ambiguity in
-- getWdPositionTitle below. Tried first.
local function getWdOfficeItemTitle(officeProperty)
local officeQid = getWdRawPropertyId(officeProperty)
if not officeQid then return nil end
return getWdItemManxLink(officeQid)
end
-- Fallback (see getWdOfficeItemTitle above, tried first): the office-
-- holder's own specific title, via their "position held" (P39) statement,
-- for a country with no P1906/P1313 set.
--
-- A head of state/government can hold several simultaneous P39 positions
-- (a shared monarch's several realms, or an MP/party-leader/PM combination),
-- with no reliable qualifier on a fresh statement to say which one is "the"
-- state office. So this collects every current P39 candidate (P1001-
-- jurisdiction-filtered ones first, when present) and uses the first that
-- resolves to a real gv sitelink or label -- in practice the actual office
-- is the one likely to have a gv article, while an ancillary role usually
-- doesn't.
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 "upper house" / "lower house" class items.
local UPPER_HOUSE_QID = "Q637846"
local LOWER_HOUSE_QID = "Q375928"
-- Resolves a bicameral legislature's two chambers via "has part(s)" (P527)
-- + "instance of" (P31) on each part. Only acts when exactly one part is
-- classified as upper and exactly one as lower; a unicameral legislature
-- (no P527 at all) or ambiguous data yields nothing for that side -- the
-- manual |thie_heose=/|thie_heese= override covers the rest. No auto-built
-- citation is attached (only a direct property fetch off the current
-- page's own item can produce one).
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
-- Wikidata's "proleptic Julian calendar" item -- not plain "Julian
-- calendar" (Q11184); a time value's calendar model always points to the
-- proleptic variant.
local JULIAN_CALENDAR_QID = "Q1985786"
-- Wd's own time-value formatting appends " (Joolagh)" to a date recorded on
-- the Julian calendar, but links it (or not) with a blind, unverified
-- wikilink to the hardcoded word "feaillere Yool". This rebuilds that
-- suffix as a real three-tier link (sitelink/label/ennym-wd), keeping Wd's
-- own "Joolagh" wording as the display text. Falls back to plain unlinked
-- "Joolagh" if nothing resolves at all.
local function getJulianCalendarSuffixLink()
local link = getWdItemManxLink(JULIAN_CALENDAR_QID, false)
if link then
local target = link:match("^%[%[([^%[%]|]+)") or link:match("^%[%[([^%[%]|]+)%]%]$")
if target then
return "[[" .. target .. "|Joolagh]]"
end
return link
end
return "Joolagh"
end
-- Row templates: plain 2-cell rows, matching every other submodule
-- (çhengaghyn, balley, bratteeyn). The old template's 3-column grid caused
-- a layout bug when mixed with 2-column rows. Sub-items get a "•" bullet +
-- lighter weight instead of a spacer column.
local ROW = '<tr%s><th style="vertical-align:top; white-space:nowrap; text-align:left; font-weight:bold; padding-left:0.4em; padding-right:0.4em;">%s</th><td style="vertical-align:top; padding-left:0.4em; padding-right:0.4em;">%s</td></tr>'
local SUBROW = '<tr%s><th style="vertical-align:top; white-space:nowrap; text-align:left; font-weight:normal; padding-left:0.9em; padding-right:0.4em;">• %s</th><td style="vertical-align:top; padding-left:0.4em; padding-right:0.4em;">%s</td></tr>'
local HEADER = '<tr class="mergedtoprow"><th colspan="2" style="text-align:left; padding-left:0.4em; padding-right:0.4em;">%s</th></tr>'
-- Builds a class="..." attribute, or an empty string.
local function trClass(name)
if name and name ~= "" then return ' class="' .. name .. '"' end
return ""
end
-- Wraps a section label in [[...]], unless it's already a full wikilink
-- (a manual |sorçh_kionedeeaght=[[target|display]] override) -- otherwise
-- that would double-bracket into a broken [[[[target|display]]]].
local function wikilinkLabel(label)
if not label or label == "" then return label end
if label:find("%[%[") then return label end
return "[[" .. label .. "]]"
end
-- Formats a run of bullet sub-rows with the merged-border classes: every
-- row but the last gets mergedrow, the last gets mergedbottomrow.
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 Module:Kishtey fys çheer uses between submodules, reused
-- here between this module's own sections -- only inserted between two
-- sections that both produced rows.
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)
-- Allow being called as p.main(args) with no frame (used by tests).
if not args then
args = frame
frame = mw.getCurrentFrame()
end
local rows = {}
local govRows = {}
local quaiylRows = {}
local foundingRows = {}
----------------------------------------------------------------
-- 1-2. REILTYS (government type) + leaders (head of state/government,
-- etc.). enmysN_fer-toshee/ennymN_fer-toshee are the old gendered
-- param names; enmys_toshiaghN/ennym_toshiaghN are the gender-neutral
-- synonyms and take priority when both are given.
----------------------------------------------------------------
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: basic form of government (P122), joining every
-- value Wikidata records. Routed through getWdItemManxLink rather
-- than Wd's own "linked" property call -- a P122 value rarely has a
-- gv sitelink, and Wd's own formatting would leak plain, unlinked
-- English otherwise. shorten=false: not a "role + country" phrase.
-- capitalize=false: only the joined line's first letter should be
-- capitalized (below), not every value.
local govTypeQids = getWdRawPropertyIds("P122")
local govTypeParts = {}
for _, qid in ipairs(govTypeQids) do
local link = getWdItemManxLink(qid, false, false)
if link then table.insert(govTypeParts, link) end
end
if #govTypeParts > 0 then
govTypeRaw = capitalizeFirstLetter(table.concat(govTypeParts, ", "))
end
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: head of state (P35) / head of government (P6).
-- Names are always forced into a link via ensureLinked. Value and
-- citation are fetched separately and the citation appended only
-- after the link is built -- see getWdPropertyWithCitation.
local hosBase, hosCitation = getWdPropertyWithCitation("P35", {"linked"})
local hos = shortenLinkedCountryName(ensureLinked(hosBase))
if hos and hosCitation then hos = hos .. hosCitation end
local hogBase, hogCitation = getWdPropertyWithCitation("P6", {"linked"})
local hog = ensureLinked(hogBase)
if hog and hogCitation then hog = hog .. hogCitation end
-- Some countries (US, France, Russia, ...) record the same person
-- as both P35 and P6 -- one office, not two. Skip the head-of-
-- government row when the raw QIDs match, rather than showing it
-- twice.
local hosQid = getWdRawPropertyId("P35")
local hogQid = getWdRawPropertyId("P6")
local sameHeadOfStateAndGovernment = hos and hog and hosQid and hogQid and hosQid == hogQid
if hos then
local hosTitle = getManual(args, {"sorçh_kione_steat"})
or getWdOfficeItemTitle("P1906") -- office held by head of state
or getWdPositionTitle("P35")
or getWikidataPropertyLabel("P35")
or "Kione steat"
table.insert(leaderPairs, {title = hosTitle, name = hos})
-- Head of state's "proxy" (e.g. the Isle of Man's Lieutenant
-- Governor) -- a representative, distinct from a deputy. Shown
-- between the head of state and head of government when
-- Wikidata records one via P1393 (a qualifier on the P35
-- statement, whose value is the office; the current holder is
-- a separate P1308 lookup on that office).
if not isNone(getManual(args, {"ynnydee_kione_steat"})) then
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
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 and not sameHeadOfStateAndGovernment then
local hogTitle = getManual(args, {"sorçh_kione_reiltys"})
or getWdOfficeItemTitle("P1313") -- office held by head of government
or getWdPositionTitle("P6")
or getWikidataPropertyLabel("P6")
or "Kione reiltys"
table.insert(leaderPairs, {title = hogTitle, name = hog})
end
end
local reiltysLabel = getGenitiveLinkedLabel("Reiltys")
if govShown then
local govClass = (#leaderPairs > 0) and "mergedtoprow" or ""
table.insert(govRows, string.format(ROW, trClass(govClass), reiltysLabel, applyRefNote(govTypeRaw, govRef, govNote, frame)))
elseif #leaderPairs > 0 then
table.insert(govRows, string.format(HEADER, reiltysLabel))
end
if #leaderPairs > 0 then
-- Manual ref/note for the whole leaders block is attached to the
-- last row (a Wikidata-sourced name already carries its own).
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.
----------------------------------------------------------------
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"})
local quaiylQid = nil
if not quaiyl then
-- Wd's own "linked" flag leaks a plain, unlinked English label when
-- there's no gv sitelink (e.g. Scotland's P194 leaking "Scottish
-- Parliament"). Chains through the raw QID and getWdItemManxLink
-- instead. QID is kept for getWdChambers below.
quaiylQid = getWdRawPropertyId("P194")
if quaiylQid then
quaiyl = getWdItemManxLink(quaiylQid, false)
end
end
if not quaiylSyrjey or not quaiylInshley then
-- Chamber names, applied independently to whichever side is still
-- unset (an explicit "none" always wins). Chained off the same
-- legislative body as `quaiyl` above.
local legislatureQid = quaiylQid or 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) + establishment
-- events -- manual-only, ported from the old template's numbered
-- slots (1-9). kionedeeaght is a synonym for kiondeeaght.
----------------------------------------------------------------
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
-- taghyrt_bunneeaghtN/date_bunneeaghtN are the new, preferred
-- spellings; taghyrtN_bunnit/dateN_bunnit (old) still work.
local event = getManual(args, {"taghyrt_bunneeaght" .. i, "taghyrt" .. i .. "_bunnit"})
local date = getManual(args, {"date_bunneeaght" .. i, "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), wikilinkLabel(foundingLabel), applyRefNote(foundingValue, foundingRef, foundingNote, frame)))
elseif #establishmentRows > 0 then
local headerLabel = applyRefNote(wikilinkLabel(foundingLabel), foundingRef, foundingNote, frame)
table.insert(foundingRows, string.format(HEADER, headerLabel))
end
appendIndentRun(foundingRows, establishmentRows)
elseif not isNone(getManual(args, {"bunnit"})) then
-- Wikidata fallback: inception (P571), only when the whole
-- establishment block was left unset (not |bunnit=none). Wd already
-- renders a full date when the statement has day precision; a
-- year-only result means Wikidata itself only has year precision.
--
-- A Julian-calendar date gets a literal " (Joolagh)" from Wd,
-- linked (or not) unreliably -- upgraded here to a real three-tier
-- link; everything else about the date is left untouched.
local inception = getWdProperty("P571")
if inception and inception:find(" (Joolagh)", 1, true) then
inception = inception:gsub(" %(Joolagh%)", " (" .. getJulianCalendarSuffixLink() .. ")", 1)
end
if inception then
table.insert(foundingRows, string.format(ROW, "", wikilinkLabel(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
e9gac2gav9qcvja86k3tg47rw2xfya7
393156
393149
2026-09-13T23:07:19Z
MacTire02
219
++
393156
Scribunto
text/plain
local p = {}
-- Wikidata fetch/citation module. Used instead of Module:WikidataIB, which
-- has no working citation-building of its own.
local wdOK, Wd = pcall(require, "Module:Wd")
-- Country genitive/mutated name forms (e.g. "Mannin" -> "Vannin", "Nalbin"
-- -> "ny h-Albey"). See getCurrentCountryGenitive/shortManxForm below.
local enmynOK, EnmynCheerey = pcall(require, "Module:Enmyn çheerey")
-- Shared "Manx label, else linked Wikidata fallback" helper -- see its own
-- header comment. Used as the last rung in getWdItemManxLink below.
local ennymWdOK, EnnymWd = pcall(require, "Module:Kishtey fys çheer/ennym-wd")
-- Returns the first non-empty manual parameter from a list of names.
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
-- Wraps a manual |imraa_*= citation in <ref>...</ref>, unless it's already
-- a rendered <ref> footnote marker (or several concatenated), e.g. "[6]" or
-- "[6][7][8][9]".
--
-- Scribunto expands a literal <ref>...</ref> tag typed inside a template
-- parameter THE MOMENT frame.args is accessed -- by the time this module
-- ever sees the value, |imraa_reiltys=<ref>{{cite web|...}}</ref><ref>{{cite
-- web|...}}</ref><ref>{{cite web|...}}</ref><ref>{{cite web|...}}</ref> has
-- ALREADY been replaced by MediaWiki with the four rendered footnote
-- markers "[6][7][8][9]" -- not literal "<ref>" wikitext. The citations
-- themselves are already fully registered and already appear correctly in
-- the References list at that point. Wrapping that already-rendered marker
-- text in ANOTHER fresh <ref>...</ref> creates a brand-new <ref> tag (never
-- seen by that earlier expansion pass) whose own content is just the
-- marker text -- producing a bogus extra numbered reference whose
-- "citation" is literally "[6][7][8][9]".
--
-- So: a value that is ENTIRELY one or more "[digits]" marker groups is
-- already fully rendered and must be passed through untouched. A value
-- that still literally contains "<ref" is also passed through unchanged,
-- as a defensive fallback in case raw wikitext ever does reach here.
-- Anything else -- bare citation prose/wikitext with no <ref> tags at all
-- -- still gets wrapped in a fresh <ref>...</ref> for convenience.
local function wrapReference(ref)
if not ref or ref == "" then return nil end
if mw.ustring.find(mw.ustring.lower(ref), "<ref", 1, true) then
return ref
end
local withoutMarkers = mw.ustring.gsub(ref, "%[%d+%]", "")
if mw.ustring.gsub(withoutMarkers, "%s", "") == "" then
return ref
end
return "<ref>" .. ref .. "</ref>"
end
-- Appends a manual <ref> and/or {{efn}} note (the imraa_*/noteyn_* params)
-- to a value, on top of any Wikidata-sourced citation it already has.
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 .. wrapReference(ref)
end
return value
end
-- Shared innards of getWdProperty/getWdPropertyWithCitation.
-- includeReference controls whether Wd's "reference" flag is passed.
local function getWdPropertyRaw(property, flags, includeReference)
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
if includeReference then table.insert(callArgs, "reference") end
table.insert(callArgs, "best") -- single best-ranked value
table.insert(callArgs, property)
local ok, result = pcall(Wd._property, callArgs)
if ok and result and result ~= "" then return result end
return nil
end
-- Fetches a Wikidata property value with its auto-built citation already
-- appended. `flags` is an optional array of extra Wd flags (e.g.
-- {"linked"}). Safe only when the result isn't going to be re-wrapped in a
-- fresh "[[...]]" by the caller -- use getWdPropertyWithCitation for that.
local function getWdProperty(property, flags)
return getWdPropertyRaw(property, flags, true)
end
-- Fetches a property's value and its citation as two separate strings.
--
-- Wd's "reference" flag builds the citation via
-- frame:extensionTag("ref", ...), which runs the <ref> tag hook
-- immediately and returns the ALREADY-RENDERED footnote marker (e.g. "[1]",
-- with real "[" "]" characters) -- not literal <ref> wikitext. If a caller
-- then wraps a sitelink-less value in its own "[[...]]" (see ensureLinked),
-- that marker's own "[" breaks the link.
--
-- Fixed by fetching the same property+flags twice (with and without
-- "reference") and diffing the two to isolate the citation, instead of
-- pattern-matching its shape. Returns `value, citation` -- citation is nil
-- when there is none, or when the two calls didn't line up as a clean
-- prefix match (falls back to the combined string in that case).
local function getWdPropertyWithCitation(property, flags)
local base = getWdPropertyRaw(property, flags, false)
if not base then return nil, nil end
local withRef = getWdPropertyRaw(property, flags, true)
if not withRef or withRef == base then return base, nil end
if withRef:sub(1, #base) == base then
local citation = withRef:sub(#base + 1)
if citation ~= "" then return base, citation end
return base, nil
end
return withRef, nil
end
-- Forces a value into a wikilink when Wd's "linked" flag didn't already
-- produce one (no gv sitelink yet), without touching a trailing citation.
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
-- Manx label of a Wikidata PROPERTY itself (e.g. P35 -> "head of state"),
-- used as a title fallback. Uses getLabelByLang(property, "gv")
-- specifically -- plain label()/mw.wikibase.label follows Wikidata's
-- fallback chain and would leak English when no Manx label exists.
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 link/label formatting) of an entity-valued property on the
-- current page's own item -- e.g. P35's value, for chaining into a lookup
-- on that person's own item (see getWdPositionTitle below).
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 the current
-- page's own item (plural version of getWdRawPropertyId above) -- e.g.
-- every P122 ("basic form of government") statement.
local function getWdRawPropertyIds(property)
if not wdOK or not Wd or not Wd._properties then return {} end
local ok, result = pcall(Wd._properties, {"raw", property})
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
-- Raw QID of a QUALIFIER on the current page's own "best" statement of
-- `property` -- e.g. the P1393 ("proxy") qualifier on a P35 statement. Call
-- shape is {"raw", "best", mainProperty, qualifierProperty}; no `eid`, so it
-- defaults to the current page's own entity.
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`) -- e.g. a leader's own P39 ("position held")
-- statements. Uses Wd's plural "properties" command so every matching
-- claim is returned, not just one. `qualifiers` is an optional
-- {qualifierProperty = requiredValue} table to filter by (e.g. P1001
-- "applies to jurisdiction" -- see getWdPositionTitle below).
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
-- QID of the Wikidata item connected to the current page.
local function getCurrentCountryQid()
local ok, id = pcall(mw.wikibase.getEntityIdForCurrentPage)
if ok and id and id ~= "" then return id end
return nil
end
-- Manx genitive form of the current page's own country/territory (e.g.
-- "Vannin" for the Isle of Man, "y Reeriaght Unnaneysit" for the UK), from
-- Module:Enmyn çheerey's table, keyed on the page's own title.
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
-- Section label linked to the country-specific article/redirect when one
-- exists (e.g. "[[Reiltys y Reeriaght Unnaneysit|Reiltys]]" for the UK,
-- "[[Reiltys Vannin|Reiltys]]" for the Isle of Man), else a plain
-- "[[Reiltys]]" when the current page's genitive can't be resolved.
local function getGenitiveLinkedLabel(baseWord)
local genitive = getCurrentCountryGenitive()
if genitive and genitive ~= "" then
return "[[" .. baseWord .. " " .. genitive .. "|" .. baseWord .. "]]"
end
return "[[" .. baseWord .. "]]"
end
-- Titles to leave unshortened even though they'd otherwise match a rung
-- below (e.g. "Çhiarn Vannin" should stay whole, not lose " Vannin").
local shortFormExceptions = {
["Çhiarn Vannin"] = true,
}
-- Strips the country name from an office title for display, e.g. "Monark y
-- Reeriaght Unnaneysit" -> "Monark". Tries, in order: Module:Enmyn
-- çheerey's exact genitive suffix, an explicit " y " split, then a blind
-- last-space split. A title with no space at all is returned unchanged.
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
-- Same idea as shortManxForm, but for a PERSON's name (a shared monarch's
-- own per-realm article, e.g. "Çhalse III y Reeriaght Unnaneysit"). Skips
-- the blind last-space rung, which would wrongly truncate an ordinary name
-- with no country suffix (e.g. "Charse III" -> "Charse").
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 a head-of-state link when it's a per-realm-
-- disambiguated article (see shortenCountrySuffixedName above), leaving the
-- link target and any citation untouched. Handles both a bare "[[target]]"
-- and an already-piped "[[target|display]]" link. Scoped to the head-of-
-- state slot only -- an ordinary head of government is never shared across
-- countries, so this shape of data doesn't arise there.
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 via the content language's own ucfirst
-- (UTF-8/digraph-safe, e.g. "çh") -- not a plain Lua upper() on byte 1.
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
-- Capitalizes the first letter a reader actually sees, even when the value
-- starts with wikilink or ennym-wd external-link markup. Only the very
-- first letter of the whole string is touched -- for a multi-value line
-- joined with commas, only the first item gets capitalized, matching
-- ordinary sentence capitalization. Manual (editor-typed) values are never
-- passed through this.
local function capitalizeFirstLetter(text)
if not text or text == "" then return text end
if text:match("^%[%[") then
local closePos = text:find("%]%]", 3, true)
local pipePos = text:find("|", 1, true)
local splitPos
if pipePos and (not closePos or pipePos < closePos) then
splitPos = pipePos -- piped: capitalize the display half only
else
splitPos = 2 -- unpiped: capitalize just past the leading "[["
end
return text:sub(1, splitPos) .. wikiUcfirst(text:sub(splitPos + 1))
elseif text:match("^%[https?://") then
-- ennym-wd external link: "[url label] <sup>(lang)</sup>" --
-- capitalize the label, right after the URL's own space.
local spacePos = text:find(" ", 2, true)
if spacePos then
return text:sub(1, spacePos) .. wikiUcfirst(text:sub(spacePos + 1))
end
return text
end
return wikiUcfirst(text)
end
-- Builds a wikilink for a Wikidata item: a gv sitelink when one exists,
-- else a gv label (as a redlink), else an ennym-wd external link to
-- Wikidata tagged with its language. Target and display are resolved
-- separately -- the gv label is always preferred for display, even when a
-- sitelink with a different title exists.
--
-- shorten (default true): strip the "role + country" suffix from the
-- display text (see shortManxForm). Pass false for an ordinary proper name
-- with no such structure (a chamber, a calendar concept).
-- capitalize (default true): capitalize a gv label's first letter. Pass
-- false when building one item out of a multi-value list, where only the
-- first item in the finished line should be capitalized by the caller
-- (see capitalizeFirstLetter).
--
-- Returns nil only when neither a sitelink nor a gv label nor an ennym-wd
-- fallback resolves to anything.
local function getWdItemManxLink(qid, shorten, capitalize)
if not qid then return nil end
if capitalize == nil then capitalize = true 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
if capitalize then
gvLabel = wikiUcfirst(gvLabel)
end
else
gvLabel = nil
end
if not sitelinkTitle and not gvLabel then
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
-- Office title from a property set directly on the country (P1906 "office
-- held by head of state" / P1313 "office held by head of government"),
-- when Wikidata records it -- avoids the multi-role ambiguity in
-- getWdPositionTitle below. Tried first.
local function getWdOfficeItemTitle(officeProperty)
local officeQid = getWdRawPropertyId(officeProperty)
if not officeQid then return nil end
return getWdItemManxLink(officeQid)
end
-- Fallback (see getWdOfficeItemTitle above, tried first): the office-
-- holder's own specific title, via their "position held" (P39) statement,
-- for a country with no P1906/P1313 set.
--
-- A head of state/government can hold several simultaneous P39 positions
-- (a shared monarch's several realms, or an MP/party-leader/PM combination),
-- with no reliable qualifier on a fresh statement to say which one is "the"
-- state office. So this collects every current P39 candidate (P1001-
-- jurisdiction-filtered ones first, when present) and uses the first that
-- resolves to a real gv sitelink or label -- in practice the actual office
-- is the one likely to have a gv article, while an ancillary role usually
-- doesn't.
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 "upper house" / "lower house" class items.
local UPPER_HOUSE_QID = "Q637846"
local LOWER_HOUSE_QID = "Q375928"
-- Resolves a bicameral legislature's two chambers via "has part(s)" (P527)
-- + "instance of" (P31) on each part. Only acts when exactly one part is
-- classified as upper and exactly one as lower; a unicameral legislature
-- (no P527 at all) or ambiguous data yields nothing for that side -- the
-- manual |thie_heose=/|thie_heese= override covers the rest. No auto-built
-- citation is attached (only a direct property fetch off the current
-- page's own item can produce one).
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
-- Wikidata's "proleptic Julian calendar" item -- not plain "Julian
-- calendar" (Q11184); a time value's calendar model always points to the
-- proleptic variant.
local JULIAN_CALENDAR_QID = "Q1985786"
-- Wd's own time-value formatting appends " (Joolagh)" to a date recorded on
-- the Julian calendar, but links it (or not) with a blind, unverified
-- wikilink to the hardcoded word "feaillere Yool". This rebuilds that
-- suffix as a real three-tier link (sitelink/label/ennym-wd), keeping Wd's
-- own "Joolagh" wording as the display text. Falls back to plain unlinked
-- "Joolagh" if nothing resolves at all.
local function getJulianCalendarSuffixLink()
local link = getWdItemManxLink(JULIAN_CALENDAR_QID, false)
if link then
local target = link:match("^%[%[([^%[%]|]+)") or link:match("^%[%[([^%[%]|]+)%]%]$")
if target then
return "[[" .. target .. "|Joolagh]]"
end
return link
end
return "Joolagh"
end
-- Row templates: plain 2-cell rows, matching every other submodule
-- (çhengaghyn, balley, bratteeyn). The old template's 3-column grid caused
-- a layout bug when mixed with 2-column rows. Sub-items get a "•" bullet +
-- lighter weight instead of a spacer column.
local ROW = '<tr%s><th style="vertical-align:top; white-space:nowrap; text-align:left; font-weight:bold; padding-left:0.4em; padding-right:0.4em;">%s</th><td style="vertical-align:top; padding-left:0.4em; padding-right:0.4em;">%s</td></tr>'
local SUBROW = '<tr%s><th style="vertical-align:top; white-space:nowrap; text-align:left; font-weight:normal; padding-left:0.9em; padding-right:0.4em;">• %s</th><td style="vertical-align:top; padding-left:0.4em; padding-right:0.4em;">%s</td></tr>'
local HEADER = '<tr class="mergedtoprow"><th colspan="2" style="text-align:left; padding-left:0.4em; padding-right:0.4em;">%s</th></tr>'
-- Builds a class="..." attribute, or an empty string.
local function trClass(name)
if name and name ~= "" then return ' class="' .. name .. '"' end
return ""
end
-- Wraps a section label in [[...]], unless it's already a full wikilink
-- (a manual |sorçh_kionedeeaght=[[target|display]] override) -- otherwise
-- that would double-bracket into a broken [[[[target|display]]]].
local function wikilinkLabel(label)
if not label or label == "" then return label end
if label:find("%[%[") then return label end
return "[[" .. label .. "]]"
end
-- Formats a run of bullet sub-rows with the merged-border classes: every
-- row but the last gets mergedrow, the last gets mergedbottomrow.
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 Module:Kishtey fys çheer uses between submodules, reused
-- here between this module's own sections -- only inserted between two
-- sections that both produced rows.
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)
-- Allow being called as p.main(args) with no frame (used by tests).
if not args then
args = frame
frame = mw.getCurrentFrame()
end
local rows = {}
local govRows = {}
local quaiylRows = {}
local foundingRows = {}
----------------------------------------------------------------
-- 1-2. REILTYS (government type) + leaders (head of state/government,
-- etc.). enmysN_fer-toshee/ennymN_fer-toshee are the old gendered
-- param names; enmys_toshiaghN/ennym_toshiaghN are the gender-neutral
-- synonyms and take priority when both are given.
----------------------------------------------------------------
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: basic form of government (P122), joining every
-- value Wikidata records. Routed through getWdItemManxLink rather
-- than Wd's own "linked" property call -- a P122 value rarely has a
-- gv sitelink, and Wd's own formatting would leak plain, unlinked
-- English otherwise. shorten=false: not a "role + country" phrase.
-- capitalize=false: only the joined line's first letter should be
-- capitalized (below), not every value.
local govTypeQids = getWdRawPropertyIds("P122")
local govTypeParts = {}
for _, qid in ipairs(govTypeQids) do
local link = getWdItemManxLink(qid, false, false)
if link then table.insert(govTypeParts, link) end
end
if #govTypeParts > 0 then
govTypeRaw = capitalizeFirstLetter(table.concat(govTypeParts, ", "))
end
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: head of state (P35) / head of government (P6).
-- Names are always forced into a link via ensureLinked. Value and
-- citation are fetched separately and the citation appended only
-- after the link is built -- see getWdPropertyWithCitation.
local hosBase, hosCitation = getWdPropertyWithCitation("P35", {"linked"})
local hos = shortenLinkedCountryName(ensureLinked(hosBase))
if hos and hosCitation then hos = hos .. hosCitation end
local hogBase, hogCitation = getWdPropertyWithCitation("P6", {"linked"})
local hog = ensureLinked(hogBase)
if hog and hogCitation then hog = hog .. hogCitation end
-- Some countries (US, France, Russia, ...) record the same person
-- as both P35 and P6 -- one office, not two. Skip the head-of-
-- government row when the raw QIDs match, rather than showing it
-- twice.
local hosQid = getWdRawPropertyId("P35")
local hogQid = getWdRawPropertyId("P6")
local sameHeadOfStateAndGovernment = hos and hog and hosQid and hogQid and hosQid == hogQid
if hos then
local hosTitle = getManual(args, {"sorçh_kione_steat"})
or getWdOfficeItemTitle("P1906") -- office held by head of state
or getWdPositionTitle("P35")
or getWikidataPropertyLabel("P35")
or "Kione steat"
table.insert(leaderPairs, {title = hosTitle, name = hos})
-- Head of state's "proxy" (e.g. the Isle of Man's Lieutenant
-- Governor) -- a representative, distinct from a deputy. Shown
-- between the head of state and head of government when
-- Wikidata records one via P1393 (a qualifier on the P35
-- statement, whose value is the office; the current holder is
-- a separate P1308 lookup on that office).
if not isNone(getManual(args, {"ynnydee_kione_steat"})) then
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
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 and not sameHeadOfStateAndGovernment then
local hogTitle = getManual(args, {"sorçh_kione_reiltys"})
or getWdOfficeItemTitle("P1313") -- office held by head of government
or getWdPositionTitle("P6")
or getWikidataPropertyLabel("P6")
or "Kione reiltys"
table.insert(leaderPairs, {title = hogTitle, name = hog})
end
end
local reiltysLabel = getGenitiveLinkedLabel("Reiltys")
if govShown then
local govClass = (#leaderPairs > 0) and "mergedtoprow" or ""
table.insert(govRows, string.format(ROW, trClass(govClass), reiltysLabel, applyRefNote(govTypeRaw, govRef, govNote, frame)))
elseif #leaderPairs > 0 then
table.insert(govRows, string.format(HEADER, reiltysLabel))
end
if #leaderPairs > 0 then
-- Manual ref/note for the whole leaders block is attached to the
-- last row (a Wikidata-sourced name already carries its own).
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.
----------------------------------------------------------------
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"})
local quaiylQid = nil
if not quaiyl then
-- Wd's own "linked" flag leaks a plain, unlinked English label when
-- there's no gv sitelink (e.g. Scotland's P194 leaking "Scottish
-- Parliament"). Chains through the raw QID and getWdItemManxLink
-- instead. QID is kept for getWdChambers below.
quaiylQid = getWdRawPropertyId("P194")
if quaiylQid then
quaiyl = getWdItemManxLink(quaiylQid, false)
end
end
if not quaiylSyrjey or not quaiylInshley then
-- Chamber names, applied independently to whichever side is still
-- unset (an explicit "none" always wins). Chained off the same
-- legislative body as `quaiyl` above.
local legislatureQid = quaiylQid or 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) + establishment
-- events -- manual-only, ported from the old template's numbered
-- slots (1-9). kionedeeaght is a synonym for kiondeeaght.
----------------------------------------------------------------
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
-- taghyrt_bunneeaghtN/date_bunneeaghtN are the new, preferred
-- spellings; taghyrtN_bunnit/dateN_bunnit (old) still work.
local event = getManual(args, {"taghyrt_bunneeaght" .. i, "taghyrt" .. i .. "_bunnit"})
local date = getManual(args, {"date_bunneeaght" .. i, "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), wikilinkLabel(foundingLabel), applyRefNote(foundingValue, foundingRef, foundingNote, frame)))
elseif #establishmentRows > 0 then
local headerLabel = applyRefNote(wikilinkLabel(foundingLabel), foundingRef, foundingNote, frame)
table.insert(foundingRows, string.format(HEADER, headerLabel))
end
appendIndentRun(foundingRows, establishmentRows)
elseif not isNone(getManual(args, {"bunnit"})) then
-- Wikidata fallback: inception (P571), only when the whole
-- establishment block was left unset (not |bunnit=none). Wd already
-- renders a full date when the statement has day precision; a
-- year-only result means Wikidata itself only has year precision.
--
-- A Julian-calendar date gets a literal " (Joolagh)" from Wd,
-- linked (or not) unreliably -- upgraded here to a real three-tier
-- link; everything else about the date is left untouched.
local inception = getWdProperty("P571")
if inception and inception:find(" (Joolagh)", 1, true) then
inception = inception:gsub(" %(Joolagh%)", " (" .. getJulianCalendarSuffixLink() .. ")", 1)
end
if inception then
table.insert(foundingRows, string.format(ROW, "", wikilinkLabel(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
sd2adaijkb9fea945mtp4hmphu1q490
393157
393156
2026-09-13T23:31:38Z
MacTire02
219
++
393157
Scribunto
text/plain
local p = {}
-- Wikidata fetch/citation module. Used instead of Module:WikidataIB, which
-- has no working citation-building of its own.
local wdOK, Wd = pcall(require, "Module:Wd")
-- Country genitive/mutated name forms (e.g. "Mannin" -> "Vannin", "Nalbin"
-- -> "ny h-Albey"). See getCurrentCountryGenitive/shortManxForm below.
local enmynOK, EnmynCheerey = pcall(require, "Module:Enmyn çheerey")
-- Shared "Manx label, else linked Wikidata fallback" helper -- see its own
-- header comment. Used as the last rung in getWdItemManxLink below.
local ennymWdOK, EnnymWd = pcall(require, "Module:Kishtey fys çheer/ennym-wd")
-- Returns the first non-empty manual parameter from a list of names.
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
-- Wraps a manual citation in <ref>...</ref>, unless it's already been
-- processed: a literal <ref> typed in a template parameter is expanded by
-- Scribunto into an opaque strip marker (\127UNIQ...QINU\127) the moment
-- frame.args is read, not literal "<ref" text -- re-wrapping that marker
-- creates a bogus extra reference. Pass strip markers and literal <ref>
-- text through unchanged; wrap anything else.
local function wrapReference(ref)
if not ref or ref == "" then return nil end
if mw.ustring.find(ref, "\127", 1, true) then
return ref
end
if mw.ustring.find(mw.ustring.lower(ref), "<ref", 1, true) then
return ref
end
return "<ref>" .. ref .. "</ref>"
end
-- Appends a manual <ref> and/or {{efn}} note (the imraa_*/noteyn_* params)
-- to a value, on top of any Wikidata-sourced citation it already has.
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 .. wrapReference(ref)
end
return value
end
-- Shared innards of getWdProperty/getWdPropertyWithCitation.
-- includeReference controls whether Wd's "reference" flag is passed.
local function getWdPropertyRaw(property, flags, includeReference)
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
if includeReference then table.insert(callArgs, "reference") end
table.insert(callArgs, "best") -- single best-ranked value
table.insert(callArgs, property)
local ok, result = pcall(Wd._property, callArgs)
if ok and result and result ~= "" then return result end
return nil
end
-- Fetches a Wikidata property value with its auto-built citation already
-- appended. `flags` is an optional array of extra Wd flags (e.g.
-- {"linked"}). Safe only when the result isn't going to be re-wrapped in a
-- fresh "[[...]]" by the caller -- use getWdPropertyWithCitation for that.
local function getWdProperty(property, flags)
return getWdPropertyRaw(property, flags, true)
end
-- Fetches a property's value and its citation as two separate strings.
--
-- Wd's "reference" flag builds the citation via
-- frame:extensionTag("ref", ...), which runs the <ref> tag hook
-- immediately and returns the ALREADY-RENDERED footnote marker (e.g. "[1]",
-- with real "[" "]" characters) -- not literal <ref> wikitext. If a caller
-- then wraps a sitelink-less value in its own "[[...]]" (see ensureLinked),
-- that marker's own "[" breaks the link.
--
-- Fixed by fetching the same property+flags twice (with and without
-- "reference") and diffing the two to isolate the citation, instead of
-- pattern-matching its shape. Returns `value, citation` -- citation is nil
-- when there is none, or when the two calls didn't line up as a clean
-- prefix match (falls back to the combined string in that case).
local function getWdPropertyWithCitation(property, flags)
local base = getWdPropertyRaw(property, flags, false)
if not base then return nil, nil end
local withRef = getWdPropertyRaw(property, flags, true)
if not withRef or withRef == base then return base, nil end
if withRef:sub(1, #base) == base then
local citation = withRef:sub(#base + 1)
if citation ~= "" then return base, citation end
return base, nil
end
return withRef, nil
end
-- Forces a value into a wikilink when Wd's "linked" flag didn't already
-- produce one (no gv sitelink yet), without touching a trailing citation.
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
-- Manx label of a Wikidata PROPERTY itself (e.g. P35 -> "head of state"),
-- used as a title fallback. Uses getLabelByLang(property, "gv")
-- specifically -- plain label()/mw.wikibase.label follows Wikidata's
-- fallback chain and would leak English when no Manx label exists.
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 link/label formatting) of an entity-valued property on the
-- current page's own item -- e.g. P35's value, for chaining into a lookup
-- on that person's own item (see getWdPositionTitle below).
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 the current
-- page's own item (plural version of getWdRawPropertyId above) -- e.g.
-- every P122 ("basic form of government") statement.
local function getWdRawPropertyIds(property)
if not wdOK or not Wd or not Wd._properties then return {} end
local ok, result = pcall(Wd._properties, {"raw", property})
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
-- Raw QID of a QUALIFIER on the current page's own "best" statement of
-- `property` -- e.g. the P1393 ("proxy") qualifier on a P35 statement. Call
-- shape is {"raw", "best", mainProperty, qualifierProperty}; no `eid`, so it
-- defaults to the current page's own entity.
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`) -- e.g. a leader's own P39 ("position held")
-- statements. Uses Wd's plural "properties" command so every matching
-- claim is returned, not just one. `qualifiers` is an optional
-- {qualifierProperty = requiredValue} table to filter by (e.g. P1001
-- "applies to jurisdiction" -- see getWdPositionTitle below).
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
-- QID of the Wikidata item connected to the current page.
local function getCurrentCountryQid()
local ok, id = pcall(mw.wikibase.getEntityIdForCurrentPage)
if ok and id and id ~= "" then return id end
return nil
end
-- Manx genitive form of the current page's own country/territory (e.g.
-- "Vannin" for the Isle of Man, "y Reeriaght Unnaneysit" for the UK), from
-- Module:Enmyn çheerey's table, keyed on the page's own title.
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
-- Section label linked to the country-specific article/redirect when one
-- exists (e.g. "[[Reiltys y Reeriaght Unnaneysit|Reiltys]]" for the UK,
-- "[[Reiltys Vannin|Reiltys]]" for the Isle of Man), else a plain
-- "[[Reiltys]]" when the current page's genitive can't be resolved.
local function getGenitiveLinkedLabel(baseWord)
local genitive = getCurrentCountryGenitive()
if genitive and genitive ~= "" then
return "[[" .. baseWord .. " " .. genitive .. "|" .. baseWord .. "]]"
end
return "[[" .. baseWord .. "]]"
end
-- Titles to leave unshortened even though they'd otherwise match a rung
-- below (e.g. "Çhiarn Vannin" should stay whole, not lose " Vannin").
local shortFormExceptions = {
["Çhiarn Vannin"] = true,
}
-- Strips the country name from an office title for display, e.g. "Monark y
-- Reeriaght Unnaneysit" -> "Monark". Tries, in order: Module:Enmyn
-- çheerey's exact genitive suffix, an explicit " y " split, then a blind
-- last-space split. A title with no space at all is returned unchanged.
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
-- Same idea as shortManxForm, but for a PERSON's name (a shared monarch's
-- own per-realm article, e.g. "Çhalse III y Reeriaght Unnaneysit"). Skips
-- the blind last-space rung, which would wrongly truncate an ordinary name
-- with no country suffix (e.g. "Charse III" -> "Charse").
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 a head-of-state link when it's a per-realm-
-- disambiguated article (see shortenCountrySuffixedName above), leaving the
-- link target and any citation untouched. Handles both a bare "[[target]]"
-- and an already-piped "[[target|display]]" link. Scoped to the head-of-
-- state slot only -- an ordinary head of government is never shared across
-- countries, so this shape of data doesn't arise there.
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 via the content language's own ucfirst
-- (UTF-8/digraph-safe, e.g. "çh") -- not a plain Lua upper() on byte 1.
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
-- Capitalizes the first letter a reader actually sees, even when the value
-- starts with wikilink or ennym-wd external-link markup. Only the very
-- first letter of the whole string is touched -- for a multi-value line
-- joined with commas, only the first item gets capitalized, matching
-- ordinary sentence capitalization. Manual (editor-typed) values are never
-- passed through this.
local function capitalizeFirstLetter(text)
if not text or text == "" then return text end
if text:match("^%[%[") then
local closePos = text:find("%]%]", 3, true)
local pipePos = text:find("|", 1, true)
local splitPos
if pipePos and (not closePos or pipePos < closePos) then
splitPos = pipePos -- piped: capitalize the display half only
else
splitPos = 2 -- unpiped: capitalize just past the leading "[["
end
return text:sub(1, splitPos) .. wikiUcfirst(text:sub(splitPos + 1))
elseif text:match("^%[https?://") then
-- ennym-wd external link: "[url label] <sup>(lang)</sup>" --
-- capitalize the label, right after the URL's own space.
local spacePos = text:find(" ", 2, true)
if spacePos then
return text:sub(1, spacePos) .. wikiUcfirst(text:sub(spacePos + 1))
end
return text
end
return wikiUcfirst(text)
end
-- Builds a wikilink for a Wikidata item: a gv sitelink when one exists,
-- else a gv label (as a redlink), else an ennym-wd external link to
-- Wikidata tagged with its language. Target and display are resolved
-- separately -- the gv label is always preferred for display, even when a
-- sitelink with a different title exists.
--
-- shorten (default true): strip the "role + country" suffix from the
-- display text (see shortManxForm). Pass false for an ordinary proper name
-- with no such structure (a chamber, a calendar concept).
-- capitalize (default true): capitalize a gv label's first letter. Pass
-- false when building one item out of a multi-value list, where only the
-- first item in the finished line should be capitalized by the caller
-- (see capitalizeFirstLetter).
--
-- Returns nil only when neither a sitelink nor a gv label nor an ennym-wd
-- fallback resolves to anything.
local function getWdItemManxLink(qid, shorten, capitalize)
if not qid then return nil end
if capitalize == nil then capitalize = true 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
if capitalize then
gvLabel = wikiUcfirst(gvLabel)
end
else
gvLabel = nil
end
if not sitelinkTitle and not gvLabel then
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
-- Office title from a property set directly on the country (P1906 "office
-- held by head of state" / P1313 "office held by head of government"),
-- when Wikidata records it -- avoids the multi-role ambiguity in
-- getWdPositionTitle below. Tried first.
local function getWdOfficeItemTitle(officeProperty)
local officeQid = getWdRawPropertyId(officeProperty)
if not officeQid then return nil end
return getWdItemManxLink(officeQid)
end
-- Fallback (see getWdOfficeItemTitle above, tried first): the office-
-- holder's own specific title, via their "position held" (P39) statement,
-- for a country with no P1906/P1313 set.
--
-- A head of state/government can hold several simultaneous P39 positions
-- (a shared monarch's several realms, or an MP/party-leader/PM combination),
-- with no reliable qualifier on a fresh statement to say which one is "the"
-- state office. So this collects every current P39 candidate (P1001-
-- jurisdiction-filtered ones first, when present) and uses the first that
-- resolves to a real gv sitelink or label -- in practice the actual office
-- is the one likely to have a gv article, while an ancillary role usually
-- doesn't.
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 "upper house" / "lower house" class items.
local UPPER_HOUSE_QID = "Q637846"
local LOWER_HOUSE_QID = "Q375928"
-- Resolves a bicameral legislature's two chambers via "has part(s)" (P527)
-- + "instance of" (P31) on each part. Only acts when exactly one part is
-- classified as upper and exactly one as lower; a unicameral legislature
-- (no P527 at all) or ambiguous data yields nothing for that side -- the
-- manual |thie_heose=/|thie_heese= override covers the rest. No auto-built
-- citation is attached (only a direct property fetch off the current
-- page's own item can produce one).
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
-- Wikidata's "proleptic Julian calendar" item -- not plain "Julian
-- calendar" (Q11184); a time value's calendar model always points to the
-- proleptic variant.
local JULIAN_CALENDAR_QID = "Q1985786"
-- Wd's own time-value formatting appends " (Joolagh)" to a date recorded on
-- the Julian calendar, but links it (or not) with a blind, unverified
-- wikilink to the hardcoded word "feaillere Yool". This rebuilds that
-- suffix as a real three-tier link (sitelink/label/ennym-wd), keeping Wd's
-- own "Joolagh" wording as the display text. Falls back to plain unlinked
-- "Joolagh" if nothing resolves at all.
local function getJulianCalendarSuffixLink()
local link = getWdItemManxLink(JULIAN_CALENDAR_QID, false)
if link then
local target = link:match("^%[%[([^%[%]|]+)") or link:match("^%[%[([^%[%]|]+)%]%]$")
if target then
return "[[" .. target .. "|Joolagh]]"
end
return link
end
return "Joolagh"
end
-- Row templates: plain 2-cell rows, matching every other submodule
-- (çhengaghyn, balley, bratteeyn). The old template's 3-column grid caused
-- a layout bug when mixed with 2-column rows. Sub-items get a "•" bullet +
-- lighter weight instead of a spacer column.
local ROW = '<tr%s><th style="vertical-align:top; white-space:nowrap; text-align:left; font-weight:bold; padding-left:0.4em; padding-right:0.4em;">%s</th><td style="vertical-align:top; padding-left:0.4em; padding-right:0.4em;">%s</td></tr>'
local SUBROW = '<tr%s><th style="vertical-align:top; white-space:nowrap; text-align:left; font-weight:normal; padding-left:0.9em; padding-right:0.4em;">• %s</th><td style="vertical-align:top; padding-left:0.4em; padding-right:0.4em;">%s</td></tr>'
local HEADER = '<tr class="mergedtoprow"><th colspan="2" style="text-align:left; padding-left:0.4em; padding-right:0.4em;">%s</th></tr>'
-- Builds a class="..." attribute, or an empty string.
local function trClass(name)
if name and name ~= "" then return ' class="' .. name .. '"' end
return ""
end
-- Wraps a section label in [[...]], unless it's already a full wikilink
-- (a manual |sorçh_kionedeeaght=[[target|display]] override) -- otherwise
-- that would double-bracket into a broken [[[[target|display]]]].
local function wikilinkLabel(label)
if not label or label == "" then return label end
if label:find("%[%[") then return label end
return "[[" .. label .. "]]"
end
-- Formats a run of bullet sub-rows with the merged-border classes: every
-- row but the last gets mergedrow, the last gets mergedbottomrow.
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 Module:Kishtey fys çheer uses between submodules, reused
-- here between this module's own sections -- only inserted between two
-- sections that both produced rows.
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)
-- Allow being called as p.main(args) with no frame (used by tests).
if not args then
args = frame
frame = mw.getCurrentFrame()
end
local rows = {}
local govRows = {}
local quaiylRows = {}
local foundingRows = {}
----------------------------------------------------------------
-- 1-2. REILTYS (government type) + leaders (head of state/government,
-- etc.). enmysN_fer-toshee/ennymN_fer-toshee are the old gendered
-- param names; enmys_toshiaghN/ennym_toshiaghN are the gender-neutral
-- synonyms and take priority when both are given.
----------------------------------------------------------------
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: basic form of government (P122), joining every
-- value Wikidata records. Routed through getWdItemManxLink rather
-- than Wd's own "linked" property call -- a P122 value rarely has a
-- gv sitelink, and Wd's own formatting would leak plain, unlinked
-- English otherwise. shorten=false: not a "role + country" phrase.
-- capitalize=false: only the joined line's first letter should be
-- capitalized (below), not every value.
local govTypeQids = getWdRawPropertyIds("P122")
local govTypeParts = {}
for _, qid in ipairs(govTypeQids) do
local link = getWdItemManxLink(qid, false, false)
if link then table.insert(govTypeParts, link) end
end
if #govTypeParts > 0 then
govTypeRaw = capitalizeFirstLetter(table.concat(govTypeParts, ", "))
end
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: head of state (P35) / head of government (P6).
-- Names are always forced into a link via ensureLinked. Value and
-- citation are fetched separately and the citation appended only
-- after the link is built -- see getWdPropertyWithCitation.
local hosBase, hosCitation = getWdPropertyWithCitation("P35", {"linked"})
local hos = shortenLinkedCountryName(ensureLinked(hosBase))
if hos and hosCitation then hos = hos .. hosCitation end
local hogBase, hogCitation = getWdPropertyWithCitation("P6", {"linked"})
local hog = ensureLinked(hogBase)
if hog and hogCitation then hog = hog .. hogCitation end
-- Some countries (US, France, Russia, ...) record the same person
-- as both P35 and P6 -- one office, not two. Skip the head-of-
-- government row when the raw QIDs match, rather than showing it
-- twice.
local hosQid = getWdRawPropertyId("P35")
local hogQid = getWdRawPropertyId("P6")
local sameHeadOfStateAndGovernment = hos and hog and hosQid and hogQid and hosQid == hogQid
if hos then
local hosTitle = getManual(args, {"sorçh_kione_steat"})
or getWdOfficeItemTitle("P1906") -- office held by head of state
or getWdPositionTitle("P35")
or getWikidataPropertyLabel("P35")
or "Kione steat"
table.insert(leaderPairs, {title = hosTitle, name = hos})
-- Head of state's "proxy" (e.g. the Isle of Man's Lieutenant
-- Governor) -- a representative, distinct from a deputy. Shown
-- between the head of state and head of government when
-- Wikidata records one via P1393 (a qualifier on the P35
-- statement, whose value is the office; the current holder is
-- a separate P1308 lookup on that office).
if not isNone(getManual(args, {"ynnydee_kione_steat"})) then
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
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 and not sameHeadOfStateAndGovernment then
local hogTitle = getManual(args, {"sorçh_kione_reiltys"})
or getWdOfficeItemTitle("P1313") -- office held by head of government
or getWdPositionTitle("P6")
or getWikidataPropertyLabel("P6")
or "Kione reiltys"
table.insert(leaderPairs, {title = hogTitle, name = hog})
end
end
local reiltysLabel = getGenitiveLinkedLabel("Reiltys")
if govShown then
local govClass = (#leaderPairs > 0) and "mergedtoprow" or ""
table.insert(govRows, string.format(ROW, trClass(govClass), reiltysLabel, applyRefNote(govTypeRaw, govRef, govNote, frame)))
elseif #leaderPairs > 0 then
table.insert(govRows, string.format(HEADER, reiltysLabel))
end
if #leaderPairs > 0 then
-- Manual ref/note for the whole leaders block is attached to the
-- last row (a Wikidata-sourced name already carries its own).
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.
----------------------------------------------------------------
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"})
local quaiylQid = nil
if not quaiyl then
-- Wd's own "linked" flag leaks a plain, unlinked English label when
-- there's no gv sitelink (e.g. Scotland's P194 leaking "Scottish
-- Parliament"). Chains through the raw QID and getWdItemManxLink
-- instead. QID is kept for getWdChambers below.
quaiylQid = getWdRawPropertyId("P194")
if quaiylQid then
quaiyl = getWdItemManxLink(quaiylQid, false)
end
end
if not quaiylSyrjey or not quaiylInshley then
-- Chamber names, applied independently to whichever side is still
-- unset (an explicit "none" always wins). Chained off the same
-- legislative body as `quaiyl` above.
local legislatureQid = quaiylQid or 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) + establishment
-- events -- manual-only, ported from the old template's numbered
-- slots (1-9). kionedeeaght is a synonym for kiondeeaght.
----------------------------------------------------------------
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
-- taghyrt_bunneeaghtN/date_bunneeaghtN are the new, preferred
-- spellings; taghyrtN_bunnit/dateN_bunnit (old) still work.
local event = getManual(args, {"taghyrt_bunneeaght" .. i, "taghyrt" .. i .. "_bunnit"})
local date = getManual(args, {"date_bunneeaght" .. i, "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), wikilinkLabel(foundingLabel), applyRefNote(foundingValue, foundingRef, foundingNote, frame)))
elseif #establishmentRows > 0 then
local headerLabel = applyRefNote(wikilinkLabel(foundingLabel), foundingRef, foundingNote, frame)
table.insert(foundingRows, string.format(HEADER, headerLabel))
end
appendIndentRun(foundingRows, establishmentRows)
elseif not isNone(getManual(args, {"bunnit"})) then
-- Wikidata fallback: inception (P571), only when the whole
-- establishment block was left unset (not |bunnit=none). Wd already
-- renders a full date when the statement has day precision; a
-- year-only result means Wikidata itself only has year precision.
--
-- A Julian-calendar date gets a literal " (Joolagh)" from Wd,
-- linked (or not) unreliably -- upgraded here to a real three-tier
-- link; everything else about the date is left untouched.
local inception = getWdProperty("P571")
if inception and inception:find(" (Joolagh)", 1, true) then
inception = inception:gsub(" %(Joolagh%)", " (" .. getJulianCalendarSuffixLink() .. ")", 1)
end
if inception then
table.insert(foundingRows, string.format(ROW, "", wikilinkLabel(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
d7lt7bdezpq68w5bv2yrbj6o7jja96v
393163
393157
2026-09-13T23:59:16Z
MacTire02
219
++
393163
Scribunto
text/plain
local p = {}
-- Wikidata fetch/citation module. Used instead of Module:WikidataIB, which
-- has no working citation-building of its own.
local wdOK, Wd = pcall(require, "Module:Wd")
-- Country genitive/mutated name forms (e.g. "Mannin" -> "Vannin", "Nalbin"
-- -> "ny h-Albey"). See getCurrentCountryGenitive/shortManxForm below.
local enmynOK, EnmynCheerey = pcall(require, "Module:Enmyn çheerey")
-- Shared "Manx label, else linked Wikidata fallback" helper -- see its own
-- header comment. Used as the last rung in getWdItemManxLink below.
local ennymWdOK, EnnymWd = pcall(require, "Module:Kishtey fys çheer/ennym-wd")
-- Returns the first non-empty manual parameter from a list of names.
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
-- Wraps a manual citation in <ref>...</ref>, unless it's already been
-- processed as one: strip out every MediaWiki strip marker
-- (\127UNIQ...QINU\127 -- the opaque placeholder Scribunto substitutes for
-- ANY extension tag inside an expanded parameter, <ref> included) and look
-- at what's left. If NOTHING real is left, the whole parameter was one or
-- more <ref>...</ref> tags typed directly by the editor (e.g.
-- |imraa_reiltys=<ref>...</ref><ref>...</ref>) -- those were already fully
-- registered and numbered the moment Scribunto expanded the parameter, so
-- re-wrapping the markers in a fresh <ref> would create a bogus extra
-- reference; pass the value through completely unchanged. But if real
-- content remains after removing markers -- most commonly a manually-typed
-- {{cite web|...}}/{{cite news|...}} call whose OWN rendered output embeds
-- an unrelated strip marker of its own (citation templates commonly emit a
-- <templatestyles/> tag for their CSS, which strips to a marker the same
-- way <ref> does) -- this is ordinary citation prose that was never
-- wrapped in <ref> at all, not an already-processed reference, and needs
-- wrapping like anything else. (A prior version of this check only tested
-- whether the value contained \127 ANYWHERE, which wrongly treated any
-- citation with an embedded <templatestyles/> marker as already-wrapped
-- and left it to render as plain visible text instead of a footnote.)
local function wrapReference(ref)
if not ref or ref == "" then return nil end
local withoutMarkers = mw.ustring.gsub(ref, "\127UNIQ.-QINU\127", "")
if mw.ustring.gsub(withoutMarkers, "%s+", "") == "" then
return ref
end
if mw.ustring.find(mw.ustring.lower(ref), "<ref", 1, true) then
return ref
end
return "<ref>" .. ref .. "</ref>"
end
-- Appends a manual <ref> and/or {{efn}} note (the imraa_*/noteyn_* params)
-- to a value, on top of any Wikidata-sourced citation it already has.
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 .. wrapReference(ref)
end
return value
end
-- Shared innards of getWdProperty/getWdPropertyWithCitation.
-- includeReference controls whether Wd's "reference" flag is passed.
local function getWdPropertyRaw(property, flags, includeReference)
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
if includeReference then table.insert(callArgs, "reference") end
table.insert(callArgs, "best") -- single best-ranked value
table.insert(callArgs, property)
local ok, result = pcall(Wd._property, callArgs)
if ok and result and result ~= "" then return result end
return nil
end
-- Fetches a Wikidata property value with its auto-built citation already
-- appended. `flags` is an optional array of extra Wd flags (e.g.
-- {"linked"}). Safe only when the result isn't going to be re-wrapped in a
-- fresh "[[...]]" by the caller -- use getWdPropertyWithCitation for that.
local function getWdProperty(property, flags)
return getWdPropertyRaw(property, flags, true)
end
-- Fetches a property's value and its citation as two separate strings.
--
-- Wd's "reference" flag builds the citation via
-- frame:extensionTag("ref", ...), which runs the <ref> tag hook
-- immediately and returns the ALREADY-RENDERED footnote marker (e.g. "[1]",
-- with real "[" "]" characters) -- not literal <ref> wikitext. If a caller
-- then wraps a sitelink-less value in its own "[[...]]" (see ensureLinked),
-- that marker's own "[" breaks the link.
--
-- Fixed by fetching the same property+flags twice (with and without
-- "reference") and diffing the two to isolate the citation, instead of
-- pattern-matching its shape. Returns `value, citation` -- citation is nil
-- when there is none, or when the two calls didn't line up as a clean
-- prefix match (falls back to the combined string in that case).
local function getWdPropertyWithCitation(property, flags)
local base = getWdPropertyRaw(property, flags, false)
if not base then return nil, nil end
local withRef = getWdPropertyRaw(property, flags, true)
if not withRef or withRef == base then return base, nil end
if withRef:sub(1, #base) == base then
local citation = withRef:sub(#base + 1)
if citation ~= "" then return base, citation end
return base, nil
end
return withRef, nil
end
-- Forces a value into a wikilink when Wd's "linked" flag didn't already
-- produce one (no gv sitelink yet), without touching a trailing citation.
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
-- Manx label of a Wikidata PROPERTY itself (e.g. P35 -> "head of state"),
-- used as a title fallback. Uses getLabelByLang(property, "gv")
-- specifically -- plain label()/mw.wikibase.label follows Wikidata's
-- fallback chain and would leak English when no Manx label exists.
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 link/label formatting) of an entity-valued property on the
-- current page's own item -- e.g. P35's value, for chaining into a lookup
-- on that person's own item (see getWdPositionTitle below).
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 the current
-- page's own item (plural version of getWdRawPropertyId above) -- e.g.
-- every P122 ("basic form of government") statement.
local function getWdRawPropertyIds(property)
if not wdOK or not Wd or not Wd._properties then return {} end
local ok, result = pcall(Wd._properties, {"raw", property})
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
-- Raw QID of a QUALIFIER on the current page's own "best" statement of
-- `property` -- e.g. the P1393 ("proxy") qualifier on a P35 statement. Call
-- shape is {"raw", "best", mainProperty, qualifierProperty}; no `eid`, so it
-- defaults to the current page's own entity.
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`) -- e.g. a leader's own P39 ("position held")
-- statements. Uses Wd's plural "properties" command so every matching
-- claim is returned, not just one. `qualifiers` is an optional
-- {qualifierProperty = requiredValue} table to filter by (e.g. P1001
-- "applies to jurisdiction" -- see getWdPositionTitle below).
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
-- QID of the Wikidata item connected to the current page.
local function getCurrentCountryQid()
local ok, id = pcall(mw.wikibase.getEntityIdForCurrentPage)
if ok and id and id ~= "" then return id end
return nil
end
-- Manx genitive form of the current page's own country/territory (e.g.
-- "Vannin" for the Isle of Man, "y Reeriaght Unnaneysit" for the UK), from
-- Module:Enmyn çheerey's table, keyed on the page's own title.
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
-- Section label linked to the country-specific article/redirect when one
-- exists (e.g. "[[Reiltys y Reeriaght Unnaneysit|Reiltys]]" for the UK,
-- "[[Reiltys Vannin|Reiltys]]" for the Isle of Man), else a plain
-- "[[Reiltys]]" when the current page's genitive can't be resolved.
local function getGenitiveLinkedLabel(baseWord)
local genitive = getCurrentCountryGenitive()
if genitive and genitive ~= "" then
return "[[" .. baseWord .. " " .. genitive .. "|" .. baseWord .. "]]"
end
return "[[" .. baseWord .. "]]"
end
-- Titles to leave unshortened even though they'd otherwise match a rung
-- below (e.g. "Çhiarn Vannin" should stay whole, not lose " Vannin").
local shortFormExceptions = {
["Çhiarn Vannin"] = true,
}
-- Strips the country name from an office title for display, e.g. "Monark y
-- Reeriaght Unnaneysit" -> "Monark". Tries, in order: Module:Enmyn
-- çheerey's exact genitive suffix, an explicit " y " split, then a blind
-- last-space split. A title with no space at all is returned unchanged.
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
-- Same idea as shortManxForm, but for a PERSON's name (a shared monarch's
-- own per-realm article, e.g. "Çhalse III y Reeriaght Unnaneysit"). Skips
-- the blind last-space rung, which would wrongly truncate an ordinary name
-- with no country suffix (e.g. "Charse III" -> "Charse").
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 a head-of-state link when it's a per-realm-
-- disambiguated article (see shortenCountrySuffixedName above), leaving the
-- link target and any citation untouched. Handles both a bare "[[target]]"
-- and an already-piped "[[target|display]]" link. Scoped to the head-of-
-- state slot only -- an ordinary head of government is never shared across
-- countries, so this shape of data doesn't arise there.
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 via the content language's own ucfirst
-- (UTF-8/digraph-safe, e.g. "çh") -- not a plain Lua upper() on byte 1.
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
-- Capitalizes the first letter a reader actually sees, even when the value
-- starts with wikilink or ennym-wd external-link markup. Only the very
-- first letter of the whole string is touched -- for a multi-value line
-- joined with commas, only the first item gets capitalized, matching
-- ordinary sentence capitalization. Manual (editor-typed) values are never
-- passed through this.
local function capitalizeFirstLetter(text)
if not text or text == "" then return text end
if text:match("^%[%[") then
local closePos = text:find("%]%]", 3, true)
local pipePos = text:find("|", 1, true)
local splitPos
if pipePos and (not closePos or pipePos < closePos) then
splitPos = pipePos -- piped: capitalize the display half only
else
splitPos = 2 -- unpiped: capitalize just past the leading "[["
end
return text:sub(1, splitPos) .. wikiUcfirst(text:sub(splitPos + 1))
elseif text:match("^%[https?://") then
-- ennym-wd external link: "[url label] <sup>(lang)</sup>" --
-- capitalize the label, right after the URL's own space.
local spacePos = text:find(" ", 2, true)
if spacePos then
return text:sub(1, spacePos) .. wikiUcfirst(text:sub(spacePos + 1))
end
return text
end
return wikiUcfirst(text)
end
-- Builds a wikilink for a Wikidata item: a gv sitelink when one exists,
-- else a gv label (as a redlink), else an ennym-wd external link to
-- Wikidata tagged with its language. Target and display are resolved
-- separately -- the gv label is always preferred for display, even when a
-- sitelink with a different title exists.
--
-- shorten (default true): strip the "role + country" suffix from the
-- display text (see shortManxForm). Pass false for an ordinary proper name
-- with no such structure (a chamber, a calendar concept).
-- capitalize (default true): capitalize a gv label's first letter. Pass
-- false when building one item out of a multi-value list, where only the
-- first item in the finished line should be capitalized by the caller
-- (see capitalizeFirstLetter).
--
-- Returns nil only when neither a sitelink nor a gv label nor an ennym-wd
-- fallback resolves to anything.
local function getWdItemManxLink(qid, shorten, capitalize)
if not qid then return nil end
if capitalize == nil then capitalize = true 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
if capitalize then
gvLabel = wikiUcfirst(gvLabel)
end
else
gvLabel = nil
end
if not sitelinkTitle and not gvLabel then
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
-- Office title from a property set directly on the country (P1906 "office
-- held by head of state" / P1313 "office held by head of government"),
-- when Wikidata records it -- avoids the multi-role ambiguity in
-- getWdPositionTitle below. Tried first.
local function getWdOfficeItemTitle(officeProperty)
local officeQid = getWdRawPropertyId(officeProperty)
if not officeQid then return nil end
return getWdItemManxLink(officeQid)
end
-- Fallback (see getWdOfficeItemTitle above, tried first): the office-
-- holder's own specific title, via their "position held" (P39) statement,
-- for a country with no P1906/P1313 set.
--
-- A head of state/government can hold several simultaneous P39 positions
-- (a shared monarch's several realms, or an MP/party-leader/PM combination),
-- with no reliable qualifier on a fresh statement to say which one is "the"
-- state office. So this collects every current P39 candidate (P1001-
-- jurisdiction-filtered ones first, when present) and uses the first that
-- resolves to a real gv sitelink or label -- in practice the actual office
-- is the one likely to have a gv article, while an ancillary role usually
-- doesn't.
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 "upper house" / "lower house" class items.
local UPPER_HOUSE_QID = "Q637846"
local LOWER_HOUSE_QID = "Q375928"
-- Resolves a bicameral legislature's two chambers via "has part(s)" (P527)
-- + "instance of" (P31) on each part. Only acts when exactly one part is
-- classified as upper and exactly one as lower; a unicameral legislature
-- (no P527 at all) or ambiguous data yields nothing for that side -- the
-- manual |thie_heose=/|thie_heese= override covers the rest. No auto-built
-- citation is attached (only a direct property fetch off the current
-- page's own item can produce one).
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
-- Wikidata's "proleptic Julian calendar" item -- not plain "Julian
-- calendar" (Q11184); a time value's calendar model always points to the
-- proleptic variant.
local JULIAN_CALENDAR_QID = "Q1985786"
-- Wd's own time-value formatting appends " (Joolagh)" to a date recorded on
-- the Julian calendar, but links it (or not) with a blind, unverified
-- wikilink to the hardcoded word "feaillere Yool". This rebuilds that
-- suffix as a real three-tier link (sitelink/label/ennym-wd), keeping Wd's
-- own "Joolagh" wording as the display text. Falls back to plain unlinked
-- "Joolagh" if nothing resolves at all.
local function getJulianCalendarSuffixLink()
local link = getWdItemManxLink(JULIAN_CALENDAR_QID, false)
if link then
local target = link:match("^%[%[([^%[%]|]+)") or link:match("^%[%[([^%[%]|]+)%]%]$")
if target then
return "[[" .. target .. "|Joolagh]]"
end
return link
end
return "Joolagh"
end
-- Row templates: plain 2-cell rows, matching every other submodule
-- (çhengaghyn, balley, bratteeyn). The old template's 3-column grid caused
-- a layout bug when mixed with 2-column rows. Sub-items get a "•" bullet +
-- lighter weight instead of a spacer column.
local ROW = '<tr%s><th style="vertical-align:top; white-space:nowrap; text-align:left; font-weight:bold; padding-left:0.4em; padding-right:0.4em;">%s</th><td style="vertical-align:top; padding-left:0.4em; padding-right:0.4em;">%s</td></tr>'
local SUBROW = '<tr%s><th style="vertical-align:top; white-space:nowrap; text-align:left; font-weight:normal; padding-left:0.9em; padding-right:0.4em;">• %s</th><td style="vertical-align:top; padding-left:0.4em; padding-right:0.4em;">%s</td></tr>'
local HEADER = '<tr class="mergedtoprow"><th colspan="2" style="text-align:left; padding-left:0.4em; padding-right:0.4em;">%s</th></tr>'
-- Builds a class="..." attribute, or an empty string.
local function trClass(name)
if name and name ~= "" then return ' class="' .. name .. '"' end
return ""
end
-- Wraps a section label in [[...]], unless it's already a full wikilink
-- (a manual |sorçh_kionedeeaght=[[target|display]] override) -- otherwise
-- that would double-bracket into a broken [[[[target|display]]]].
local function wikilinkLabel(label)
if not label or label == "" then return label end
if label:find("%[%[") then return label end
return "[[" .. label .. "]]"
end
-- Formats a run of bullet sub-rows with the merged-border classes: every
-- row but the last gets mergedrow, the last gets mergedbottomrow.
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 Module:Kishtey fys çheer uses between submodules, reused
-- here between this module's own sections -- only inserted between two
-- sections that both produced rows.
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)
-- Allow being called as p.main(args) with no frame (used by tests).
if not args then
args = frame
frame = mw.getCurrentFrame()
end
local rows = {}
local govRows = {}
local quaiylRows = {}
local foundingRows = {}
----------------------------------------------------------------
-- 1-2. REILTYS (government type) + leaders (head of state/government,
-- etc.). enmysN_fer-toshee/ennymN_fer-toshee are the old gendered
-- param names; enmys_toshiaghN/ennym_toshiaghN are the gender-neutral
-- synonyms and take priority when both are given.
----------------------------------------------------------------
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: basic form of government (P122), joining every
-- value Wikidata records. Routed through getWdItemManxLink rather
-- than Wd's own "linked" property call -- a P122 value rarely has a
-- gv sitelink, and Wd's own formatting would leak plain, unlinked
-- English otherwise. shorten=false: not a "role + country" phrase.
-- capitalize=false: only the joined line's first letter should be
-- capitalized (below), not every value.
local govTypeQids = getWdRawPropertyIds("P122")
local govTypeParts = {}
for _, qid in ipairs(govTypeQids) do
local link = getWdItemManxLink(qid, false, false)
if link then table.insert(govTypeParts, link) end
end
if #govTypeParts > 0 then
govTypeRaw = capitalizeFirstLetter(table.concat(govTypeParts, ", "))
end
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: head of state (P35) / head of government (P6).
-- Names are always forced into a link via ensureLinked. Value and
-- citation are fetched separately and the citation appended only
-- after the link is built -- see getWdPropertyWithCitation.
local hosBase, hosCitation = getWdPropertyWithCitation("P35", {"linked"})
local hos = shortenLinkedCountryName(ensureLinked(hosBase))
if hos and hosCitation then hos = hos .. hosCitation end
local hogBase, hogCitation = getWdPropertyWithCitation("P6", {"linked"})
local hog = ensureLinked(hogBase)
if hog and hogCitation then hog = hog .. hogCitation end
-- Some countries (US, France, Russia, ...) record the same person
-- as both P35 and P6 -- one office, not two. Skip the head-of-
-- government row when the raw QIDs match, rather than showing it
-- twice.
local hosQid = getWdRawPropertyId("P35")
local hogQid = getWdRawPropertyId("P6")
local sameHeadOfStateAndGovernment = hos and hog and hosQid and hogQid and hosQid == hogQid
if hos then
local hosTitle = getManual(args, {"sorçh_kione_steat"})
or getWdOfficeItemTitle("P1906") -- office held by head of state
or getWdPositionTitle("P35")
or getWikidataPropertyLabel("P35")
or "Kione steat"
table.insert(leaderPairs, {title = hosTitle, name = hos})
-- Head of state's "proxy" (e.g. the Isle of Man's Lieutenant
-- Governor) -- a representative, distinct from a deputy. Shown
-- between the head of state and head of government when
-- Wikidata records one via P1393 (a qualifier on the P35
-- statement, whose value is the office; the current holder is
-- a separate P1308 lookup on that office).
if not isNone(getManual(args, {"ynnydee_kione_steat"})) then
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
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 and not sameHeadOfStateAndGovernment then
local hogTitle = getManual(args, {"sorçh_kione_reiltys"})
or getWdOfficeItemTitle("P1313") -- office held by head of government
or getWdPositionTitle("P6")
or getWikidataPropertyLabel("P6")
or "Kione reiltys"
table.insert(leaderPairs, {title = hogTitle, name = hog})
end
end
local reiltysLabel = getGenitiveLinkedLabel("Reiltys")
if govShown then
local govClass = (#leaderPairs > 0) and "mergedtoprow" or ""
table.insert(govRows, string.format(ROW, trClass(govClass), reiltysLabel, applyRefNote(govTypeRaw, govRef, govNote, frame)))
elseif #leaderPairs > 0 then
table.insert(govRows, string.format(HEADER, reiltysLabel))
end
if #leaderPairs > 0 then
-- Manual ref/note for the whole leaders block is attached to the
-- last row (a Wikidata-sourced name already carries its own).
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.
----------------------------------------------------------------
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"})
local quaiylQid = nil
if not quaiyl then
-- Wd's own "linked" flag leaks a plain, unlinked English label when
-- there's no gv sitelink (e.g. Scotland's P194 leaking "Scottish
-- Parliament"). Chains through the raw QID and getWdItemManxLink
-- instead. QID is kept for getWdChambers below.
quaiylQid = getWdRawPropertyId("P194")
if quaiylQid then
quaiyl = getWdItemManxLink(quaiylQid, false)
end
end
if not quaiylSyrjey or not quaiylInshley then
-- Chamber names, applied independently to whichever side is still
-- unset (an explicit "none" always wins). Chained off the same
-- legislative body as `quaiyl` above.
local legislatureQid = quaiylQid or 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) + establishment
-- events -- manual-only, ported from the old template's numbered
-- slots (1-9). kionedeeaght is a synonym for kiondeeaght.
----------------------------------------------------------------
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
-- taghyrt_bunneeaghtN/date_bunneeaghtN are the new, preferred
-- spellings; taghyrtN_bunnit/dateN_bunnit (old) still work.
local event = getManual(args, {"taghyrt_bunneeaght" .. i, "taghyrt" .. i .. "_bunnit"})
local date = getManual(args, {"date_bunneeaght" .. i, "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), wikilinkLabel(foundingLabel), applyRefNote(foundingValue, foundingRef, foundingNote, frame)))
elseif #establishmentRows > 0 then
local headerLabel = applyRefNote(wikilinkLabel(foundingLabel), foundingRef, foundingNote, frame)
table.insert(foundingRows, string.format(HEADER, headerLabel))
end
appendIndentRun(foundingRows, establishmentRows)
elseif not isNone(getManual(args, {"bunnit"})) then
-- Wikidata fallback: inception (P571), only when the whole
-- establishment block was left unset (not |bunnit=none). Wd already
-- renders a full date when the statement has day precision; a
-- year-only result means Wikidata itself only has year precision.
--
-- A Julian-calendar date gets a literal " (Joolagh)" from Wd,
-- linked (or not) unreliably -- upgraded here to a real three-tier
-- link; everything else about the date is left untouched.
local inception = getWdProperty("P571")
if inception and inception:find(" (Joolagh)", 1, true) then
inception = inception:gsub(" %(Joolagh%)", " (" .. getJulianCalendarSuffixLink() .. ")", 1)
end
if inception then
table.insert(foundingRows, string.format(ROW, "", wikilinkLabel(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
884oj8yxj34ct6ylaec31u6l8oqk7h2
393164
393163
2026-09-14T00:04:53Z
MacTire02
219
++
393164
Scribunto
text/plain
local p = {}
-- Wikidata fetch/citation module. Used instead of Module:WikidataIB, which
-- has no working citation-building of its own.
local wdOK, Wd = pcall(require, "Module:Wd")
-- Country genitive/mutated name forms (e.g. "Mannin" -> "Vannin", "Nalbin"
-- -> "ny h-Albey"). See getCurrentCountryGenitive/shortManxForm below.
local enmynOK, EnmynCheerey = pcall(require, "Module:Enmyn çheerey")
-- Shared "Manx label, else linked Wikidata fallback" helper -- see its own
-- header comment. Used as the last rung in getWdItemManxLink below.
local ennymWdOK, EnnymWd = pcall(require, "Module:Kishtey fys çheer/ennym-wd")
-- Returns the first non-empty manual parameter from a list of names.
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
-- Wraps a manual citation in <ref>...</ref>, unless it's already fully
-- <ref>-tagged (Scribunto expands a literal <ref> in a parameter into an
-- opaque \127UNIQ...QINU\127 strip marker before this module sees it, so we
-- strip those out and check what's left -- nothing left means it was
-- already tag(s), pass through unchanged; real text left over -- e.g. a
-- bare {{cite web}} call whose own <templatestyles/> leaves an incidental
-- marker -- means it still needs wrapping).
local function wrapReference(ref)
if not ref or ref == "" then return nil end
local withoutMarkers = mw.ustring.gsub(ref, "\127UNIQ.-QINU\127", "")
if mw.ustring.gsub(withoutMarkers, "%s+", "") == "" then
return ref
end
if mw.ustring.find(mw.ustring.lower(ref), "<ref", 1, true) then
return ref
end
return "<ref>" .. ref .. "</ref>"
end
-- Appends a manual <ref> and/or {{efn}} note (the imraa_*/noteyn_* params)
-- to a value, on top of any Wikidata-sourced citation it already has.
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 .. wrapReference(ref)
end
return value
end
-- Shared innards of getWdProperty/getWdPropertyWithCitation.
-- includeReference controls whether Wd's "reference" flag is passed.
local function getWdPropertyRaw(property, flags, includeReference)
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
if includeReference then table.insert(callArgs, "reference") end
table.insert(callArgs, "best") -- single best-ranked value
table.insert(callArgs, property)
local ok, result = pcall(Wd._property, callArgs)
if ok and result and result ~= "" then return result end
return nil
end
-- Fetches a Wikidata property value with its auto-built citation already
-- appended. `flags` is an optional array of extra Wd flags (e.g.
-- {"linked"}). Safe only when the result isn't going to be re-wrapped in a
-- fresh "[[...]]" by the caller -- use getWdPropertyWithCitation for that.
local function getWdProperty(property, flags)
return getWdPropertyRaw(property, flags, true)
end
-- Fetches a property's value and its already-rendered citation (e.g. "[1]")
-- as two separate strings, by fetching with and without Wd's "reference"
-- flag and diffing them -- so a caller can wrap the bare value in "[[...]]"
-- (ensureLinked) without the citation's own "[" breaking the link. Returns
-- `value, citation`; citation is nil when there is none.
local function getWdPropertyWithCitation(property, flags)
local base = getWdPropertyRaw(property, flags, false)
if not base then return nil, nil end
local withRef = getWdPropertyRaw(property, flags, true)
if not withRef or withRef == base then return base, nil end
if withRef:sub(1, #base) == base then
local citation = withRef:sub(#base + 1)
if citation ~= "" then return base, citation end
return base, nil
end
return withRef, nil
end
-- Forces a value into a wikilink when Wd's "linked" flag didn't already
-- produce one (no gv sitelink yet), without touching a trailing citation.
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
-- Manx label of a Wikidata PROPERTY itself (e.g. P35 -> "head of state"),
-- used as a title fallback. getLabelByLang (not plain label()) avoids
-- leaking an English fallback when no Manx label exists.
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 link/label formatting) of an entity-valued property on the
-- current page's own item -- e.g. P35's value, for chaining into a lookup
-- on that person's own item (see getWdPositionTitle below).
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 the current
-- page's own item (plural version of getWdRawPropertyId above) -- e.g.
-- every P122 ("basic form of government") statement.
local function getWdRawPropertyIds(property)
if not wdOK or not Wd or not Wd._properties then return {} end
local ok, result = pcall(Wd._properties, {"raw", property})
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
-- Raw QID of a QUALIFIER on the current page's own "best" statement of
-- `property` -- e.g. the P1393 ("proxy") qualifier on a P35 statement. Call
-- shape is {"raw", "best", mainProperty, qualifierProperty}; no `eid`, so it
-- defaults to the current page's own entity.
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`) -- e.g. a leader's own P39 ("position held")
-- statements. Uses Wd's plural "properties" command so every matching
-- claim is returned, not just one. `qualifiers` is an optional
-- {qualifierProperty = requiredValue} table to filter by (e.g. P1001
-- "applies to jurisdiction" -- see getWdPositionTitle below).
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
-- QID of the Wikidata item connected to the current page.
local function getCurrentCountryQid()
local ok, id = pcall(mw.wikibase.getEntityIdForCurrentPage)
if ok and id and id ~= "" then return id end
return nil
end
-- Manx genitive form of the current page's own country/territory (e.g.
-- "Vannin" for the Isle of Man, "y Reeriaght Unnaneysit" for the UK), from
-- Module:Enmyn çheerey's table, keyed on the page's own title.
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
-- Section label linked to the country-specific article/redirect when one
-- exists (e.g. "[[Reiltys y Reeriaght Unnaneysit|Reiltys]]" for the UK,
-- "[[Reiltys Vannin|Reiltys]]" for the Isle of Man), else a plain
-- "[[Reiltys]]" when the current page's genitive can't be resolved.
local function getGenitiveLinkedLabel(baseWord)
local genitive = getCurrentCountryGenitive()
if genitive and genitive ~= "" then
return "[[" .. baseWord .. " " .. genitive .. "|" .. baseWord .. "]]"
end
return "[[" .. baseWord .. "]]"
end
-- Titles to leave unshortened even though they'd otherwise match a rung
-- below (e.g. "Çhiarn Vannin" should stay whole, not lose " Vannin").
local shortFormExceptions = {
["Çhiarn Vannin"] = true,
}
-- Strips the country name from an office title for display, e.g. "Monark y
-- Reeriaght Unnaneysit" -> "Monark". Tries, in order: Module:Enmyn
-- çheerey's exact genitive suffix, an explicit " y " split, then a blind
-- last-space split. A title with no space at all is returned unchanged.
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
-- Same idea as shortManxForm, for a shared monarch's own per-realm article
-- name (e.g. "Çhalse III y Reeriaght Unnaneysit"). Skips the blind
-- last-space rung, which would wrongly truncate "Charse III" -> "Charse".
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 a head-of-state link when it's a per-realm-
-- disambiguated article, leaving the link target and any citation
-- untouched. Head-of-state only -- a head of government is never shared
-- across countries, so this shape of data doesn't arise there.
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 via the content language's own ucfirst
-- (UTF-8/digraph-safe, e.g. "çh") -- not a plain Lua upper() on byte 1.
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
-- Capitalizes the first letter a reader actually sees, even through a
-- leading wikilink or ennym-wd external-link marker -- for a comma-joined
-- multi-value line, only the first item. Never applied to manual values.
local function capitalizeFirstLetter(text)
if not text or text == "" then return text end
if text:match("^%[%[") then
local closePos = text:find("%]%]", 3, true)
local pipePos = text:find("|", 1, true)
local splitPos
if pipePos and (not closePos or pipePos < closePos) then
splitPos = pipePos -- piped: capitalize the display half only
else
splitPos = 2 -- unpiped: capitalize just past the leading "[["
end
return text:sub(1, splitPos) .. wikiUcfirst(text:sub(splitPos + 1))
elseif text:match("^%[https?://") then
-- ennym-wd external link: "[url label] <sup>(lang)</sup>" --
-- capitalize the label, right after the URL's own space.
local spacePos = text:find(" ", 2, true)
if spacePos then
return text:sub(1, spacePos) .. wikiUcfirst(text:sub(spacePos + 1))
end
return text
end
return wikiUcfirst(text)
end
-- Builds a wikilink for a Wikidata item: gv sitelink, else gv label (as a
-- redlink), else an ennym-wd external link to Wikidata. Display text always
-- prefers the gv label, even when a sitelink has a different title.
-- shorten (default true): strip a "role + country" suffix (shortManxForm) --
-- pass false for an ordinary proper name (a chamber, a calendar concept).
-- capitalize (default true): pass false when building one item of a
-- multi-value list, where only the caller's finished line gets capitalized.
-- Returns nil only when nothing resolves at all.
local function getWdItemManxLink(qid, shorten, capitalize)
if not qid then return nil end
if capitalize == nil then capitalize = true 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
if capitalize then
gvLabel = wikiUcfirst(gvLabel)
end
else
gvLabel = nil
end
if not sitelinkTitle and not gvLabel then
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
-- Office title from a property set directly on the country (P1906 "office
-- held by head of state" / P1313 "office held by head of government"),
-- when Wikidata records it -- avoids the multi-role ambiguity in
-- getWdPositionTitle below. Tried first.
local function getWdOfficeItemTitle(officeProperty)
local officeQid = getWdRawPropertyId(officeProperty)
if not officeQid then return nil end
return getWdItemManxLink(officeQid)
end
-- Fallback for a country with no P1906/P1313 set: the officeholder's own
-- "position held" (P39). A person can hold several concurrent P39s (several
-- realms, or an MP/party-leader/PM combo) with no reliable qualifier saying
-- which is "the" state office, so this tries every current candidate
-- (P1001-jurisdiction-filtered first) and uses the first with a real gv
-- article -- in practice the actual office is the one likely to have one.
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 "upper house" / "lower house" class items.
local UPPER_HOUSE_QID = "Q637846"
local LOWER_HOUSE_QID = "Q375928"
-- Resolves a bicameral legislature's two chambers via "has part(s)" (P527)
-- + "instance of" (P31) on each part. Unicameral (no P527) or ambiguous
-- data yields nothing for that side; no auto-built citation is attached.
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
-- Wikidata's "proleptic Julian calendar" item -- not plain "Julian
-- calendar" (Q11184); a time value's calendar model always points to the
-- proleptic variant.
local JULIAN_CALENDAR_QID = "Q1985786"
-- Wd appends " (Joolagh)" for a Julian-calendar date, with a blind,
-- unverified link. Rebuilds it as a real three-tier link, keeping "Joolagh"
-- as the display text; falls back to plain unlinked text if nothing resolves.
local function getJulianCalendarSuffixLink()
local link = getWdItemManxLink(JULIAN_CALENDAR_QID, false)
if link then
local target = link:match("^%[%[([^%[%]|]+)") or link:match("^%[%[([^%[%]|]+)%]%]$")
if target then
return "[[" .. target .. "|Joolagh]]"
end
return link
end
return "Joolagh"
end
-- Row templates: plain 2-cell rows, matching every other submodule
-- (çhengaghyn, balley, bratteeyn). The old template's 3-column grid caused
-- a layout bug when mixed with 2-column rows. Sub-items get a "•" bullet +
-- lighter weight instead of a spacer column.
local ROW = '<tr%s><th style="vertical-align:top; white-space:nowrap; text-align:left; font-weight:bold; padding-left:0.4em; padding-right:0.4em;">%s</th><td style="vertical-align:top; padding-left:0.4em; padding-right:0.4em;">%s</td></tr>'
local SUBROW = '<tr%s><th style="vertical-align:top; white-space:nowrap; text-align:left; font-weight:normal; padding-left:0.9em; padding-right:0.4em;">• %s</th><td style="vertical-align:top; padding-left:0.4em; padding-right:0.4em;">%s</td></tr>'
local HEADER = '<tr class="mergedtoprow"><th colspan="2" style="text-align:left; padding-left:0.4em; padding-right:0.4em;">%s</th></tr>'
-- Builds a class="..." attribute, or an empty string.
local function trClass(name)
if name and name ~= "" then return ' class="' .. name .. '"' end
return ""
end
-- Wraps a section label in [[...]], unless it's already a full wikilink
-- (a manual |sorçh_kionedeeaght=[[target|display]] override) -- otherwise
-- that would double-bracket into a broken [[[[target|display]]]].
local function wikilinkLabel(label)
if not label or label == "" then return label end
if label:find("%[%[") then return label end
return "[[" .. label .. "]]"
end
-- Formats a run of bullet sub-rows with the merged-border classes: every
-- row but the last gets mergedrow, the last gets mergedbottomrow.
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 Module:Kishtey fys çheer uses between submodules, reused
-- here between this module's own sections -- only inserted between two
-- sections that both produced rows.
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)
-- Allow being called as p.main(args) with no frame (used by tests).
if not args then
args = frame
frame = mw.getCurrentFrame()
end
local rows = {}
local govRows = {}
local quaiylRows = {}
local foundingRows = {}
----------------------------------------------------------------
-- 1-2. REILTYS (government type) + leaders (head of state/government,
-- etc.). enmysN_fer-toshee/ennymN_fer-toshee are the old gendered
-- param names; enmys_toshiaghN/ennym_toshiaghN are the gender-neutral
-- synonyms and take priority when both are given.
----------------------------------------------------------------
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: basic form of government (P122), joining every
-- value. Routed through getWdItemManxLink (not Wd's own "linked"
-- flag) since a P122 value rarely has a gv sitelink and would
-- otherwise leak unlinked English.
local govTypeQids = getWdRawPropertyIds("P122")
local govTypeParts = {}
for _, qid in ipairs(govTypeQids) do
local link = getWdItemManxLink(qid, false, false)
if link then table.insert(govTypeParts, link) end
end
if #govTypeParts > 0 then
govTypeRaw = capitalizeFirstLetter(table.concat(govTypeParts, ", "))
end
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: head of state (P35) / head of government (P6).
local hosBase, hosCitation = getWdPropertyWithCitation("P35", {"linked"})
local hos = shortenLinkedCountryName(ensureLinked(hosBase))
if hos and hosCitation then hos = hos .. hosCitation end
local hogBase, hogCitation = getWdPropertyWithCitation("P6", {"linked"})
local hog = ensureLinked(hogBase)
if hog and hogCitation then hog = hog .. hogCitation end
-- Some countries (US, France, Russia, ...) record the same person as
-- both P35 and P6 -- skip the head-of-government row when they match.
local hosQid = getWdRawPropertyId("P35")
local hogQid = getWdRawPropertyId("P6")
local sameHeadOfStateAndGovernment = hos and hog and hosQid and hogQid and hosQid == hogQid
if hos then
local hosTitle = getManual(args, {"sorçh_kione_steat"})
or getWdOfficeItemTitle("P1906") -- office held by head of state
or getWdPositionTitle("P35")
or getWikidataPropertyLabel("P35")
or "Kione steat"
table.insert(leaderPairs, {title = hosTitle, name = hos})
-- Head of state's "proxy" (e.g. the Isle of Man's Lieutenant
-- Governor), via P1393 (a qualifier on P35, value = the office;
-- P1308 on that office = the current holder).
if not isNone(getManual(args, {"ynnydee_kione_steat"})) then
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
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 and not sameHeadOfStateAndGovernment then
local hogTitle = getManual(args, {"sorçh_kione_reiltys"})
or getWdOfficeItemTitle("P1313") -- office held by head of government
or getWdPositionTitle("P6")
or getWikidataPropertyLabel("P6")
or "Kione reiltys"
table.insert(leaderPairs, {title = hogTitle, name = hog})
end
end
local reiltysLabel = getGenitiveLinkedLabel("Reiltys")
if govShown then
local govClass = (#leaderPairs > 0) and "mergedtoprow" or ""
table.insert(govRows, string.format(ROW, trClass(govClass), reiltysLabel, applyRefNote(govTypeRaw, govRef, govNote, frame)))
elseif #leaderPairs > 0 then
table.insert(govRows, string.format(HEADER, reiltysLabel))
end
if #leaderPairs > 0 then
-- Manual ref/note for the whole leaders block is attached to the
-- last row (a Wikidata-sourced name already carries its own).
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.
----------------------------------------------------------------
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"})
local quaiylQid = nil
if not quaiyl then
-- Wd's "linked" flag leaks unlinked English with no gv sitelink
-- (e.g. Scotland's P194); chain through the raw QID instead.
quaiylQid = getWdRawPropertyId("P194")
if quaiylQid then
quaiyl = getWdItemManxLink(quaiylQid, false)
end
end
if not quaiylSyrjey or not quaiylInshley then
-- Chamber names, applied independently to whichever side is unset.
local legislatureQid = quaiylQid or 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) + establishment
-- events -- manual-only, ported from the old template's numbered
-- slots (1-9). kionedeeaght is a synonym for kiondeeaght.
----------------------------------------------------------------
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
-- taghyrt_bunneeaghtN/date_bunneeaghtN (new) vs. taghyrtN_bunnit/
-- dateN_bunnit (old, still works).
local event = getManual(args, {"taghyrt_bunneeaght" .. i, "taghyrt" .. i .. "_bunnit"})
local date = getManual(args, {"date_bunneeaght" .. i, "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), wikilinkLabel(foundingLabel), applyRefNote(foundingValue, foundingRef, foundingNote, frame)))
elseif #establishmentRows > 0 then
local headerLabel = applyRefNote(wikilinkLabel(foundingLabel), foundingRef, foundingNote, frame)
table.insert(foundingRows, string.format(HEADER, headerLabel))
end
appendIndentRun(foundingRows, establishmentRows)
elseif not isNone(getManual(args, {"bunnit"})) then
-- Wikidata fallback: inception (P571), only when the whole
-- establishment block was left unset (not |bunnit=none).
local inception = getWdProperty("P571")
if inception and inception:find(" (Joolagh)", 1, true) then
inception = inception:gsub(" %(Joolagh%)", " (" .. getJulianCalendarSuffixLink() .. ")", 1)
end
if inception then
table.insert(foundingRows, string.format(ROW, "", wikilinkLabel(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
lrvym0u4ov8sse8kxynzoajwt8kt2l8
Module:Kishtey fys çheer/craueeaght
828
55872
393144
393121
2026-09-13T22:14:26Z
MacTire02
219
baarney
393144
Scribunto
text/plain
local p = {}
-- Module:Kishtey fys çheer/craueeaght ("Religion") -- a brand-new section
-- with NO equivalent in the old HTML template at all (unlike its sibling
-- /possanyn_kynneeagh "Ethnic groups", which carries an old parameter
-- forward). Built to match your reference screenshot: a "Craueeaght
-- (<year>)[ref]" label, with the full breakdown (whatever mix of
-- percentages/religions an editor enters) as the value -- structurally
-- identical to /possanyn_kynneeagh, just with new parameter names since
-- there's no old ones to preserve:
--
-- |craueeaght= -- the value (a free-form list, same as the
-- old template already expects editors to
-- hand-format for `possanyn_kynneeagh`)
-- |blein_craueeaght= -- the census/survey year, shown in
-- parentheses after the label
-- |imraa_craueeaght= -- manual <ref> citation (attached to the
-- LABEL, right after the year -- see
-- /possanyn_kynneeagh's header comment for
-- why)
-- |noteyn_craueeaght= -- manual {{efn}} footnote
--
-- Label is a plain (unpiped) [[Craueeaght]] link, per your instruction --
-- "religion" doesn't need the singular/plural-linking-trick
-- /possanyn_kynneeagh's `[[Possan kynneeagh|Possanyn kynneeagh]]` uses (the
-- article title itself, "Craueeaght", already IS the word wanted on
-- display).
--
-- No Wikidata fallback, for exactly the same reason as
-- /possanyn_kynneeagh: Wikidata's P140 "religion or worldview" is
-- sometimes recorded on a country's own item with P1107 "proportion"
-- qualifiers per religion, but -- like a census religion breakdown always
-- is -- this is sparse, inconsistently populated, and highly sensitive to
-- exactly which categories/year a given source used, making it a poor fit
-- for a confident single-value fallback. See /possanyn_kynneeagh's own
-- header comment for the fuller rationale (identical here); revisiting
-- this later, if ever needed, is a small, additive change to this one file
-- alone.
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
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
local ROW = '<tr><th style="vertical-align:top; white-space:nowrap; text-align:left; font-weight:bold; padding-left:0.4em; padding-right:0.4em;">%s</th><td style="vertical-align:top; padding-left:0.4em; padding-right:0.4em;">%s</td></tr>'
function p.main(frame, args)
if not args then
args = frame
frame = mw.getCurrentFrame()
end
local value = getManual(args, {"craueeaght"})
if not value or isNone(value) then return nil end
local year = getManual(args, {"blein_craueeaght"})
local ref = getManual(args, {"imraa_craueeaght"})
local note = getManual(args, {"noteyn_craueeaght"})
local label = "[[Craueeaght]]"
if year then
label = label .. " (" .. year .. ")"
end
label = applyRefNote(label, ref, note, frame)
return string.format(ROW, label, value)
end
return p
ihq90tyesdx6ed26olkfe76ndbs1kyp
393150
393144
2026-09-13T22:27:10Z
MacTire02
219
++
393150
Scribunto
text/plain
local p = {}
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
local function wrapReference(ref)
if not ref or ref == "" then return nil end
if mw.ustring.find(mw.ustring.lower(ref), "<ref", 1, true) then
return ref
end
return "<ref>" .. ref .. "</ref>"
end
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 .. wrapReference(ref)
end
return value
end
local ROW = '<tr><th style="vertical-align:top; white-space:nowrap; text-align:left; font-weight:bold; padding-left:0.4em; padding-right:0.4em;">%s</th><td style="vertical-align:top; padding-left:0.4em; padding-right:0.4em;">%s</td></tr>'
function p.main(frame, args)
if not args then
args = frame
frame = mw.getCurrentFrame()
end
local value = getManual(args, {"craueeaght"})
if not value or isNone(value) then return nil end
local year = getManual(args, {"blein_craueeaght"})
local ref = getManual(args, {"imraa_craueeaght"})
local note = getManual(args, {"noteyn_craueeaght"})
local label = "[[Craueeaght]]"
if year then
label = label .. " (" .. year .. ")"
end
label = applyRefNote(label, ref, note, frame)
return string.format(ROW, label, value)
end
return p
4jc2fj3njfkktuu7aq7084sslqqiqhy
393151
393150
2026-09-13T22:27:40Z
MacTire02
219
++
393151
Scribunto
text/plain
local p = {}
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
local function wrapReference(ref)
if not ref or ref == "" then return nil end
if mw.ustring.find(mw.ustring.lower(ref), "<ref", 1, true) then
return ref
end
return "<ref>" .. ref .. "</ref>"
end
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 .. wrapReference(ref)
end
return value
end
-- Same plain 2-cell row grid as every other submodule (see Module:Kishtey
-- fys çheer/reiltys's own ROW comment for the full rationale).
local ROW = '<tr><th style="vertical-align:top; white-space:nowrap; text-align:left; font-weight:bold; padding-left:0.4em; padding-right:0.4em;">%s</th><td style="vertical-align:top; padding-left:0.4em; padding-right:0.4em;">%s</td></tr>'
function p.main(frame, args)
if not args then
args = frame
frame = mw.getCurrentFrame()
end
local value = getManual(args, {"possanyn_kynneeagh"})
if not value or isNone(value) then return nil end
local year = getManual(args, {"blein_possanyn_kynneeagh"})
local ref = getManual(args, {"imraa_possanyn_kynneeagh"})
local note = getManual(args, {"noteyn_possanyn_kynneeagh"})
local label = "[[Possan kynneeagh|Possanyn kynneeagh]]"
if year then
label = label .. " (" .. year .. ")"
end
label = applyRefNote(label, ref, note, frame)
return string.format(ROW, label, value)
end
return p
8y3r8lx5mgot6xwo3bcki23f8bluu0p
393152
393151
2026-09-13T22:28:19Z
MacTire02
219
++
393152
Scribunto
text/plain
local p = {}
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
local function wrapReference(ref)
if not ref or ref == "" then return nil end
if mw.ustring.find(mw.ustring.lower(ref), "<ref", 1, true) then
return ref
end
return "<ref>" .. ref .. "</ref>"
end
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 .. wrapReference(ref)
end
return value
end
local ROW = '<tr><th style="vertical-align:top; white-space:nowrap; text-align:left; font-weight:bold; padding-left:0.4em; padding-right:0.4em;">%s</th><td style="vertical-align:top; padding-left:0.4em; padding-right:0.4em;">%s</td></tr>'
function p.main(frame, args)
if not args then
args = frame
frame = mw.getCurrentFrame()
end
local value = getManual(args, {"craueeaght"})
if not value or isNone(value) then return nil end
local year = getManual(args, {"blein_craueeaght"})
local ref = getManual(args, {"imraa_craueeaght"})
local note = getManual(args, {"noteyn_craueeaght"})
local label = "[[Craueeaght]]"
if year then
label = label .. " (" .. year .. ")"
end
label = applyRefNote(label, ref, note, frame)
return string.format(ROW, label, value)
end
return p
4jc2fj3njfkktuu7aq7084sslqqiqhy
393158
393152
2026-09-13T23:32:58Z
MacTire02
219
++
393158
Scribunto
text/plain
local p = {}
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
-- Wraps a manual citation in <ref>...</ref>, unless it's already been
-- processed: a literal <ref> typed in a template parameter is expanded by
-- Scribunto into an opaque strip marker (\127UNIQ...QINU\127) the moment
-- frame.args is read, not literal "<ref" text -- re-wrapping that marker
-- creates a bogus extra reference. Pass strip markers and literal <ref>
-- text through unchanged; wrap anything else.
local function wrapReference(ref)
if not ref or ref == "" then return nil end
if mw.ustring.find(ref, "\127", 1, true) then
return ref
end
if mw.ustring.find(mw.ustring.lower(ref), "<ref", 1, true) then
return ref
end
return "<ref>" .. ref .. "</ref>"
end
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 .. wrapReference(ref)
end
return value
end
local ROW = '<tr><th style="vertical-align:top; white-space:nowrap; text-align:left; font-weight:bold; padding-left:0.4em; padding-right:0.4em;">%s</th><td style="vertical-align:top; padding-left:0.4em; padding-right:0.4em;">%s</td></tr>'
function p.main(frame, args)
if not args then
args = frame
frame = mw.getCurrentFrame()
end
local value = getManual(args, {"craueeaght"})
if not value or isNone(value) then return nil end
local year = getManual(args, {"blein_craueeaght"})
local ref = getManual(args, {"imraa_craueeaght"})
local note = getManual(args, {"noteyn_craueeaght"})
local label = "[[Craueeaght]]"
if year then
label = label .. " (" .. year .. ")"
end
label = applyRefNote(label, ref, note, frame)
return string.format(ROW, label, value)
end
return p
meo6lg6roroz3ufchn66ebpjqw112wk
393165
393158
2026-09-14T00:05:14Z
MacTire02
219
++
393165
Scribunto
text/plain
local p = {}
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
-- Wraps a manual citation in <ref>...</ref>, unless it's already fully
-- <ref>-tagged (Scribunto expands a literal <ref> in a parameter into an
-- opaque \127UNIQ...QINU\127 strip marker before this module sees it, so we
-- strip those out and check what's left -- nothing left means it was
-- already tag(s), pass through unchanged; real text left over -- e.g. a
-- bare {{cite web}} call whose own <templatestyles/> leaves an incidental
-- marker -- means it still needs wrapping).
local function wrapReference(ref)
if not ref or ref == "" then return nil end
local withoutMarkers = mw.ustring.gsub(ref, "\127UNIQ.-QINU\127", "")
if mw.ustring.gsub(withoutMarkers, "%s+", "") == "" then
return ref
end
if mw.ustring.find(mw.ustring.lower(ref), "<ref", 1, true) then
return ref
end
return "<ref>" .. ref .. "</ref>"
end
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 .. wrapReference(ref)
end
return value
end
local ROW = '<tr><th style="vertical-align:top; white-space:nowrap; text-align:left; font-weight:bold; padding-left:0.4em; padding-right:0.4em;">%s</th><td style="vertical-align:top; padding-left:0.4em; padding-right:0.4em;">%s</td></tr>'
function p.main(frame, args)
if not args then
args = frame
frame = mw.getCurrentFrame()
end
local value = getManual(args, {"craueeaght"})
if not value or isNone(value) then return nil end
local year = getManual(args, {"blein_craueeaght"})
local ref = getManual(args, {"imraa_craueeaght"})
local note = getManual(args, {"noteyn_craueeaght"})
local label = "[[Craueeaght]]"
if year then
label = label .. " (" .. year .. ")"
end
label = applyRefNote(label, ref, note, frame)
return string.format(ROW, label, value)
end
return p
o7i0mitvjcsfl32amplbr3zrvfp521u
393171
393165
2026-09-14T00:29:55Z
MacTire02
219
++
393171
Scribunto
text/plain
local p = {}
-- Shared "Manx label, else linked Wikidata fallback" helper, for a religion
-- item with no gv label at all.
local ennymWdOK, EnnymWd = pcall(require, "Module:Kishtey fys çheer/ennym-wd")
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
-- Wraps a manual citation in <ref>...</ref>, unless it's already fully
-- <ref>-tagged (Scribunto expands a literal <ref> in a parameter into an
-- opaque \127UNIQ...QINU\127 strip marker before this module sees it, so we
-- strip those out and check what's left -- nothing left means it was
-- already tag(s), pass through unchanged; real text left over -- e.g. a
-- bare {{cite web}} call whose own <templatestyles/> leaves an incidental
-- marker -- means it still needs wrapping).
local function wrapReference(ref)
if not ref or ref == "" then return nil end
local withoutMarkers = mw.ustring.gsub(ref, "\127UNIQ.-QINU\127", "")
if mw.ustring.gsub(withoutMarkers, "%s+", "") == "" then
return ref
end
if mw.ustring.find(mw.ustring.lower(ref), "<ref", 1, true) then
return ref
end
return "<ref>" .. ref .. "</ref>"
end
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 .. wrapReference(ref)
end
return value
end
local ROW = '<tr><th style="vertical-align:top; white-space:nowrap; text-align:left; font-weight:bold; padding-left:0.4em; padding-right:0.4em;">%s</th><td style="vertical-align:top; padding-left:0.4em; padding-right:0.4em;">%s</td></tr>'
-- Resolves a religion item to a link: gv sitelink, else gv label (as a
-- redlink), else an ennym-wd external link to Wikidata.
local function getWdItemLink(qid)
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 not (okLabel and gvLabel and gvLabel ~= "") then gvLabel = nil end
if not sitelinkTitle and not gvLabel then
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 display = gvLabel or sitelinkTitle
if target == display then return "[[" .. target .. "]]" end
return "[[" .. target .. "|" .. display .. "]]"
end
-- e.g. 0.547 -> "54.7%"; drops a trailing ".0".
local function formatProportion(fraction)
local formatted = string.format("%.1f", fraction * 100)
return formatted:gsub("%.0$", "") .. "%"
end
-- Wikidata fallback: religion/worldview (P140), each optionally qualified
-- with a proportion (P1107). Sorted by proportion, largest first, only
-- when every entry has one; otherwise left in Wikidata's own statement
-- order. No auto-built citation (this module doesn't go through Module:Wd).
local function getWdReligions()
local entity = mw.wikibase.getEntityObject()
if not entity then return nil end
local statements = entity:getBestStatements("P140")
if not statements or #statements == 0 then return nil end
local items = {}
for _, statement in ipairs(statements) do
local mainsnak = statement.mainsnak
if mainsnak and mainsnak.snaktype == "value" and mainsnak.datavalue
and mainsnak.datavalue.type == "wikibase-entityid" then
local idValue = mainsnak.datavalue.value
local qid = idValue.id or ("Q" .. tostring(idValue["numeric-id"]))
local link = getWdItemLink(qid)
if link then
local pct = nil
local quals = statement.qualifiers and statement.qualifiers.P1107
local qualSnak = quals and quals[1]
if qualSnak and qualSnak.datavalue and qualSnak.datavalue.value then
pct = tonumber(qualSnak.datavalue.value.amount)
end
table.insert(items, { link = link, pct = pct })
end
end
end
if #items == 0 then return nil end
local allHavePct = true
for _, item in ipairs(items) do
if not item.pct then allHavePct = false break end
end
if allHavePct then
table.sort(items, function(a, b) return a.pct > b.pct end)
end
local parts = {}
for _, item in ipairs(items) do
if item.pct then
table.insert(parts, formatProportion(item.pct) .. " " .. item.link)
else
table.insert(parts, item.link)
end
end
return table.concat(parts, "<br/>")
end
function p.main(frame, args)
if not args then
args = frame
frame = mw.getCurrentFrame()
end
local value = getManual(args, {"craueeaght"})
if not value then
value = getWdReligions()
end
if not value or isNone(value) then return nil end
local year = getManual(args, {"blein_craueeaght"})
local ref = getManual(args, {"imraa_craueeaght"})
local note = getManual(args, {"noteyn_craueeaght"})
local label = "[[Craueeaght]]"
if year then
label = label .. " (" .. year .. ")"
end
label = applyRefNote(label, ref, note, frame)
return string.format(ROW, label, value)
end
return p
kzr3ibcg7rnvamwh5oh4eefr20szaph
Module:Kishtey fys çheer/possanyn kynneeagh
828
55873
393145
393122
2026-09-13T22:15:14Z
MacTire02
219
++
393145
Scribunto
text/plain
local p = {}
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
-- Same manual ref/note channel every other submodule in this system uses.
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
-- Same plain 2-cell row grid as every other submodule (see Module:Kishtey
-- fys çheer/reiltys's own ROW comment for the full rationale).
local ROW = '<tr><th style="vertical-align:top; white-space:nowrap; text-align:left; font-weight:bold; padding-left:0.4em; padding-right:0.4em;">%s</th><td style="vertical-align:top; padding-left:0.4em; padding-right:0.4em;">%s</td></tr>'
function p.main(frame, args)
if not args then
args = frame
frame = mw.getCurrentFrame()
end
local value = getManual(args, {"possanyn_kynneeagh"})
if not value or isNone(value) then return nil end
local year = getManual(args, {"blein_possanyn_kynneeagh"})
local ref = getManual(args, {"imraa_possanyn_kynneeagh"})
local note = getManual(args, {"noteyn_possanyn_kynneeagh"})
local label = "[[Possan kynneeagh|Possanyn kynneeagh]]"
if year then
label = label .. " (" .. year .. ")"
end
label = applyRefNote(label, ref, note, frame)
return string.format(ROW, label, value)
end
return p
bu98akp0zfw4petgrsjqnbttbkfpdze
393153
393145
2026-09-13T22:29:00Z
MacTire02
219
++
393153
Scribunto
text/plain
local p = {}
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
local function wrapReference(ref)
if not ref or ref == "" then return nil end
if mw.ustring.find(mw.ustring.lower(ref), "<ref", 1, true) then
return ref
end
return "<ref>" .. ref .. "</ref>"
end
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 .. wrapReference(ref)
end
return value
end
-- Same plain 2-cell row grid as every other submodule (see Module:Kishtey
-- fys çheer/reiltys's own ROW comment for the full rationale).
local ROW = '<tr><th style="vertical-align:top; white-space:nowrap; text-align:left; font-weight:bold; padding-left:0.4em; padding-right:0.4em;">%s</th><td style="vertical-align:top; padding-left:0.4em; padding-right:0.4em;">%s</td></tr>'
function p.main(frame, args)
if not args then
args = frame
frame = mw.getCurrentFrame()
end
local value = getManual(args, {"possanyn_kynneeagh"})
if not value or isNone(value) then return nil end
local year = getManual(args, {"blein_possanyn_kynneeagh"})
local ref = getManual(args, {"imraa_possanyn_kynneeagh"})
local note = getManual(args, {"noteyn_possanyn_kynneeagh"})
local label = "[[Possan kynneeagh|Possanyn kynneeagh]]"
if year then
label = label .. " (" .. year .. ")"
end
label = applyRefNote(label, ref, note, frame)
return string.format(ROW, label, value)
end
return p
8y3r8lx5mgot6xwo3bcki23f8bluu0p
393159
393153
2026-09-13T23:34:28Z
MacTire02
219
++
393159
Scribunto
text/plain
local p = {}
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
-- Wraps a manual citation in <ref>...</ref>, unless it's already been
-- processed: a literal <ref> typed in a template parameter is expanded by
-- Scribunto into an opaque strip marker (\127UNIQ...QINU\127) the moment
-- frame.args is read, not literal "<ref" text -- re-wrapping that marker
-- creates a bogus extra reference. Pass strip markers and literal <ref>
-- text through unchanged; wrap anything else.
local function wrapReference(ref)
if not ref or ref == "" then return nil end
if mw.ustring.find(ref, "\127", 1, true) then
return ref
end
if mw.ustring.find(mw.ustring.lower(ref), "<ref", 1, true) then
return ref
end
return "<ref>" .. ref .. "</ref>"
end
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 .. wrapReference(ref)
end
return value
end
-- Same plain 2-cell row grid as every other submodule (see Module:Kishtey
-- fys çheer/reiltys's own ROW comment for the full rationale).
local ROW = '<tr><th style="vertical-align:top; white-space:nowrap; text-align:left; font-weight:bold; padding-left:0.4em; padding-right:0.4em;">%s</th><td style="vertical-align:top; padding-left:0.4em; padding-right:0.4em;">%s</td></tr>'
function p.main(frame, args)
if not args then
args = frame
frame = mw.getCurrentFrame()
end
local value = getManual(args, {"possanyn_kynneeagh"})
if not value or isNone(value) then return nil end
local year = getManual(args, {"blein_possanyn_kynneeagh"})
local ref = getManual(args, {"imraa_possanyn_kynneeagh"})
local note = getManual(args, {"noteyn_possanyn_kynneeagh"})
local label = "[[Possan kynneeagh|Possanyn kynneeagh]]"
if year then
label = label .. " (" .. year .. ")"
end
label = applyRefNote(label, ref, note, frame)
return string.format(ROW, label, value)
end
return p
5p68fujv9omqdmr944uul9plniix7nu
393166
393159
2026-09-14T00:05:37Z
MacTire02
219
++
393166
Scribunto
text/plain
local p = {}
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
-- Wraps a manual citation in <ref>...</ref>, unless it's already fully
-- <ref>-tagged (Scribunto expands a literal <ref> in a parameter into an
-- opaque \127UNIQ...QINU\127 strip marker before this module sees it, so we
-- strip those out and check what's left -- nothing left means it was
-- already tag(s), pass through unchanged; real text left over -- e.g. a
-- bare {{cite web}} call whose own <templatestyles/> leaves an incidental
-- marker -- means it still needs wrapping).
local function wrapReference(ref)
if not ref or ref == "" then return nil end
local withoutMarkers = mw.ustring.gsub(ref, "\127UNIQ.-QINU\127", "")
if mw.ustring.gsub(withoutMarkers, "%s+", "") == "" then
return ref
end
if mw.ustring.find(mw.ustring.lower(ref), "<ref", 1, true) then
return ref
end
return "<ref>" .. ref .. "</ref>"
end
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 .. wrapReference(ref)
end
return value
end
-- Same plain 2-cell row grid as every other submodule (see Module:Kishtey
-- fys çheer/reiltys's own ROW comment for the full rationale).
local ROW = '<tr><th style="vertical-align:top; white-space:nowrap; text-align:left; font-weight:bold; padding-left:0.4em; padding-right:0.4em;">%s</th><td style="vertical-align:top; padding-left:0.4em; padding-right:0.4em;">%s</td></tr>'
function p.main(frame, args)
if not args then
args = frame
frame = mw.getCurrentFrame()
end
local value = getManual(args, {"possanyn_kynneeagh"})
if not value or isNone(value) then return nil end
local year = getManual(args, {"blein_possanyn_kynneeagh"})
local ref = getManual(args, {"imraa_possanyn_kynneeagh"})
local note = getManual(args, {"noteyn_possanyn_kynneeagh"})
local label = "[[Possan kynneeagh|Possanyn kynneeagh]]"
if year then
label = label .. " (" .. year .. ")"
end
label = applyRefNote(label, ref, note, frame)
return string.format(ROW, label, value)
end
return p
2icst8yw3euyzq3d5ocy7v45d8hi3k5
393170
393166
2026-09-14T00:14:20Z
MacTire02
219
++
393170
Scribunto
text/plain
local p = {}
-- Shared "Manx label, else linked Wikidata fallback" helper, for an ethnic-
-- group item with no gv label at all.
local ennymWdOK, EnnymWd = pcall(require, "Module:Kishtey fys çheer/ennym-wd")
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
-- Wraps a manual citation in <ref>...</ref>, unless it's already fully
-- <ref>-tagged (Scribunto expands a literal <ref> in a parameter into an
-- opaque \127UNIQ...QINU\127 strip marker before this module sees it, so we
-- strip those out and check what's left -- nothing left means it was
-- already tag(s), pass through unchanged; real text left over -- e.g. a
-- bare {{cite web}} call whose own <templatestyles/> leaves an incidental
-- marker -- means it still needs wrapping).
local function wrapReference(ref)
if not ref or ref == "" then return nil end
local withoutMarkers = mw.ustring.gsub(ref, "\127UNIQ.-QINU\127", "")
if mw.ustring.gsub(withoutMarkers, "%s+", "") == "" then
return ref
end
if mw.ustring.find(mw.ustring.lower(ref), "<ref", 1, true) then
return ref
end
return "<ref>" .. ref .. "</ref>"
end
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 .. wrapReference(ref)
end
return value
end
-- Same plain 2-cell row grid as every other submodule (see Module:Kishtey
-- fys çheer/reiltys's own ROW comment for the full rationale).
local ROW = '<tr><th style="vertical-align:top; white-space:nowrap; text-align:left; font-weight:bold; padding-left:0.4em; padding-right:0.4em;">%s</th><td style="vertical-align:top; padding-left:0.4em; padding-right:0.4em;">%s</td></tr>'
-- Resolves an ethnic-group item to a link: gv sitelink, else gv label (as a
-- redlink), else an ennym-wd external link to Wikidata.
local function getWdItemLink(qid)
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 not (okLabel and gvLabel and gvLabel ~= "") then gvLabel = nil end
if not sitelinkTitle and not gvLabel then
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 display = gvLabel or sitelinkTitle
if target == display then return "[[" .. target .. "]]" end
return "[[" .. target .. "|" .. display .. "]]"
end
-- e.g. 0.947 -> "94.7%"; drops a trailing ".0".
local function formatProportion(fraction)
local formatted = string.format("%.1f", fraction * 100)
return formatted:gsub("%.0$", "") .. "%"
end
-- Wikidata fallback: ethnic groups (P172), each optionally qualified with a
-- proportion (P1107). Sorted by proportion, largest first, only when every
-- entry has one; otherwise left in Wikidata's own statement order. No
-- auto-built citation (this module doesn't go through Module:Wd).
local function getWdEthnicGroups()
local entity = mw.wikibase.getEntityObject()
if not entity then return nil end
local statements = entity:getBestStatements("P172")
if not statements or #statements == 0 then return nil end
local items = {}
for _, statement in ipairs(statements) do
local mainsnak = statement.mainsnak
if mainsnak and mainsnak.snaktype == "value" and mainsnak.datavalue
and mainsnak.datavalue.type == "wikibase-entityid" then
local idValue = mainsnak.datavalue.value
local qid = idValue.id or ("Q" .. tostring(idValue["numeric-id"]))
local link = getWdItemLink(qid)
if link then
local pct = nil
local quals = statement.qualifiers and statement.qualifiers.P1107
local qualSnak = quals and quals[1]
if qualSnak and qualSnak.datavalue and qualSnak.datavalue.value then
pct = tonumber(qualSnak.datavalue.value.amount)
end
table.insert(items, { link = link, pct = pct })
end
end
end
if #items == 0 then return nil end
local allHavePct = true
for _, item in ipairs(items) do
if not item.pct then allHavePct = false break end
end
if allHavePct then
table.sort(items, function(a, b) return a.pct > b.pct end)
end
local parts = {}
for _, item in ipairs(items) do
if item.pct then
table.insert(parts, formatProportion(item.pct) .. " " .. item.link)
else
table.insert(parts, item.link)
end
end
return table.concat(parts, "<br/>")
end
function p.main(frame, args)
if not args then
args = frame
frame = mw.getCurrentFrame()
end
local value = getManual(args, {"possanyn_kynneeagh"})
if not value then
value = getWdEthnicGroups()
end
if not value or isNone(value) then return nil end
local year = getManual(args, {"blein_possanyn_kynneeagh"})
local ref = getManual(args, {"imraa_possanyn_kynneeagh"})
local note = getManual(args, {"noteyn_possanyn_kynneeagh"})
local label = "[[Possan kynneeagh|Possanyn kynneeagh]]"
if year then
label = label .. " (" .. year .. ")"
end
label = applyRefNote(label, ref, note, frame)
return string.format(ROW, label, value)
end
return p
1yjedcsm0xzrrlyh6gmtk19oatjq1yv
Module:Kishtey fys çheer/eaghtyr
828
55874
393173
2026-09-14T00:58:19Z
MacTire02
219
+eaghtyr
393173
Scribunto
text/plain
local p = {}
local KM2_PER_MI2 = 2.589988110336
-- Recognized Wikidata area units (P2046), mapped to their km² factor.
-- Q712226 = square kilometre, Q232291 = square mile. Anything else
-- (hectare, acre, m², ...) is left unconverted rather than risking a wrong
-- guess -- the manual |eaghtyr_km2= override always remains available.
local AREA_UNIT_FACTORS = {
Q712226 = 1,
Q232291 = KM2_PER_MI2,
}
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
-- Wraps a manual citation in <ref>...</ref>, unless it's already fully
-- <ref>-tagged (Scribunto expands a literal <ref> in a parameter into an
-- opaque \127UNIQ...QINU\127 strip marker before this module sees it, so we
-- strip those out and check what's left -- nothing left means it was
-- already tag(s), pass through unchanged; real text left over -- e.g. a
-- bare {{cite web}} call whose own <templatestyles/> leaves an incidental
-- marker -- means it still needs wrapping).
local function wrapReference(ref)
if not ref or ref == "" then return nil end
local withoutMarkers = mw.ustring.gsub(ref, "\127UNIQ.-QINU\127", "")
if mw.ustring.gsub(withoutMarkers, "%s+", "") == "" then
return ref
end
if mw.ustring.find(mw.ustring.lower(ref), "<ref", 1, true) then
return ref
end
return "<ref>" .. ref .. "</ref>"
end
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 .. wrapReference(ref)
end
return value
end
-- Same row grid as Module:Kishtey fys çheer/reiltys (header + bulleted
-- indented sub-rows), since Eaghtyr has the same shape: a section header
-- with several stat lines beneath it.
local SUBROW = '<tr%s><th style="vertical-align:top; white-space:nowrap; text-align:left; font-weight:normal; padding-left:0.9em; padding-right:0.4em;">• %s</th><td style="vertical-align:top; padding-left:0.4em; padding-right:0.4em;">%s</td></tr>'
local HEADER = '<tr class="mergedtoprow"><th colspan="2" style="text-align:left; padding-left:0.4em; padding-right:0.4em;">%s</th></tr>'
local function trClass(name)
if name and name ~= "" then return ' class="' .. name .. '"' end
return ""
end
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
-- e.g. 1234567.5 -> "1,234,567.5"; drops a trailing ".0" and groups the
-- integer part in thousands. Only used for numbers this module computed
-- itself (Wikidata's raw amount, the auto-converted sq-mi figure) -- a
-- manual value is always passed through exactly as the editor typed it.
local function formatNumber(n)
local isNeg = n < 0
n = math.abs(n)
local formatted = string.format("%.2f", n):gsub("%.?0+$", "")
local intPart, decPart = formatted:match("^(%d+)%.?(%d*)$")
local grouped = intPart:reverse():gsub("(%d%d%d)", "%1,"):reverse():gsub("^,", "")
local result = (decPart and decPart ~= "") and (grouped .. "." .. decPart) or grouped
return isNeg and ("-" .. result) or result
end
-- Wikidata fallback: total area (P2046), converted to km² when the unit is
-- one this module recognizes (see AREA_UNIT_FACTORS). Returns a plain
-- number, not a formatted string -- the caller decides display/rounding.
local function getWdAreaKm2()
local entity = mw.wikibase.getEntityObject()
if not entity then return nil end
local statements = entity:getBestStatements("P2046")
if not statements or #statements == 0 then return nil end
local mainsnak = statements[1].mainsnak
if not (mainsnak and mainsnak.snaktype == "value" and mainsnak.datavalue
and mainsnak.datavalue.type == "quantity") then
return nil
end
local value = mainsnak.datavalue.value
local amount = tonumber(value.amount)
if not amount then return nil end
local unitQid = value.unit and value.unit:match("Q%d+$")
local factor = unitQid and AREA_UNIT_FACTORS[unitQid]
if not factor then return nil end
return amount * factor
end
function p.main(frame, args)
if not args then
args = frame
frame = mw.getCurrentFrame()
end
local headerLabel = getManual(args, {"sorçh_eaghtyr"}) or "Eaghtyr"
local ref = getManual(args, {"imraa_eaghtyr"})
local note = getManual(args, {"noteyn_eaghtyr"})
------------------------------------------------------------------
-- Total area ("Yn clane"): manual km² value, else Wikidata (P2046).
-- An explicit |eaghtyr_km2=none suppresses this row (and the sq-mi
-- conversion with it) without touching water%/the custom row below.
------------------------------------------------------------------
local km2Manual = getManual(args, {"eaghtyr_km2"})
local km2Str, km2Number
if km2Manual then
if not isNone(km2Manual) then
km2Str = km2Manual
km2Number = tonumber((km2Manual:gsub(",", "")))
end
else
km2Number = getWdAreaKm2()
if km2Number then km2Str = formatNumber(km2Number) end
end
local totalItem = nil
if km2Str then
local label = getManual(args, {"eaghtyr_lipaid"}) or "Yn clane"
local foScreeuyn = getManual(args, {"eaghtyr_fo-screeuyn"}) or ""
local rhenk = getManual(args, {"eaghtyr_rhenk"})
local miKerManual = getManual(args, {"eaghtyr_mi_ker"})
local miKerStr = miKerManual
if not miKerStr and km2Number then
miKerStr = formatNumber(math.floor(km2Number / KM2_PER_MI2 + 0.5))
end
local value = km2Str .. " [[km²]] " .. foScreeuyn
if rhenk then
value = value .. "([[Rolley çheeraghyn as thallooyn foddey ersooyl rere eaghtyr|" .. rhenk .. "]]) "
end
if miKerStr then
value = value .. "<br/>" .. miKerStr .. " [[Meeiley cherrinagh|mi ker]] "
end
value = applyRefNote(value, ref, note, frame)
totalItem = {label, value}
end
------------------------------------------------------------------
-- Water (%): manual only -- no Wikidata property reliably covers this.
------------------------------------------------------------------
local waterItem = nil
local water = getManual(args, {"ushtey_sy_cheead"})
if water and not isNone(water) then
waterItem = {"[[Ushtey]] ([['Sy cheead|%]])", water}
end
------------------------------------------------------------------
-- Custom second stat row: fully manual, generic label/value pass-through.
------------------------------------------------------------------
local customItem = nil
local customLabel = getManual(args, {"eaghtyr_lipaid2"})
if customLabel then
local customValue = getManual(args, {"eaghtyr_fysseree2"}) or ""
customItem = {customLabel, customValue}
end
if not totalItem and not waterItem and not customItem then return nil end
local rows = {}
if totalItem then
table.insert(rows, string.format(HEADER, headerLabel))
else
-- No total row (e.g. |eaghtyr_km2=none with only water%/custom set):
-- attach the section's own citation to the header instead.
table.insert(rows, string.format(HEADER, applyRefNote(headerLabel, ref, note, frame)))
end
local items = {}
if totalItem then table.insert(items, totalItem) end
if waterItem then table.insert(items, waterItem) end
if customItem then table.insert(items, customItem) end
appendIndentRun(rows, items)
return table.concat(rows)
end
return p
9qb28zsgt16aour1wcflpcx6xfwvupw
393174
393173
2026-09-14T01:02:41Z
MacTire02
219
km2
393174
Scribunto
text/plain
local p = {}
local KM2_PER_MI2 = 2.589988110336
-- Recognized Wikidata area units (P2046), mapped to their km² factor.
-- Q712226 = square kilometre, Q232291 = square mile. Anything else
-- (hectare, acre, m², ...) is left unconverted rather than risking a wrong
-- guess -- the manual |eaghtyr_km2= override always remains available.
local AREA_UNIT_FACTORS = {
Q712226 = 1,
Q232291 = KM2_PER_MI2,
}
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
-- Wraps a manual citation in <ref>...</ref>, unless it's already fully
-- <ref>-tagged (Scribunto expands a literal <ref> in a parameter into an
-- opaque \127UNIQ...QINU\127 strip marker before this module sees it, so we
-- strip those out and check what's left -- nothing left means it was
-- already tag(s), pass through unchanged; real text left over -- e.g. a
-- bare {{cite web}} call whose own <templatestyles/> leaves an incidental
-- marker -- means it still needs wrapping).
local function wrapReference(ref)
if not ref or ref == "" then return nil end
local withoutMarkers = mw.ustring.gsub(ref, "\127UNIQ.-QINU\127", "")
if mw.ustring.gsub(withoutMarkers, "%s+", "") == "" then
return ref
end
if mw.ustring.find(mw.ustring.lower(ref), "<ref", 1, true) then
return ref
end
return "<ref>" .. ref .. "</ref>"
end
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 .. wrapReference(ref)
end
return value
end
-- Same row grid as Module:Kishtey fys çheer/reiltys (header + bulleted
-- indented sub-rows), since Eaghtyr has the same shape: a section header
-- with several stat lines beneath it.
local SUBROW = '<tr%s><th style="vertical-align:top; white-space:nowrap; text-align:left; font-weight:normal; padding-left:0.9em; padding-right:0.4em;">• %s</th><td style="vertical-align:top; padding-left:0.4em; padding-right:0.4em;">%s</td></tr>'
local HEADER = '<tr class="mergedtoprow"><th colspan="2" style="text-align:left; padding-left:0.4em; padding-right:0.4em;">%s</th></tr>'
local function trClass(name)
if name and name ~= "" then return ' class="' .. name .. '"' end
return ""
end
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
-- e.g. 1234567.5 -> "1,234,567.5"; drops a trailing ".0" and groups the
-- integer part in thousands. Only used for numbers this module computed
-- itself (Wikidata's raw amount, the auto-converted sq-mi figure) -- a
-- manual value is always passed through exactly as the editor typed it.
local function formatNumber(n)
local isNeg = n < 0
n = math.abs(n)
local formatted = string.format("%.2f", n):gsub("%.?0+$", "")
local intPart, decPart = formatted:match("^(%d+)%.?(%d*)$")
local grouped = intPart:reverse():gsub("(%d%d%d)", "%1,"):reverse():gsub("^,", "")
local result = (decPart and decPart ~= "") and (grouped .. "." .. decPart) or grouped
return isNeg and ("-" .. result) or result
end
-- Wikidata fallback: total area (P2046), converted to km² when the unit is
-- one this module recognizes (see AREA_UNIT_FACTORS). Returns a plain
-- number, not a formatted string -- the caller decides display/rounding.
local function getWdAreaKm2()
local entity = mw.wikibase.getEntityObject()
if not entity then return nil end
local statements = entity:getBestStatements("P2046")
if not statements or #statements == 0 then return nil end
local mainsnak = statements[1].mainsnak
if not (mainsnak and mainsnak.snaktype == "value" and mainsnak.datavalue
and mainsnak.datavalue.type == "quantity") then
return nil
end
local value = mainsnak.datavalue.value
local amount = tonumber(value.amount)
if not amount then return nil end
local unitQid = value.unit and value.unit:match("Q%d+$")
local factor = unitQid and AREA_UNIT_FACTORS[unitQid]
if not factor then return nil end
return amount * factor
end
function p.main(frame, args)
if not args then
args = frame
frame = mw.getCurrentFrame()
end
local headerLabel = getManual(args, {"sorçh_eaghtyr"}) or "Eaghtyr"
local ref = getManual(args, {"imraa_eaghtyr"})
local note = getManual(args, {"noteyn_eaghtyr"})
------------------------------------------------------------------
-- Total area ("Yn clane"): manual km² value, else Wikidata (P2046).
-- An explicit |eaghtyr_km2=none suppresses this row (and the sq-mi
-- conversion with it) without touching water%/the custom row below.
------------------------------------------------------------------
local km2Manual = getManual(args, {"eaghtyr_km2"})
local km2Str, km2Number
if km2Manual then
if not isNone(km2Manual) then
km2Str = km2Manual
km2Number = tonumber((km2Manual:gsub(",", "")))
end
else
km2Number = getWdAreaKm2()
if km2Number then km2Str = formatNumber(km2Number) end
end
local totalItem = nil
if km2Str then
local label = getManual(args, {"eaghtyr_lipaid"}) or "Yn clane"
local foScreeuyn = getManual(args, {"eaghtyr_fo-screeuyn"}) or ""
local rhenk = getManual(args, {"eaghtyr_rhenk"})
local miKerManual = getManual(args, {"eaghtyr_mi_ker"})
local miKerStr = miKerManual
if not miKerStr and km2Number then
miKerStr = formatNumber(math.floor(km2Number / KM2_PER_MI2 + 0.5))
end
local value = km2Str .. " [[km²|km<sup>2</sup>]] " .. foScreeuyn
if rhenk then
value = value .. "([[Rolley çheeraghyn as thallooyn foddey ersooyl rere eaghtyr|" .. rhenk .. "]]) "
end
if miKerStr then
value = value .. "<br/>" .. miKerStr .. " [[Meeiley cherrinagh|mi ker]] "
end
value = applyRefNote(value, ref, note, frame)
totalItem = {label, value}
end
------------------------------------------------------------------
-- Water (%): manual only -- no Wikidata property reliably covers this.
------------------------------------------------------------------
local waterItem = nil
local water = getManual(args, {"ushtey_sy_cheead"})
if water and not isNone(water) then
waterItem = {"[[Ushtey]] ([['Sy cheead|%]])", water}
end
------------------------------------------------------------------
-- Custom second stat row: fully manual, generic label/value pass-through.
------------------------------------------------------------------
local customItem = nil
local customLabel = getManual(args, {"eaghtyr_lipaid2"})
if customLabel then
local customValue = getManual(args, {"eaghtyr_fysseree2"}) or ""
customItem = {customLabel, customValue}
end
if not totalItem and not waterItem and not customItem then return nil end
local rows = {}
if totalItem then
table.insert(rows, string.format(HEADER, headerLabel))
else
-- No total row (e.g. |eaghtyr_km2=none with only water%/custom set):
-- attach the section's own citation to the header instead.
table.insert(rows, string.format(HEADER, applyRefNote(headerLabel, ref, note, frame)))
end
local items = {}
if totalItem then table.insert(items, totalItem) end
if waterItem then table.insert(items, waterItem) end
if customItem then table.insert(items, customItem) end
appendIndentRun(rows, items)
return table.concat(rows)
end
return p
op0o5j1t59fo22rrpx6n50rjyphltta
Module:Kishtey fys çheer/pobble
828
55875
393175
2026-09-14T01:27:51Z
MacTire02
219
moddyl noa
393175
Scribunto
text/plain
local p = {}
local KM2_PER_MI2 = 2.589988110336
-- P459 ("determination method or standard") qualifier values that
-- distinguish a census from an estimate -- verified directly against
-- wikidata.org, not guessed.
local CENSUS_QID = "Q39825"
local ESTIMATE_QID = "Q791801"
-- Same recognized-area-unit allow-list as Module:Kishtey fys çheer/eaghtyr,
-- duplicated here for the density auto-calc (population ÷ area).
local AREA_UNIT_FACTORS = {
Q712226 = 1,
Q232291 = KM2_PER_MI2,
}
-- Citation-building only (a raw entity fetch can't render Wikidata's own
-- reference snaks into a <ref>) -- see getWdCitation below.
local wdOK, Wd = pcall(require, "Module:Wd")
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
-- Wraps a manual citation in <ref>...</ref>, unless it's already fully
-- <ref>-tagged (Scribunto expands a literal <ref> in a parameter into an
-- opaque \127UNIQ...QINU\127 strip marker before this module sees it, so we
-- strip those out and check what's left -- nothing left means it was
-- already tag(s), pass through unchanged; real text left over means it
-- still needs wrapping).
local function wrapReference(ref)
if not ref or ref == "" then return nil end
local withoutMarkers = mw.ustring.gsub(ref, "\127UNIQ.-QINU\127", "")
if mw.ustring.gsub(withoutMarkers, "%s+", "") == "" then
return ref
end
if mw.ustring.find(mw.ustring.lower(ref), "<ref", 1, true) then
return ref
end
return "<ref>" .. ref .. "</ref>"
end
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 .. wrapReference(ref)
end
return value
end
-- Same header + bulleted sub-rows grid as reiltys/eaghtyr.
local SUBROW = '<tr%s><th style="vertical-align:top; white-space:nowrap; text-align:left; font-weight:normal; padding-left:0.9em; padding-right:0.4em;">• %s</th><td style="vertical-align:top; padding-left:0.4em; padding-right:0.4em;">%s</td></tr>'
local HEADER = '<tr class="mergedtoprow"><th colspan="2" style="text-align:left; padding-left:0.4em; padding-right:0.4em;">%s</th></tr>'
local function trClass(name)
if name and name ~= "" then return ' class="' .. name .. '"' end
return ""
end
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
-- e.g. 1234567.5 -> "1,234,567.5" (decimals=2 default); 96.75 with
-- decimals=1 -> "96.8". Trims a trailing ".0" and groups the integer part
-- in thousands. Only for numbers this module computed itself -- a manual
-- value is always passed through exactly as the editor typed it.
local function formatNumber(n, decimals)
decimals = decimals or 2
local isNeg = n < 0
n = math.abs(n)
local formatted = string.format("%." .. decimals .. "f", n):gsub("%.?0+$", "")
local intPart, decPart = formatted:match("^(%d+)%.?(%d*)$")
local grouped = intPart:reverse():gsub("(%d%d%d)", "%1,"):reverse():gsub("^,", "")
local result = (decPart and decPart ~= "") and (grouped .. "." .. decPart) or grouped
return isNeg and ("-" .. result) or result
end
-- Colored increase/decrease/steady arrow, prepended to a Wikidata-sourced
-- population figure -- matching enwiki infoboxes' {{increase}}/{{decrease}}/
-- {{steady}} look. Hardcoded rather than routed through gv.wiki templates
-- of the same name, since it's not known whether those exist there yet.
local function trendArrow(direction)
if direction == "up" then
return '<span style="color:green;" title="Bishaghey">▲</span>'
elseif direction == "down" then
return '<span style="color:red;" title="Ismoo">▼</span>'
elseif direction == "steady" then
return '<span style="color:gray;" title="Kiune">►</span>'
end
return ""
end
-- All P1082 ("population") statements on the current item, each reduced to
-- {amount, year, method}. `method` is the raw P459 qualifier QID (nil if
-- absent) -- classify() below turns that into "census"/"estimate"/nil.
-- Sorted ascending by year, so the LAST matching entry in a single pass is
-- always the most recent one.
local function getWdPopulationStatements()
local entity = mw.wikibase.getEntityObject()
if not entity then return {} end
local statements = entity:getBestStatements("P1082")
if not statements then return {} end
local results = {}
for _, statement in ipairs(statements) do
local mainsnak = statement.mainsnak
if mainsnak and mainsnak.snaktype == "value" and mainsnak.datavalue
and mainsnak.datavalue.type == "quantity" then
local amount = tonumber(mainsnak.datavalue.value.amount)
local timeQuals = statement.qualifiers and statement.qualifiers.P585
local timeSnak = timeQuals and timeQuals[1]
local timeValue = timeSnak and timeSnak.datavalue and timeSnak.datavalue.value
local year = timeValue and timeValue.time and tonumber(timeValue.time:match("(%-?%d+)%-"))
if amount and year then
local methodQuals = statement.qualifiers and statement.qualifiers.P459
local methodSnak = methodQuals and methodQuals[1]
local methodValue = methodSnak and methodSnak.datavalue and methodSnak.datavalue.value
local method = methodValue and (methodValue.id or ("Q" .. tostring(methodValue["numeric-id"])))
table.insert(results, {amount = amount, year = year, method = method})
end
end
end
table.sort(results, function(a, b) return a.year < b.year end)
return results
end
local function classify(entry)
if entry.method == CENSUS_QID then return "census" end
if entry.method == ESTIMATE_QID then return "estimate" end
return nil
end
-- Increase/decrease/steady, comparing `entry` to whichever entry in the
-- same (chronologically sorted) list immediately precedes it -- census and
-- estimate data points are compared against each other here, matching how
-- a reader actually reads a population trend, not just within one category.
local function trendFor(allEntries, targetEntry)
local prev = nil
for _, entry in ipairs(allEntries) do
if entry == targetEntry then break end
prev = entry
end
if not prev then return nil end
if targetEntry.amount > prev.amount then return "up" end
if targetEntry.amount < prev.amount then return "down" end
return "steady"
end
-- Shared innards of a Wd-based fetch, filtered to one exact statement via
-- its own P459/P585 qualifier values (see getWdCitation below).
local function getWdPropertyRaw(property, extraArgs, includeReference)
if not wdOK or not Wd or not Wd._property then return nil end
local callArgs = {}
if includeReference then table.insert(callArgs, "reference") end
table.insert(callArgs, "best")
table.insert(callArgs, property)
for k, v in pairs(extraArgs or {}) do callArgs[k] = v end
local ok, result = pcall(Wd._property, callArgs)
if ok and result and result ~= "" then return result end
return nil
end
-- The auto-built citation for ONE already-identified P1082 statement
-- (pinned down by its own P459 method + P585 year, so this can't pick up
-- a different statement's reference). Returns nil if Wd is unavailable,
-- the statement has no usable reference, or the year carries finer-than-
-- year precision (P585's raw value then won't string-match a plain year --
-- a graceful "no citation shown" rather than a wrong one).
local function getWdCitation(property, extraArgs)
local base = getWdPropertyRaw(property, extraArgs, false)
if not base then return nil end
local withRef = getWdPropertyRaw(property, extraArgs, true)
if not withRef or withRef == base then return nil end
if withRef:sub(1, #base) == base then
local citation = withRef:sub(#base + 1)
if citation ~= "" then return citation end
end
return nil
end
-- Wikidata fallback for density: total area (P2046), converted to km² when
-- the unit is one this module recognizes -- duplicated from eaghtyr.lua
-- rather than shared, per this project's per-file convention.
local function getWdAreaKm2()
local entity = mw.wikibase.getEntityObject()
if not entity then return nil end
local statements = entity:getBestStatements("P2046")
if not statements or #statements == 0 then return nil end
local mainsnak = statements[1].mainsnak
if not (mainsnak and mainsnak.snaktype == "value" and mainsnak.datavalue
and mainsnak.datavalue.type == "quantity") then
return nil
end
local value = mainsnak.datavalue.value
local amount = tonumber(value.amount)
if not amount then return nil end
local unitQid = value.unit and value.unit:match("Q%d+$")
local factor = unitQid and AREA_UNIT_FACTORS[unitQid]
if not factor then return nil end
return amount * factor
end
-- Builds one census/estimate row from manual params, else Wikidata.
-- `labelWord` is "Coontey-pobble" or "Ooley-pobble"; `methodQid` picks
-- which P459 category to read; `manualTrendAgainst` (a resolved number,
-- may be nil) lets a manual estimate get a trend arrow against the
-- census figure when there's no Wikidata history to compare against.
local function buildPopulationItem(args, frame, paramPrefix, labelWord, methodQid, statements, manualTrendAgainst)
local manual = getManual(args, {"pobble_" .. paramPrefix})
local year = getManual(args, {"blein_" .. paramPrefix .. "_pobble"})
local rhenk = getManual(args, {"rhenk_" .. paramPrefix .. "_pobble"})
local ref = getManual(args, {"imraa_" .. paramPrefix .. "_pobble"})
local note = getManual(args, {"noteyn_" .. paramPrefix .. "_pobble"})
if manual then
if isNone(manual) then return nil, nil end
local number = tonumber((manual:gsub(",", "")))
local trend = (number and manualTrendAgainst) and (
number > manualTrendAgainst and "up"
or number < manualTrendAgainst and "down"
or "steady"
) or nil
local label = labelWord .. (year and (" " .. year) or "")
local value = (trend and trendArrow(trend) or "") .. manual .. " "
if rhenk then
value = value .. "([[Rolley çheeraghyn rere earroo yn phobble|" .. rhenk .. "]]) "
end
value = applyRefNote(value, ref, note, frame)
return {label, value}, number
end
local latest = nil
for _, entry in ipairs(statements) do
if classify(entry) == (methodQid == CENSUS_QID and "census" or "estimate") then
latest = entry
end
end
if not latest then return nil, nil end
local trend = trendFor(statements, latest)
local citation = getWdCitation("P1082", {P459 = methodQid, P585 = tostring(latest.year)})
local label = labelWord .. " " .. latest.year
local value = (trend and trendArrow(trend) or "") .. formatNumber(latest.amount) .. " "
if rhenk then
value = value .. "([[Rolley çheeraghyn rere earroo yn phobble|" .. rhenk .. "]]) "
end
if citation then value = value .. citation end
value = applyRefNote(value, ref, note, frame)
return {label, value}, latest.amount
end
function p.main(frame, args)
if not args then
args = frame
frame = mw.getCurrentFrame()
end
local headerLabel = getManual(args, {"sorçh_pobble"}) or "[[Earroo yn phobble]]"
local wdStatements = nil
local function statements()
if wdStatements == nil then wdStatements = getWdPopulationStatements() end
return wdStatements
end
------------------------------------------------------------------
-- Census, then estimate (old template's own order) -- census is
-- resolved first so a manual estimate can compare its trend against it.
------------------------------------------------------------------
local censusItem, censusNumber = buildPopulationItem(args, frame, "coontey", "Coontey-pobble", CENSUS_QID, statements(), nil)
local estimateItem, estimateNumber = buildPopulationItem(args, frame, "ooley", "Ooley-pobble", ESTIMATE_QID, statements(), censusNumber)
------------------------------------------------------------------
-- Density: manual km², else population ÷ area (both must resolve).
-- No auto citation -- a computed ratio isn't one citable statement.
------------------------------------------------------------------
local densityRef = getManual(args, {"imraa_glooaght_pobble"})
local densityNote = getManual(args, {"noteyn_glooaght_pobble"})
local densityManual = getManual(args, {"glooaght_pobble_km2"})
local densityItem = nil
local densityKm2Str, densityKm2Number
if densityManual then
if not isNone(densityManual) then
densityKm2Str = densityManual
densityKm2Number = tonumber((densityManual:gsub(",", "")))
end
else
local populationForDensity = estimateNumber or censusNumber
local areaKm2 = populationForDensity and getWdAreaKm2()
if populationForDensity and areaKm2 and areaKm2 > 0 then
densityKm2Number = populationForDensity / areaKm2
densityKm2Str = formatNumber(densityKm2Number, 1)
end
end
if densityKm2Str then
local foScreeuyn = getManual(args, {"gloo_pob_fo-screeuyn"}) or ""
local rhenk = getManual(args, {"rhenk_glooaght_pobble"})
local miKerManual = getManual(args, {"glooaght_pobble_mi_ker"})
local miKerStr = miKerManual
if not miKerStr and densityKm2Number then
miKerStr = formatNumber(densityKm2Number * KM2_PER_MI2, 1)
end
local value = densityKm2Str .. "/km<sup>2</sup> " .. foScreeuyn
if rhenk then
value = value .. "([[Rolley çheeraghyn rere glooaght y phobble|" .. rhenk .. "]]) "
end
if miKerStr then
value = value .. "<br/>" .. miKerStr .. "/mi ker"
end
value = applyRefNote(value, densityRef, densityNote, frame)
densityItem = {"[[Glooaght y phobble|Glooaght]]", value}
end
if not censusItem and not estimateItem and not densityItem then return nil end
local rows = {string.format(HEADER, headerLabel)}
local items = {}
if estimateItem then table.insert(items, estimateItem) end
if censusItem then table.insert(items, censusItem) end
if densityItem then table.insert(items, densityItem) end
appendIndentRun(rows, items)
return table.concat(rows)
end
return p
hh78td56sttlemq4k7z9pjrxxar9fc6
393177
393175
2026-09-14T01:33:33Z
MacTire02
219
++
393177
Scribunto
text/plain
local p = {}
local KM2_PER_MI2 = 2.589988110336
-- P459 ("determination method or standard") qualifier values that
-- distinguish a census from an estimate -- verified directly against
-- wikidata.org, not guessed.
local CENSUS_QID = "Q39825"
local ESTIMATE_QID = "Q791801"
-- Same recognized-area-unit allow-list as Module:Kishtey fys çheer/eaghtyr,
-- duplicated here for the density auto-calc (population ÷ area).
local AREA_UNIT_FACTORS = {
Q712226 = 1,
Q232291 = KM2_PER_MI2,
}
-- Citation-building only (a raw entity fetch can't render Wikidata's own
-- reference snaks into a <ref>) -- see getWdCitation below.
local wdOK, Wd = pcall(require, "Module:Wd")
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
-- Wraps a manual citation in <ref>...</ref>, unless it's already fully
-- <ref>-tagged (Scribunto expands a literal <ref> in a parameter into an
-- opaque \127UNIQ...QINU\127 strip marker before this module sees it, so we
-- strip those out and check what's left -- nothing left means it was
-- already tag(s), pass through unchanged; real text left over means it
-- still needs wrapping).
local function wrapReference(ref)
if not ref or ref == "" then return nil end
local withoutMarkers = mw.ustring.gsub(ref, "\127UNIQ.-QINU\127", "")
if mw.ustring.gsub(withoutMarkers, "%s+", "") == "" then
return ref
end
if mw.ustring.find(mw.ustring.lower(ref), "<ref", 1, true) then
return ref
end
return "<ref>" .. ref .. "</ref>"
end
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 .. wrapReference(ref)
end
return value
end
-- Same header + bulleted sub-rows grid as reiltys/eaghtyr.
local SUBROW = '<tr%s><th style="vertical-align:top; white-space:nowrap; text-align:left; font-weight:normal; padding-left:0.9em; padding-right:0.4em;">• %s</th><td style="vertical-align:top; padding-left:0.4em; padding-right:0.4em;">%s</td></tr>'
local HEADER = '<tr class="mergedtoprow"><th colspan="2" style="text-align:left; padding-left:0.4em; padding-right:0.4em;">%s</th></tr>'
local function trClass(name)
if name and name ~= "" then return ' class="' .. name .. '"' end
return ""
end
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
-- e.g. 1234567.5 -> "1,234,567.5" (decimals=2 default); 96.75 with
-- decimals=1 -> "96.8". Trims a trailing ".0" and groups the integer part
-- in thousands. Only for numbers this module computed itself -- a manual
-- value is always passed through exactly as the editor typed it.
local function formatNumber(n, decimals)
decimals = decimals or 2
local isNeg = n < 0
n = math.abs(n)
local formatted = string.format("%." .. decimals .. "f", n):gsub("%.?0+$", "")
local intPart, decPart = formatted:match("^(%d+)%.?(%d*)$")
local grouped = intPart:reverse():gsub("(%d%d%d)", "%1,"):reverse():gsub("^,", "")
local result = (decPart and decPart ~= "") and (grouped .. "." .. decPart) or grouped
return isNeg and ("-" .. result) or result
end
-- Colored increase/decrease/steady arrow, prepended to a Wikidata-sourced
-- population figure -- matching enwiki infoboxes' {{increase}}/{{decrease}}/
-- {{steady}} look. Hardcoded rather than routed through gv.wiki templates
-- of the same name, since it's not known whether those exist there yet.
local function trendArrow(direction)
if direction == "up" then
return '<span style="color:green;" title="Bishaghey">▲</span>'
elseif direction == "down" then
return '<span style="color:red;" title="Ismoo">▼</span>'
elseif direction == "steady" then
return '<span style="color:gray;" title="Kiune">►</span>'
end
return ""
end
-- All P1082 ("population") statements on the current item, each reduced to
-- {amount, year, method}. `method` is the raw P459 qualifier QID (nil if
-- absent) -- classify() below turns that into "census"/"estimate"/nil.
-- Sorted ascending by year, so the LAST matching entry in a single pass is
-- always the most recent one.
local function getWdPopulationStatements()
local entity = mw.wikibase.getEntityObject()
if not entity then return {} end
local statements = entity:getBestStatements("P1082")
if not statements then return {} end
local results = {}
for _, statement in ipairs(statements) do
local mainsnak = statement.mainsnak
if mainsnak and mainsnak.snaktype == "value" and mainsnak.datavalue
and mainsnak.datavalue.type == "quantity" then
local amount = tonumber(mainsnak.datavalue.value.amount)
local timeQuals = statement.qualifiers and statement.qualifiers.P585
local timeSnak = timeQuals and timeQuals[1]
local timeValue = timeSnak and timeSnak.datavalue and timeSnak.datavalue.value
local year = timeValue and timeValue.time and tonumber(timeValue.time:match("(%-?%d+)%-"))
if amount and year then
local methodQuals = statement.qualifiers and statement.qualifiers.P459
local methodSnak = methodQuals and methodQuals[1]
local methodValue = methodSnak and methodSnak.datavalue and methodSnak.datavalue.value
local method = methodValue and (methodValue.id or ("Q" .. tostring(methodValue["numeric-id"])))
table.insert(results, {amount = amount, year = year, method = method})
end
end
end
table.sort(results, function(a, b) return a.year < b.year end)
return results
end
-- "census" only when explicitly tagged as one; every other statement
-- (tagged "estimation", tagged something else entirely, or with no P459
-- qualifier at all -- common in the wild, since not every contributor
-- tags a population figure's determination method) defaults to
-- "estimate", so a country with untagged data still shows its most
-- recent population instead of showing nothing at all.
local function classify(entry)
if entry.method == CENSUS_QID then return "census" end
return "estimate"
end
-- Increase/decrease/steady, comparing `entry` to whichever entry in the
-- same (chronologically sorted) list immediately precedes it -- census and
-- estimate data points are compared against each other here, matching how
-- a reader actually reads a population trend, not just within one category.
local function trendFor(allEntries, targetEntry)
local prev = nil
for _, entry in ipairs(allEntries) do
if entry == targetEntry then break end
prev = entry
end
if not prev then return nil end
if targetEntry.amount > prev.amount then return "up" end
if targetEntry.amount < prev.amount then return "down" end
return "steady"
end
-- Shared innards of a Wd-based fetch, filtered to one exact statement via
-- its own P459/P585 qualifier values (see getWdCitation below).
local function getWdPropertyRaw(property, extraArgs, includeReference)
if not wdOK or not Wd or not Wd._property then return nil end
local callArgs = {}
if includeReference then table.insert(callArgs, "reference") end
table.insert(callArgs, "best")
table.insert(callArgs, property)
for k, v in pairs(extraArgs or {}) do callArgs[k] = v end
local ok, result = pcall(Wd._property, callArgs)
if ok and result and result ~= "" then return result end
return nil
end
-- The auto-built citation for ONE already-identified P1082 statement
-- (pinned down by its own P459 method + P585 year, so this can't pick up
-- a different statement's reference). Returns nil if Wd is unavailable,
-- the statement has no usable reference, or the year carries finer-than-
-- year precision (P585's raw value then won't string-match a plain year --
-- a graceful "no citation shown" rather than a wrong one).
local function getWdCitation(property, extraArgs)
local base = getWdPropertyRaw(property, extraArgs, false)
if not base then return nil end
local withRef = getWdPropertyRaw(property, extraArgs, true)
if not withRef or withRef == base then return nil end
if withRef:sub(1, #base) == base then
local citation = withRef:sub(#base + 1)
if citation ~= "" then return citation end
end
return nil
end
-- Wikidata fallback for density: total area (P2046), converted to km² when
-- the unit is one this module recognizes -- duplicated from eaghtyr.lua
-- rather than shared, per this project's per-file convention.
local function getWdAreaKm2()
local entity = mw.wikibase.getEntityObject()
if not entity then return nil end
local statements = entity:getBestStatements("P2046")
if not statements or #statements == 0 then return nil end
local mainsnak = statements[1].mainsnak
if not (mainsnak and mainsnak.snaktype == "value" and mainsnak.datavalue
and mainsnak.datavalue.type == "quantity") then
return nil
end
local value = mainsnak.datavalue.value
local amount = tonumber(value.amount)
if not amount then return nil end
local unitQid = value.unit and value.unit:match("Q%d+$")
local factor = unitQid and AREA_UNIT_FACTORS[unitQid]
if not factor then return nil end
return amount * factor
end
-- Builds one census/estimate row from manual params, else Wikidata.
-- `labelWord` is "Coontey-pobble" or "Ooley-pobble"; `methodQid` picks
-- which P459 category to read; `manualTrendAgainst` (a resolved number,
-- may be nil) lets a manual estimate get a trend arrow against the
-- census figure when there's no Wikidata history to compare against.
local function buildPopulationItem(args, frame, paramPrefix, labelWord, methodQid, statements, manualTrendAgainst)
local manual = getManual(args, {"pobble_" .. paramPrefix})
local year = getManual(args, {"blein_" .. paramPrefix .. "_pobble"})
local rhenk = getManual(args, {"rhenk_" .. paramPrefix .. "_pobble"})
local ref = getManual(args, {"imraa_" .. paramPrefix .. "_pobble"})
local note = getManual(args, {"noteyn_" .. paramPrefix .. "_pobble"})
if manual then
if isNone(manual) then return nil, nil end
local number = tonumber((manual:gsub(",", "")))
local trend = (number and manualTrendAgainst) and (
number > manualTrendAgainst and "up"
or number < manualTrendAgainst and "down"
or "steady"
) or nil
local label = labelWord .. (year and (" " .. year) or "")
local value = (trend and trendArrow(trend) or "") .. manual .. " "
if rhenk then
value = value .. "([[Rolley çheeraghyn rere earroo yn phobble|" .. rhenk .. "]]) "
end
value = applyRefNote(value, ref, note, frame)
return {label, value}, number
end
local latest = nil
for _, entry in ipairs(statements) do
if classify(entry) == (methodQid == CENSUS_QID and "census" or "estimate") then
latest = entry
end
end
if not latest then return nil, nil end
local trend = trendFor(statements, latest)
-- Filter by the statement's OWN method value (which may be absent, or
-- something other than the census/estimate QID being asked for -- see
-- classify()'s "everything not census is an estimate" default), never
-- by the hardcoded methodQid, so the citation still finds a match for
-- data that isn't tagged the way this module expects.
local citationArgs = {P585 = tostring(latest.year)}
if latest.method then citationArgs.P459 = latest.method end
local citation = getWdCitation("P1082", citationArgs)
local label = labelWord .. " " .. latest.year
local value = (trend and trendArrow(trend) or "") .. formatNumber(latest.amount) .. " "
if rhenk then
value = value .. "([[Rolley çheeraghyn rere earroo yn phobble|" .. rhenk .. "]]) "
end
if citation then value = value .. citation end
value = applyRefNote(value, ref, note, frame)
return {label, value}, latest.amount
end
function p.main(frame, args)
if not args then
args = frame
frame = mw.getCurrentFrame()
end
local headerLabel = getManual(args, {"sorçh_pobble"}) or "[[Earroo yn phobble]]"
local wdStatements = nil
local function statements()
if wdStatements == nil then wdStatements = getWdPopulationStatements() end
return wdStatements
end
------------------------------------------------------------------
-- Census, then estimate (old template's own order) -- census is
-- resolved first so a manual estimate can compare its trend against it.
------------------------------------------------------------------
local censusItem, censusNumber = buildPopulationItem(args, frame, "coontey", "Coontey-pobble", CENSUS_QID, statements(), nil)
local estimateItem, estimateNumber = buildPopulationItem(args, frame, "ooley", "Ooley-pobble", ESTIMATE_QID, statements(), censusNumber)
------------------------------------------------------------------
-- Density: manual km², else population ÷ area (both must resolve).
-- No auto citation -- a computed ratio isn't one citable statement.
------------------------------------------------------------------
local densityRef = getManual(args, {"imraa_glooaght_pobble"})
local densityNote = getManual(args, {"noteyn_glooaght_pobble"})
local densityManual = getManual(args, {"glooaght_pobble_km2"})
local densityItem = nil
local densityKm2Str, densityKm2Number
if densityManual then
if not isNone(densityManual) then
densityKm2Str = densityManual
densityKm2Number = tonumber((densityManual:gsub(",", "")))
end
else
local populationForDensity = estimateNumber or censusNumber
local areaKm2 = populationForDensity and getWdAreaKm2()
if populationForDensity and areaKm2 and areaKm2 > 0 then
densityKm2Number = populationForDensity / areaKm2
densityKm2Str = formatNumber(densityKm2Number, 1)
end
end
if densityKm2Str then
local foScreeuyn = getManual(args, {"gloo_pob_fo-screeuyn"}) or ""
local rhenk = getManual(args, {"rhenk_glooaght_pobble"})
local miKerManual = getManual(args, {"glooaght_pobble_mi_ker"})
local miKerStr = miKerManual
if not miKerStr and densityKm2Number then
miKerStr = formatNumber(densityKm2Number * KM2_PER_MI2, 1)
end
local value = densityKm2Str .. "/km<sup>2</sup> " .. foScreeuyn
if rhenk then
value = value .. "([[Rolley çheeraghyn rere glooaght y phobble|" .. rhenk .. "]]) "
end
if miKerStr then
value = value .. "<br/>" .. miKerStr .. "/mi ker"
end
value = applyRefNote(value, densityRef, densityNote, frame)
densityItem = {"[[Glooaght y phobble|Glooaght]]", value}
end
if not censusItem and not estimateItem and not densityItem then return nil end
local rows = {string.format(HEADER, headerLabel)}
local items = {}
if estimateItem then table.insert(items, estimateItem) end
if censusItem then table.insert(items, censusItem) end
if densityItem then table.insert(items, densityItem) end
appendIndentRun(rows, items)
return table.concat(rows)
end
return p
dogp6qju5gydol2kc9ojepsnbtexm5d
393180
393177
2026-09-14T01:48:18Z
MacTire02
219
++
393180
Scribunto
text/plain
local p = {}
local KM2_PER_MI2 = 2.589988110336
-- P459 ("determination method or standard") qualifier values that
-- distinguish a census from an estimate -- verified directly against
-- wikidata.org, not guessed.
local CENSUS_QID = "Q39825"
local ESTIMATE_QID = "Q791801"
-- Same recognized-area-unit allow-list as Module:Kishtey fys çheer/eaghtyr,
-- duplicated here for the density auto-calc (population ÷ area).
local AREA_UNIT_FACTORS = {
Q712226 = 1,
Q232291 = KM2_PER_MI2,
}
-- Citation-building only (a raw entity fetch can't render Wikidata's own
-- reference snaks into a <ref>) -- see getWdCitation below.
local wdOK, Wd = pcall(require, "Module:Wd")
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
-- Wraps a manual citation in <ref>...</ref>, unless it's already fully
-- <ref>-tagged (Scribunto expands a literal <ref> in a parameter into an
-- opaque \127UNIQ...QINU\127 strip marker before this module sees it, so we
-- strip those out and check what's left -- nothing left means it was
-- already tag(s), pass through unchanged; real text left over means it
-- still needs wrapping).
local function wrapReference(ref)
if not ref or ref == "" then return nil end
local withoutMarkers = mw.ustring.gsub(ref, "\127UNIQ.-QINU\127", "")
if mw.ustring.gsub(withoutMarkers, "%s+", "") == "" then
return ref
end
if mw.ustring.find(mw.ustring.lower(ref), "<ref", 1, true) then
return ref
end
return "<ref>" .. ref .. "</ref>"
end
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 .. wrapReference(ref)
end
return value
end
-- Same header + bulleted sub-rows grid as reiltys/eaghtyr.
local SUBROW = '<tr%s><th style="vertical-align:top; white-space:nowrap; text-align:left; font-weight:normal; padding-left:0.9em; padding-right:0.4em;">• %s</th><td style="vertical-align:top; padding-left:0.4em; padding-right:0.4em;">%s</td></tr>'
local HEADER = '<tr class="mergedtoprow"><th colspan="2" style="text-align:left; padding-left:0.4em; padding-right:0.4em;">%s</th></tr>'
local function trClass(name)
if name and name ~= "" then return ' class="' .. name .. '"' end
return ""
end
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
-- e.g. 1234567.5 -> "1,234,567.5" (decimals=2 default); 96.75 with
-- decimals=1 -> "96.8". Trims a trailing ".0" and groups the integer part
-- in thousands. Only for numbers this module computed itself -- a manual
-- value is always passed through exactly as the editor typed it.
local function formatNumber(n, decimals)
decimals = decimals or 2
local isNeg = n < 0
n = math.abs(n)
local formatted = string.format("%." .. decimals .. "f", n):gsub("%.?0+$", "")
local intPart, decPart = formatted:match("^(%d+)%.?(%d*)$")
local grouped = intPart:reverse():gsub("(%d%d%d)", "%1,"):reverse():gsub("^,", "")
local result = (decPart and decPart ~= "") and (grouped .. "." .. decPart) or grouped
return isNeg and ("-" .. result) or result
end
-- Colored increase/decrease/steady arrow, prepended to a Wikidata-sourced
-- population figure -- matching enwiki infoboxes' {{increase}}/{{decrease}}/
-- {{steady}} look. Hardcoded rather than routed through gv.wiki templates
-- of the same name, since it's not known whether those exist there yet.
local function trendArrow(direction)
if direction == "up" then
return '<span style="color:green;" title="Bishaghey">▲</span>'
elseif direction == "down" then
return '<span style="color:red;" title="Ismoo">▼</span>'
elseif direction == "steady" then
return '<span style="color:gray;" title="Kiune">►</span>'
end
return ""
end
-- All P1082 ("population") statements on the current item, each reduced to
-- {amount, rawAmount, year, method}. `rawAmount` is Wikidata's own amount
-- string with the leading "+" stripped -- kept alongside the parsed number
-- so getWdReferenceForValue below can match the exact statement byte-for-
-- byte. `method` is the raw P459 qualifier QID (nil if absent) --
-- classify() below turns that into "census"/"estimate". Sorted ascending
-- by year, so the LAST matching entry in a single pass is always the most
-- recent one.
local function getWdPopulationStatements()
local entity = mw.wikibase.getEntityObject()
if not entity then return {} end
local statements = entity:getBestStatements("P1082")
if not statements then return {} end
local results = {}
for _, statement in ipairs(statements) do
local mainsnak = statement.mainsnak
if mainsnak and mainsnak.snaktype == "value" and mainsnak.datavalue
and mainsnak.datavalue.type == "quantity" then
local rawAmount = mainsnak.datavalue.value.amount
local amount = tonumber(rawAmount)
local timeQuals = statement.qualifiers and statement.qualifiers.P585
local timeSnak = timeQuals and timeQuals[1]
local timeValue = timeSnak and timeSnak.datavalue and timeSnak.datavalue.value
local year = timeValue and timeValue.time and tonumber(timeValue.time:match("(%-?%d+)%-"))
if amount and year then
local methodQuals = statement.qualifiers and statement.qualifiers.P459
local methodSnak = methodQuals and methodQuals[1]
local methodValue = methodSnak and methodSnak.datavalue and methodSnak.datavalue.value
local method = methodValue and (methodValue.id or ("Q" .. tostring(methodValue["numeric-id"])))
table.insert(results, {
amount = amount,
rawAmount = rawAmount and rawAmount:gsub("^%+", ""),
year = year,
method = method,
})
end
end
end
table.sort(results, function(a, b) return a.year < b.year end)
return results
end
-- Whether a P459 value counts as "census". Real-world data almost never
-- tags this with the bare, generic Q39825 -- countries tag it with their
-- OWN census event instead (e.g. "2020 United States Census", Q23766566),
-- a different QID every country and every census year, so matching a
-- fixed QID list would miss almost all of them. Instead: the item's own
-- English label -- every one of these item names contains the word
-- "census" -- is checked for that word; anything else (an estimation
-- item, something else entirely, or no P459 at all) defaults to
-- "estimate", so untagged data still shows rather than disappearing.
local function isCensusMethod(methodQid)
if not methodQid then return false end
if methodQid == CENSUS_QID then return true end
local ok, label = pcall(mw.wikibase.getLabelByLang, methodQid, "en")
return ok and label ~= nil and mw.ustring.find(mw.ustring.lower(label), "census", 1, true) ~= nil
end
local function classify(entry)
if isCensusMethod(entry.method) then return "census" end
return "estimate"
end
-- Increase/decrease/steady, comparing `entry` to whichever entry in the
-- same (chronologically sorted) list immediately precedes it -- census and
-- estimate data points are compared against each other here, matching how
-- a reader actually reads a population trend, not just within one category.
local function trendFor(allEntries, targetEntry)
local prev = nil
for _, entry in ipairs(allEntries) do
if entry == targetEntry then break end
prev = entry
end
if not prev then return nil end
if targetEntry.amount > prev.amount then return "up" end
if targetEntry.amount < prev.amount then return "down" end
return "steady"
end
-- The auto-built citation for ONE already-identified P1082 statement,
-- pinned down by its own exact population VALUE rather than by
-- reconstructing a P585 date string -- real census dates are commonly
-- stored at day precision ("2020-04-01"), which a plain-year string can
-- never match, silently losing the citation. Matching on the statement's
-- own raw amount (Wd's cfg.propertyValue, compared via snakEqualsValue)
-- has no such precision trap: it's an exact match against the one
-- statement this module already resolved. Wd._reference itself returns
-- ready-made "<ref>...</ref>" wikitext (or "" on no match/no reference),
-- so the result here can be appended directly -- no further wrapping.
local function getWdReferenceForValue(property, rawAmount)
if not wdOK or not Wd or not Wd._reference or not rawAmount then return nil end
local ok, result = pcall(Wd._reference, {"best", property, rawAmount})
if ok and result and result ~= "" then return result end
return nil
end
-- Wikidata fallback for density: total area (P2046), converted to km² when
-- the unit is one this module recognizes -- duplicated from eaghtyr.lua
-- rather than shared, per this project's per-file convention.
local function getWdAreaKm2()
local entity = mw.wikibase.getEntityObject()
if not entity then return nil end
local statements = entity:getBestStatements("P2046")
if not statements or #statements == 0 then return nil end
local mainsnak = statements[1].mainsnak
if not (mainsnak and mainsnak.snaktype == "value" and mainsnak.datavalue
and mainsnak.datavalue.type == "quantity") then
return nil
end
local value = mainsnak.datavalue.value
local amount = tonumber(value.amount)
if not amount then return nil end
local unitQid = value.unit and value.unit:match("Q%d+$")
local factor = unitQid and AREA_UNIT_FACTORS[unitQid]
if not factor then return nil end
return amount * factor
end
-- Builds one census/estimate row from manual params, else Wikidata.
-- `labelWord` is "Coontey-pobble" or "Ooley-pobble"; `methodQid` picks
-- which P459 category to read; `manualTrendAgainst` (a resolved number,
-- may be nil) lets a manual estimate get a trend arrow against the
-- census figure when there's no Wikidata history to compare against.
local function buildPopulationItem(args, frame, paramPrefix, labelWord, methodQid, statements, manualTrendAgainst)
local manual = getManual(args, {"pobble_" .. paramPrefix})
local year = getManual(args, {"blein_" .. paramPrefix .. "_pobble"})
local rhenk = getManual(args, {"rhenk_" .. paramPrefix .. "_pobble"})
local ref = getManual(args, {"imraa_" .. paramPrefix .. "_pobble"})
local note = getManual(args, {"noteyn_" .. paramPrefix .. "_pobble"})
if manual then
if isNone(manual) then return nil, nil end
local number = tonumber((manual:gsub(",", "")))
local trend = (number and manualTrendAgainst) and (
number > manualTrendAgainst and "up"
or number < manualTrendAgainst and "down"
or "steady"
) or nil
local label = labelWord .. (year and (" " .. year) or "")
local value = (trend and trendArrow(trend) or "") .. manual .. " "
if rhenk then
value = value .. "([[Rolley çheeraghyn rere earroo yn phobble|" .. rhenk .. "]]) "
end
value = applyRefNote(value, ref, note, frame)
return {label, value}, number
end
local latest = nil
for _, entry in ipairs(statements) do
if classify(entry) == (methodQid == CENSUS_QID and "census" or "estimate") then
latest = entry
end
end
if not latest then return nil, nil end
local trend = trendFor(statements, latest)
local citation = getWdReferenceForValue("P1082", latest.rawAmount)
local label = labelWord .. " " .. latest.year
local value = (trend and trendArrow(trend) or "") .. formatNumber(latest.amount) .. " "
if rhenk then
value = value .. "([[Rolley çheeraghyn rere earroo yn phobble|" .. rhenk .. "]]) "
end
if citation then value = value .. citation end
value = applyRefNote(value, ref, note, frame)
return {label, value}, latest.amount
end
function p.main(frame, args)
if not args then
args = frame
frame = mw.getCurrentFrame()
end
local headerLabel = getManual(args, {"sorçh_pobble"}) or "[[Earroo yn phobble]]"
local wdStatements = nil
local function statements()
if wdStatements == nil then wdStatements = getWdPopulationStatements() end
return wdStatements
end
------------------------------------------------------------------
-- Census, then estimate (old template's own order) -- census is
-- resolved first so a manual estimate can compare its trend against it.
------------------------------------------------------------------
local censusItem, censusNumber = buildPopulationItem(args, frame, "coontey", "Coontey-pobble", CENSUS_QID, statements(), nil)
local estimateItem, estimateNumber = buildPopulationItem(args, frame, "ooley", "Ooley-pobble", ESTIMATE_QID, statements(), censusNumber)
------------------------------------------------------------------
-- Density: manual km², else population ÷ area (both must resolve).
-- No auto citation -- a computed ratio isn't one citable statement.
------------------------------------------------------------------
local densityRef = getManual(args, {"imraa_glooaght_pobble"})
local densityNote = getManual(args, {"noteyn_glooaght_pobble"})
local densityManual = getManual(args, {"glooaght_pobble_km2"})
local densityItem = nil
local densityKm2Str, densityKm2Number
if densityManual then
if not isNone(densityManual) then
densityKm2Str = densityManual
densityKm2Number = tonumber((densityManual:gsub(",", "")))
end
else
local populationForDensity = estimateNumber or censusNumber
local areaKm2 = populationForDensity and getWdAreaKm2()
if populationForDensity and areaKm2 and areaKm2 > 0 then
densityKm2Number = populationForDensity / areaKm2
densityKm2Str = formatNumber(densityKm2Number, 1)
end
end
if densityKm2Str then
local foScreeuyn = getManual(args, {"gloo_pob_fo-screeuyn"}) or ""
local rhenk = getManual(args, {"rhenk_glooaght_pobble"})
local miKerManual = getManual(args, {"glooaght_pobble_mi_ker"})
local miKerStr = miKerManual
if not miKerStr and densityKm2Number then
miKerStr = formatNumber(densityKm2Number * KM2_PER_MI2, 1)
end
local value = densityKm2Str .. "/km<sup>2</sup> " .. foScreeuyn
if rhenk then
value = value .. "([[Rolley çheeraghyn rere glooaght y phobble|" .. rhenk .. "]]) "
end
if miKerStr then
value = value .. "<br/>" .. miKerStr .. "/mi ker"
end
value = applyRefNote(value, densityRef, densityNote, frame)
densityItem = {"[[Glooaght y phobble|Glooaght]]", value}
end
if not censusItem and not estimateItem and not densityItem then return nil end
local rows = {string.format(HEADER, headerLabel)}
local items = {}
if estimateItem then table.insert(items, estimateItem) end
if censusItem then table.insert(items, censusItem) end
if densityItem then table.insert(items, densityItem) end
appendIndentRun(rows, items)
return table.concat(rows)
end
return p
4ltzdaaic74cm8tt82y9do4xpjdis5i
Clowan:Yn Americkey Hwoaie
10
55876
393185
2026-09-14T02:12:26Z
MacTire02
219
MacTire02 moved page [[Clowan:Yn Americkey Hwoaie]] to [[Clowan:America Hwoaie]] over redirect
393185
wikitext
text/x-wiki
#REDIRECT [[Clowan:America Hwoaie]]
9dp6zdk6jas1axs8zgjyjvdipkdpn96